From 763c38430e66ae94969b61c048341285cbff0b4d Mon Sep 17 00:00:00 2001 From: Zack Spear Date: Fri, 26 Jan 2024 13:19:40 -0800 Subject: [PATCH] feat: add manage account link to all versions of upc dropdown --- .../UserProfile/DropdownContent.vue | 28 +++++++++++-------- web/store/account.ts | 13 +++++++++ web/store/callback.ts | 3 +- 3 files changed, 32 insertions(+), 12 deletions(-) diff --git a/web/components/UserProfile/DropdownContent.vue b/web/components/UserProfile/DropdownContent.vue index 15875bb2e..48543ac17 100644 --- a/web/components/UserProfile/DropdownContent.vue +++ b/web/components/UserProfile/DropdownContent.vue @@ -6,25 +6,25 @@ import { BellAlertIcon, CogIcon, KeyIcon, + UserIcon, } from '@heroicons/vue/24/solid'; import { - ACCOUNT, CONNECT_DASHBOARD, WEBGUI_CONNECT_SETTINGS, WEBGUI_TOOLS_REGISTRATION, } from '~/helpers/urls'; +import { useAccountStore } from '~/store/account'; import { useErrorsStore } from '~/store/errors'; import { useServerStore } from '~/store/server'; import { useUpdateOsStore } from '~/store/updateOs'; -import { useUpdateOsActionsStore } from '~/store/updateOsActions'; import type { UserProfileLink } from '~/types/userProfile'; const props = defineProps<{ t: any; }>(); +const accountStore = useAccountStore(); const errorsStore = useErrorsStore(); const updateOsStore = useUpdateOsStore(); -const updateOsActionsStore = useUpdateOsActionsStore(); const { errors } = storeToRefs(errorsStore); const { @@ -45,6 +45,16 @@ const signOutAction = computed(() => stateData.value.actions?.filter((act: { nam */ const filteredKeyActions = computed(() => keyActions.value?.filter(action => !['renew'].includes(action.name))); +const manageUnraidNetAccount = computed(() => { + return { + external: true, + click: () => { accountStore.manage(); }, + icon: UserIcon, + text: props.t('Manage Unraid.net Account'), + title: props.t('Manage Unraid.net Account in new tab'), + }; +}); + const links = computed(():UserProfileLink[] => { return [ ...(regUpdatesExpired.value @@ -90,13 +100,7 @@ const links = computed(():UserProfileLink[] => { text: props.t('Go to Connect'), title: props.t('Opens Connect in new tab'), }, - { - external: true, - href: ACCOUNT.toString(), - icon: ArrowTopRightOnSquareIcon, - text: props.t('Manage Unraid.net Account'), - title: props.t('Manage Unraid.net Account in new tab'), - }, + ...([manageUnraidNetAccount.value]), { href: WEBGUI_CONNECT_SETTINGS.toString(), icon: CogIcon, @@ -105,7 +109,9 @@ const links = computed(():UserProfileLink[] => { }, ...(signOutAction.value), ] - : [] + : [ + ...([manageUnraidNetAccount.value]), + ] ), ]; }); diff --git a/web/store/account.ts b/web/store/account.ts index 13fbea8b3..c8727f3c2 100644 --- a/web/store/account.ts +++ b/web/store/account.ts @@ -72,6 +72,18 @@ export const useAccountStore = defineStore('account', () => { const accountActionType = computed(() => accountAction.value?.type); // Actions + const manage = () => { + callbackStore.send( + ACCOUNT_CALLBACK.toString(), + [{ + server: { + ...serverAccountPayload.value, + }, + type: 'manage', + }], + inIframe.value ? 'newTab' : undefined, + ); + }; const recover = () => { callbackStore.send( ACCOUNT_CALLBACK.toString(), @@ -255,6 +267,7 @@ export const useAccountStore = defineStore('account', () => { // Getters accountActionType, // Actions + manage, recover, replace, signIn, diff --git a/web/store/callback.ts b/web/store/callback.ts index e4717ee58..4844108e1 100644 --- a/web/store/callback.ts +++ b/web/store/callback.ts @@ -23,7 +23,8 @@ export type Redeem = 'redeem'; export type Renew = 'renew'; export type Upgrade = 'upgrade'; export type UpdateOs = 'updateOs'; -export type AccountActionTypes = Troubleshoot | SignIn | SignOut | OemSignOut; +export type Manage = 'manage'; +export type AccountActionTypes = Troubleshoot | SignIn | SignOut | OemSignOut | Manage; export type AccountKeyActionTypes = Recover | Replace | TrialExtend | TrialStart | UpdateOs; export type PurchaseActionTypes = Purchase | Redeem | Renew | Upgrade;