mirror of
https://github.com/appwrite/console.git
synced 2026-11-18 20:47:21 +00:00
address design comments.
This commit is contained in:
1 parent
b7269b9697
commit
7d89169cf2
9 files changed
+154
-53
No files matched your search
@@ -6,7 +6,10 @@
|
||||
import { organization } from '$lib/stores/organization';
|
||||
import { BillingPlan, Dependencies } from '$lib/constants';
|
||||
import type { BackupArchive, BackupRestoration } from '$lib/sdk/backups';
|
||||
import { invalidate } from '$app/navigation';
|
||||
import { goto, invalidate } from '$app/navigation';
|
||||
import { page } from '$app/stores';
|
||||
import { addNotification } from '$lib/stores/notifications';
|
||||
import { base } from '$app/paths';
|
||||
|
||||
let backupRestoreItems: {
|
||||
archives: Map<string, BackupArchive>;
|
||||
@@ -16,9 +19,37 @@
|
||||
restorations: new Map()
|
||||
};
|
||||
|
||||
let openStates = {
|
||||
archives: true,
|
||||
restorations: true
|
||||
};
|
||||
|
||||
$: showBackupRestoreBox =
|
||||
backupRestoreItems.archives.size > 0 || backupRestoreItems.restorations.size > 0;
|
||||
|
||||
let lastDatabaseRestorationId = null;
|
||||
|
||||
const showRestoreNotification = (newDatabaseId: string, newDatabaseName: string) => {
|
||||
if (newDatabaseId && newDatabaseName && lastDatabaseRestorationId !== newDatabaseId) {
|
||||
const project = $page.params.project;
|
||||
lastDatabaseRestorationId = newDatabaseId;
|
||||
|
||||
addNotification({
|
||||
type: 'success',
|
||||
isHtml: true,
|
||||
message: `Restoration complete. <b>${newDatabaseName}</b> has been created.`,
|
||||
buttons: [
|
||||
{
|
||||
name: 'View restored data',
|
||||
method: () => {
|
||||
goto(`${base}/project-${project}/databases/database-${newDatabaseId}`);
|
||||
}
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
const fetchBackupRestores = async () => {
|
||||
try {
|
||||
const query = [
|
||||
@@ -54,7 +85,16 @@
|
||||
|
||||
if (collectionMap.has($id)) {
|
||||
collectionMap.get($id).status = status;
|
||||
if (status === 'completed') invalidate(Dependencies.BACKUPS);
|
||||
if (status === 'completed') {
|
||||
invalidate(Dependencies.BACKUPS);
|
||||
|
||||
if ($collection === 'restorations') {
|
||||
const { newId, newName } =
|
||||
collectionMap.get($id).options?.['databases']?.['database'][0] || {};
|
||||
|
||||
showRestoreNotification(newId, newName);
|
||||
}
|
||||
}
|
||||
} else if (status === 'pending' || status === 'processing' || status === 'uploading') {
|
||||
collectionMap.set($id, payload);
|
||||
}
|
||||
@@ -78,8 +118,20 @@
|
||||
}
|
||||
};
|
||||
|
||||
const text = (status: string, key: string) => {
|
||||
const service = key === 'archives' ? 'backup' : 'restore';
|
||||
if (status === 'completed') {
|
||||
return `Database ${service} complete`;
|
||||
} else if (status === 'failed') {
|
||||
return `Database ${service} failed`;
|
||||
} else {
|
||||
return 'Preparing database...';
|
||||
}
|
||||
};
|
||||
|
||||
const handleClose = (which: string) => {
|
||||
backupRestoreItems[which] = new Map();
|
||||
if (which === 'restorations') lastDatabaseRestorationId = null;
|
||||
};
|
||||
|
||||
// TODO: `startedAt` is probably not correct here. need more info.
|
||||
@@ -117,6 +169,15 @@
|
||||
<h4 class="upload-box-title">
|
||||
<span class="text">{titleText}</span>
|
||||
</h4>
|
||||
<button
|
||||
class="upload-box-button"
|
||||
class:is-open={!openStates[key]}
|
||||
aria-label="toggle upload box"
|
||||
on:click={() => {
|
||||
openStates[key] = !openStates[key];
|
||||
}}>
|
||||
<span class="icon-cheveron-up" aria-hidden="true" />
|
||||
</button>
|
||||
<button
|
||||
class="upload-box-button"
|
||||
aria-label="close backup restore box"
|
||||
@@ -125,25 +186,31 @@
|
||||
</button>
|
||||
</header>
|
||||
|
||||
<div class="upload-box-content is-open">
|
||||
{#each [...items.values()] as item, index (item.$id)}
|
||||
<section
|
||||
class="progress-bar"
|
||||
class:u-padding-block-end-32={index !== items.size - 1}>
|
||||
<div
|
||||
class="progress-bar-top-line u-flex u-gap-8 u-main-space-between">
|
||||
<span class="body-text-2"> Preparing database... </span>
|
||||
<div class="upload-box-content" class:is-open={openStates[key]}>
|
||||
<ul class="upload-box-list">
|
||||
{#each [...items.values()] as item, index (item.$id)}
|
||||
<li class="upload-box-item">
|
||||
<section
|
||||
class="progress-bar u-width-full-line"
|
||||
class:u-padding-block-end-32={index !== items.size - 1}>
|
||||
<div
|
||||
class="progress-bar-top-line u-flex u-gap-8 u-main-space-between">
|
||||
<span class="body-text-2">
|
||||
{text(item.status, key)}
|
||||
</span>
|
||||
|
||||
<span class="backup-name">
|
||||
{backupName(item, key)}
|
||||
</span>
|
||||
</div>
|
||||
<div
|
||||
class="progress-bar-container"
|
||||
class:is-danger={item.status === 'failed'}
|
||||
style="--graph-size:{graphSize(item.status)}%" />
|
||||
</section>
|
||||
{/each}
|
||||
<span class="backup-name">
|
||||
{backupName(item, key)}
|
||||
</span>
|
||||
</div>
|
||||
<div
|
||||
class="progress-bar-container"
|
||||
class:is-danger={item.status === 'failed'}
|
||||
style="--graph-size:{graphSize(item.status)}%" />
|
||||
</section>
|
||||
</li>
|
||||
{/each}
|
||||
</ul>
|
||||
</div>
|
||||
</section>
|
||||
{/if}
|
||||
@@ -152,8 +219,11 @@
|
||||
{/if}
|
||||
|
||||
<style>
|
||||
.upload-box-title {
|
||||
font-size: 10px;
|
||||
}
|
||||
|
||||
.upload-box-content {
|
||||
padding: 1.5rem;
|
||||
min-width: 400px;
|
||||
max-width: 100vw;
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@
|
||||
{/if}
|
||||
</div>
|
||||
{#if description.length > 0}
|
||||
<p class="u-margin-block-start-4">
|
||||
<p class="modal-description u-margin-block-start-4">
|
||||
<slot name="description">
|
||||
{description}
|
||||
</slot>
|
||||
|
||||
@@ -47,7 +47,8 @@ async function fetchPolicies(databases: Models.DatabaseList) {
|
||||
databases.databases.map(async (database) => {
|
||||
try {
|
||||
const { policies } = await sdk.forProject.backups.listPolicies([
|
||||
Query.limit(3), // not all fit in the table so 3 should be enough.
|
||||
// TODO: are all needed!?
|
||||
// Query.limit(3),
|
||||
Query.equal('resourceType', 'database'),
|
||||
Query.equal('resourceId', database.$id)
|
||||
]);
|
||||
|
||||
@@ -98,7 +98,7 @@
|
||||
{#if showPlanUpgradeAlert}
|
||||
<Alert type="warning" dismissible on:dismiss={() => (showPlanUpgradeAlert = false)}>
|
||||
<svelte:fragment slot="title">This database won't be backed up</svelte:fragment>
|
||||
Upgrade your plan to manage database backup policies
|
||||
Upgrade your plan to ensure your data stays safe with advanced backup policies.
|
||||
<svelte:fragment slot="buttons">
|
||||
<Button href={$upgradeURL} text>Upgrade plan</Button>
|
||||
</svelte:fragment>
|
||||
|
||||
+2
-6
@@ -47,7 +47,7 @@
|
||||
timeout: 15000,
|
||||
buttons: [
|
||||
{
|
||||
name: 'Leave Feedback',
|
||||
name: 'Leave feedback',
|
||||
method: () => {
|
||||
feedback.toggleFeedback();
|
||||
dismissAllNotifications();
|
||||
@@ -225,11 +225,7 @@
|
||||
Manual backups are <b>retained forever</b> unless manually deleted. Use them when making significant
|
||||
changes to your data structure or as a safeguard for future rollbacks.
|
||||
</p>
|
||||
<Alert type="info">
|
||||
<svelte:fragment slot="title">
|
||||
Depending on the size of your data, this may take a while.
|
||||
</svelte:fragment>
|
||||
</Alert>
|
||||
<Alert type="info">Depending on the size of your data, this may take a while.</Alert>
|
||||
<svelte:fragment slot="footer">
|
||||
<Button text on:click={() => ($showCreateBackup = false)}>Cancel</Button>
|
||||
<Button submit>Create</Button>
|
||||
|
||||
+11
-6
@@ -39,10 +39,10 @@
|
||||
let policyInEdit = null;
|
||||
let policyRetention = 30;
|
||||
let selectedTime = '00:00';
|
||||
let backupPolicyName = null;
|
||||
let policyNameError: boolean;
|
||||
let policyFrequency = 'monthly';
|
||||
let monthlyBackupFrequency = 'end';
|
||||
$: backupPolicyName = `${capitalize(policyFrequency)} backup`;
|
||||
|
||||
$: customRetentionEnabled = policyRetention === -1;
|
||||
let customRetention = { ...customRetainingOptions[2], number: null };
|
||||
@@ -51,7 +51,6 @@
|
||||
policyInEdit = null;
|
||||
policyRetention = 30;
|
||||
selectedTime = '00:00';
|
||||
backupPolicyName = null;
|
||||
policyFrequency = 'monthly';
|
||||
monthlyBackupFrequency = 'end';
|
||||
|
||||
@@ -228,7 +227,7 @@
|
||||
<InputSelect
|
||||
label="Frequency"
|
||||
id="policyFrequency"
|
||||
placeholder="Select runtime"
|
||||
placeholder="Select frequency"
|
||||
bind:value={policyFrequency}
|
||||
options={['hourly', 'daily', 'weekly', 'monthly'].map(
|
||||
(freq) => ({
|
||||
@@ -355,7 +354,8 @@
|
||||
</div>
|
||||
</section>
|
||||
{:else}
|
||||
<div class="u-flex u-main-space-between u-padding-inline-4 u-width-full-line">
|
||||
<div
|
||||
class="custom-policy-wrapper u-flex flex-vertical-mobile u-gap-16 u-main-space-between u-padding-inline-4 u-width-full-line">
|
||||
<button class="custom-policy-text" on:click={() => (showCustomPolicy = true)}
|
||||
>Create custom policy
|
||||
</button>
|
||||
@@ -364,8 +364,7 @@
|
||||
<span>Total:</span>
|
||||
{#if totalPolicies.length}
|
||||
<span style="text-decoration: line-through;"
|
||||
>${totalPolicies.length * policyPricing}
|
||||
.00</span>
|
||||
>${totalPolicies.length * policyPricing}.00</span>
|
||||
{/if}
|
||||
<span>$0.00 until Jan 1st 2025</span>
|
||||
</div>
|
||||
@@ -409,4 +408,10 @@
|
||||
:global(.height-fit-content) {
|
||||
height: fit-content;
|
||||
}
|
||||
|
||||
@media (max-width: 767.99px) {
|
||||
.flex-vertical-mobile {
|
||||
flex-direction: column-reverse !important;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
+10
-5
@@ -150,9 +150,8 @@
|
||||
<div
|
||||
class="u-flex u-gap-4 u-cross-center policy-item-subtitles darker-neutral-color">
|
||||
<span
|
||||
style="font-size: 1rem; margin-bottom: 2px; color: {lastBackupDates[
|
||||
policy.$id
|
||||
]
|
||||
class="medium-ellipse"
|
||||
style="color: {lastBackupDates[policy.$id]
|
||||
? 'hsl(var(--color-success-100))'
|
||||
: 'inherit'};">●</span>
|
||||
<span class="policy-item-subtitles">
|
||||
@@ -247,6 +246,7 @@
|
||||
title="Delete policy"
|
||||
icon="exclamation"
|
||||
state="warning"
|
||||
size="small"
|
||||
bind:show={showDelete}
|
||||
headerDivider={false}
|
||||
onSubmit={deletePolicy}>
|
||||
@@ -294,6 +294,11 @@
|
||||
font-size: 0.25rem;
|
||||
}
|
||||
|
||||
:global(.medium-ellipse) {
|
||||
font-size: 0.5rem;
|
||||
color: hsl(var(--color-neutral-20));
|
||||
}
|
||||
|
||||
:global(.u-gap-6) {
|
||||
gap: 0.375rem;
|
||||
}
|
||||
@@ -352,13 +357,13 @@
|
||||
}
|
||||
|
||||
:global(.show-more-policy-button) {
|
||||
background: transparent;
|
||||
border-radius: 1rem;
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
.show-more-policy-wrapper {
|
||||
padding-inline: 13px;
|
||||
padding-block-end: 4px;
|
||||
padding-block-end: 0.875rem;
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
|
||||
+27
-11
@@ -43,7 +43,7 @@
|
||||
selectedBackups.push(selectedBackup.$id);
|
||||
}
|
||||
|
||||
const message = `${selectedBackups.length} backup${selectedBackups.length > 1 ? 's' : ''} deleted`;
|
||||
const message = `${selectedBackups.length} backup${selectedBackups.length > 1 ? 's have been' : ''} deleted`;
|
||||
|
||||
const promises = selectedBackups.map((archiveId) =>
|
||||
sdk.forProject.backups.deleteArchive(archiveId)
|
||||
@@ -122,13 +122,19 @@
|
||||
{@const retainedUntil = new Date(
|
||||
new Date(policy?.$createdAt).getTime() + policy?.retention * 24 * 60 * 60 * 1000
|
||||
)}
|
||||
{@const formattedRetainedUntil = `${retainedUntil.getDate()} ${retainedUntil.toLocaleString('en-US', { month: 'short' })}, ${retainedUntil.getFullYear()} ${retainedUntil.toLocaleTimeString('en-US', { hour12: false })}`}
|
||||
<TableRow>
|
||||
<TableCellCheck
|
||||
bind:selectedIds={selectedBackups}
|
||||
disabled={backup.status !== 'completed'}
|
||||
id={backup.status !== 'completed' ? null : backup.$id} />
|
||||
<TableCell title={backup.$createdAt}>
|
||||
{cleanBackupName(backup)}
|
||||
<span
|
||||
use:tooltip={{
|
||||
content: timeFromNow(backup.$createdAt)
|
||||
}}>
|
||||
{cleanBackupName(backup)}
|
||||
</span>
|
||||
</TableCell>
|
||||
<TableCell title="Backup Size">
|
||||
{#if backup.status === 'completed'}
|
||||
@@ -155,7 +161,7 @@
|
||||
<span
|
||||
use:tooltip={{
|
||||
content: policy
|
||||
? `Retained until: ${retainedUntil}`
|
||||
? `Retained until: ${formattedRetainedUntil}`
|
||||
: `Retained forever`
|
||||
}}>
|
||||
{policy?.name || 'Manual'}
|
||||
@@ -237,8 +243,8 @@
|
||||
<b>{selectedBackups.length}</b> {selectedBackups.length > 1 ? 'backups' : 'backup'}?
|
||||
{:else}
|
||||
<b>{cleanBackupName(selectedBackup)}</b>?
|
||||
<br />This action is irreversible.
|
||||
{/if}
|
||||
<br />This action is irreversible.
|
||||
</p>
|
||||
|
||||
<svelte:fragment slot="footer">
|
||||
@@ -248,12 +254,15 @@
|
||||
</Modal>
|
||||
|
||||
<Modal title="Restore backup" bind:show={showRestore} onSubmit={restoreBackup}>
|
||||
<p class="text" data-private>
|
||||
<p class="text" data-private style="padding-inline-end: 2rem;">
|
||||
Restoring this backup will duplicate the database from the selected backup version. This
|
||||
action may take a while.
|
||||
</p>
|
||||
|
||||
<Card isTile style="border-radius: var(--border-radius-small, 8px); padding: 1rem;">
|
||||
<Card
|
||||
isTile
|
||||
class="restore-modal-inner-card"
|
||||
style="border-radius: var(--border-radius-small, 8px); padding: 1rem;">
|
||||
<div class="u-flex u-flex-vertical u-gap-4">
|
||||
<span class="body-text-2 u-bold darker-neutral-color">
|
||||
{cleanBackupName(selectedBackup)}
|
||||
@@ -270,7 +279,7 @@
|
||||
</div>
|
||||
</Card>
|
||||
|
||||
<FormList>
|
||||
<FormList gap={8}>
|
||||
<InputText
|
||||
id="name"
|
||||
label="Database name"
|
||||
@@ -305,12 +314,19 @@
|
||||
</Modal>
|
||||
|
||||
<style lang="scss">
|
||||
.icon-dots-horizontal {
|
||||
font-size: 1.5rem;
|
||||
:global(.custom-height-table-column .table-col) {
|
||||
height: 54px;
|
||||
padding: 0 1rem; /* removes vertical padding for constrained height */
|
||||
}
|
||||
|
||||
:global(.custom-height-table-column .table-col) {
|
||||
height: 38px;
|
||||
:global(.restore-modal-inner-card) {
|
||||
background: hsl(var(--color-neutral-5));
|
||||
border: 1px solid hsl(var(--color-neutral-10));
|
||||
}
|
||||
|
||||
:global(.theme-dark .restore-modal-inner-card) {
|
||||
background: hsl(var(--color-neutral-85));
|
||||
border: 1px solid hsl(var(--color-neutral-80));
|
||||
}
|
||||
|
||||
.actions {
|
||||
|
||||
+9
-1
@@ -65,7 +65,7 @@
|
||||
{title}
|
||||
</h3>
|
||||
|
||||
<span class="u-padding-inline-end-32">
|
||||
<span class="upgrade-description">
|
||||
{message} Schedule automatic or manual backups to protect your data and ensure
|
||||
quick recovery.
|
||||
</span>
|
||||
@@ -89,3 +89,11 @@
|
||||
</div>
|
||||
</Card>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
@media (min-width: 768px) {
|
||||
.upgrade-description {
|
||||
padding-inline-end: 16ch;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
Reference in new issue
Block a user