Skip to content

Commit

Permalink
fix: always show Preview Gcode in context menu
Browse files Browse the repository at this point in the history
Signed-off-by: Pedro Lamas <[email protected]>
  • Loading branch information
pedrolamas committed Jan 10, 2023
1 parent 9aac206 commit 55eb71b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/components/widgets/filesystem/FileSystem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -672,10 +672,10 @@ export default class FileSystem extends Mixins(StateMixin, FilesMixin, ServicesM
this.getGcode(file)
.then(response => response?.data)
.then((gcode) => {
// If we aren't on the dashboard, push the user back there.
if (this.$router.currentRoute.path !== '/') {
this.$router.push({ path: '/' })
if (this.$router.currentRoute.path !== '/' || !this.$store.getters['layout/isEnabledInCurrentLayout']('gcode-preview-card')) {
this.$router.push({ path: '/preview' })
}
this.$store.dispatch('gcodePreview/loadGcode', {
file,
gcode
Expand Down
7 changes: 5 additions & 2 deletions src/components/widgets/filesystem/FileSystemContextMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,11 @@ export default class FileSystemContextMenu extends Mixins(StateMixin, FilesMixin
}
get canPreviewGcode () {
const layoutName = this.$store.getters['layout/getSpecificLayoutName']
return (this.$store.getters['layout/isEnabledInLayout'](layoutName, 'gcode-preview-card') && this.root === 'gcodes')
return (
this.file.type === 'file' &&
this.file.extension === 'gcode' &&
this.root === 'gcodes'
)
}
get supportsJobQueue (): boolean {
Expand Down
6 changes: 6 additions & 0 deletions src/store/layout/getters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ export const getters: GetterTree<LayoutState, RootState> = {
return configs.find(configs => configs.id === id)?.enabled ?? false
},

isEnabledInCurrentLayout: (state, getters) => (id: string) => {
const layout = getters.getSpecificLayoutName

return getters.isEnabledInLayout(layout, id)
},

/**
* Return a layout's container given a layout name and container name.
*/
Expand Down

0 comments on commit 55eb71b

Please sign in to comment.