diff --git a/src/lib/layout/containerHeader.svelte b/src/lib/layout/containerHeader.svelte index 404e518fc..2ac9e01ab 100644 --- a/src/lib/layout/containerHeader.svelte +++ b/src/lib/layout/containerHeader.svelte @@ -78,6 +78,10 @@ onMount(() => { dispatch('data', { isButtonDisabled, limit, tier }); }); + + // on free plan, if the only db is deleted, + // `create database` button needs to be enabled again. + $: if (isLimited) dispatch('data', { isButtonDisabled, limit, tier }); diff --git a/src/routes/(console)/project-[project]/databases/database-[database]/backups/createPolicy.svelte b/src/routes/(console)/project-[project]/databases/database-[database]/backups/createPolicy.svelte index d44a7d9d5..a04f02bf8 100644 --- a/src/routes/(console)/project-[project]/databases/database-[database]/backups/createPolicy.svelte +++ b/src/routes/(console)/project-[project]/databases/database-[database]/backups/createPolicy.svelte @@ -46,12 +46,15 @@ }); let policyInEdit = null; + let policyBeingEdited = null; + let policyRetention = 30; let selectedTime = '00:00'; let policyNameError: boolean; let policyFrequency = 'monthly'; let monthlyBackupFrequency = 'end'; + $: policyInputError = customRetention.number === 0; $: daysSelectionArray = []; $: backupPolicyName = `${capitalize(policyFrequency)} backup`; @@ -270,12 +273,19 @@ on:click={() => { policyInEdit = policy.id; backupPolicyName = policy.label; - policyRetention = policy.retained; selectedTime = policy.selectedTime; policyFrequency = policy.plainTextFrequency; monthlyBackupFrequency = policy.monthlyBackupFrequency; daysSelectionArray = policy.weeklySelectedDays; + policyRetention = !backupRetainingOptions.some( + (option) => option.value === policy.retained + ) + ? -1 // -1 is for custom policy + : policy.retained; + + // re-add if edit is cancelled + policyBeingEdited = policy; // do not show in the list can cause confusion. listOfCustomPolicies = [ @@ -388,22 +398,28 @@ options={backupRetainingOptions} /> {#if customRetentionEnabled} -
-
- -
+
+
+
+ +
- + +
+ {#if policyInputError} + Value should be between 1 and {customRetention.max} + {/if}
{/if} @@ -411,12 +427,29 @@ Every backup created under this policy will be retained forever. {:else} - Every backup created under this policy will be - retained for - {backupRetainingOptions.find( + {@const period = + backupRetainingOptions.find( (option) => option.value === policyRetention )?.label ?? '3 months'} - before being automatically deleted. + + {@const description = + period === 'Custom' + ? `${customRetention.number} ${ + customRetention.number === 1 + ? customRetention.label.slice( + 0, + -1 + ) + : customRetention.label + }` + : period} + + {#if (period === 'Custom' && customRetention.number !== null && customRetention.number !== 0) || period !== 'Custom'} + Every backup created under this policy will be + retained for + {description} + before being automatically deleted. + {/if} {/if} @@ -436,11 +469,19 @@ {/if}
-
+
@@ -453,6 +494,10 @@ return; } + if (policyInputError) { + return; + } + policyNameError = false; handleSavePolicy(); }}> @@ -535,4 +580,17 @@ display: none; } } + + /** the modal, for some reason has issues with inner padding on smaller devices. */ + @media (max-width: 409px) { + .modal { + --p-modal-padding: 0.95rem; + } + } + + @media (max-width: 315px) { + .modal { + --p-modal-padding: 0.9rem; + } + }