feat(preview): expose availability and handle missing services
Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
This commit is contained in:
@@ -6,6 +6,7 @@ import { createPinia } from 'pinia'
|
||||
import { PerfectScrollbarPlugin } from 'vue3-perfect-scrollbar'
|
||||
import { useModuleStore } from '@KTXC/stores/moduleStore'
|
||||
import { useTenantStore } from '@KTXC/stores/tenantStore'
|
||||
import { usePreviewStore } from '@KTXC/stores/previewStore'
|
||||
import { useUserStore } from '@KTXC/stores/userStore'
|
||||
import { useL10nStore } from '@KTXC/stores/l10nStore'
|
||||
import { useThemeStore } from '@KTXC/stores/themeStore'
|
||||
@@ -41,6 +42,7 @@ globalWindow.Pinia = PiniaLib as unknown
|
||||
(async () => {
|
||||
const moduleStore = useModuleStore();
|
||||
const tenantStore = useTenantStore();
|
||||
const previewStore = usePreviewStore();
|
||||
const userStore = useUserStore();
|
||||
const l10nStore = useL10nStore();
|
||||
const themeStore = useThemeStore();
|
||||
@@ -49,6 +51,7 @@ globalWindow.Pinia = PiniaLib as unknown
|
||||
try {
|
||||
const payload = await fetchWrapper.get('/init');
|
||||
moduleStore.init(payload?.modules ?? {});
|
||||
previewStore.init(payload?.preview ?? null);
|
||||
tenantStore.init(payload?.tenant ?? null);
|
||||
userStore.init(payload?.user ?? {});
|
||||
layoutStore.hydrateFromSettings();
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
// Stores
|
||||
export { useModuleStore } from '../stores/moduleStore'
|
||||
export { useTenantStore } from '../stores/tenantStore'
|
||||
export { usePreviewStore } from '../stores/previewStore'
|
||||
export type { PreviewAvailability } from '../stores/previewStore'
|
||||
export { useUserStore } from '../stores/userStore'
|
||||
export { useIntegrationStore } from '../stores/integrationStore'
|
||||
export { useLayoutStore } from '../stores/layoutStore'
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
import { defineStore } from 'pinia'
|
||||
import { ref } from 'vue'
|
||||
|
||||
export interface PreviewAvailability {
|
||||
enabled: boolean
|
||||
storage: boolean
|
||||
generation: boolean
|
||||
}
|
||||
|
||||
const unavailable = (): PreviewAvailability => ({
|
||||
enabled: false,
|
||||
storage: false,
|
||||
generation: false,
|
||||
})
|
||||
|
||||
export const usePreviewStore = defineStore('previewStore', () => {
|
||||
const availability = ref<PreviewAvailability>(unavailable())
|
||||
|
||||
function init(data?: Partial<PreviewAvailability> | null): void {
|
||||
availability.value = {
|
||||
enabled: data?.enabled ?? false,
|
||||
storage: data?.storage ?? false,
|
||||
generation: data?.generation ?? false,
|
||||
}
|
||||
}
|
||||
|
||||
function reset(): void {
|
||||
availability.value = unavailable()
|
||||
}
|
||||
|
||||
return {
|
||||
availability,
|
||||
init,
|
||||
reset,
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user