|
276 | 276 | } |
277 | 277 |
|
278 | 278 | let databaseRefreshState: "idle" | "refreshing" | "done" = "idle"; |
| 279 | + let tableRefreshState: "idle" | "refreshing" | "done" = "idle"; |
279 | 280 |
|
280 | 281 | function refreshDatabases() { |
281 | 282 | databaseRefreshState = "refreshing"; |
|
287 | 288 | }); |
288 | 289 | } |
289 | 290 |
|
| 291 | + function refreshTables() { |
| 292 | + if (selectedDatabaseId) { |
| 293 | + tableRefreshState = "refreshing"; |
| 294 | + pushEvent("refresh_tables", { database_id: selectedDatabaseId }, () => { |
| 295 | + tableRefreshState = "done"; |
| 296 | + setTimeout(() => { |
| 297 | + tableRefreshState = "idle"; |
| 298 | + }, 2000); |
| 299 | + }); |
| 300 | + } |
| 301 | + } |
| 302 | +
|
290 | 303 | // Add computed property for schema disabled state |
291 | 304 | $: isSchemaSelectionDisabled = tableMode === "include"; |
292 | 305 |
|
|
517 | 530 | {#if tableMode !== "all"} |
518 | 531 | <div class="border rounded-lg overflow-hidden"> |
519 | 532 | <div class="p-2 border-b bg-gray-50"> |
520 | | - <div class="relative"> |
521 | | - <SearchIcon |
522 | | - class="absolute left-2 top-1/2 transform -translate-y-1/2 text-gray-400 h-4 w-4" |
523 | | - /> |
524 | | - <Input |
525 | | - type="search" |
526 | | - placeholder="Search tables..." |
527 | | - class="pl-8" |
528 | | - bind:value={searchTableQuery} |
529 | | - /> |
| 533 | + <div class="flex items-center space-x-2"> |
| 534 | + <div class="relative flex-1"> |
| 535 | + <SearchIcon |
| 536 | + class="absolute left-2 top-1/2 transform -translate-y-1/2 text-gray-400 h-4 w-4" |
| 537 | + /> |
| 538 | + <Input |
| 539 | + type="search" |
| 540 | + placeholder="Search tables..." |
| 541 | + class="pl-8" |
| 542 | + bind:value={searchTableQuery} |
| 543 | + /> |
| 544 | + </div> |
| 545 | + <Tooltip.Root> |
| 546 | + <Tooltip.Trigger> |
| 547 | + <Button |
| 548 | + variant="outline" |
| 549 | + size="sm" |
| 550 | + on:click={refreshTables} |
| 551 | + disabled={tableRefreshState === "refreshing" || |
| 552 | + !selectedDatabaseId} |
| 553 | + class="p-2" |
| 554 | + aria-label="Refresh Tables" |
| 555 | + > |
| 556 | + {#if tableRefreshState === "refreshing"} |
| 557 | + <RotateCwIcon class="h-5 w-5 animate-spin" /> |
| 558 | + {:else if tableRefreshState === "done"} |
| 559 | + <CheckIcon class="h-5 w-5 text-green-500" /> |
| 560 | + {:else} |
| 561 | + <RotateCwIcon class="h-5 w-5" /> |
| 562 | + {/if} |
| 563 | + </Button> |
| 564 | + </Tooltip.Trigger> |
| 565 | + <Tooltip.Content> |
| 566 | + <p class="text-xs">Refresh tables</p> |
| 567 | + </Tooltip.Content> |
| 568 | + </Tooltip.Root> |
530 | 569 | </div> |
531 | 570 | </div> |
532 | 571 | <div class="max-h-[200px] overflow-y-auto"> |
|
0 commit comments