diff --git a/packages/builder/src/components/portal/overview/backups/ActionsRenderer.svelte b/packages/builder/src/components/portal/overview/backups/ActionsRenderer.svelte index c43a78c437..834b2b1969 100644 --- a/packages/builder/src/components/portal/overview/backups/ActionsRenderer.svelte +++ b/packages/builder/src/components/portal/overview/backups/ActionsRenderer.svelte @@ -1,6 +1,5 @@
- Restore - +
- Delete + {#if row.type !== "restore"} + Restore + Delete + Download + {/if} Update - Download
diff --git a/packages/builder/src/components/portal/overview/backups/AppSizeRenderer.svelte b/packages/builder/src/components/portal/overview/backups/AppSizeRenderer.svelte new file mode 100644 index 0000000000..c103399f5b --- /dev/null +++ b/packages/builder/src/components/portal/overview/backups/AppSizeRenderer.svelte @@ -0,0 +1,41 @@ + + +
+ {#if automations != null && screens != null && datasources != null} +
+ +
{datasources || 0}
+
+
+ +
{screens || 0}
+
+
+ +
{automations || 0}
+
+ {/if} +
+ + diff --git a/packages/builder/src/components/portal/overview/backups/BackupsTab.svelte b/packages/builder/src/components/portal/overview/backups/BackupsTab.svelte index 5f58f2a8d7..9812279b24 100644 --- a/packages/builder/src/components/portal/overview/backups/BackupsTab.svelte +++ b/packages/builder/src/components/portal/overview/backups/BackupsTab.svelte @@ -12,14 +12,13 @@ import { backups } from "stores/portal" import { createPaginationStore } from "helpers/pagination" - import DatasourceRenderer from "./DatasourceRenderer.svelte" - import ScreensRenderer from "./ScreensRenderer.svelte" - import AutomationsRenderer from "./AutomationsRenderer.svelte" + import AppSizeRenderer from "./AppSizeRenderer.svelte" import CreateBackupModal from "./CreateBackupModal.svelte" - import TriggerRenderer from "./TriggerRenderer.svelte" import ActionsRenderer from "./ActionsRenderer.svelte" import DateRenderer from "./DateRenderer.svelte" - import DaysRenderer from "./DaysRenderer.svelte" + import UserRenderer from "./UserRenderer.svelte" + import StatusRenderer from "./StatusRenderer.svelte" + import TypeRenderer from "./TypeRenderer.svelte" export let app @@ -38,66 +37,47 @@ } const schema = { - trigger: { - displayName: "Trigger", - }, - days: { - displayName: null, - }, - - name: { - displayName: "Name", + type: { + displayName: "Type", }, createdAt: { displayName: "Date", }, - datasources: { - displayName: "Data", + name: { + displayName: "Name", }, - screens: { - displayName: "Screens", + appSize: { + displayName: "App size", }, - automations: { - displayName: "Automations", - }, - userId: { + createdBy: { displayName: "User", }, + status: { + displayName: "Status", + }, actions: { displayName: null, }, } const customRenderers = [ - { column: "datasources", component: DatasourceRenderer }, - { column: "screens", component: ScreensRenderer }, - { column: "automations", component: AutomationsRenderer }, - { column: "trigger", component: TriggerRenderer }, + { column: "appSize", component: AppSizeRenderer }, { column: "actions", component: ActionsRenderer }, { column: "createdAt", component: DateRenderer }, - { column: "days", component: DaysRenderer }, + { column: "createdBy", component: UserRenderer }, + { column: "status", component: StatusRenderer }, + { column: "type", component: TypeRenderer }, ] function flattenBackups(backups) { return backups.map(backup => { return { ...backup, - days: getDaysBetween(backup.timestamp), ...backup?.contents, } }) } - function getDaysBetween(date) { - const now = new Date() - const backupDate = new Date(date) - backupDate.setDate(backupDate.getDate() - 1) - const oneDay = 24 * 60 * 60 * 1000 - return now > backupDate - ? Math.round(Math.abs((now - backupDate) / oneDay)) - : 0 - } - async function fetchBackups(trigger, page) { const response = await backups.searchBackups({ appId: app.instance._id, @@ -123,6 +103,7 @@ } async function handleButtonClick({ detail }) { + console.log(detail.type) if (detail.type === "backupDelete") { await backups.deleteBackup({ appId: app.instance._id, diff --git a/packages/builder/src/components/portal/overview/backups/DatasourceRenderer.svelte b/packages/builder/src/components/portal/overview/backups/DatasourceRenderer.svelte index e69fa2f625..198339dae9 100644 --- a/packages/builder/src/components/portal/overview/backups/DatasourceRenderer.svelte +++ b/packages/builder/src/components/portal/overview/backups/DatasourceRenderer.svelte @@ -5,8 +5,10 @@
- -
{value || 0}
+ {#if value != null} + +
{value || 0}
+ {/if}
diff --git a/packages/builder/src/components/portal/overview/backups/ScreensRenderer.svelte b/packages/builder/src/components/portal/overview/backups/ScreensRenderer.svelte deleted file mode 100644 index e97f140da7..0000000000 --- a/packages/builder/src/components/portal/overview/backups/ScreensRenderer.svelte +++ /dev/null @@ -1,19 +0,0 @@ - - -
- -
{value || 0}
-
- - diff --git a/packages/builder/src/components/portal/overview/backups/StatusRenderer.svelte b/packages/builder/src/components/portal/overview/backups/StatusRenderer.svelte new file mode 100644 index 0000000000..8fd98f663e --- /dev/null +++ b/packages/builder/src/components/portal/overview/backups/StatusRenderer.svelte @@ -0,0 +1,10 @@ + + + + {status} + diff --git a/packages/builder/src/components/portal/overview/backups/TriggerRenderer.svelte b/packages/builder/src/components/portal/overview/backups/TriggerRenderer.svelte deleted file mode 100644 index f896cb03c5..0000000000 --- a/packages/builder/src/components/portal/overview/backups/TriggerRenderer.svelte +++ /dev/null @@ -1,32 +0,0 @@ - - -
- {#if value === "publish"} - -
{trigger}
- {:else if value === "manual"} - -
{trigger}
- {:else if value === "scheduled"} - -
{trigger}
- {:else if value === "restore"} - -
{trigger}
- {/if} -
- - diff --git a/packages/builder/src/components/portal/overview/backups/TypeRenderer.svelte b/packages/builder/src/components/portal/overview/backups/TypeRenderer.svelte new file mode 100644 index 0000000000..9057a2adee --- /dev/null +++ b/packages/builder/src/components/portal/overview/backups/TypeRenderer.svelte @@ -0,0 +1,20 @@ + + +
+ {trigger} + {type} +
+ + diff --git a/packages/builder/src/components/portal/overview/backups/AutomationsRenderer.svelte b/packages/builder/src/components/portal/overview/backups/UserRenderer.svelte similarity index 55% rename from packages/builder/src/components/portal/overview/backups/AutomationsRenderer.svelte rename to packages/builder/src/components/portal/overview/backups/UserRenderer.svelte index 08ea5fb118..42b25bcca8 100644 --- a/packages/builder/src/components/portal/overview/backups/AutomationsRenderer.svelte +++ b/packages/builder/src/components/portal/overview/backups/UserRenderer.svelte @@ -1,12 +1,14 @@
- -
{value || 0}
+ {#if value != null} +
{username}
+ {/if}