π₯ π₯ π₯ A Free & Self-hostable Airtable Alternative
TypeScript airtableairtable-alternativeautomatic-apihacktoberfestlow-codeno-codeno-code-databaseno-code-platformpostgresqlrest-apirestful-apispreadsheetsqliteswagger
feat: add back to base button in non base routes
Ramesh Mane919770bac6ce
diff --git a/packages/nc-gui/components/dashboard/BackToBase/BreadcrumbVariant.vue b/packages/nc-gui/components/dashboard/BackToBase/BreadcrumbVariant.vuenew file mode 100644index 0000000000..685a551038--- /dev/null+++ b/packages/nc-gui/components/dashboard/BackToBase/BreadcrumbVariant.vue@@ -0,0 +1,45 @@+<!-- Back to Base: breadcrumb variant.+ Full-width bar rendered between the breadcrumb row and the page tabs.+ Only visible when shouldShow is true and variant is 'breadcrumb'. -->+<script lang="ts" setup>+const { shouldShow, navigateToBase, lastVisitedBase } = useBackToBase()+</script>++<template>+ <Transition name="nc-btb-bc">+ <div+ v-if="shouldShow"+ class="nc-btb-bar w-full flex items-center gap-2 px-4 h-9 border-b-1 border-nc-border-gray-medium bg-nc-bg-gray-extralight cursor-pointer select-none group hover:bg-nc-bg-brand-light transition-colors duration-150"+ data-testid="nc-btb-bar"+ @click="navigateToBase"+ >+ <GeneralIcon+ icon="chevronLeft"+ class="flex-none h-4 w-4 text-nc-content-gray-muted group-hover:text-nc-content-brand transition-colors duration-150"+ />+ <span class="text-small font-medium text-nc-content-gray-subtle group-hover:text-nc-content-brand transition-colors duration-150">+ {{ $t('labels.backToBase') }}+ </span>+ <span+ v-if="lastVisitedBase?.title"+ class="text-small font-semibold text-nc-content-gray group-hover:text-nc-content-brand transition-colors duration-150 truncate"+ >+ {{ lastVisitedBase.title }}+ </span>+ </div>+ </Transition>+</template>++<style lang="scss" scoped>+.nc-btb-bc-enter-active,+.nc-btb-bc-leave-active {+ transition: opacity 0.15s ease, max-height 0.15s ease;+ max-height: 2.25rem; /* h-9 */+ overflow: hidden;+}+.nc-btb-bc-enter-from,+.nc-btb-bc-leave-to {+ opacity: 0;+ max-height: 0;+}+</style>diff --git a/packages/nc-gui/components/workspace/View.vue b/packages/nc-gui/components/workspace/View.vueindex cc6197797f..ce7bd62abc 100644--- a/packages/nc-gui/components/workspace/View.vue+++ b/packages/nc-gui/components/workspace/View.vue@@ -123,6 +123,8 @@ watch(},)+const { shouldShow: btbShouldShow } = useBackToBase()+onMounted(() => {hideSidebar.value = true})@@ -133,7 +135,7 @@ onBeforeUnmount(() => {</script><template>- <div v-if="currentWorkspace" class="flex w-full flex-col nc-workspace-settings">+ <div v-if="currentWorkspace" class="flex w-full flex-col nc-workspace-settings h-full overflow-hidden"><divv-if="!props.workspaceId"class="min-w-0 p-2 h-[var(--topbar-height)] border-b-1 border-nc-border-gray-medium flex items-center gap-2"@@ -154,6 +156,7 @@ onBeforeUnmount(() => {{{ $t('title.teamAndSettings') }}</h1></div>+<GeneralHideLeftSidebarBtn v-if="isMobileMode && isLeftSidebarOpen" /></div><template v-else>@@ -191,7 +194,10 @@ onBeforeUnmount(() => {</NcPageHeader></template>- <NcTabs v-model:active-key="tab">+ <!-- Back-to-base full-width bar: shown between breadcrumb and tabs (breadcrumb variant only) -->+ <DashboardBackToBaseBreadcrumbVariant />++ <NcTabs v-model:active-key="tab" class="flex-1 min-h-0"><template #leftExtra><div class="w-3"></div></template>@@ -258,7 +264,7 @@ onBeforeUnmount(() => {</div></template>- <WorkspaceSso class="!h-[calc(100vh_-_92px)]" />+ <WorkspaceSso :class="btbShouldShow ? '!h-[calc(100vh-128px)]' : '!h-[calc(100vh-92px)]'" /></a-tab-pane></template></template>diff --git a/packages/nc-gui/components/workspace/integrations/view.vue b/packages/nc-gui/components/workspace/integrations/view.vueindex 823255240e..eb4baeec23 100644--- a/packages/nc-gui/components/workspace/integrations/view.vue+++ b/packages/nc-gui/components/workspace/integrations/view.vue@@ -14,6 +14,8 @@ const { loadCollaborators } = workspaceStoreconst { isFromIntegrationPage, integrationPaginationData, activeViewTab, loadIntegrations } = useProvideIntegrationViewStore()+const { shouldShow: btbShouldShow } = useBackToBase()+const currentWorkspace = computedAsync(async () => {await loadRoles(undefined, {}, _activeWorkspace.value?.id)return _activeWorkspace.value@@ -64,7 +66,11 @@ onBeforeMount(() => {{{ $t('general.integrations') }}</h1></div>+</div>++ <DashboardBackToBaseBreadcrumbVariant />+<NcTabs v-model:active-key="activeViewTab"><template #leftExtra><div class="w-3"></div>@@ -77,7 +83,7 @@ onBeforeMount(() => {{{ $t('general.integrations') }}</div></template>- <div class="h-[calc(100vh-92px)]">+ <div :class="btbShouldShow ? 'h-[calc(100vh-128px)]' : 'h-[calc(100vh-92px)]'"><WorkspaceIntegrationsTab show-filter /></div></a-tab-pane>@@ -100,7 +106,7 @@ onBeforeMount(() => {</div></div></template>- <div class="h-[calc(100vh-92px)] p-6">+ <div :class="[btbShouldShow ? 'h-[calc(100vh-128px)]' : 'h-[calc(100vh-92px)]', 'p-6']"><WorkspaceIntegrationsConnectionsTab /></div></a-tab-pane>diff --git a/packages/nc-gui/composables/useBackToBase.ts b/packages/nc-gui/composables/useBackToBase.tsnew file mode 100644index 0000000000..057b5234dd--- /dev/null+++ b/packages/nc-gui/composables/useBackToBase.ts@@ -0,0 +1,38 @@+export const useBackToBase = () => {+ const router = useRouter()+ const route = router.currentRoute++ const { navigateToProject } = useGlobal()+ const { basesList } = storeToRefs(useBases())+ const { activeWorkspaceId } = storeToRefs(useWorkspace())+ const { isMobileMode } = useGlobal()++ // hideMiniSidebar is true on full-screen flows (payment, checkout, pricing, upgrade)+ // β we don't want back-to-base intruding on those pages+ const { hideMiniSidebar } = storeToRefs(useSidebarStore())++ const isOnBasePage = computed(() => route.value.name?.toString().startsWith('index-typeOrId-baseId-') ?? false)++ const lastVisitedBase = computed(() => {+ const lastId = ncLastVisitedBase().get()+ return lastId ? basesList.value?.find((b) => b.id === lastId) ?? basesList.value?.[0] : basesList.value?.[0]+ })++ const shouldShow = computed(() => !isOnBasePage.value && !hideMiniSidebar.value && !!lastVisitedBase.value)++ const navigateToBase = () => {+ if (!lastVisitedBase.value) return+ navigateToProject({+ workspaceId: isEeUI ? activeWorkspaceId.value : undefined,+ baseId: lastVisitedBase.value.id,+ })+ }++ return {+ isOnBasePage,+ lastVisitedBase,+ shouldShow,+ navigateToBase,+ isMobileMode,+ }+}diff --git a/packages/nc-gui/lang/en.json b/packages/nc-gui/lang/en.jsonindex 86151c1aba..c257e6c455 100644--- a/packages/nc-gui/lang/en.json+++ b/packages/nc-gui/lang/en.json@@ -1543,6 +1543,7 @@"controlAppearance": "Control your Appearance.","accountEmailID": "Account Email ID","backToWorkspace": "Back to Workspace",+ "backToBase": "Back to Base","untitledToken": "Untitled token","tableName": "Table name","createView": "Create view",