add: button to notification when index is created from non main page.

This commit is contained in:
Darshan committed 2025-08-16 17:35:17 +05:30
1 parent d460c8357e
commit 894b5b742a
1 file changed
+24 -10
@@ -1,6 +1,7 @@
<script lang="ts">
import { invalidate } from '$app/navigation';
import { base } from '$app/paths';
import { page } from '$app/state';
import { goto, invalidate } from '$app/navigation';
import { Submit, trackError, trackEvent } from '$lib/actions/analytics';
import { Dependencies } from '$lib/constants';
import { Button, InputNumber, InputSelect, InputText } from '$lib/elements/forms';
@@ -63,6 +64,11 @@
const addColumnDisabled = $derived(!columnList.at(-1)?.value || !columnList.at(-1)?.order);
const isOnIndexesPage = $derived(page.route.id?.endsWith('/indexes'));
const navigatorPathToIndexes = $derived(
`${base}/project-${page.params.region}-${page.params.project}/databases/database-${databaseId}/table-${$table?.$id}/indexes`
);
$effect(() => {
if (showCreateIndex) {
initialize();
@@ -80,15 +86,15 @@
}
try {
await sdk.forProject(page.params.region, page.params.project).grids.createIndex(
await sdk.forProject(page.params.region, page.params.project).grids.createIndex({
databaseId,
$table.$id,
tableId: $table.$id,
key,
selectedType,
columnList.map((a) => a.value),
columnList.map((a) => a.order),
columnList.map((a) => (a.length ? Number(a.length) : null))
);
type: selectedType,
columns: columnList.map((a) => a.value),
orders: columnList.map((a) => a.order),
lengths: columnList.map((a) => (a.length ? Number(a.length) : null))
});
await Promise.allSettled([
invalidate(Dependencies.TABLE),
@@ -96,8 +102,16 @@
]);
addNotification({
message: 'Creating index',
type: 'success'
message: 'Index is being created',
type: 'success',
buttons: !isOnIndexesPage
? [
{
name: 'View index',
method: () => goto(navigatorPathToIndexes)
}
]
: undefined
});
trackEvent(Submit.IndexCreate);
showCreateIndex = false;