Skip to content

Commit

Permalink
refactor: replace route.path with route.name
Browse files Browse the repository at this point in the history
Signed-off-by: Pedro Lamas <pedrolamas@gmail.com>
  • Loading branch information
pedrolamas committed Feb 17, 2025
1 parent 9cb9da4 commit f71d4b0
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 19 deletions.
2 changes: 1 addition & 1 deletion src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
(socketConnected && apiConnected) &&
(!klippyReady || hasWarnings) &&
!inLayout &&
$route.path !== '/login'
$route.name !== 'login'
"
>
<v-col>
Expand Down
25 changes: 11 additions & 14 deletions src/components/layout/AppBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -329,23 +329,20 @@ export default class AppBar extends Mixins(StateMixin, ServicesMixin, FilesMixin
}
get isDashboard () {
return this.$route.path === '/'
return this.$route.name === 'home'
}
handleResetLayout () {
const pathLayouts: Record<string, string> = {
'/diagnostics': 'diagnostics'
}
const pathLayout = pathLayouts[this.$route.path]
let layoutDefaultState
if (pathLayout) {
// reset to default init state
layoutDefaultState = defaultState().layouts[pathLayout]
} else {
// reset dashboard to default layout
layoutDefaultState = this.$store.getters['layout/getLayout']('dashboard')
}
const pathLayouts = [
'diagnostics'
]
const pathLayout = pathLayouts.includes(this.$route.name ?? '')
? this.$route.name
: undefined
const layoutDefaultState = pathLayout
? defaultState().layouts[pathLayout]
: this.$store.getters['layout/getLayout']('dashboard')
const toReset = pathLayout ?? this.$store.getters['layout/getSpecificLayoutName']
Expand Down
2 changes: 1 addition & 1 deletion src/components/ui/AppNavItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export default class AppNavItem extends Mixins(StateMixin, BrowserMixin) {
if (
shortcut === this.accelerator &&
!eventTargetIsContentEditable(event) &&
this.$router.currentRoute.name !== this.to
this.$route.name !== this.to
) {
event.preventDefault()
Expand Down
4 changes: 2 additions & 2 deletions src/components/widgets/filesystem/FileSystem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -785,7 +785,7 @@ export default class FileSystem extends Mixins(StateMixin, FilesMixin, ServicesM
if (!gcode) return
if (
this.$router.currentRoute.name !== 'home' ||
this.$route.name !== 'home' ||
!this.$store.getters['layout/isEnabledInCurrentLayout']('gcode-preview-card')
) {
this.$router.push({ name: 'gcode_preview' })
Expand Down Expand Up @@ -866,7 +866,7 @@ export default class FileSystem extends Mixins(StateMixin, FilesMixin, ServicesM
SocketActions.printerPrintStart(filename)
// If we aren't on the dashboard, push the user back there.
if (this.$router.currentRoute.name !== 'home') {
if (this.$route.name !== 'home') {
this.$router.push({ name: 'home' })
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/widgets/spoolman/SpoolSelectionDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,7 @@ export default class SpoolSelectionDialog extends Mixins(StateMixin, BrowserMixi
if (this.filename) {
await SocketActions.printerPrintStart(this.filename)
if (this.$router.currentRoute.name !== 'home') {
if (this.$route.name !== 'home') {
this.$router.push({ name: 'home' })
}
}
Expand Down

0 comments on commit f71d4b0

Please # to comment.