From 28559240ea76a39af9ca6bd456e7dd3a4000a4e9 Mon Sep 17 00:00:00 2001 From: Arturo Manzoli Date: Tue, 7 Jan 2025 17:54:40 -0300 Subject: [PATCH 1/2] Store: App-interface: Add dialog queue Signed-off-by: Arturo Manzoli App: Implement startup dialogs queue Signed-off-by: Arturo Manzoli --- src/App.vue | 50 ++++++++++++++++++++++++++++++-------- src/stores/appInterface.ts | 11 +++++++++ src/types/ui.ts | 14 +++++++++++ 3 files changed, 65 insertions(+), 10 deletions(-) create mode 100644 src/types/ui.ts diff --git a/src/App.vue b/src/App.vue index f50106e6c..2e07879f5 100644 --- a/src/App.vue +++ b/src/App.vue @@ -313,10 +313,12 @@ - - - + + +
+ +
diff --git a/src/stores/appInterface.ts b/src/stores/appInterface.ts index 00b900fd9..cee473f46 100644 --- a/src/stores/appInterface.ts +++ b/src/stores/appInterface.ts @@ -4,6 +4,7 @@ import { watch } from 'vue' import { defaultDisplayUnitPreferences } from '@/assets/defaults' import { useBlueOsStorage } from '@/composables/settingsSyncer' +import { DialogOnQueue } from '@/types/ui' const { width: windowWidth, height: windowHeight } = useWindowSize() @@ -28,6 +29,8 @@ export const useAppInterfaceStore = defineStore('responsive', { isGlassModalAlwaysOnTop: false, isTutorialVisible: false, configPanelVisible: false, + dialogQueue: [] as DialogOnQueue[], + activeDialog: undefined as DialogOnQueue | undefined, }), actions: { updateWidth() { @@ -41,6 +44,14 @@ export const useAppInterfaceStore = defineStore('responsive', { .padStart(2, '0') this.UIGlassEffect.bgColor = `#${hex}${alphaHex}` }, + enqueueDialog(dialog: DialogOnQueue) { + this.dialogQueue.push(dialog) + }, + openNextDialogOnQueue() { + if (this.dialogQueue.length > 0) { + this.activeDialog = this.dialogQueue.shift() + } + }, }, getters: { isXs: (state) => state.width < 720, // Extra small devices (5-6" mobile screens in landscape) diff --git a/src/types/ui.ts b/src/types/ui.ts new file mode 100644 index 000000000..1b94a78c2 --- /dev/null +++ b/src/types/ui.ts @@ -0,0 +1,14 @@ +export type DialogOnQueue = { + /** + * Dialog Id + */ + id: string + /** + * Component to be rendered + */ + component: any + /** + * Props to be passed to the component + */ + props?: Record +} From f6e9ea45ceeffdd19d1d9dd3007eb04cd1e4872b Mon Sep 17 00:00:00 2001 From: Arturo Manzoli Date: Tue, 7 Jan 2025 17:57:58 -0300 Subject: [PATCH 2/2] App: Startup dialogs: Implement changes to run under dialog queue Signed-off-by: Arturo Manzoli --- src/components/InteractionDialog.vue | 14 ++++++++- src/components/Tutorial.vue | 19 +++--------- src/components/UpdateNotification.vue | 35 ++++++++++++++++------- src/components/VehicleDiscoveryDialog.vue | 14 +++++++-- 4 files changed, 53 insertions(+), 29 deletions(-) diff --git a/src/components/InteractionDialog.vue b/src/components/InteractionDialog.vue index c8b413a8a..a4adf7863 100644 --- a/src/components/InteractionDialog.vue +++ b/src/components/InteractionDialog.vue @@ -1,5 +1,11 @@ + @@ -37,6 +38,9 @@ import { onBeforeMount, ref } from 'vue' import InteractionDialog, { type Action } from '@/components/InteractionDialog.vue' import { app_version } from '@/libs/cosmos' import { isElectron } from '@/libs/utils' +import { useAppInterfaceStore } from '@/stores/appInterface' + +const interfaceStore = useAppInterfaceStore() const showUpdateDialog = ref(false) const dialogTitle = ref('') @@ -52,6 +56,11 @@ const updateInfo = ref({ }) const ignoredUpdateVersions = useStorage('cockpit-ignored-update-versions', []) +const handleClose = (): void => { + interfaceStore.openNextDialogOnQueue() + showUpdateDialog.value = false +} + const formatDate = (date: string): string => { return new Date(date).toLocaleDateString('en-US', { year: 'numeric', month: 'long', day: 'numeric' }) } @@ -75,7 +84,9 @@ onBeforeMount(() => { dialogVariant.value = 'info' dialogActions.value = [] showProgress.value = false - showUpdateDialog.value = true + if (interfaceStore.activeDialog?.id === 'UpdateNotification' || interfaceStore.activeDialog === undefined) { + showUpdateDialog.value = true + } }) window.electronAPI.onUpdateNotAvailable(() => { @@ -87,7 +98,7 @@ onBeforeMount(() => { { text: 'OK', action: () => { - showUpdateDialog.value = false + interfaceStore.openNextDialogOnQueue() }, }, ] @@ -107,7 +118,7 @@ onBeforeMount(() => { console.log(`User chose to ignore version ${updateInfo.value.version}`) ignoredUpdateVersions.value.push(updateInfo.value.version) window.electronAPI!.cancelUpdate() - showUpdateDialog.value = false + interfaceStore.openNextDialogOnQueue() }, }, { @@ -121,7 +132,7 @@ onBeforeMount(() => { action: () => { console.log('User chose to cancel the update for the Electron app.') window.electronAPI!.cancelUpdate() - showUpdateDialog.value = false + interfaceStore.openNextDialogOnQueue() dialogMessage.value = 'Downloading update...' }, }, @@ -132,7 +143,7 @@ onBeforeMount(() => { text: 'Not Now', action: () => { window.electronAPI!.cancelUpdate() - showUpdateDialog.value = false + interfaceStore.openNextDialogOnQueue() }, }, ] @@ -140,11 +151,13 @@ onBeforeMount(() => { // Check if this version is in the ignored list if (ignoredUpdateVersions.value.includes(info.version)) { console.log(`Skipping ignored version ${info.version}.`) - showUpdateDialog.value = false + interfaceStore.openNextDialogOnQueue() return } - showUpdateDialog.value = true + if (interfaceStore.activeDialog?.id === 'UpdateNotification' || interfaceStore.activeDialog === undefined) { + showUpdateDialog.value = true + } }) window.electronAPI.onDownloadProgress((progressInfo) => { @@ -164,18 +177,20 @@ onBeforeMount(() => { action: () => { console.log('User chose to install the update for the Electron app now.') window.electronAPI!.installUpdate() - showUpdateDialog.value = false + interfaceStore.openNextDialogOnQueue() }, }, { text: 'Later', action: () => { console.log('User chose to install the update for the Electron app later.') - showUpdateDialog.value = false + interfaceStore.openNextDialogOnQueue() }, }, ] - showUpdateDialog.value = true + if (interfaceStore.activeDialog?.id === 'UpdateNotification' || interfaceStore.activeDialog === undefined) { + showUpdateDialog.value = true + } }) }) diff --git a/src/components/VehicleDiscoveryDialog.vue b/src/components/VehicleDiscoveryDialog.vue index 456f5fb99..1365690d1 100644 --- a/src/components/VehicleDiscoveryDialog.vue +++ b/src/components/VehicleDiscoveryDialog.vue @@ -47,15 +47,18 @@