From 2d9e2e81ae729f081d1fe7c266d0200c0ecdc351 Mon Sep 17 00:00:00 2001 From: Paul Neubauer Date: Fri, 16 Jun 2023 13:05:00 +0200 Subject: [PATCH 01/10] Load common theme into store --- packages/web-runtime/src/container/bootstrap.ts | 6 +++--- packages/web-runtime/src/helpers/theme.ts | 4 ++-- packages/web-runtime/src/pages/accessDenied.vue | 2 +- packages/web-runtime/src/store/config.ts | 11 ++++++++++- 4 files changed, 16 insertions(+), 7 deletions(-) diff --git a/packages/web-runtime/src/container/bootstrap.ts b/packages/web-runtime/src/container/bootstrap.ts index fffc60f5879..e5ca501e831 100644 --- a/packages/web-runtime/src/container/bootstrap.ts +++ b/packages/web-runtime/src/container/bootstrap.ts @@ -217,13 +217,13 @@ export const announceTheme = async ({ designSystem: any runtimeConfiguration?: RuntimeConfiguration }): Promise => { - const { theme } = await loadTheme(runtimeConfiguration?.theme) - await store.dispatch('loadThemes', { theme }) + const { web, common } = await loadTheme(runtimeConfiguration?.theme) + await store.dispatch('loadThemes', { theme: web, common }) const currentThemeName = useLocalStorage('oc_currentThemeName', null) // note: use null as default so that we can fall back to system preferences if (unref(currentThemeName) === null) { currentThemeName.value = useDefaultThemeName() } - await store.dispatch('loadTheme', { theme: theme[unref(currentThemeName)] || theme.default }) + await store.dispatch('loadTheme', { theme: web[unref(currentThemeName)] || web.default }) app.use(designSystem, { tokens: store.getters.theme.designTokens diff --git a/packages/web-runtime/src/helpers/theme.ts b/packages/web-runtime/src/helpers/theme.ts index 7ff062c2fb3..1595b98fd35 100644 --- a/packages/web-runtime/src/helpers/theme.ts +++ b/packages/web-runtime/src/helpers/theme.ts @@ -3,7 +3,7 @@ import defaultTheme from '../../themes/owncloud/theme.json' import { v4 as uuidV4 } from 'uuid' export const loadTheme = async (location = '') => { - const defaults = { theme: defaultTheme.web || defaultTheme } + const defaults = { web: defaultTheme.web || defaultTheme, common: defaultTheme.common || {} } if (location.split('.').pop() !== 'json') { if (isEqual(process.env.NODE_ENV, 'development')) { @@ -18,7 +18,7 @@ export const loadTheme = async (location = '') => { return defaults } const theme = await response.json() - return { theme: theme.web || theme } + return { web: theme.web || theme, common: theme.common || {} } } catch (e) { console.error( `Failed to load theme '${location}' is not a valid json file, using default theme.` diff --git a/packages/web-runtime/src/pages/accessDenied.vue b/packages/web-runtime/src/pages/accessDenied.vue index 00a843c7d38..d3461f72128 100644 --- a/packages/web-runtime/src/pages/accessDenied.vue +++ b/packages/web-runtime/src/pages/accessDenied.vue @@ -40,7 +40,7 @@ export default defineComponent({ return store.getters.configuration.currentTheme.logo.login }) const cardTitle = computed(() => { - return $gettext('Logged out') + return $gettext('Not logged in') }) const cardHint = computed(() => { return $gettext('You were automatically logged out for security reasons.') diff --git a/packages/web-runtime/src/store/config.ts b/packages/web-runtime/src/store/config.ts index aece2d8efa7..4c57b01d481 100644 --- a/packages/web-runtime/src/store/config.ts +++ b/packages/web-runtime/src/store/config.ts @@ -15,6 +15,11 @@ const state = { authority: '' }, themes: [], + commonTheme: { + name: '', + solgan: '', + logo: '' + }, currentTheme: { general: { name: '', @@ -81,8 +86,9 @@ const actions = { loadTheme(context, { theme }) { context.commit('LOAD_THEME', theme) }, - loadThemes(context, { theme }) { + loadThemes(context, { theme, common }) { context.commit('LOAD_THEMES', theme) + context.commit('LOAD_COMMON', common) } } @@ -106,6 +112,9 @@ const mutations = { }, LOAD_THEMES(state, theme) { state.themes = theme + }, + LOAD_COMMON(state, common) { + state.commonTheme = common } } From 12fd39eeb46fd41e0d3e6e182dc8f067def46fd2 Mon Sep 17 00:00:00 2001 From: Paul Neubauer Date: Mon, 19 Jun 2023 10:36:43 +0200 Subject: [PATCH 02/10] Implement url in access denied page --- .../web-runtime/src/pages/accessDenied.vue | 20 +++++++++++++++++-- packages/web-runtime/src/store/config.ts | 6 ++++-- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/packages/web-runtime/src/pages/accessDenied.vue b/packages/web-runtime/src/pages/accessDenied.vue index d3461f72128..a56500c60b9 100644 --- a/packages/web-runtime/src/pages/accessDenied.vue +++ b/packages/web-runtime/src/pages/accessDenied.vue @@ -5,6 +5,14 @@