Skip to content

Commit

Permalink
feat: block some buttons when user uploading files
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanlinjui committed Dec 22, 2024
1 parent fc83e42 commit 9fb5bcc
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
11 changes: 6 additions & 5 deletions src/routes/template/[id]/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
let isPublic = false;
let subtasks: string[] = [];
let showDeleteModal = false;
let isUploading = false;
const templateRef = doc(db, 'templates', $page.params.id);
const [template, { unsubscribe }] = subscribe<Template>(templateRef);
Expand Down Expand Up @@ -125,7 +126,7 @@
<div class="container mx-auto max-w-4xl px-4 py-8">
<div class="mb-8 flex items-center justify-between">
<h1 class="text-3xl font-bold">Edit Template</h1>
<Button color="primary" on:click={startSession}>
<Button color="primary" on:click={startSession} disabled={isUploading}>
<Play class="mr-2 h-4 w-4" />
Start Session
</Button>
Expand Down Expand Up @@ -191,21 +192,21 @@
<div class="border-t pt-6">
{#key $template}
{#if $template}
<ResourceList template={$template} />
<ResourceList template={$template} bind:isUploading />
{/if}
{/key}
</div>

<div class="flex justify-end gap-4 border-t pt-6">
<Button color="alternative" href="/dashboard">
<Button color="alternative" href="/dashboard" disabled={isUploading}>
<X class="mr-2 h-4 w-4" />
Back to Dashboard
</Button>
<Button color="red" on:click={() => (showDeleteModal = true)}>
<Button color="red" on:click={() => (showDeleteModal = true)} disabled={isUploading}>
<Trash2 class="mr-2 h-4 w-4" />
Delete this Template
</Button>
<Button type="submit" color="primary">
<Button type="submit" color="primary" disabled={isUploading}>
<Save class="mr-2 h-4 w-4" />
Save Changes
</Button>
Expand Down
9 changes: 7 additions & 2 deletions src/routes/template/[id]/ResourceList.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
// Props
export let template: Template;
export let isUploading: boolean = false;
// State
let resources = template.resources;
Expand All @@ -23,7 +24,6 @@
let isDragging = false;
let tempFile: File | null = null;
let success = '';
let isUploading = false;
let expandedResources = new Set<string>();
let dragError = false;
Expand Down Expand Up @@ -238,7 +238,12 @@
{/if}
</div>
</div>
<Button color="red" size="sm" on:click={() => deleteResource(resource.id)}>
<Button
color="red"
size="sm"
on:click={() => deleteResource(resource.id)}
disabled={isUploading}
>
<Trash2 class="h-4 w-4" />
</Button>
</div>
Expand Down

0 comments on commit 9fb5bcc

Please sign in to comment.