Merge pull request #1407 from ItzNotABug/fix-minor-ui-issues

Update copy for custom retention
This commit is contained in:
Torsten Dittmann authored and GitHub committed 2024-10-15 09:21:17 +02:00
commit 26d001e46f
2 files changed
+83 -21

No files matched your search

+4
View File
@@ -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 });
</script>
<!-- Show only if on Cloud, alerts are enabled, and it isn't a project limited service -->
@@ -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} />
<span class="u-flex u-flex-vertical u-gap-8">
{#if customRetentionEnabled}
<div class="u-flex u-gap-8 u-padding-block-start-12">
<div class="u-width-150">
<InputNumber
min={1}
id="number"
placeholder="11"
max={customRetention.max}
bind:value={customRetention.number} />
</div>
<div class="u-flex-vertical u-gap-2">
<div class="u-flex u-gap-8">
<div class="u-width-150">
<InputNumber
min={1}
id="number"
placeholder="11"
max={customRetention.max}
bind:value={customRetention.number} />
</div>
<InputSelect
fullWidth
id="retention"
placeholder="Months"
options={customRetainingOptions}
bind:value={customRetention.value} />
<InputSelect
fullWidth
id="retention"
placeholder="Months"
options={customRetainingOptions}
bind:value={customRetention.value} />
</div>
{#if policyInputError}
<Helper type="warning"
>Value should be between 1 and {customRetention.max}</Helper>
{/if}
</div>
{/if}
<span>
@@ -411,12 +427,29 @@
Every backup created under this policy will be
retained <b>forever</b>.
{:else}
Every backup created under this policy will be
retained for <b>
{backupRetainingOptions.find(
{@const period =
backupRetainingOptions.find(
(option) => option.value === policyRetention
)?.label ?? '3 months'}
</b> 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 <b>
{description}
</b> before being automatically deleted.
{/if}
{/if}
</span>
</span>
@@ -436,11 +469,19 @@
{/if}
</div>
<div class="u-main-end u-flex u-gap-8">
<div class="button-container u-main-end u-flex u-gap-8">
<Button
text
on:click={() => {
policyInEdit = false;
showCustomPolicy = false;
if (policyBeingEdited) {
listOfCustomPolicies = [
...listOfCustomPolicies,
policyBeingEdited
];
}
}}
>Cancel
</Button>
@@ -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;
}
}
</style>