Skip to content

Commit fdbd14f

Browse files
authored
Merge pull request #6539 from FlowFuse/feature/6513/allow-setting-custom-themes
Enhance theme selection with support for custom themes
2 parents 786a993 + f2e3ed1 commit fdbd14f

1 file changed

Lines changed: 20 additions & 2 deletions

File tree

  • frontend/src/pages/admin/Template/sections

frontend/src/pages/admin/Template/sections/Editor.vue

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,19 @@
110110
</div>
111111
<div class="flex flex-col sm:flex-row">
112112
<div class="w-full max-w-md sm:mr-8">
113-
<FormRow v-model="editable.settings.theme" :disabled="!editTemplate && !editable.policy.theme" type="select" :options="themes">
113+
<FormRow v-model="editable.settings.theme" :disabled="!editTemplate && !editable.policy.theme" type="uneditable" :options="themeOptions" wrapper-class="max-w-sm">
114114
Editor Theme
115115
<template #append><ChangeIndicator :value="editable.changed.settings.theme" /></template>
116+
<template #description>Choose a standard FlowFuse theme or enter the name of a loaded custom theme</template>
117+
<template #input>
118+
<ff-combobox
119+
v-model="editable.settings.theme"
120+
:options="themeOptions"
121+
:disabled="!editTemplate && !editable.policy.theme"
122+
:hasCustomValue="true"
123+
data-el="theme-dropdown"
124+
/>
125+
</template>
116126
</FormRow>
117127
</div>
118128
<LockSetting v-model="editable.policy.theme" class="flex justify-end flex-col" :editTemplate="editTemplate" :changed="editable.changed.policy.theme" />
@@ -231,7 +241,7 @@ export default {
231241
data () {
232242
return {
233243
timezones: timezonesData.timezones,
234-
themes: [
244+
defaultThemes: [
235245
{ label: 'FlowFuse Light', value: 'forge-light' },
236246
{ label: 'FlowFuse Dark', value: 'forge-dark' }
237247
] // FUTURE: Get from theme plugins
@@ -278,6 +288,14 @@ export default {
278288
return true
279289
}
280290
return SemVer.satisfies(SemVer.coerce(launcherVersion), '>=2.12.0')
291+
},
292+
themeOptions () {
293+
if (this.modelValue?.settings?.theme && !this.defaultThemes.map(th => th.value).includes(this.modelValue.settings.theme)) {
294+
// set the custom theme as one of the available options
295+
return [...this.defaultThemes, { label: this.modelValue.settings.theme, value: this.modelValue.settings.theme }]
296+
}
297+
298+
return this.defaultThemes
281299
}
282300
}
283301
}

0 commit comments

Comments
 (0)