Skip to content

Commit 5b664d8

Browse files
authored
Merge pull request #6623 from FlowFuse/chore/extract-device-editor-nested-routes
Refactor device routes and update references to use consistent naming convention
2 parents b467299 + f8f06dc commit 5b664d8

File tree

6 files changed

+105
-76
lines changed

6 files changed

+105
-76
lines changed

frontend/src/components/bill-of-materials/InstancesItem.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<div class="title truncate">
44
<h6 v-if="isDevice">
55
<IconDeviceSolid class="ff-icon text-teal-700" />
6-
<router-link :to="{name: 'DeviceOverview', params: {id: instance.id}}" class="ff-link">
6+
<router-link :to="{name: 'device-overview', params: {id: instance.id}}" class="ff-link">
77
{{ instance.name }}
88
</router-link>
99
</h6>

frontend/src/components/global-search/components/ResultSection.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ export default {
9595
routeName = 'instance-overview'
9696
break
9797
case 'device':
98-
routeName = 'DeviceOverview'
98+
routeName = 'device-overview'
9999
break
100100
default:
101101
routeName = ''

frontend/src/components/pipelines/DeployStageDialog.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@
111111
Device snapshots can be managed on the
112112
<router-link
113113
:to="{
114-
name: 'DeviceSnapshots',
114+
name: 'device-version-history',
115115
params: { id: stage.device.id },
116116
}"
117117
>
@@ -154,7 +154,7 @@
154154
Device snapshots can be managed on the
155155
<router-link
156156
:to="{
157-
name: 'DeviceSnapshots',
157+
name: 'device-version-history',
158158
params: { id: stage.device.id },
159159
}"
160160
>

frontend/src/pages/application/DeviceGroup/devices.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
<ff-checkbox v-model="device.selected" />
5050
</ff-data-table-cell>
5151
<ff-data-table-cell>
52-
<router-link :to="{name: 'DeviceOverview', params: {id: device.id}}">{{ device.name }}</router-link>
52+
<router-link :to="{name: 'device-overview', params: {id: device.id}}">{{ device.name }}</router-link>
5353
</ff-data-table-cell>
5454
<ff-data-table-cell>{{ device.type }}</ff-data-table-cell>
5555
</ff-data-table-row>
@@ -80,7 +80,7 @@
8080
<ff-checkbox v-model="device.selected" class="inline" />
8181
</ff-data-table-cell>
8282
<ff-data-table-cell class="w-1/3">
83-
<router-link :to="{name: 'DeviceOverview', params: {id: device.id}}">{{ device.name }}</router-link>
83+
<router-link :to="{name: 'device-overview', params: {id: device.id}}">{{ device.name }}</router-link>
8484
</ff-data-table-cell>
8585
<ff-data-table-cell class="w-1/3">{{ device.name }}</ff-data-table-cell>
8686
<ff-data-table-cell v-if="!editMode" class="w-1/3">

