feat(preview): expose availability and handle missing services
Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
This commit is contained in:
@@ -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