-
+
@@ -29,9 +29,35 @@ export default {
}
},
computed: {
- ...mapState('account', ['teamMembership'])
+ ...mapState('account', ['teamMembership']),
+ sideNav () {
+ const canEditDevice = this.hasPermission('device:edit', { application: this.device.application })
+ const isApplicationOwned = this.device.ownerType === 'application'
+
+ const nav = [
+ { name: 'General', path: { name: 'device-settings-general', props: { id: this.device.id } } },
+ { name: 'Environment', path: { name: 'device-settings-environment' } },
+ { name: 'Editor', path: { name: 'device-settings-editor' }, hidden: !(canEditDevice && isApplicationOwned) },
+ { name: 'Security', path: { name: 'device-settings-security' }, hidden: !(canEditDevice && isApplicationOwned) },
+ { name: 'Palette', path: { name: 'device-settings-palette' }, hidden: !(canEditDevice && isApplicationOwned) },
+ { name: 'Danger', path: { name: 'device-settings-danger' }, hidden: !canEditDevice }
+ ]
+
+ if (!this.$route.name.includes('-editor-')) return nav
+
+ return nav.map(route => ({
+ ...route,
+ path: {
+ ...route.path,
+ name: route.path.name.replace('device-', 'device-editor-')
+ }
+ }))
+ }
},
- mounted () {
+ async mounted () {
+ // compensate for the time it takes for the device to load when reloading the page or accessing the page via URL
+ while (!this.device) await new Promise(resolve => setTimeout(resolve, 250))
+
if (this.checkAccess()) {
// device state polling is disabled on settings pages (in ../index.vue:pollTimer())
// so we need to manually refresh the device upon mounting
@@ -44,18 +70,6 @@ export default {
useRouter().push({ replace: true, path: 'overview' })
return false
}
- this.sideNavigation = [
- { name: 'General', path: './general' },
- { name: 'Environment', path: './environment' }
- ]
- if (this.hasPermission('device:edit', { application: this.device.application })) {
- if (this.device.ownerType === 'application') {
- this.sideNavigation.push({ name: 'Security', path: './security' })
- this.sideNavigation.push({ name: 'Palette', path: './palette' })
- }
- this.sideNavigation.push({ name: 'Danger', path: './danger' })
- }
- return true
}
},
watch: {
diff --git a/frontend/src/pages/device/routes.js b/frontend/src/pages/device/routes.js
index 0d46eaa663..31922fa07f 100644
--- a/frontend/src/pages/device/routes.js
+++ b/frontend/src/pages/device/routes.js
@@ -7,6 +7,7 @@ import DeviceLogs from './Logs.vue'
import DeviceOverview from './Overview.vue'
import DevicePerformance from './Performance.vue'
import DeviceSettingsDanger from './Settings/Danger.vue'
+import DeviceSettingsEditor from './Settings/Editor.vue'
import DeviceSettingsEnvironment from './Settings/Environment.vue'
import DeviceSettingsGeneral from './Settings/General.vue'
import DeviceSettingsPalette from './Settings/Palette.vue'
@@ -44,6 +45,11 @@ const children = [
path: 'environment',
component: DeviceSettingsEnvironment
},
+ {
+ name: 'device-settings-editor',
+ path: 'editor',
+ component: DeviceSettingsEditor
+ },
{
name: 'device-settings-security',
path: 'security',