Skip to content

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

feat(frontend): default value and placeholder of retention period (#2364)

Liu Ji8bc6749c0bc4
diff --git a/frontend/src/assets/css/tailwind.css b/frontend/src/assets/css/tailwind.css
index 1641936875..22d89f28cf 100644
--- a/frontend/src/assets/css/tailwind.css
+++ b/frontend/src/assets/css/tailwind.css
@@ -226,6 +226,18 @@
@apply origin-bottom-left;
animation: thumb-up 1s ease-in-out infinite;
}
+
+ /* Remove the ticker in the number field for webkit */
+ input.hide-ticker::-webkit-outer-spin-button,
+ input.hide-ticker::-webkit-inner-spin-button {
+ -webkit-appearance: none;
+ margin: 0;
+ }
+
+ /* Remove the ticker in the number field for Firefox */
+ input[type="number"].hide-ticker {
+ -moz-appearance: textfield;
+ }
}
.fade-enter-active,
diff --git a/frontend/src/components/DatabaseBackup/DatabaseBackupSettingForm.vue b/frontend/src/components/DatabaseBackup/DatabaseBackupSettingForm.vue
index ad9418341e..94f74c0763 100644
--- a/frontend/src/components/DatabaseBackup/DatabaseBackupSettingForm.vue
+++ b/frontend/src/components/DatabaseBackup/DatabaseBackupSettingForm.vue
@@ -103,13 +103,10 @@
</label>
<div class="w-[16rem]">
<input
- type="text"
+ type="number"
+ class="textfield w-full hide-ticker"
+ :placeholder="String(DEFAULT_BACKUP_RETENTION_PERIOD_DAYS)"
:value="retentionPeriodDaysInputValue"
- class="textfield w-full"
- :class="
- state.setting.retentionPeriodTs <= 0 &&
- '!border-red-600 focus:!ring-red-600'
- "
@input="(e: any) => setRetentionPeriodDays(e.target.value)"
/>
</div>
@@ -158,7 +155,7 @@ import {
AVAILABLE_HOURS_OF_DAY,
PLAN_SCHEDULES,
DEFAULT_BACKUP_RETENTION_PERIOD_TS,
- levelOfSchedule,
+ DEFAULT_BACKUP_RETENTION_PERIOD_DAYS,
localFromUTC,
localToUTC,
parseScheduleFromBackupSetting,
@@ -250,10 +247,6 @@ const isValid = computed((): boolean => {
return true;
}
- if (!setting.retentionPeriodTs || setting.retentionPeriodTs <= 0) {
- return false;
- }
-
return true;
});
@@ -263,6 +256,10 @@ const handleSave = async () => {
}
const { setting } = state;
+ if (setting.enabled && setting.retentionPeriodTs <= 0) {
+ // Set default value to retentionPeriodTs if needed.
+ setting.retentionPeriodTs = DEFAULT_BACKUP_RETENTION_PERIOD_TS;
+ }
const newBackupSetting: BackupSettingUpsert = {
databaseId: props.database.id,
diff --git a/frontend/src/components/DatabaseBackup/utils.ts b/frontend/src/components/DatabaseBackup/utils.ts
index 9832a3c2e3..6ba3f3affb 100644
--- a/frontend/src/components/DatabaseBackup/utils.ts
+++ b/frontend/src/components/DatabaseBackup/utils.ts
@@ -14,7 +14,9 @@ export const PLAN_SCHEDULES: BackupPlanPolicySchedule[] = [
export const AVAILABLE_DAYS_OF_WEEK = [...Array(7).keys()]; // [0...6]
export const AVAILABLE_HOURS_OF_DAY = [...Array(24).keys()]; // [0...23]
-export const DEFAULT_BACKUP_RETENTION_PERIOD_TS = 7 * 3600 * 24; // 7 days
+export const DEFAULT_BACKUP_RETENTION_PERIOD_DAYS = 7;
+export const DEFAULT_BACKUP_RETENTION_PERIOD_TS =
+ DEFAULT_BACKUP_RETENTION_PERIOD_DAYS * 3600 * 24; // 7 days
export function parseScheduleFromBackupSetting(
backupSetting: BackupSettingEdit