Skip to content

Commit

Permalink
fix(Editor): fix docs link for Kalico (#2080)
Browse files Browse the repository at this point in the history
Signed-off-by: Stefan Dej <[email protected]>
  • Loading branch information
meteyou authored Dec 17, 2024
1 parent ea1dd67 commit 4c86d7c
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 12 deletions.
12 changes: 7 additions & 5 deletions src/components/TheEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ import { Component, Mixins, Ref, Watch } from 'vue-property-decorator'
import BaseMixin from '@/components/mixins/base'
import { capitalize, formatFilesize, windowBeforeUnloadFunction } from '@/plugins/helpers'
import Panel from '@/components/ui/Panel.vue'
import { availableKlipperConfigReferenceTranslations } from '@/store/variables'
import { klipperRepos } from '@/store/variables'
import CodemirrorAsync from '@/components/inputs/CodemirrorAsync'
import {
mdiClose,
Expand Down Expand Up @@ -346,13 +346,15 @@ export default class TheEditor extends Mixins(BaseMixin) {
get klipperConfigReference(): string {
const currentLanguage = this.currentLanguage
const translations = availableKlipperConfigReferenceTranslations
let url = 'https://www.klipper3d.org/Config_Reference.html'
const klipperRepo = klipperRepos[this.klipperAppName] ?? klipperRepos.Klipper
if (translations.includes(currentLanguage)) {
url = `https://www.klipper3d.org/${currentLanguage}/Config_Reference.html`
let url = klipperRepo.url
if (klipperRepo.docsLanguages?.includes(currentLanguage)) {
url += `${currentLanguage}/`
}
url += 'Config_Reference.html'
return url
}
Expand Down
4 changes: 4 additions & 0 deletions src/components/mixins/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ export default class BaseMixin extends Vue {
return this.socketIsConnected && this.klipperState === 'ready'
}

get klipperAppName() {
return this.$store.state.printer.app_name ?? 'Klipper'
}

get printerIsPrinting() {
return this.klipperReadyForGui && ['printing', 'paused'].includes(this.printer_state)
}
Expand Down
7 changes: 7 additions & 0 deletions src/store/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,10 @@ export interface Theme {
}
css?: boolean
}

export interface KlipperRepos {
[name: string]: {
url: string
docsLanguages?: string[]
}
}
21 changes: 14 additions & 7 deletions src/store/variables.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Theme } from '@/store/types'
import { KlipperRepos, Theme } from '@/store/types'

export const defaultMode = 'dark'
export const defaultTheme = 'mainsail'
Expand Down Expand Up @@ -128,12 +128,6 @@ export const hiddenRootDirectories = ['gcodes', 'timelapse', 'timelapse_frames']
*/
export const hiddenDirectories = ['.git']

/*
* List of available Klipper config reference translations
* https://www.klipper3d.org/Config_Reference.html
*/
export const availableKlipperConfigReferenceTranslations = ['it', 'hu', 'zh']

/*
* List of all downloadable logfiles
*/
Expand Down Expand Up @@ -204,3 +198,16 @@ export const themes: Theme[] = [
logo: { show: true, light: false },
},
]

/*
* List of all supported Klipper-Repos
*/
export const klipperRepos: KlipperRepos = {
Klipper: {
url: 'https://www.klipper3d.org/',
docsLanguages: ['it', 'hu', 'zh'],
},
Kalico: {
url: 'https://docs.kalico.gg/',
},
}

0 comments on commit 4c86d7c

Please sign in to comment.