From a633e2ff82fbfa8bbc86c7b255fbbec8d48d6c33 Mon Sep 17 00:00:00 2001 From: Zack Spear Date: Wed, 31 May 2023 15:36:51 -0700 Subject: [PATCH] refactor: dropdown components --- components/UserProfile/Dropdown.vue | 78 ++++++---------------- components/UserProfile/DropdownItem.vue | 64 ++++++++++++++++++ components/UserProfile/DropdownWrapper.vue | 5 ++ store/server.ts | 6 +- types/server.ts | 4 +- types/userProfile.ts | 10 +++ 6 files changed, 105 insertions(+), 62 deletions(-) create mode 100644 components/UserProfile/DropdownItem.vue create mode 100644 components/UserProfile/DropdownWrapper.vue create mode 100644 types/userProfile.ts diff --git a/components/UserProfile/Dropdown.vue b/components/UserProfile/Dropdown.vue index 4cc921705..9e64ada92 100644 --- a/components/UserProfile/Dropdown.vue +++ b/components/UserProfile/Dropdown.vue @@ -4,31 +4,23 @@ import { ArrowRightOnRectangleIcon, ArrowTopRightOnSquareIcon, CogIcon } from '@ import { ACCOUNT, CONNECT_DASHBOARD, PLUGIN_SETTINGS } from '~/helpers/urls'; import { useServerStore } from '~/store/server'; - -export interface Props { - show?: boolean; -} - -withDefaults(defineProps(), { - show: false, -}); +import type { ServerStateDataAction } from '~/types/server'; +import type { UserProfileLink } from '~/types/userProfile'; const myServersEnv = ref('Staging'); -const devEnv = ref(true); +const devEnv = ref('development'); const serverStore = useServerStore(); const { stateData } = storeToRefs(serverStore); -interface Link { - emphasize?: boolean; - external?: boolean; - href: string; - icon?: typeof CogIcon; - text: string; - title?: string; -} +// Intended to hide sign in and sign out from actions v-for in UPC dropdown so we can display them separately +const stateDataKeyActions = computed((): ServerStateDataAction[] | undefined => { + const notAllowed = ['signIn', 'signOut']; + if (!stateData.value.actions) return; + return stateData.value.actions.filter(action => !notAllowed.includes(action.name)); +}); -const links = computed(():Link[] => { +const links = computed(():UserProfileLink[] => { return [ { emphasize: true, @@ -56,22 +48,19 @@ const links = computed(():Link[] => {