Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

add basic database backup component UX.

spinningbot9353d23a1ddc
diff --git a/frontend/package.json b/frontend/package.json
index 188480d51a..6c25993379 100644
--- a/frontend/package.json
+++ b/frontend/package.json
@@ -23,6 +23,7 @@
"uuid": "^8.3.2",
"vue": "^3.0.11",
"vue-router": "^4.0.8",
+ "vue-uuid": "^2.0.2",
"vuex": "^4.0.0"
},
"devDependencies": {
diff --git a/frontend/src/components/BackupTable.vue b/frontend/src/components/BackupTable.vue
new file mode 100644
index 0000000000..7a5f56dddd
--- /dev/null
+++ b/frontend/src/components/BackupTable.vue
@@ -0,0 +1,69 @@
+<template>
+ <BBTable
+ :columnList="columnList"
+ :dataSource="backupList"
+ :showHeader="true"
+ :leftBordered="true"
+ :rightBordered="true"
+ >
+ <template v-slot:body="{ rowData: backup }">
+ <BBTableCell :leftPadding="4" class="w-8">
+ {{ backup.name }}
+ </BBTableCell>
+ <BBTableCell class="w-8">
+ {{ backup.path }}
+ </BBTableCell>
+ <BBTableCell class="w-4">
+ {{ backup.time }}
+ </BBTableCell>
+ <BBTableCell class="w-4">
+ {{ backup.creator }}
+ </BBTableCell>
+ </template>
+ </BBTable>
+</template>
+
+<script lang="ts">
+import { computed, PropType } from "vue";
+import { BBTableColumn } from "../bbkit/types";
+import { Backup } from "../types";
+import { bytesToString, databaseSlug } from "../utils";
+import { useRouter } from "vue-router";
+import { useStore } from "vuex";
+
+const columnList: BBTableColumn[] =
+ [
+ {
+ title: "Name",
+ },
+ {
+ title: "Path",
+ },
+ {
+ title: "Time",
+ },
+ {
+ title: "Creator",
+ },
+ ];
+
+export default {
+ name: "BackupTable",
+ components: {},
+ props: {
+ backupList: {
+ required: true,
+ type: Object as PropType<Backup[]>,
+ },
+ },
+ setup(props, ctx) {
+ const store = useStore();
+ const router = useRouter();
+
+ return {
+ columnList,
+ bytesToString,
+ };
+ },
+};
+</script>
diff --git a/frontend/src/components/DatabaseBackupPanel.vue b/frontend/src/components/DatabaseBackupPanel.vue
new file mode 100644
index 0000000000..2eb1d6767f
--- /dev/null
+++ b/frontend/src/components/DatabaseBackupPanel.vue
@@ -0,0 +1,95 @@
+<template>
+ <div class="pt-6">
+ <div class="text-lg leading-6 font-medium text-main mb-4">Take a backup</div>
+ <div class="grid grid-cols-1 gap-y-6 gap-x-4 sm:grid-cols-10">
+ <div class="sm:col-span-3 sm:col-start-1">
+ <label for="backupName" class="textlabel block"> Name </label>
+ <input
+ required
+ type="text"
+ id="backupName"
+ name="backupName"
+ placeholder="backup-unique-name"
+ class="textfield mt-1 w-full"
+ :value="state.backupName"
+ @input="updateInstance('backupName', $event.target.value)"
+ />
+ </div>
+ <div class="sm:col-span-6">
+ <label for="backupPath" class="textlabel block"> Path </label>
+ <input
+ type="text"
+ id="backupPath"
+ name="backupPath"
+ placeholder="e.g. backup-1.sql | /tmp/backup-1.sql"
+ class="textfield mt-1 w-full"
+ :value="state.backupPath"
+ @input="updateInstance('backupPath', $event.target.value)"
+ />
+ </div>
+ <div class="sm:col-span-1">
+ <label> Click </label>
+ <button
+ @click.prevent="testConnection"
+ type="button"
+ class="btn-normal whitespace-nowrap items-center"
+ >
+ Backup now
+ </button>
+ </div>
+ </div>
+ </div>
+ <div class="pt-6">
+ <div class="text-lg leading-6 font-medium text-main mb-4">Backups</div>
+ <BackupTable
+ :backupList="backupList"
+ />
+ </div>
+</template>
+
+<script lang="ts">
+import { computed, reactive, PropType, ComputedRef } from "vue";
+import { useStore } from "vuex";
+import { useRouter } from "vue-router";
+import { uuid } from 'vue-uuid';
+import { Backup } from "../types";
+import BackupTable from "../components/BackupTable.vue";
+
+interface LocalState {
+ backupName: string;
+ backupPath: string;
+}
+
+export default {
+ name: "DatabaseBackupPanel",
+ props: {
+ },
+ components: {
+ BackupTable,
+ },
+ setup(props, ctx) {
+ const store = useStore();
+ const router = useRouter();
+
+ const state = reactive<LocalState>({
+ backupName: uuid.v1(),
+ backupPath: "backup.sql",
+ });
+
+ const backupList = <Backup[]>[
+ {id: 1, database: {}, creator: {}, createdTs: 123, name: "777a8cc0-edd1-11eb-af34-7f52646e3685", path: "1.sql",},
+ {id: 2, database: {}, creator: {}, createdTs: 123, name: "777a8cc0-edd1-11eb-af34-7f52646e3685", path: "/home/hello/world/1.sql",},
+ ];
+
+ const updateInstance = (field: string, value: string) => {
+ (state as any)[field] = value;
+ };
+
+ return {
+ state,
+ backupList,
+ updateInstance,
+ };
+},
+}
+</script>
\ No newline at end of file
diff --git a/frontend/src/types/backup.ts b/frontend/src/types/backup.ts
new file mode 100644
index 0000000000..5984f43a47
--- /dev/null
+++ b/frontend/src/types/backup.ts
@@ -0,0 +1,18 @@
+import { Database } from "./database";
+import { BackupId } from "./id";
+import { Principal } from "./principal";
+
+// Backup
+export type Backup = {
+ id: BackupId;
+
+ // Related fields
+ database: Database;
+
+ // Standard fields
+ creator: Principal;
+ createdTs: number;
+
+ name: string;
+ path: string;
+};
diff --git a/frontend/src/types/id.ts b/frontend/src/types/id.ts
index 9c665d8e22..f19310ecf0 100644
--- a/frontend/src/types/id.ts
+++ b/frontend/src/types/id.ts
@@ -49,6 +49,8 @@ export type RepositoryId = IdType;
export type MigrationHistoryId = IdType;
+export type BackupId = IdType;
+
export type CommandId = IdType;
export type CommandRegisterId = IdType;
diff --git a/frontend/src/types/index.ts b/frontend/src/types/index.ts
index 5f2bd1b76d..e9888d9645 100644
--- a/frontend/src/types/index.ts
+++ b/frontend/src/types/index.ts
@@ -26,3 +26,4 @@ export * from "./store";
export * from "./table";
export * from "./tableIndex";
export * from "./vcs";
+export * from "./backup";
diff --git a/frontend/src/views/DatabaseDetail.vue b/frontend/src/views/DatabaseDetail.vue
index a2cf5d30af..439b199958 100644
--- a/frontend/src/views/DatabaseDetail.vue
+++ b/frontend/src/views/DatabaseDetail.vue
@@ -176,6 +176,9 @@
<template v-if="state.selectedIndex == OVERVIEW_TAB">
<DatabaseOverviewPanel id="overview" :database="database" />
</template>
+ <template v-if="state.selectedIndex == BACKUP_TAB">
+ <DatabaseBackupPanel />
+ </template>
</div>
</template>
@@ -185,12 +188,14 @@ import { useStore } from "vuex";
import { useRouter } from "vue-router";
import MemberSelect from "../components/MemberSelect.vue";
import ProjectSelect from "../components/ProjectSelect.vue";
+import DatabaseBackupPanel from "../components/DatabaseBackupPanel.vue";
import DatabaseOverviewPanel from "../components/DatabaseOverviewPanel.vue";
import { consoleLink, idFromSlug, instanceSlug, isDBAOrOwner } from "../utils";
import { ProjectId, UNKNOWN_ID, DEFAULT_PROJECT_ID } from "../types";
import { isEmpty } from "lodash";
const OVERVIEW_TAB = 0;
+const BACKUP_TAB = 1;
type DatabaseTabItem = {
name: string;
@@ -199,6 +204,7 @@ type DatabaseTabItem = {
const databaseTabItemList: DatabaseTabItem[] = [
{ name: "Overview", hash: "overview" },
+ // TODO: implement backup component. { name: "Backup", hash: "backup" },
];
interface LocalState {
@@ -219,6 +225,7 @@ export default {
MemberSelect,
ProjectSelect,
DatabaseOverviewPanel,
+ DatabaseBackupPanel,
},
setup(props, ctx) {
const store = useStore();
@@ -336,6 +343,7 @@ export default {
return {
OVERVIEW_TAB,
+ BACKUP_TAB,
state,
database,
databaseConsoleLink,