CSS cleanup
This commit is contained in:
24
src/lib/components/ActionStatus.svelte
Normal file
24
src/lib/components/ActionStatus.svelte
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
<script lang="ts" module>
|
||||||
|
export interface Status {
|
||||||
|
tone: 'ok' | 'danger';
|
||||||
|
text: string;
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<script lang="ts">
|
||||||
|
/**
|
||||||
|
* A form's result, shown after its buttons in the same row. It's always there (empty when
|
||||||
|
* there's nothing to say), so a message appearing never moves anything.
|
||||||
|
*/
|
||||||
|
let { status }: { status: Status | null | undefined } = $props();
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<p class="action-status small tone-{status?.tone ?? 'ok'}" role="status">{status?.text ?? ''}</p>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.action-status {
|
||||||
|
flex: 1 1 14rem;
|
||||||
|
min-width: 0;
|
||||||
|
color: var(--tone);
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -1,11 +1,29 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { enhance } from '$app/forms';
|
import { enhance } from '$app/forms';
|
||||||
import { SvelteSet } from 'svelte/reactivity';
|
import { SvelteSet } from 'svelte/reactivity';
|
||||||
|
import ActionStatus, { type Status } from '#lib/components/ActionStatus.svelte';
|
||||||
|
import StableText from '#lib/components/StableText.svelte';
|
||||||
import TreeName from '#lib/components/TreeName.svelte';
|
import TreeName from '#lib/components/TreeName.svelte';
|
||||||
import type { TreeNode } from '#lib/server/status/tree-view.ts';
|
import type { TreeNode } from '#lib/server/status/tree-view.ts';
|
||||||
|
|
||||||
/** The admin form for choosing which of a project's folders sync. */
|
/** The admin form for choosing which of a project's folders sync. */
|
||||||
let { nodes, excluded }: { nodes: TreeNode[]; excluded: string[] } = $props();
|
let {
|
||||||
|
nodes,
|
||||||
|
excluded,
|
||||||
|
status
|
||||||
|
}: {
|
||||||
|
nodes: TreeNode[];
|
||||||
|
excluded: string[];
|
||||||
|
/** The result of the last save, if any. */
|
||||||
|
status: Status | null;
|
||||||
|
} = $props();
|
||||||
|
|
||||||
|
const LABELS = {
|
||||||
|
on: 'Syncs',
|
||||||
|
off: 'Not synced',
|
||||||
|
covered: 'Not synced (a folder above is unticked)'
|
||||||
|
};
|
||||||
|
const LABEL_OPTIONS = Object.values(LABELS);
|
||||||
|
|
||||||
/** Folders left unticked. Starts from what's saved, and starts over when that changes. */
|
/** Folders left unticked. Starts from what's saved, and starts over when that changes. */
|
||||||
const unticked = $derived(new SvelteSet(excluded));
|
const unticked = $derived(new SvelteSet(excluded));
|
||||||
@@ -92,11 +110,10 @@
|
|||||||
aria-label="Sync {folder.name}"
|
aria-label="Sync {folder.name}"
|
||||||
onchange={() => toggle(unticked, folder.sourceId)}
|
onchange={() => toggle(unticked, folder.sourceId)}
|
||||||
/>
|
/>
|
||||||
{#if covered}
|
<StableText
|
||||||
Not synced (a folder above is unticked)
|
text={covered ? LABELS.covered : ticked ? LABELS.on : LABELS.off}
|
||||||
{:else}
|
options={LABEL_OPTIONS}
|
||||||
{ticked ? 'Syncs' : 'Not synced'}
|
/>
|
||||||
{/if}
|
|
||||||
</label>
|
</label>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
@@ -106,6 +123,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="actions">
|
<div class="actions">
|
||||||
<button class="button primary">Save folders</button>
|
<button class="button primary">Save folders</button>
|
||||||
|
<ActionStatus {status} />
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
{/if}
|
{/if}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { enhance } from '$app/forms';
|
import { enhance } from '$app/forms';
|
||||||
|
import StableText from '#lib/components/StableText.svelte';
|
||||||
import type { RunRequestResult } from '#lib/server/sync/coordinator.ts';
|
import type { RunRequestResult } from '#lib/server/sync/coordinator.ts';
|
||||||
|
|
||||||
let {
|
let {
|
||||||
@@ -34,7 +35,7 @@
|
|||||||
const MESSAGES: Record<RunRequestResult['status'], (r: RunRequestResult) => string> = {
|
const MESSAGES: Record<RunRequestResult['status'], (r: RunRequestResult) => string> = {
|
||||||
started: () => 'Sync started.',
|
started: () => 'Sync started.',
|
||||||
'already-running': () => 'A sync is already running for this project.',
|
'already-running': () => 'A sync is already running for this project.',
|
||||||
cooldown: () => 'Run now was used moments ago. It will be available again shortly.',
|
cooldown: () => 'Run now was used moments ago. Try again shortly.',
|
||||||
unavailable: (r) => (r.status === 'unavailable' ? r.reason : '')
|
unavailable: (r) => (r.status === 'unavailable' ? r.reason : '')
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
@@ -55,13 +56,10 @@
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<button class="button primary" disabled={running || remaining > 0 || !!unavailable}>
|
<button class="button primary" disabled={running || remaining > 0 || !!unavailable}>
|
||||||
{#if running}
|
<StableText
|
||||||
Syncing…
|
text={running ? 'Syncing…' : remaining > 0 ? `Run now (${remaining}s)` : 'Run now'}
|
||||||
{:else if remaining > 0}
|
options={['Syncing…', `Run now (${cooldownSeconds}s)`, 'Run now']}
|
||||||
Run now ({remaining}s)
|
/>
|
||||||
{:else}
|
|
||||||
Run now
|
|
||||||
{/if}
|
|
||||||
</button>
|
</button>
|
||||||
<p class="small muted" role="status">{unavailable ?? message ?? ''}</p>
|
<p class="small muted" role="status">{unavailable ?? message ?? ''}</p>
|
||||||
</form>
|
</form>
|
||||||
@@ -73,9 +71,12 @@
|
|||||||
gap: 0.3rem;
|
gap: 0.3rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Always two lines tall, so a message appearing doesn't push the page down. */
|
||||||
.run-now p {
|
.run-now p {
|
||||||
max-width: 22rem;
|
width: 22rem;
|
||||||
|
max-width: 100%;
|
||||||
text-align: right;
|
text-align: right;
|
||||||
min-height: 1.2em;
|
height: 3em;
|
||||||
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
30
src/lib/components/StableText.svelte
Normal file
30
src/lib/components/StableText.svelte
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
/**
|
||||||
|
* Text that changes between known values without changing size: it keeps room for the
|
||||||
|
* longest of `options`, so the buttons and fields around it never move.
|
||||||
|
*/
|
||||||
|
let { text, options }: { text: string; options: readonly string[] } = $props();
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<span class="stable">
|
||||||
|
<span>{text}</span>
|
||||||
|
{#each options as option (option)}
|
||||||
|
<span class="reserve" aria-hidden="true">{option}</span>
|
||||||
|
{/each}
|
||||||
|
</span>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.stable {
|
||||||
|
display: inline-grid;
|
||||||
|
font-variant-numeric: tabular-nums;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Every variant sits in the same cell, so the cell is as wide as the widest one. */
|
||||||
|
.stable > span {
|
||||||
|
grid-area: 1 / 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.reserve {
|
||||||
|
visibility: hidden;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -20,6 +20,20 @@ export async function attempt<T, E extends object = object>(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* `attempt` for pages with several forms. Success and failure both carry the action's name,
|
||||||
|
* so the page can show the message beside the button that was used.
|
||||||
|
*/
|
||||||
|
export function attemptAction<E extends object = object>(
|
||||||
|
action: string,
|
||||||
|
work: () => Promise<string>,
|
||||||
|
echo?: E
|
||||||
|
) {
|
||||||
|
return attempt(async () => ({ action, message: await work() }), { action, ...echo } as {
|
||||||
|
action: string;
|
||||||
|
} & E);
|
||||||
|
}
|
||||||
|
|
||||||
/** A form field as a string (empty if missing or a file). */
|
/** A form field as a string (empty if missing or a file). */
|
||||||
export function field(data: FormData, name: string): string {
|
export function field(data: FormData, name: string): string {
|
||||||
const value = data.get(name);
|
const value = data.get(name);
|
||||||
|
|||||||
@@ -59,6 +59,9 @@
|
|||||||
|
|
||||||
html {
|
html {
|
||||||
-webkit-text-size-adjust: 100%;
|
-webkit-text-size-adjust: 100%;
|
||||||
|
/* Keep room for the scrollbar even when the page is short, so filtering or collapsing a
|
||||||
|
list never shifts everything sideways. */
|
||||||
|
scrollbar-gutter: stable;
|
||||||
}
|
}
|
||||||
|
|
||||||
body {
|
body {
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { enhance } from '$app/forms';
|
import { enhance } from '$app/forms';
|
||||||
|
import ActionStatus from '#lib/components/ActionStatus.svelte';
|
||||||
import type { PageProps } from './$types';
|
import type { PageProps } from './$types';
|
||||||
|
|
||||||
let { data, form }: PageProps = $props();
|
let { data, form }: PageProps = $props();
|
||||||
@@ -22,9 +23,6 @@
|
|||||||
</div>
|
</div>
|
||||||
{:else}
|
{:else}
|
||||||
<form method="POST" class="form" use:enhance>
|
<form method="POST" class="form" use:enhance>
|
||||||
{#if form?.error}
|
|
||||||
<div class="notice tone-danger" role="alert">{form.error}</div>
|
|
||||||
{/if}
|
|
||||||
<div class="field">
|
<div class="field">
|
||||||
<label for="username">Username</label>
|
<label for="username">Username</label>
|
||||||
<input
|
<input
|
||||||
@@ -48,6 +46,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="actions">
|
<div class="actions">
|
||||||
<button class="button primary">Log in</button>
|
<button class="button primary">Log in</button>
|
||||||
|
<ActionStatus status={form?.error ? { tone: 'danger', text: form.error } : null} />
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
{/if}
|
{/if}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { error, redirect } from '@sveltejs/kit';
|
import { error, redirect } from '@sveltejs/kit';
|
||||||
import { services } from '#lib/server/app.ts';
|
import { services } from '#lib/server/app.ts';
|
||||||
import { attempt, field, fields } from '#lib/server/forms.ts';
|
import { attemptAction, field, fields } from '#lib/server/forms.ts';
|
||||||
import { idParam } from '#lib/server/params.ts';
|
import { idParam } from '#lib/server/params.ts';
|
||||||
import type { Actions, PageServerLoad } from './$types';
|
import type { Actions, PageServerLoad } from './$types';
|
||||||
|
|
||||||
@@ -19,10 +19,11 @@ export const actions: Actions = {
|
|||||||
sourceInput: field(data, 'sourceInput'),
|
sourceInput: field(data, 'sourceInput'),
|
||||||
targetInput: field(data, 'targetInput')
|
targetInput: field(data, 'targetInput')
|
||||||
};
|
};
|
||||||
return attempt(
|
return attemptAction(
|
||||||
|
'save',
|
||||||
async () => {
|
async () => {
|
||||||
await services().projectService.update(idParam(params.id), values);
|
await services().projectService.update(idParam(params.id), values);
|
||||||
return { saved: true };
|
return 'Changes saved.';
|
||||||
},
|
},
|
||||||
{ values }
|
{ values }
|
||||||
);
|
);
|
||||||
@@ -31,26 +32,26 @@ export const actions: Actions = {
|
|||||||
folders: async ({ params, request }) => {
|
folders: async ({ params, request }) => {
|
||||||
const data = await request.formData();
|
const data = await request.formData();
|
||||||
const choice = { shown: fields(data, 'folder'), synced: fields(data, 'sync') };
|
const choice = { shown: fields(data, 'folder'), synced: fields(data, 'sync') };
|
||||||
return attempt(async () => {
|
return attemptAction('folders', async () => {
|
||||||
await services().projectService.setFolderSync(idParam(params.id), choice);
|
await services().projectService.setFolderSync(idParam(params.id), choice);
|
||||||
return { foldersSaved: true };
|
return 'Folders saved. ACC catches up on the next sync.';
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
resume: ({ params }) =>
|
resume: ({ params }) =>
|
||||||
attempt(async () => {
|
attemptAction('resume', async () => {
|
||||||
await services().projectService.resume(idParam(params.id));
|
await services().projectService.resume(idParam(params.id));
|
||||||
return { resumed: true };
|
return 'Resumed. It syncs again on the next run.';
|
||||||
}),
|
}),
|
||||||
|
|
||||||
reset: ({ params }) =>
|
reset: ({ params }) =>
|
||||||
attempt(async () => {
|
attemptAction('reset', async () => {
|
||||||
await services().projectService.reset(idParam(params.id));
|
await services().projectService.reset(idParam(params.id));
|
||||||
return { reset: true };
|
return 'Reset. The next sync reads SharePoint from scratch.';
|
||||||
}),
|
}),
|
||||||
|
|
||||||
delete: ({ params }) =>
|
delete: ({ params }) =>
|
||||||
attempt(async () => {
|
attemptAction('delete', async () => {
|
||||||
await services().projectService.delete(idParam(params.id));
|
await services().projectService.delete(idParam(params.id));
|
||||||
redirect(303, '/admin');
|
redirect(303, '/admin');
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,11 +1,20 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { enhance, type SubmitFunction } from '$app/forms';
|
import { enhance, type SubmitFunction } from '$app/forms';
|
||||||
import { resolve } from '$app/paths';
|
import { resolve } from '$app/paths';
|
||||||
|
import ActionStatus, { type Status } from '#lib/components/ActionStatus.svelte';
|
||||||
import FolderSyncForm from '#lib/components/FolderSyncForm.svelte';
|
import FolderSyncForm from '#lib/components/FolderSyncForm.svelte';
|
||||||
import ProjectFields from '#lib/components/ProjectFields.svelte';
|
import ProjectFields from '#lib/components/ProjectFields.svelte';
|
||||||
import type { PageProps } from './$types';
|
import type { PageProps } from './$types';
|
||||||
|
|
||||||
let { data, form }: PageProps = $props();
|
let { data, form }: PageProps = $props();
|
||||||
|
|
||||||
|
/** The result of one of the page's forms, if it was the last one used. */
|
||||||
|
const statusOf = (action: string): Status | null => {
|
||||||
|
if (form?.action !== action) return null;
|
||||||
|
return form.error
|
||||||
|
? { tone: 'danger', text: form.error }
|
||||||
|
: { tone: 'ok', text: form.message ?? '' };
|
||||||
|
};
|
||||||
const project = $derived(data.detail.project);
|
const project = $derived(data.detail.project);
|
||||||
const values = $derived(form && 'values' in form && form.values ? form.values : project);
|
const values = $derived(form && 'values' in form && form.values ? form.values : project);
|
||||||
const enabled = $derived(
|
const enabled = $derived(
|
||||||
@@ -34,20 +43,6 @@
|
|||||||
>
|
>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{#if form?.error}
|
|
||||||
<div class="notice tone-danger" role="alert">{form.error}</div>
|
|
||||||
{:else if form && 'saved' in form}
|
|
||||||
<div class="notice tone-ok" role="status">Changes saved.</div>
|
|
||||||
{:else if form && 'reset' in form}
|
|
||||||
<div class="notice tone-ok" role="status">
|
|
||||||
Project reset. The next sync reads the SharePoint folder from scratch.
|
|
||||||
</div>
|
|
||||||
{:else if form && 'resumed' in form}
|
|
||||||
<div class="notice tone-ok" role="status">Project resumed. It syncs again on the next run.</div>
|
|
||||||
{:else if form && 'foldersSaved' in form}
|
|
||||||
<div class="notice tone-ok" role="status">Folders saved. ACC catches up on the next sync.</div>
|
|
||||||
{/if}
|
|
||||||
|
|
||||||
{#if project.pausedReason}
|
{#if project.pausedReason}
|
||||||
<section class="section">
|
<section class="section">
|
||||||
<h2>Paused</h2>
|
<h2>Paused</h2>
|
||||||
@@ -58,10 +53,17 @@
|
|||||||
moved for good, reset the project and point it at the new folder.
|
moved for good, reset the project and point it at the new folder.
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<form method="POST" action="?/resume" use:enhance>
|
<form method="POST" action="?/resume" class="actions" use:enhance>
|
||||||
<button class="button">Resume syncing</button>
|
<button class="button">Resume syncing</button>
|
||||||
|
<ActionStatus status={statusOf('resume')} />
|
||||||
</form>
|
</form>
|
||||||
</section>
|
</section>
|
||||||
|
{:else if statusOf('resume')}
|
||||||
|
<!-- Kept in place after resuming, so the page below doesn't jump up. -->
|
||||||
|
<section class="section">
|
||||||
|
<h2>Paused</h2>
|
||||||
|
<div class="notice tone-ok" role="status">{statusOf('resume')?.text}</div>
|
||||||
|
</section>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
<section class="section">
|
<section class="section">
|
||||||
@@ -85,6 +87,7 @@
|
|||||||
</label>
|
</label>
|
||||||
<div class="actions">
|
<div class="actions">
|
||||||
<button class="button primary">Save changes</button>
|
<button class="button primary">Save changes</button>
|
||||||
|
<ActionStatus status={statusOf('save')} />
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</section>
|
</section>
|
||||||
@@ -96,7 +99,11 @@
|
|||||||
ACC are deleted on the next sync, and come back if you tick the folder again. New folders sync
|
ACC are deleted on the next sync, and come back if you tick the folder again. New folders sync
|
||||||
unless they're inside an unticked one.
|
unless they're inside an unticked one.
|
||||||
</p>
|
</p>
|
||||||
<FolderSyncForm nodes={data.detail.tree} excluded={project.excludedFolderIds} />
|
<FolderSyncForm
|
||||||
|
nodes={data.detail.tree}
|
||||||
|
excluded={project.excludedFolderIds}
|
||||||
|
status={statusOf('folders')}
|
||||||
|
/>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<section class="section danger-zone">
|
<section class="section danger-zone">
|
||||||
@@ -112,11 +119,13 @@
|
|||||||
<form
|
<form
|
||||||
method="POST"
|
method="POST"
|
||||||
action="?/reset"
|
action="?/reset"
|
||||||
|
class="option-form"
|
||||||
use:enhance={confirmFirst(
|
use:enhance={confirmFirst(
|
||||||
`Reset ${project.name}? The next sync re-reads the SharePoint folder from scratch.`
|
`Reset ${project.name}? The next sync re-reads the SharePoint folder from scratch.`
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
<button class="button danger">Reset project</button>
|
<button class="button danger">Reset project</button>
|
||||||
|
<ActionStatus status={statusOf('reset')} />
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
<div class="option">
|
<div class="option">
|
||||||
@@ -130,9 +139,11 @@
|
|||||||
<form
|
<form
|
||||||
method="POST"
|
method="POST"
|
||||||
action="?/delete"
|
action="?/delete"
|
||||||
|
class="option-form"
|
||||||
use:enhance={confirmFirst(`Remove ${project.name}? This can't be undone.`)}
|
use:enhance={confirmFirst(`Remove ${project.name}? This can't be undone.`)}
|
||||||
>
|
>
|
||||||
<button class="button danger">Remove project</button>
|
<button class="button danger">Remove project</button>
|
||||||
|
<ActionStatus status={statusOf('delete')} />
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
@@ -164,4 +175,14 @@
|
|||||||
gap: 0.25rem;
|
gap: 0.25rem;
|
||||||
max-width: 60ch;
|
max-width: 60ch;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* The message goes under the button, in a column as wide as the longest one, so the
|
||||||
|
button stays where it is whether or not there's a message. */
|
||||||
|
.option-form {
|
||||||
|
display: grid;
|
||||||
|
justify-items: end;
|
||||||
|
gap: 0.3rem;
|
||||||
|
width: 16rem;
|
||||||
|
text-align: right;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { enhance } from '$app/forms';
|
import { enhance } from '$app/forms';
|
||||||
import { resolve } from '$app/paths';
|
import { resolve } from '$app/paths';
|
||||||
|
import ActionStatus from '#lib/components/ActionStatus.svelte';
|
||||||
import ProjectFields from '#lib/components/ProjectFields.svelte';
|
import ProjectFields from '#lib/components/ProjectFields.svelte';
|
||||||
|
import StableText from '#lib/components/StableText.svelte';
|
||||||
import type { PageProps } from './$types';
|
import type { PageProps } from './$types';
|
||||||
|
|
||||||
let { form }: PageProps = $props();
|
let { form }: PageProps = $props();
|
||||||
@@ -33,15 +35,16 @@
|
|||||||
};
|
};
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{#if form?.error}
|
|
||||||
<div class="notice tone-danger" role="alert">{form.error}</div>
|
|
||||||
{/if}
|
|
||||||
<ProjectFields values={form?.values ?? {}} />
|
<ProjectFields values={form?.values ?? {}} />
|
||||||
<div class="actions">
|
<div class="actions">
|
||||||
<button class="button primary" disabled={saving}>
|
<button class="button primary" disabled={saving}>
|
||||||
{saving ? 'Checking folders…' : 'Add project'}
|
<StableText
|
||||||
|
text={saving ? 'Checking folders…' : 'Add project'}
|
||||||
|
options={['Checking folders…', 'Add project']}
|
||||||
|
/>
|
||||||
</button>
|
</button>
|
||||||
<a class="button" href={resolve('/admin')}>Cancel</a>
|
<a class="button" href={resolve('/admin')}>Cancel</a>
|
||||||
|
<ActionStatus status={form?.error ? { tone: 'danger', text: form.error } : null} />
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -18,9 +18,12 @@ export const actions: Actions = {
|
|||||||
|
|
||||||
retry: async ({ params, request }) => {
|
retry: async ({ params, request }) => {
|
||||||
const sourceId = field(await request.formData(), 'sourceId');
|
const sourceId = field(await request.formData(), 'sourceId');
|
||||||
return attempt(async () => {
|
return attempt(
|
||||||
await services().projectService.retryItem(idParam(params.id), sourceId);
|
async () => {
|
||||||
return { retried: sourceId };
|
await services().projectService.retryItem(idParam(params.id), sourceId);
|
||||||
});
|
return { retried: sourceId };
|
||||||
|
},
|
||||||
|
{ sourceId }
|
||||||
|
);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { enhance } from '$app/forms';
|
import { enhance } from '$app/forms';
|
||||||
import { resolve } from '$app/paths';
|
import { resolve } from '$app/paths';
|
||||||
|
import ActionStatus from '#lib/components/ActionStatus.svelte';
|
||||||
import AutoRefresh from '#lib/components/AutoRefresh.svelte';
|
import AutoRefresh from '#lib/components/AutoRefresh.svelte';
|
||||||
import Badge from '#lib/components/Badge.svelte';
|
import Badge from '#lib/components/Badge.svelte';
|
||||||
import FileTree from '#lib/components/FileTree.svelte';
|
import FileTree from '#lib/components/FileTree.svelte';
|
||||||
@@ -77,9 +78,6 @@
|
|||||||
{#if detail.issues.length > 0}
|
{#if detail.issues.length > 0}
|
||||||
<section class="section" aria-labelledby="issues-heading">
|
<section class="section" aria-labelledby="issues-heading">
|
||||||
<h2 id="issues-heading">Issues</h2>
|
<h2 id="issues-heading">Issues</h2>
|
||||||
{#if form?.error}
|
|
||||||
<div class="notice tone-danger" role="alert">{form.error}</div>
|
|
||||||
{/if}
|
|
||||||
<ul class="issues">
|
<ul class="issues">
|
||||||
{#each detail.issues as issue (issue.sourceId ?? issue.message)}
|
{#each detail.issues as issue (issue.sourceId ?? issue.message)}
|
||||||
<li>
|
<li>
|
||||||
@@ -96,9 +94,14 @@
|
|||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
{#if issue.sourceId}
|
{#if issue.sourceId}
|
||||||
<form method="POST" action="?/retry" use:enhance>
|
<form method="POST" action="?/retry" class="retry" use:enhance>
|
||||||
<input type="hidden" name="sourceId" value={issue.sourceId} />
|
<input type="hidden" name="sourceId" value={issue.sourceId} />
|
||||||
<button class="button compact" disabled={detail.running}>Retry on next sync</button>
|
<button class="button compact" disabled={detail.running}>Retry on next sync</button>
|
||||||
|
<ActionStatus
|
||||||
|
status={form?.error && form.sourceId === issue.sourceId
|
||||||
|
? { tone: 'danger', text: form.error }
|
||||||
|
: null}
|
||||||
|
/>
|
||||||
</form>
|
</form>
|
||||||
{/if}
|
{/if}
|
||||||
</li>
|
</li>
|
||||||
@@ -185,6 +188,15 @@
|
|||||||
border-top: 1px solid var(--rule);
|
border-top: 1px solid var(--rule);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* The message goes under the button in a fixed-width column, so the button stays put. */
|
||||||
|
.retry {
|
||||||
|
display: grid;
|
||||||
|
justify-items: end;
|
||||||
|
gap: 0.3rem;
|
||||||
|
width: 16rem;
|
||||||
|
text-align: right;
|
||||||
|
}
|
||||||
|
|
||||||
.issue-text {
|
.issue-text {
|
||||||
display: grid;
|
display: grid;
|
||||||
gap: 0.15rem;
|
gap: 0.15rem;
|
||||||
|
|||||||
Reference in New Issue
Block a user