From a263113147d7d0a812dfee6a0210766c5f6f81e4 Mon Sep 17 00:00:00 2001 From: Nivedin <53208152+nivedin@users.noreply.github.com> Date: Mon, 7 Apr 2025 19:56:29 +0530 Subject: [PATCH] chore: add organization dashboard link to profile dropdown (#4952) --- packages/hoppscotch-common/locales/en.json | 1 + .../src/components/app/Header.vue | 31 ++++++++++++++++++- .../src/platform/organization.ts | 1 + 3 files changed, 32 insertions(+), 1 deletion(-) diff --git a/packages/hoppscotch-common/locales/en.json b/packages/hoppscotch-common/locales/en.json index 495505aa..578f68e7 100644 --- a/packages/hoppscotch-common/locales/en.json +++ b/packages/hoppscotch-common/locales/en.json @@ -755,6 +755,7 @@ "url": "URL" }, "navigation": { + "admin_dashboard": "Dashboard", "doc": "Docs", "graphql": "GraphQL", "profile": "Profile", diff --git a/packages/hoppscotch-common/src/components/app/Header.vue b/packages/hoppscotch-common/src/components/app/Header.vue index af10a8f0..4d528bf0 100644 --- a/packages/hoppscotch-common/src/components/app/Header.vue +++ b/packages/hoppscotch-common/src/components/app/Header.vue @@ -199,6 +199,7 @@ tabindex="0" @keyup.p="profile.$el.click()" @keyup.s="settings.$el.click()" + @keyup.d="dashboard.$el.click()" @keyup.l="logout.$el.click()" @keyup.escape="hide()" > @@ -231,6 +232,15 @@ :shortcut="['S']" @click="hide()" /> + (null) : ref(null) +const isUserAdmin = ref(false) + const currentState = kernelMode === "desktop" && instanceSwitcherService ? useReadonlyStream( @@ -346,6 +359,21 @@ const workspaceSelectorFlagEnabled = computed( const showInstallButton = computed(() => !!pwaDefferedPrompt.value) +/** + * Show the dashboard link if the user is not on the default cloud instance and is an admin + */ +onMounted(async () => { + const { organization } = platform + + if (!organization || organization.isDefaultCloudInstance) return + + const orgInfo = await organization.getOrgInfo() + + if (orgInfo) { + isUserAdmin.value = !!orgInfo.isAdmin + } +}) + const showTeamsModal = ref(false) const breakpoints = useBreakpoints(breakpointsTailwind) @@ -517,6 +545,7 @@ const deleteTeam = () => { const tippyActions = ref(null) const profile = ref(null) const settings = ref(null) +const dashboard = ref(null) const logout = ref(null) const accountActions = ref(null) diff --git a/packages/hoppscotch-common/src/platform/organization.ts b/packages/hoppscotch-common/src/platform/organization.ts index 3ef32c4b..aa39db23 100644 --- a/packages/hoppscotch-common/src/platform/organization.ts +++ b/packages/hoppscotch-common/src/platform/organization.ts @@ -3,6 +3,7 @@ export type OrganizationPlatformDef = { getOrgInfo: () => Promise<{ orgID: string orgDomain: string + isAdmin: boolean } | null> getRootDomain: () => string initiateOnboarding: () => void