Skip to content

Commit 7c69e0e

Browse files
committed
next: Cleanup
1 parent f2d29bc commit 7c69e0e

File tree

9 files changed

+67
-19
lines changed

9 files changed

+67
-19
lines changed

src/Exceptionless.Web/ClientApp/src/lib/features/projects/components/dialogs/remove-project-dialog.svelte

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
<!-- filepath: /Users/blake/Projects/Exceptionless/Exceptionless/src/Exceptionless.Web/ClientApp/src/lib/features/projects/components/confirm-project-delete-AlertDialog.svelte -->
21
<script lang="ts">
32
import * as AlertDialog from '$comp/ui/alert-dialog';
43
import { buttonVariants } from '$comp/ui/button';

src/Exceptionless.Web/ClientApp/src/lib/features/projects/components/dialogs/reset-project-data-dialog.svelte

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
<!-- filepath: /Users/blake/Projects/Exceptionless/Exceptionless/src/Exceptionless.Web/ClientApp/src/lib/features/projects/components/confirm-project-delete-AlertDialog.svelte -->
21
<script lang="ts">
32
import * as AlertDialog from '$comp/ui/alert-dialog';
43
import { buttonVariants } from '$comp/ui/button';

src/Exceptionless.Web/ClientApp/src/lib/features/projects/components/table/options.svelte.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ export function getColumns<TProject extends ViewProject>(mode: GetProjectsMode =
6262
header: 'Actions',
6363
id: 'actions',
6464
meta: {
65-
class: 'w-32'
65+
class: 'w-16'
6666
}
6767
});
6868

src/Exceptionless.Web/ClientApp/src/lib/features/projects/components/table/project-actions-cell.svelte

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
<!-- filepath: /Users/blake/Projects/Exceptionless/Exceptionless/src/Exceptionless.Web/ClientApp/src/lib/features/projects/components/project-actions.svelte -->
21
<script lang="ts">
32
import { goto } from '$app/navigation';
43
import { Button } from '$comp/ui/button';

src/Exceptionless.Web/ClientApp/src/lib/features/shared/components/copy-to-clipboard-button.svelte

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import type { VariantProps } from 'tailwind-variants';
44
55
import { Button, type ButtonProps, type buttonVariants } from '$comp/ui/button';
6+
import { UseClipboard } from '$lib/hooks/use-clipboard.svelte';
67
import ClipboardCopy from 'lucide-svelte/icons/clipboard-copy';
78
import { toast } from 'svelte-sonner';
89
@@ -14,11 +15,13 @@
1415
1516
let { children, size = 'icon', title = 'Copy to Clipboard', value }: Props = $props();
1617
18+
const clipboard = new UseClipboard();
19+
1720
async function copyToClipboard() {
18-
try {
19-
await navigator.clipboard.writeText(value ?? '');
21+
await clipboard.copy(value ?? '');
22+
if (clipboard.copied) {
2023
toast.success('Copy to clipboard succeeded');
21-
} catch {
24+
} else {
2225
toast.error('Copy to clipboard failed');
2326
}
2427
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
type Options = {
2+
/** The time before the copied status is reset. */
3+
delay: number;
4+
};
5+
6+
export class UseClipboard {
7+
get copied() {
8+
return this.#copiedStatus === 'success';
9+
}
10+
get status() {
11+
return this.#copiedStatus;
12+
}
13+
#copiedStatus = $state<'failure' | 'success'>();
14+
15+
private delay: number;
16+
17+
private timeout: ReturnType<typeof setTimeout> | undefined = undefined;
18+
19+
constructor({ delay = 500 }: Partial<Options> = {}) {
20+
this.delay = delay;
21+
}
22+
23+
async copy(text: string) {
24+
if (this.timeout) {
25+
this.#copiedStatus = undefined;
26+
clearTimeout(this.timeout);
27+
}
28+
29+
try {
30+
await navigator.clipboard.writeText(text);
31+
32+
this.#copiedStatus = 'success';
33+
34+
this.timeout = setTimeout(() => {
35+
this.#copiedStatus = undefined;
36+
}, this.delay);
37+
} catch {
38+
this.#copiedStatus = 'failure';
39+
40+
this.timeout = setTimeout(() => {
41+
this.#copiedStatus = undefined;
42+
}, this.delay);
43+
}
44+
45+
return this.#copiedStatus;
46+
}
47+
}

src/Exceptionless.Web/ClientApp/src/routes/(app)/project/[projectId]/+layout.svelte

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,10 @@
3131

3232
<Card.Root>
3333
<Card.Header>
34-
<Card.Title class="text-2xl" level={2}>Settings</Card.Title>
34+
<Card.Title class="text-2xl" level={2}
35+
>{#if projectResponse.isSuccess}{projectResponse.data.name}
36+
{/if} Settings</Card.Title
37+
>
3538
<Card.Description>Manage your project settings and integrations.</Card.Description>
3639
</Card.Header>
3740
<Separator class="mx-6 my-6 w-auto" />

src/Exceptionless.Web/ClientApp/src/routes/(app)/project/add/+page.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
toast.dismiss(toastId);
3333
try {
3434
await createProject.mutateAsync(form.data);
35-
toastId = toast.success('Project created successfully');
35+
toastId = toast.success('Project added successfully');
3636
await goto('/next/project/configure');
3737
3838
// HACK: This is to prevent sveltekit from stealing focus

src/Exceptionless.Web/ClientApp/src/routes/(app)/project/list/+page.svelte

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,19 +39,17 @@
3939
}
4040
}
4141
42-
const projectsQuery = $derived(
43-
getOrganizationProjectsQuery({
44-
params: context.parameters,
45-
route: {
46-
get organizationId() {
47-
return organization.current;
48-
}
42+
const projectsQuery = getOrganizationProjectsQuery({
43+
params: context.parameters,
44+
route: {
45+
get organizationId() {
46+
return organization.current;
4947
}
50-
})
51-
);
48+
}
49+
});
5250
5351
watch(
54-
() => projectsQuery.isSuccess,
52+
() => projectsQuery.dataUpdatedAt,
5553
() => {
5654
if (projectsQuery.isSuccess) {
5755
context.data = projectsQuery.data.data || [];

0 commit comments

Comments
 (0)