Skip to content

Commit

Permalink
add refresh confirm dialog (#6309)
Browse files Browse the repository at this point in the history
  • Loading branch information
lovincyrus authored Dec 20, 2024
1 parent a00746a commit 9061a24
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 1 deletion.
11 changes: 10 additions & 1 deletion web-admin/src/features/projects/status/ProjectResources.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@
import { useQueryClient } from "@tanstack/svelte-query";
import Button from "web-common/src/components/button/Button.svelte";
import ProjectResourcesTable from "./ProjectResourcesTable.svelte";
import RefreshConfirmDialog from "./RefreshConfirmDialog.svelte";
const queryClient = useQueryClient();
const createTrigger = createRuntimeServiceCreateTrigger();
let isReconciling = false;
let isRefreshConfirmDialogOpen = false;
$: ({ instanceId } = $runtime);
Expand Down Expand Up @@ -75,7 +77,9 @@
<h2 class="text-lg font-medium">Resources</h2>
<Button
type="secondary"
on:click={refreshAllSourcesAndModels}
on:click={() => {
isRefreshConfirmDialogOpen = true;
}}
disabled={isReconciling}
>
{#if isReconciling}
Expand All @@ -95,3 +99,8 @@
<ProjectResourcesTable data={$resources.data} />
{/if}
</section>

<RefreshConfirmDialog
bind:open={isRefreshConfirmDialogOpen}
onRefresh={refreshAllSourcesAndModels}
/>
49 changes: 49 additions & 0 deletions web-admin/src/features/projects/status/RefreshConfirmDialog.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<script lang="ts">
import {
AlertDialog,
AlertDialogContent,
AlertDialogDescription,
AlertDialogFooter,
AlertDialogHeader,
AlertDialogTitle,
AlertDialogTrigger,
} from "@rilldata/web-common/components/alert-dialog/index.js";
import { Button } from "@rilldata/web-common/components/button/index.js";
export let open = false;
export let onRefresh: () => void;
async function handleRefresh() {
try {
onRefresh();
open = false;
} catch (error) {
console.error("Failed to refresh resource:", error);
}
}
</script>

<AlertDialog bind:open>
<AlertDialogTrigger asChild>
<div class="hidden"></div>
</AlertDialogTrigger>
<AlertDialogContent>
<AlertDialogHeader>
<AlertDialogTitle>Refresh all sources and models?</AlertDialogTitle>
<AlertDialogDescription>
<div class="mt-1">
This will refresh all sources and models in the project.
</div>
</AlertDialogDescription>
</AlertDialogHeader>
<AlertDialogFooter>
<Button
type="plain"
on:click={() => {
open = false;
}}>Cancel</Button
>
<Button type="primary" on:click={handleRefresh}>Yes, refresh</Button>
</AlertDialogFooter>
</AlertDialogContent>
</AlertDialog>

1 comment on commit 9061a24

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.