From 1932479b98013db1d1998a60dbd01155d027fd33 Mon Sep 17 00:00:00 2001 From: Stefan Dej Date: Tue, 10 Dec 2024 23:21:39 +0100 Subject: [PATCH] fix(Editor): fix docs link for Kalico Signed-off-by: Stefan Dej --- src/components/TheEditor.vue | 12 +++++++----- src/components/mixins/base.ts | 4 ++++ src/store/types.ts | 7 +++++++ src/store/variables.ts | 21 ++++++++++++++------- 4 files changed, 32 insertions(+), 12 deletions(-) diff --git a/src/components/TheEditor.vue b/src/components/TheEditor.vue index f122c2ca0..d0d5e0378 100644 --- a/src/components/TheEditor.vue +++ b/src/components/TheEditor.vue @@ -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, @@ -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 } diff --git a/src/components/mixins/base.ts b/src/components/mixins/base.ts index 4aabadbc8..3e825f941 100644 --- a/src/components/mixins/base.ts +++ b/src/components/mixins/base.ts @@ -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) } diff --git a/src/store/types.ts b/src/store/types.ts index c004690e7..11cdd6d22 100644 --- a/src/store/types.ts +++ b/src/store/types.ts @@ -58,3 +58,10 @@ export interface Theme { } css?: boolean } + +export interface KlipperRepos { + [name: string]: { + url: string + docsLanguages?: string[] + } +} diff --git a/src/store/variables.ts b/src/store/variables.ts index a56935af5..74dc2a847 100644 --- a/src/store/variables.ts +++ b/src/store/variables.ts @@ -1,4 +1,4 @@ -import { Theme } from '@/store/types' +import { KlipperRepos, Theme } from '@/store/types' export const defaultMode = 'dark' export const defaultTheme = 'mainsail' @@ -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 */ @@ -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/', + }, +}