Skip to content

Commit d1fe2ff

Browse files
authored
Merge pull request #2100 from undb-io/release/v1.0.0-104
Release version v1.0.0-104
2 parents 887dfca + 3468672 commit d1fe2ff

File tree

24 files changed

+302
-191
lines changed

24 files changed

+302
-191
lines changed

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
# Changelog
22

3+
## v1.0.0-104
4+
5+
6+
### 🩹 Fixes
7+
8+
- Fix handle on table deleted ([c351539](https://github.com/undb-io/undb/commit/c351539))
9+
10+
### ❤️ Contributors
11+
12+
- Nichenqin ([@nichenqin](http://github.com/nichenqin))
13+
314
## v1.0.0-103
415

516

apps/frontend/src/lib/components/blocks/aggregate/aggregate.svelte

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,19 @@
99
import * as Tooltip from "$lib/components/ui/tooltip"
1010
1111
const table = getTable()
12+
13+
export let tableId: string | undefined
1214
export let viewId: string | undefined
1315
export let shareId: string | undefined
1416
export let ignoreView: boolean = false
1517
1618
export let widget: IWidgetDTO
1719
export let aggregate: IAggregate
1820
19-
$: isValid = isValidWidget(widget)
21+
$: isValid = isValidWidget(widget) && !!tableId
2022
2123
const getAggregate = createQuery({
22-
queryKey: ["aggregate", $table.id.value, widget.id],
24+
queryKey: ["aggregate", widget.id],
2325
queryFn: () => {
2426
const agg =
2527
aggregate.type === "count"
@@ -28,15 +30,15 @@
2830
if (shareId) {
2931
return trpc.shareData.aggregate.query({
3032
shareId,
31-
tableId: $table.id.value,
33+
tableId,
3234
viewId,
3335
aggregate: agg,
3436
condition: aggregate.condition,
3537
ignoreView,
3638
})
3739
}
3840
return trpc.record.aggregate.query({
39-
tableId: $table.id.value,
41+
tableId,
4042
viewId,
4143
aggregate: agg,
4244
condition: aggregate.condition,
@@ -45,7 +47,7 @@
4547
},
4648
})
4749
48-
let value = derived([getAggregate, table], ([$data, $table]) => {
50+
let value = derived([getAggregate], ([$data]) => {
4951
if (aggregate.type === "count") {
5052
return ($data.data as any)?.[ID_TYPE]
5153
}

apps/frontend/src/lib/components/blocks/aggregate/config/aggregate-config.svelte

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -37,17 +37,19 @@
3737
const value = writable<MaybeConditionGroup<IAggregateCondition> | undefined>(
3838
toMaybeConditionGroup(aggregate.condition),
3939
)
40-
$: validValue = $value ? parseValidAggregateCondition($table.schema, $value) : undefined
41-
$: visibleFields = $table.getOrderedVisibleFields()
40+
$: validValue = $value && $table ? parseValidAggregateCondition($table.schema, $value) : undefined
41+
$: visibleFields = $table?.getOrderedVisibleFields()
4242
4343
const client = useQueryClient()
4444
4545
const updateWidgetMutation = createMutation({
4646
mutationFn: trpc.table.view.widget.update.mutate,
4747
async onSuccess(data, variables, context) {
48-
await invalidate(`table:${$table.id.value}`)
49-
await tick()
50-
await client.invalidateQueries({ queryKey: ["aggregate", $table.id.value, widget.id] })
48+
if ($table) {
49+
await invalidate(`table:${$table.id.value}`)
50+
await tick()
51+
await client.invalidateQueries({ queryKey: ["aggregate", $table.id.value, widget.id] })
52+
}
5153
onSuccess()
5254
},
5355
onError(error, variables, context) {
@@ -58,9 +60,11 @@
5860
const updateDashboardWidget = createMutation({
5961
mutationFn: trpc.dashboard.widget.update.mutate,
6062
async onSuccess(data, variables, context) {
61-
await invalidate(`dashboard:${$dashboard.id.value}`)
62-
await tick()
63-
await client.invalidateQueries({ queryKey: ["aggregate", $table.id.value, widget.id] })
63+
if ($table) {
64+
await invalidate(`dashboard:${$dashboard.id.value}`)
65+
await tick()
66+
await client.invalidateQueries({ queryKey: ["aggregate", $table.id.value, widget.id] })
67+
}
6468
onSuccess()
6569
},
6670
})
@@ -90,7 +94,7 @@
9094
},
9195
})
9296
} else {
93-
if (!viewId) {
97+
if (!viewId || !$table) {
9498
return
9599
}
96100
$updateWidgetMutation.mutate({
@@ -164,12 +168,14 @@
164168
<div class="text-sm font-medium">Filters</div>
165169
</div>
166170

167-
<FiltersEditor
168-
bind:value={$value}
169-
table={$table}
170-
filter={(field) => visibleFields.some((f) => f.id.value === field.id) && getIsFilterableFieldType(field.type)}
171-
class="rounded-md border"
172-
></FiltersEditor>
171+
{#if $table}
172+
<FiltersEditor
173+
bind:value={$value}
174+
table={$table}
175+
filter={(field) => visibleFields.some((f) => f.id.value === field.id) && getIsFilterableFieldType(field.type)}
176+
class="rounded-md border"
177+
></FiltersEditor>
178+
{/if}
173179
</div>
174180

175181
<div class="flex justify-end">

apps/frontend/src/lib/components/blocks/base/base-detail.svelte

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@
9494
</Table.Body>
9595
{:else}
9696
<div class="flex flex-1 items-center justify-center">
97-
<div class="text-muted-foreground -translate-y-48">
97+
<div class="text-muted-foreground">
9898
<div class="flex flex-col items-center gap-1 space-y-2 text-center">
9999
<SquareMousePointer class="text-primary h-10 w-10" />
100100
<h3 class="text-sm font-bold tracking-tight">{base.name} have no tables</h3>
@@ -108,7 +108,8 @@
108108
}}
109109
>
110110
<PlusIcon class="mr-2 h-4 w-4" />
111-
Create New Table</Button
111+
Create New Table
112+
</Button
112113
>
113114
<Button
114115
class="w-48"
@@ -119,8 +120,8 @@
119120
}}
120121
>
121122
<ImportIcon class="mr-2 h-4 w-4" />
122-
Import Table</Button
123-
>
123+
Import Table
124+
</Button>
124125
{/if}
125126
</div>
126127
</div>

apps/frontend/src/lib/components/blocks/base/empty-base.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
</script>
55

66
<main class="flex h-full flex-col overflow-hidden">
7-
<div class="flex flex-1 -translate-y-20 items-center justify-center rounded-lg border border-dashed shadow-sm">
7+
<div class="flex flex-1 items-center justify-center rounded-lg border border-dashed shadow-sm">
88
<div class="flex flex-col items-center gap-2 text-center">
99
<InboxIcon class="text-muted-foreground h-16 w-16" />
1010
<h3 class="text-sm font-bold tracking-tight">There is no base in the space.</h3>

apps/frontend/src/lib/components/blocks/dashboard/create-dialog.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
})
6363
</script>
6464

65-
<form method="POST" class=" space-y-6" use:enhance>
65+
<form method="POST" class="space-y-3" use:enhance>
6666
<Form.Field {form} name="name">
6767
<Form.Control let:attrs>
6868
<Form.Label>Name</Form.Label>
@@ -74,6 +74,6 @@
7474

7575
<Form.Button disabled={$createDashboard.isPending}>Submit</Form.Button>
7676
{#if browser}
77-
<SuperDebug data={$formData} />
77+
<!-- <SuperDebug data={$formData} /> -->
7878
{/if}
7979
</form>

apps/frontend/src/lib/components/blocks/dashboard/dashboard-widget.svelte

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,16 @@
77
import { setTable } from "$lib/store/table.store"
88
import { writable } from "svelte/store"
99
10-
export let tableId: string
10+
export let tableId: string | undefined
1111
export let widget: IWidgetDTO
1212
export let movePointerDown: ((e: Event) => void) | undefined = undefined
1313
export let resizePointerDown: ((e: Event) => void) | undefined = undefined
1414
1515
const store = new GetDashboardWidgetTableStore()
1616
onMount(() => {
17-
store.fetch({ variables: { tableId } })
17+
if (tableId) {
18+
store.fetch({ variables: { tableId } })
19+
}
1820
})
1921
2022
$: table = $store.data?.table
@@ -25,6 +27,4 @@
2527
}
2628
</script>
2729

28-
{#if table}
29-
<Widget {widget} {tableId} {movePointerDown} {resizePointerDown} />
30-
{/if}
30+
<Widget {widget} {tableId} {movePointerDown} {resizePointerDown} />

apps/frontend/src/lib/components/blocks/delete-table/delete-table-dialog.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626
const deleteTableMutation = createMutation({
2727
mutationFn: trpc.table.delete.mutate,
2828
async onSuccess(data, variables, context) {
29-
await invalidateAll()
3029
await goto("/")
30+
await invalidateAll()
3131
},
3232
onError(error, variables, context) {
3333
toast.error(error.message)

0 commit comments

Comments
 (0)