Skip to content

Commit

Permalink
feat(Site): show archived sites
Browse files Browse the repository at this point in the history
- only backups list
- fix some typing while at it
  • Loading branch information
BreadGenie committed Nov 5, 2024
1 parent 03c80d0 commit c4fa7d0
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 14 deletions.
6 changes: 4 additions & 2 deletions dashboard/src2/components/TabsWithRouter.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
1 change: 1 addition & 0 deletions dashboard/src2/objects/common/apps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
7 changes: 3 additions & 4 deletions dashboard/src2/objects/common/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions dashboard/src2/objects/common/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, unknown>;
Expand Down
9 changes: 8 additions & 1 deletion dashboard/src2/objects/site.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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')
),
Expand All @@ -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',
Expand Down Expand Up @@ -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'],
Expand Down Expand Up @@ -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 => {
Expand Down Expand Up @@ -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 };
Expand All @@ -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 => {
Expand Down Expand Up @@ -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 => {
Expand Down
2 changes: 1 addition & 1 deletion dashboard/src2/pages/DetailPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
<div>
<TabsWithRouter
v-if="!$resources.document.get.error && $resources.document.get.fetched"
:document="$resources.document?.doc"
:tabs="tabs"
>
<template #tab-content="{ tab }">
Expand Down Expand Up @@ -57,7 +58,6 @@ import ActionButton from '../components/ActionButton.vue';
import { Breadcrumbs } from 'frappe-ui';
import { getObject } from '../objects';
import TabsWithRouter from '../components/TabsWithRouter.vue';
import AlertBanner from '../components/AlertBanner.vue';
let subscribed = {};
Expand Down
16 changes: 10 additions & 6 deletions press/press/doctype/site/site.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,14 +203,18 @@ def get_list_query(query, filters=None, **list_args):
benches_with_available_update,
)

benches_with_available_update = benches_with_available_update()

Site = frappe.qb.DocType("Site")
sites = query.where(Site.status != "Archived").select(Site.bench).run(as_dict=1)

for site in sites:
if site.bench in benches_with_available_update:
site.status = "Update Available"
status = filters.get("status")
if status == "Archived":
sites = query.where(Site.status == status).run(as_dict=1)

Check warning on line 210 in press/press/doctype/site/site.py

View check run for this annotation

Codecov / codecov/patch

press/press/doctype/site/site.py#L208-L210

Added lines #L208 - L210 were not covered by tests
else:
benches_with_available_update = benches_with_available_update()
sites = query.where(Site.status != "Archived").select(Site.bench).run(as_dict=1)

Check warning on line 213 in press/press/doctype/site/site.py

View check run for this annotation

Codecov / codecov/patch

press/press/doctype/site/site.py#L212-L213

Added lines #L212 - L213 were not covered by tests

for site in sites:
if site.bench in benches_with_available_update:
site.status = "Update Available"

Check warning on line 217 in press/press/doctype/site/site.py

View check run for this annotation

Codecov / codecov/patch

press/press/doctype/site/site.py#L215-L217

Added lines #L215 - L217 were not covered by tests

return sites

Expand Down

0 comments on commit c4fa7d0

Please sign in to comment.