frontend/src/pages/device/index.vue

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -247,13 +247,13 @@ export default {
247247
return [
248248
{
249249
label: 'Overview',
250-
to: { name: 'DeviceOverview' },
250+
to: { name: 'device-overview' },
251251
tag: 'device-overview'
252252
},
253253
{
254254
label: 'Version History',
255255
to: {
256-
name: 'DeviceSnapshots',
256+
name: 'device-version-history',
257257
params: { id: this.$route.params.id }
258258
},
259259
tag: 'version-history'
@@ -281,7 +281,7 @@ export default {
281281
},
282282
{
283283
label: 'Developer Mode',
284-
to: { name: 'DeviceDeveloperMode' },
284+
to: { name: 'device-developer-mode' },
285285
tag: 'device-devmode',
286286
hidden: !(this.isDevModeAvailable && this.device.mode === 'developer')
287287
}
@@ -333,7 +333,7 @@ export default {
333333
// the device status is empty or the device is in a transition state
334334
// This is to prevent settings pages from refreshing the device state while modifying settings
335335
// See `watch: { device: { handler () ... in pages/device/Settings/General.vue for why that happens
336-
const settingsPages = ['DeviceOverview', 'DeviceDeveloperMode']
336+
const settingsPages = ['device-overview', 'device-developer-mode']
337337
try {
338338
if (settingsPages.includes(this.$route.name)) {
339339
await this.loadDevice()

frontend/src/pages/device/routes.js

Lines changed: 95 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -17,86 +17,115 @@ import VersionHistoryRoutes from './VersionHistory/routes.js'
1717

1818
import Device from './index.vue'
1919

20-
export default [
20+
const children = [
2121
{
22-
path: '/device/:id',
23-
redirect: to => {
24-
return { name: 'DeviceOverview', params: to.params }
25-
},
26-
name: 'Device',
27-
component: Device,
22+
name: 'device-overview',
23+
path: 'overview',
24+
component: DeviceOverview
25+
},
26+
{
27+
path: 'settings',
28+
name: 'device-settings',
29+
component: DeviceSettings,
2830
meta: {
29-
title: 'Device - Overview'
31+
title: 'Device - Settings'
3032
},
33+
redirect: { name: 'device-settings-general' },
3134
children: [
32-
{ path: 'overview', component: DeviceOverview, name: 'DeviceOverview' },
33-
{
34-
path: 'settings',
35-
name: 'device-settings',
36-
component: DeviceSettings,
37-
meta: {
38-
title: 'Device - Settings'
39-
},
40-
redirect: to => {
41-
return `/device/${to.params.id}/settings/general`
42-
},
43-
children: [
44-
{ path: 'general', component: DeviceSettingsGeneral },
45-
{ path: 'environment', component: DeviceSettingsEnvironment },
46-
{ path: 'security', component: DeviceSettingsSecurity },
47-
{ path: 'palette', component: DeviceSettingsPalette },
48-
{ path: 'danger', component: DeviceSettingsDanger }
49-
]
50-
},
5135
{
52-
path: 'audit-log',
53-
name: 'device-audit-log',
54-
component: DeviceAuditLog,
55-
meta: {
56-
title: 'Device - Audit Log'
57-
}
36+
name: 'device-settings-general',
37+
path: 'general',
38+
component: DeviceSettingsGeneral
5839
},
5940
{
60-
path: 'logs',
61-
name: 'device-logs',
62-
component: DeviceLogs,
63-
meta: {
64-
title: 'Device - Logs'
65-
}
41+
name: 'device-settings-environment',
42+
path: 'environment',
43+
component: DeviceSettingsEnvironment
6644
},
6745
{
68-
path: 'performance',
69-
name: 'device-performance',
70-
component: DevicePerformance,
71-
meta: {
72-
title: 'Device - Performance'
73-
}
46+
name: 'device-settings-security',
47+
path: 'security',
48+
component: DeviceSettingsSecurity
7449
},
7550
{
76-
path: 'version-history',
77-
name: 'DeviceSnapshots',
78-
component: VersionHistory,
79-
meta: {
80-
title: 'Device - Version History'
81-
},
82-
redirect: to => {
83-
const features = store.getters['account/featuresCheck']
84-
const name = features.isTimelineFeatureEnabled ? 'device-version-history-timeline' : 'device-snapshots'
85-
return {
86-
name,
87-
params: to.params
88-
}
89-
},
90-
children: [...VersionHistoryRoutes]
51+
name: 'device-settings-palette',
52+
path: 'palette',
53+
component: DeviceSettingsPalette
9154
},
9255
{
93-
path: 'developer-mode',
94-
name: 'DeviceDeveloperMode',
95-
component: DeviceDeveloperMode,
96-
meta: {
97-
title: 'Device - Developer Mode'
98-
}
56+
name: 'device-settings-danger',
57+
path: 'danger',
58+
component: DeviceSettingsDanger
9959
}
10060
]
61+
},
62+
{
63+
path: 'audit-log',
64+
name: 'device-audit-log',
65+
component: DeviceAuditLog,
66+
meta: {
67+
title: 'Device - Audit Log'
68+
}
69+
},
70+
{
71+
path: 'logs',
72+
name: 'device-logs',
73+
component: DeviceLogs,
74+
meta: {
75+
title: 'Device - Logs'
76+
}
77+
},
78+
{
79+
path: 'performance',
80+
name: 'device-performance',
81+
component: DevicePerformance,
82+
meta: {
83+
title: 'Device - Performance'
84+
}
85+
},
86+
{
87+
path: 'version-history',
88+
name: 'device-version-history',
89+
component: VersionHistory,
90+
meta: {
91+
title: 'Device - Version History'
92+
},
93+
redirect: to => {
94+
const features = store.getters['account/featuresCheck']
95+
const name = features.isTimelineFeatureEnabled ? 'device-version-history-timeline' : 'device-snapshots'
96+
return {
97+
name,
98+
params: to.params
99+
}
100+
},
101+
children: [...VersionHistoryRoutes]
102+
},
103+
{
104+
path: 'developer-mode',
105+
name: 'device-developer-mode',
106+
component: DeviceDeveloperMode,
107+
meta: {
108+
title: 'Device - Developer Mode'
109+
}
110+
}
111+
]
112+
113+
export { children }
114+
115+
export default [
116+
{
117+
path: '/device/:id',
118+
redirect: to => {
119+
return {
120+
name: 'device-overview',
121+
params: to.params
122+
}
123+
},
124+
name: 'Device',
125+
component: Device,
126+
meta: {
127+
title: 'Device - Overview'
128+
},
129+
children
101130
}
102131
]

0 commit comments

Comments
 (0)