diff --git a/dashboard/src2/components/TabsWithRouter.vue b/dashboard/src2/components/TabsWithRouter.vue index 5895204caf..82ff0dbc5b 100644 --- a/dashboard/src2/components/TabsWithRouter.vue +++ b/dashboard/src2/components/TabsWithRouter.vue @@ -12,13 +12,15 @@ import { Tabs } from 'frappe-ui'; export default { name: 'TabsWithRouter', - props: ['tabs'], + props: ['tabs', 'document'], components: { FTabs: Tabs }, computed: { visibleTabs() { - return this.tabs.filter(tab => (tab.condition ? tab.condition() : true)); + return this.tabs.filter(tab => + tab.condition ? tab.condition({ doc: this.document }) : true + ); }, currentTab: { get() { diff --git a/dashboard/src2/objects/common/apps.ts b/dashboard/src2/objects/common/apps.ts index f6766b2c1e..703d43bb1c 100644 --- a/dashboard/src2/objects/common/apps.ts +++ b/dashboard/src2/objects/common/apps.ts @@ -20,6 +20,7 @@ export function getAppsTab(forSite: boolean) { icon: icon('grid'), route: 'apps', type: 'list', + condition: docResource => forSite && docResource.doc?.status !== 'Archived', list: getAppsTabList(forSite) } satisfies Tab as Tab; } diff --git a/dashboard/src2/objects/common/index.ts b/dashboard/src2/objects/common/index.ts index 7ea64875b8..3f3c74bcae 100644 --- a/dashboard/src2/objects/common/index.ts +++ b/dashboard/src2/objects/common/index.ts @@ -3,10 +3,9 @@ import { renderDialog } from '../../utils/components'; import type { BannerConfig, ColumnField, - Resource, + DocumentResource, Route, - Row, - Tab + Row } from './types'; import { trialDays } from '../../utils/site'; import { planTitle } from '../../utils/format'; @@ -27,7 +26,7 @@ export const clusterOptions = [ 'Zurich' ]; -export function getUpsellBanner(site: Resource, title: string) { +export function getUpsellBanner(site: DocumentResource, title: string) { if (site.doc.current_plan?.private_benches || !site.doc.group_public) return; return { diff --git a/dashboard/src2/objects/common/types.ts b/dashboard/src2/objects/common/types.ts index a7b767bfec..a7b22d94c4 100644 --- a/dashboard/src2/objects/common/types.ts +++ b/dashboard/src2/objects/common/types.ts @@ -122,6 +122,7 @@ export interface Tab { icon: Icon; route: string; type: string; + condition?: (r: DocumentResource) => boolean; childrenRoutes?: string[]; component?: AsyncComponent; props?: (r: DocumentResource) => Record; diff --git a/dashboard/src2/objects/site.js b/dashboard/src2/objects/site.js index e0de9e6d20..e604fdc44c 100644 --- a/dashboard/src2/objects/site.js +++ b/dashboard/src2/objects/site.js @@ -85,7 +85,7 @@ export default { type: 'select', label: 'Status', fieldname: 'status', - options: ['', 'Active', 'Inactive', 'Suspended', 'Broken'] + options: ['', 'Active', 'Inactive', 'Suspended', 'Broken', 'Archived'] }, { type: 'link', @@ -242,6 +242,7 @@ export default { icon: icon('home'), route: 'overview', type: 'Component', + condition: site => site.doc?.status !== 'Archived', component: defineAsyncComponent(() => import('../components/SiteOverview.vue') ), @@ -254,6 +255,7 @@ export default { icon: icon('bar-chart-2'), route: 'insights', type: 'Component', + condition: site => site.doc?.status !== 'Archived', redirectTo: 'Site Analytics', childrenRoutes: [ 'Site Jobs', @@ -345,6 +347,7 @@ export default { icon: icon('external-link'), route: 'domains', type: 'list', + condition: site => site.doc?.status !== 'Archived', list: { doctype: 'Site Domain', fields: ['redirect_to_primary'], @@ -903,6 +906,7 @@ export default { icon: icon('settings'), route: 'site-config', type: 'list', + condition: site => site.doc?.status !== 'Archived', list: { doctype: 'Site Config', filters: site => { @@ -1035,6 +1039,7 @@ export default { icon: icon('sliders'), route: 'actions', type: 'Component', + condition: site => site.doc?.status !== 'Archived', component: SiteActions, props: site => { return { site: site.doc?.name }; @@ -1045,6 +1050,7 @@ export default { icon: icon('arrow-up-circle'), route: 'updates', type: 'list', + condition: site => site.doc?.status !== 'Archived', list: { doctype: 'Site Update', filters: site => { @@ -1302,6 +1308,7 @@ export default { icon: icon('activity'), route: 'activity', type: 'list', + condition: site => site.doc?.status !== 'Archived', list: { doctype: 'Site Activity', filters: site => { diff --git a/dashboard/src2/pages/DetailPage.vue b/dashboard/src2/pages/DetailPage.vue index 483eaeca10..d43e8c5f29 100644 --- a/dashboard/src2/pages/DetailPage.vue +++ b/dashboard/src2/pages/DetailPage.vue @@ -29,6 +29,7 @@