From e3c3cb0688998da932e870dbbb137d4d2e421756 Mon Sep 17 00:00:00 2001 From: Zack Spear Date: Fri, 1 Sep 2023 16:01:07 -0700 Subject: [PATCH] fix(web): sign out ux hide api error --- web/components/UserProfile/CallbackFeedback.vue | 7 ++++++- web/locales/en_US.json | 4 +++- web/store/account.ts | 8 +++++++- web/store/errors.ts | 1 + web/store/server.ts | 11 +++++++++-- web/store/unraidApi.ts | 2 ++ 6 files changed, 28 insertions(+), 5 deletions(-) diff --git a/web/components/UserProfile/CallbackFeedback.vue b/web/components/UserProfile/CallbackFeedback.vue index fca74bd6d..6235b7fe6 100644 --- a/web/components/UserProfile/CallbackFeedback.vue +++ b/web/components/UserProfile/CallbackFeedback.vue @@ -48,7 +48,6 @@ const { refreshServerStateStatus, username, } = storeToRefs(serverStore); - /** * Post sign in success state: * If we're on the Connect settings page in the webGUI @@ -145,6 +144,12 @@ const accountActionStatusCopy = computed((): { text: string; } => { return { text: props.t('Ready to update Connect account configuration'), }; + case 'waiting': + return { + text: accountAction.value?.type === 'signIn' + ? props.t('Signing In') + : props.t('Signing Out'), + }; case 'updating': return { text: accountAction.value?.type === 'signIn' diff --git a/web/locales/en_US.json b/web/locales/en_US.json index e2e4b161a..576c22711 100644 --- a/web/locales/en_US.json +++ b/web/locales/en_US.json @@ -198,5 +198,7 @@ "Install Recovered": "Install Recovered", "Install Replaced": "Install Replaced", "Your free Trial key provides all the functionality of a Pro Registration key": "Your free Trial key provides all the functionality of a Pro Registration key", - "Calculating trial expiration…": "Calculating trial expiration…" + "Calculating trial expiration…": "Calculating trial expiration…", + "Signing In": "Signing In", + "Signing Out": "Signing Out" } diff --git a/web/store/account.ts b/web/store/account.ts index 7d2ad3694..8e89e2d5e 100644 --- a/web/store/account.ts +++ b/web/store/account.ts @@ -30,7 +30,7 @@ export const useAccountStore = defineStore('account', () => { // State const accountAction = ref(); const accountActionHide = ref(false); - const accountActionStatus = ref<'failed' | 'ready' | 'success' | 'updating'>('ready'); + const accountActionStatus = ref<'failed' | 'ready' | 'success' | 'updating' | 'waiting'>('ready'); /** * Handling sign in / out via graph api @@ -39,10 +39,16 @@ export const useAccountStore = defineStore('account', () => { const connectSignInPayload = ref(); const setConnectSignInPayload = (payload: ConnectSignInMutationPayload | undefined) => { connectSignInPayload.value = payload; + if (payload) { + accountActionStatus.value = 'waiting'; + } }; const queueConnectSignOut = ref(false); const setQueueConnectSignOut = (data: boolean) => { queueConnectSignOut.value = data; + if (data) { + accountActionStatus.value = 'waiting'; + } }; watchEffect(() => { if (unraidApiClient.value && connectSignInPayload.value) { diff --git a/web/store/errors.ts b/web/store/errors.ts index fb9abcea2..7c722fa24 100644 --- a/web/store/errors.ts +++ b/web/store/errors.ts @@ -42,6 +42,7 @@ export const useErrorsStore = defineStore('errors', () => { }; const setError = (error: Error) => { + console.error('[setError]', error); errors.value.push(error); }; diff --git a/web/store/server.ts b/web/store/server.ts index 559187132..3fa81828c 100644 --- a/web/store/server.ts +++ b/web/store/server.ts @@ -619,8 +619,15 @@ export const useServerStore = defineStore('server', () => { }); const cloudError = computed((): Error | undefined => { - // if we're not registered then the cloud error should be ignored - if (!registered.value || !cloud.value?.error) { return; } + // if we're not registered or we're in the process of signing out then the cloud error should be ignored + if (!registered.value + || !cloud.value?.error + || accountStore.accountActionType === 'signOut' + || accountStore.accountActionType === 'oemSignOut' + ) { + return; + } + // otherwise if we are we should display any cloud errors return { actions: [ { diff --git a/web/store/unraidApi.ts b/web/store/unraidApi.ts index 42a0e5e32..855158ca1 100644 --- a/web/store/unraidApi.ts +++ b/web/store/unraidApi.ts @@ -89,6 +89,8 @@ export const useUnraidApiStore = defineStore('unraidApi', () => { console.error('[GraphQL error]', error, error.error.message); if (error.error.message.includes('offline')) { unraidApiStatus.value = 'offline'; + // attempt to automatically restart the unraid-api + if (unraidApiRestartAction) restartUnraidApiClient(); } if (error.error.message && error.error.message.includes(ERROR_CORS_403)) { prioritizeCorsError = true;