mirror of
https://github.com/appwrite/console.git
synced 2026-06-06 19:27:48 +00:00
add: column suggestions.
This commit is contained in:
1 parent
2b466b3569
commit
60d993a532
12 files changed
+508
-59
No files matched your search
@@ -274,9 +274,12 @@ export enum Submit {
|
||||
DatabaseDelete = 'submit_database_delete',
|
||||
DatabaseUpdateName = 'submit_database_update_name',
|
||||
DatabaseImportCsv = 'submit_database_import_csv',
|
||||
|
||||
ColumnCreate = 'submit_column_create',
|
||||
ColumnUpdate = 'submit_column_update',
|
||||
ColumnDelete = 'submit_column_delete',
|
||||
ColumnSuggestions = 'submit_column_suggestions',
|
||||
|
||||
RowCreate = 'submit_row_create',
|
||||
RowDelete = 'submit_row_delete',
|
||||
RowUpdate = 'submit_row_update',
|
||||
|
||||
@@ -126,7 +126,8 @@ const sdkForProject = {
|
||||
proxy: new Proxy(clientProject),
|
||||
migrations: new Migrations(clientProject),
|
||||
sites: new Sites(clientProject),
|
||||
tablesDB: new TablesDB(clientProject)
|
||||
tablesDB: new TablesDB(clientProject),
|
||||
console: new Console(clientProject) // for suggestions API
|
||||
};
|
||||
|
||||
export const realtime = {
|
||||
|
||||
+32
-20
@@ -12,21 +12,25 @@
|
||||
import { isSmallViewport } from '$lib/stores/viewport';
|
||||
import { SortButton } from '$lib/components';
|
||||
import type { Column } from '$lib/helpers/types';
|
||||
import { type Columns, expandTabs } from '../table-[table]/store';
|
||||
import { expandTabs } from '../table-[table]/store';
|
||||
import SpreadsheetContainer from '../table-[table]/layout/spreadsheet.svelte';
|
||||
import { onDestroy, onMount } from 'svelte';
|
||||
import { debounce } from '$lib/helpers/debounce';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import { page } from '$app/state';
|
||||
import { tableColumnSuggestions } from './store';
|
||||
import type { Models } from '@appwrite.io/console';
|
||||
import {
|
||||
type ColumnInput,
|
||||
mapSuggestedColumns,
|
||||
type SuggestedColumnSchema,
|
||||
tableColumnSuggestions
|
||||
} from './store';
|
||||
import { addNotification } from '$lib/stores/notifications';
|
||||
import { Submit, trackError, trackEvent } from '$lib/actions/analytics';
|
||||
|
||||
const {
|
||||
onColumnsFinalized = undefined
|
||||
}: {
|
||||
onColumnsFinalized?: (
|
||||
columns: Exclude<Columns, Models.ColumnRelationship>[]
|
||||
) => Promise<void>;
|
||||
onColumnsFinalized?: (columns: SuggestedColumnSchema[]) => void | Promise<void>;
|
||||
} = $props();
|
||||
|
||||
/**
|
||||
@@ -216,29 +220,37 @@
|
||||
});
|
||||
|
||||
async function suggestColumns() {
|
||||
console.log('tableColumnSuggestions', $tableColumnSuggestions.enabled);
|
||||
|
||||
if (!$tableColumnSuggestions.enabled) return;
|
||||
|
||||
$tableColumnSuggestions.thinking = true;
|
||||
|
||||
try {
|
||||
const suggestedColumns = await sdk
|
||||
.forConsoleIn(page.params.repository)
|
||||
const suggestedColumns = (await sdk
|
||||
.forProject(page.params.region, page.params.project)
|
||||
.console.suggestColumns({
|
||||
databaseId: page.params.database,
|
||||
tableId: page.params.table,
|
||||
context: $tableColumnSuggestions.context
|
||||
});
|
||||
context: $tableColumnSuggestions.context ?? undefined
|
||||
})) as unknown as {
|
||||
total: number;
|
||||
columns: ColumnInput[];
|
||||
};
|
||||
|
||||
console.log(JSON.stringify(suggestedColumns, null, 2));
|
||||
trackEvent(Submit.ColumnSuggestions, {
|
||||
total: suggestedColumns.total,
|
||||
tableName: $tableColumnSuggestions.table?.name ?? undefined
|
||||
});
|
||||
|
||||
await onColumnsFinalized?.(suggestedColumns.columns);
|
||||
} catch (e) {
|
||||
// `null` means
|
||||
// we couldn't make columns!
|
||||
await onColumnsFinalized?.(null);
|
||||
await onColumnsFinalized(mapSuggestedColumns(suggestedColumns.columns));
|
||||
} catch (error) {
|
||||
addNotification({
|
||||
type: 'error',
|
||||
message: error.message
|
||||
});
|
||||
|
||||
trackError(error, Submit.ColumnSuggestions);
|
||||
} finally {
|
||||
$tableColumnSuggestions.table = null;
|
||||
$tableColumnSuggestions.context = null;
|
||||
$tableColumnSuggestions.enabled = false;
|
||||
$tableColumnSuggestions.thinking = false;
|
||||
}
|
||||
}
|
||||
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
export * from './store';
|
||||
export { default as Empty } from './empty.svelte';
|
||||
export { default as Input } from './input.svelte';
|
||||
export { default as Review } from './review.svelte';
|
||||
+348
@@ -0,0 +1,348 @@
|
||||
<script lang="ts">
|
||||
import { Modal, Confirm } from '$lib/components';
|
||||
import { Divider, Icon, Layout } from '@appwrite.io/pink-svelte';
|
||||
import { columnOptions } from '../table-[table]/columns/store.js';
|
||||
import { Button, InputSelect, InputText } from '$lib/elements/forms';
|
||||
import { faker } from '@faker-js/faker';
|
||||
import { IconX } from '@appwrite.io/pink-icons-svelte';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import { page } from '$app/state';
|
||||
import type { SuggestedColumnSchema } from './store';
|
||||
import { addNotification } from '$lib/stores/notifications';
|
||||
import { invalidate } from '$app/navigation';
|
||||
import { Dependencies } from '$lib/constants';
|
||||
import { Submit, trackError, trackEvent } from '$lib/actions/analytics';
|
||||
import type { Columns } from '$routes/(console)/project-[region]-[project]/databases/database-[database]/table-[table]/store';
|
||||
|
||||
let {
|
||||
show = $bindable(),
|
||||
columns = $bindable()
|
||||
}: {
|
||||
show: boolean;
|
||||
columns: SuggestedColumnSchema[];
|
||||
} = $props();
|
||||
|
||||
let draft = $state(columns);
|
||||
let confirmDismiss = $state(false);
|
||||
let creatingColumns = $state(false);
|
||||
|
||||
const original = structuredClone(columns);
|
||||
const canReset = $derived(JSON.stringify(draft) !== JSON.stringify(original));
|
||||
|
||||
const columnTypeOptions = columnOptions
|
||||
.filter((col) => col.type !== 'relationship')
|
||||
.map((attr) => ({
|
||||
label: attr.name,
|
||||
leadingIcon: attr.icon,
|
||||
value: attr.format || attr.type
|
||||
}));
|
||||
|
||||
function removeColumn(key: string) {
|
||||
const idx = draft.findIndex((c) => c.key === key);
|
||||
if (idx !== -1) {
|
||||
draft.splice(idx, 1);
|
||||
draft = [...draft];
|
||||
}
|
||||
}
|
||||
|
||||
function resetDraft() {
|
||||
draft = structuredClone(original);
|
||||
}
|
||||
|
||||
function getCurrentValue(column: SuggestedColumnSchema): string {
|
||||
return column.format || column.type;
|
||||
}
|
||||
|
||||
function normalizeColumnType(
|
||||
newValue: string,
|
||||
column: SuggestedColumnSchema
|
||||
): SuggestedColumnSchema {
|
||||
const option = columnOptions.find((opt) => (opt.format || opt.type) === newValue);
|
||||
|
||||
const updated: SuggestedColumnSchema = {
|
||||
...column,
|
||||
type: option.type,
|
||||
format: option.format || null,
|
||||
size: undefined,
|
||||
min: undefined,
|
||||
max: undefined,
|
||||
default: null
|
||||
};
|
||||
|
||||
const hadDefault = column.default !== undefined && column.default !== null;
|
||||
const canHaveDefault = hadDefault && !column.required;
|
||||
|
||||
switch (option.type) {
|
||||
case 'string':
|
||||
updated.size = option.format === 'ip' ? 64 : 255;
|
||||
if (canHaveDefault) {
|
||||
switch (option.format) {
|
||||
case 'email':
|
||||
updated.default = faker.internet.email();
|
||||
break;
|
||||
case 'ip':
|
||||
updated.default = faker.internet.ip();
|
||||
break;
|
||||
case 'url':
|
||||
updated.default = faker.internet.url();
|
||||
break;
|
||||
default:
|
||||
updated.default = faker.lorem.word();
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 'integer':
|
||||
updated.min = 0;
|
||||
updated.max = 100;
|
||||
if (canHaveDefault) {
|
||||
updated.default = faker.number.int({ min: updated.min, max: updated.max });
|
||||
}
|
||||
break;
|
||||
|
||||
case 'double':
|
||||
updated.min = 0;
|
||||
updated.max = 100;
|
||||
if (canHaveDefault) {
|
||||
updated.default = faker.number.float({
|
||||
min: updated.min,
|
||||
max: updated.max,
|
||||
fractionDigits: 2
|
||||
});
|
||||
}
|
||||
break;
|
||||
|
||||
case 'boolean':
|
||||
if (canHaveDefault) {
|
||||
updated.default = faker.datatype.boolean();
|
||||
}
|
||||
break;
|
||||
|
||||
case 'datetime':
|
||||
if (canHaveDefault) {
|
||||
updated.default = faker.date.recent().toISOString();
|
||||
}
|
||||
break;
|
||||
|
||||
case 'point':
|
||||
if (canHaveDefault) {
|
||||
updated.default = [faker.location.longitude(), faker.location.latitude()];
|
||||
}
|
||||
break;
|
||||
|
||||
case 'linestring':
|
||||
if (canHaveDefault) {
|
||||
updated.default = Array.from({ length: 5 }, () => [
|
||||
faker.location.longitude(),
|
||||
faker.location.latitude()
|
||||
]);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'polygon':
|
||||
if (canHaveDefault) {
|
||||
const points = Array.from({ length: 5 }, () => [
|
||||
faker.location.longitude(),
|
||||
faker.location.latitude()
|
||||
]);
|
||||
points.push(points[0]);
|
||||
updated.default = [points];
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return updated;
|
||||
}
|
||||
|
||||
async function createColumns() {
|
||||
creatingColumns = true;
|
||||
const client = sdk.forProject(page.params.region, page.params.project);
|
||||
|
||||
try {
|
||||
const results = [];
|
||||
|
||||
for (const column of draft) {
|
||||
const baseParams = {
|
||||
databaseId: page.params.database,
|
||||
tableId: page.params.table,
|
||||
key: column.key,
|
||||
required: column.required || false
|
||||
};
|
||||
|
||||
let columnResult: Columns;
|
||||
switch (column.type) {
|
||||
case 'string':
|
||||
if (column.format) {
|
||||
switch (column.format) {
|
||||
case 'email':
|
||||
columnResult =
|
||||
await client.tablesDB.createEmailColumn(baseParams);
|
||||
break;
|
||||
case 'ip':
|
||||
columnResult = await client.tablesDB.createIpColumn(baseParams);
|
||||
break;
|
||||
case 'url':
|
||||
columnResult =
|
||||
await client.tablesDB.createUrlColumn(baseParams);
|
||||
break;
|
||||
case 'enum':
|
||||
columnResult = await client.tablesDB.createEnumColumn({
|
||||
...baseParams,
|
||||
elements: []
|
||||
});
|
||||
break;
|
||||
default:
|
||||
columnResult = await client.tablesDB.createStringColumn({
|
||||
...baseParams,
|
||||
size: column.size || 255,
|
||||
xdefault: (column.default as string) || null
|
||||
});
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
columnResult = await client.tablesDB.createStringColumn({
|
||||
...baseParams,
|
||||
size: column.size || 255,
|
||||
xdefault: (column.default as string) || null
|
||||
});
|
||||
}
|
||||
break;
|
||||
|
||||
case 'integer':
|
||||
columnResult = await client.tablesDB.createIntegerColumn({
|
||||
...baseParams,
|
||||
min: column.min,
|
||||
max: column.max,
|
||||
xdefault: (column.default as number) || null
|
||||
});
|
||||
break;
|
||||
|
||||
case 'double':
|
||||
columnResult = await client.tablesDB.createFloatColumn({
|
||||
...baseParams,
|
||||
min: column.min,
|
||||
max: column.max,
|
||||
xdefault: (column.default as number) || null
|
||||
});
|
||||
break;
|
||||
|
||||
case 'boolean':
|
||||
columnResult = await client.tablesDB.createBooleanColumn({
|
||||
...baseParams,
|
||||
xdefault: (column.default as boolean) || null
|
||||
});
|
||||
break;
|
||||
|
||||
case 'datetime':
|
||||
columnResult = await client.tablesDB.createDatetimeColumn({
|
||||
...baseParams,
|
||||
xdefault: (column.default as string) || null
|
||||
});
|
||||
break;
|
||||
|
||||
case 'point':
|
||||
columnResult = await client.tablesDB.createPointColumn(baseParams);
|
||||
break;
|
||||
|
||||
case 'linestring':
|
||||
columnResult = await client.tablesDB.createLineColumn(baseParams);
|
||||
break;
|
||||
|
||||
case 'polygon':
|
||||
columnResult = await client.tablesDB.createPolygonColumn(baseParams);
|
||||
break;
|
||||
}
|
||||
|
||||
results.push(columnResult);
|
||||
}
|
||||
|
||||
await invalidate(Dependencies.TABLE);
|
||||
|
||||
show = false;
|
||||
columns = null;
|
||||
|
||||
addNotification({
|
||||
type: 'success',
|
||||
message: 'Columns created successfully'
|
||||
});
|
||||
|
||||
trackEvent(Submit.ColumnCreate, { type: 'suggestions' });
|
||||
} catch (error) {
|
||||
trackError(error, Submit.ColumnCreate);
|
||||
addNotification({
|
||||
type: 'error',
|
||||
message: error.message
|
||||
});
|
||||
} finally {
|
||||
creatingColumns = false;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<Modal bind:show dismissible={false} title="Review columns" onSubmit={createColumns}>
|
||||
<svelte:fragment slot="description">
|
||||
Review and edit suggested columns before applying
|
||||
</svelte:fragment>
|
||||
|
||||
<Layout.Stack direction="column" gap="l">
|
||||
{#each draft as column, index (index)}
|
||||
<Layout.Stack direction="row" justifyContent="space-between" alignItems="center">
|
||||
<InputText required id={'name-' + column.key} bind:value={draft[index].key} />
|
||||
|
||||
<InputSelect
|
||||
required
|
||||
id={'type-' + column.key}
|
||||
value={getCurrentValue(draft[index])}
|
||||
options={columnTypeOptions}
|
||||
on:change={(event) => {
|
||||
draft[index] = normalizeColumnType(event.detail, draft[index]);
|
||||
draft = [...draft];
|
||||
}} />
|
||||
|
||||
<Button
|
||||
icon
|
||||
extraCompact
|
||||
on:click={() => removeColumn(column.key)}
|
||||
disabled={draft.length <= 1 || creatingColumns}>
|
||||
<Icon icon={IconX} size="s" />
|
||||
</Button>
|
||||
</Layout.Stack>
|
||||
|
||||
{#if index !== draft.length - 1}
|
||||
<Divider />
|
||||
{/if}
|
||||
{/each}
|
||||
</Layout.Stack>
|
||||
|
||||
<svelte:fragment slot="footer">
|
||||
<Layout.Stack direction="row" justifyContent="space-between" alignItems="center">
|
||||
<Button text disabled={!canReset || creatingColumns} on:click={resetDraft}
|
||||
>Reset</Button>
|
||||
|
||||
<Layout.Stack direction="row" alignItems="flex-end" inline>
|
||||
<Button text disabled={creatingColumns} on:click={() => (confirmDismiss = true)}
|
||||
>Dismiss</Button>
|
||||
|
||||
<Button
|
||||
submit
|
||||
submissionLoader
|
||||
forceShowLoader={creatingColumns}
|
||||
disabled={creatingColumns}>Confirm</Button>
|
||||
</Layout.Stack>
|
||||
</Layout.Stack>
|
||||
</svelte:fragment>
|
||||
</Modal>
|
||||
|
||||
<Confirm
|
||||
confirmDeletion
|
||||
action="Dismiss"
|
||||
title="Dismiss columns"
|
||||
bind:open={confirmDismiss}
|
||||
onSubmit={() => {
|
||||
resetDraft();
|
||||
show = false;
|
||||
columns = null;
|
||||
}}>
|
||||
Are you sure you want to dismiss these columns suggested by AI? This action is irreversible.
|
||||
</Confirm>
|
||||
+54
-2
@@ -3,11 +3,63 @@ import { writable } from 'svelte/store';
|
||||
export type TableColumnSuggestions = {
|
||||
enabled: boolean;
|
||||
thinking: boolean;
|
||||
context?: string | null;
|
||||
context?: string | undefined;
|
||||
|
||||
/* for safety when in tables page */
|
||||
table: {
|
||||
id: string;
|
||||
name: string;
|
||||
};
|
||||
};
|
||||
|
||||
export type SuggestedColumnSchema = {
|
||||
key: string;
|
||||
type: string;
|
||||
required: boolean;
|
||||
default?: string | number | boolean | number[] | number[][] | number[][][] | null;
|
||||
size?: number;
|
||||
min?: number;
|
||||
max?: number;
|
||||
format?: string | null;
|
||||
};
|
||||
|
||||
export const tableColumnSuggestions = writable<TableColumnSuggestions>({
|
||||
enabled: false,
|
||||
context: null,
|
||||
thinking: false
|
||||
thinking: false,
|
||||
table: null
|
||||
});
|
||||
|
||||
export type ColumnInput = {
|
||||
name: string;
|
||||
type: string;
|
||||
required?: boolean;
|
||||
default?: string | number | boolean | number[] | number[][] | number[][][] | null;
|
||||
size?: number;
|
||||
min?: number;
|
||||
max?: number;
|
||||
format?: string;
|
||||
formatOptions?: {
|
||||
min?: number;
|
||||
max?: number;
|
||||
};
|
||||
};
|
||||
|
||||
export function mapSuggestedColumns<T extends ColumnInput>(columns: T[]): SuggestedColumnSchema[] {
|
||||
return columns.map((col) => ({
|
||||
key: col.name,
|
||||
type: col.type,
|
||||
required: col.required ?? false,
|
||||
default: col.default ?? null,
|
||||
size: col.type === 'string' ? (col.size ?? undefined) : undefined,
|
||||
min:
|
||||
col.type === 'integer' || col.type === 'double'
|
||||
? (col.min ?? col.formatOptions?.min ?? undefined)
|
||||
: undefined,
|
||||
max:
|
||||
col.type === 'integer' || col.type === 'double'
|
||||
? (col.max ?? col.formatOptions?.max ?? undefined)
|
||||
: undefined,
|
||||
format: col.format ?? null
|
||||
}));
|
||||
}
|
||||
+8
-10
@@ -10,7 +10,6 @@
|
||||
} from '$lib/commandCenter';
|
||||
import { tablesSearcher } from '$lib/commandCenter/searchers';
|
||||
import { Dependencies } from '$lib/constants';
|
||||
import type { Models } from '@appwrite.io/console';
|
||||
import CreateTable from './createTable.svelte';
|
||||
import { showCreateTable } from './store';
|
||||
import { TablesPanel } from '$lib/commandCenter/panels';
|
||||
@@ -24,14 +23,6 @@
|
||||
const project = page.params.project;
|
||||
const databaseId = page.params.database;
|
||||
|
||||
async function handleCreate(event: CustomEvent<Models.Table>) {
|
||||
$showCreateTable = false;
|
||||
await invalidate(Dependencies.DATABASE);
|
||||
await goto(
|
||||
`${base}/project-${page.params.region}-${project}/databases/database-${databaseId}/table-${event.detail.$id}`
|
||||
);
|
||||
}
|
||||
|
||||
$: $registerCommands([
|
||||
{
|
||||
label: 'Create table',
|
||||
@@ -152,4 +143,11 @@
|
||||
|
||||
<slot />
|
||||
|
||||
<CreateTable bind:showCreate={$showCreateTable} on:created={handleCreate} />
|
||||
<CreateTable
|
||||
bind:showCreate={$showCreateTable}
|
||||
onTableCreated={async (table) => {
|
||||
await invalidate(Dependencies.DATABASE);
|
||||
await goto(
|
||||
`${base}/project-${page.params.region}-${project}/databases/database-${databaseId}/table-${table.$id}`
|
||||
);
|
||||
}} />
|
||||
+37
-21
@@ -6,26 +6,28 @@
|
||||
import { Button, InputText } from '$lib/elements/forms';
|
||||
import { addNotification } from '$lib/stores/notifications';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import { ID } from '@appwrite.io/console';
|
||||
import { createEventDispatcher } from 'svelte';
|
||||
import { ID, type Models } from '@appwrite.io/console';
|
||||
import { subNavigation } from '$lib/stores/database';
|
||||
import { Input as SuggestionsInput } from './(suggestions)/index';
|
||||
import { Input as SuggestionsInput, tableColumnSuggestions } from './(suggestions)/index';
|
||||
|
||||
let {
|
||||
showCreate = $bindable(false)
|
||||
showCreate = $bindable(false),
|
||||
onTableCreated
|
||||
}: {
|
||||
showCreate: boolean;
|
||||
onTableCreated: (table: Models.Table) => void | Promise<void>;
|
||||
} = $props();
|
||||
|
||||
const databaseId = page.params.database;
|
||||
const dispatch = createEventDispatcher();
|
||||
|
||||
let name = $state('');
|
||||
let id: string = $state(null);
|
||||
let touchedId = $state(false);
|
||||
let error: string = $state(null);
|
||||
|
||||
const create = async () => {
|
||||
let creatingTable = $state(false);
|
||||
|
||||
async function createTable() {
|
||||
error = null;
|
||||
try {
|
||||
const table = await sdk
|
||||
@@ -36,23 +38,35 @@
|
||||
name
|
||||
});
|
||||
|
||||
showCreate = false;
|
||||
subNavigation.update();
|
||||
$tableColumnSuggestions.table = {
|
||||
id: table.$id,
|
||||
name: table.name
|
||||
};
|
||||
|
||||
dispatch('created', table);
|
||||
addNotification({
|
||||
type: 'success',
|
||||
message: `${name} has been created`
|
||||
});
|
||||
name = id = null;
|
||||
trackEvent(Submit.TableCreate, {
|
||||
customId: !!id
|
||||
});
|
||||
updateAndCleanup();
|
||||
|
||||
await onTableCreated(table);
|
||||
|
||||
showCreate = false;
|
||||
creatingTable = false;
|
||||
} catch (e) {
|
||||
error = e.message;
|
||||
trackError(e, Submit.TableCreate);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function updateAndCleanup() {
|
||||
subNavigation.update();
|
||||
|
||||
addNotification({
|
||||
type: 'success',
|
||||
message: `${name} has been created`
|
||||
});
|
||||
|
||||
trackEvent(Submit.TableCreate, { customId: !!id });
|
||||
|
||||
name = id = null;
|
||||
}
|
||||
|
||||
function toIdFormat(str: string): string {
|
||||
return str
|
||||
@@ -79,7 +93,7 @@
|
||||
});
|
||||
</script>
|
||||
|
||||
<Modal title="Create table" size="m" bind:show={showCreate} onSubmit={create} bind:error>
|
||||
<Modal title="Create table" size="m" bind:show={showCreate} onSubmit={createTable} bind:error>
|
||||
<InputText
|
||||
id="name"
|
||||
label="Name"
|
||||
@@ -108,7 +122,9 @@
|
||||
<SuggestionsInput />
|
||||
|
||||
<svelte:fragment slot="footer">
|
||||
<Button secondary on:click={() => (showCreate = false)}>Cancel</Button>
|
||||
<Button submit>Create</Button>
|
||||
<Button secondary disabled={creatingTable} on:click={() => (showCreate = false)}
|
||||
>Cancel</Button>
|
||||
<Button submit disabled={creatingTable} submissionLoader forceShowLoader={creatingTable}
|
||||
>Create</Button>
|
||||
</svelte:fragment>
|
||||
</Modal>
|
||||
+2
@@ -62,6 +62,7 @@
|
||||
import { preferences } from '$lib/stores/preferences';
|
||||
import { buildRowUrl, isRelationship } from './rows/store';
|
||||
import { chunks } from '$lib/helpers/array';
|
||||
import { Submit, trackEvent } from '$lib/actions/analytics';
|
||||
|
||||
let editRow: EditRow;
|
||||
let editRelatedRow: EditRelatedRow;
|
||||
@@ -256,6 +257,7 @@
|
||||
columns = await generateColumns($project, page.params.database, page.params.table);
|
||||
|
||||
await invalidate(Dependencies.TABLE);
|
||||
trackEvent(Submit.ColumnCreate, { type: 'faker' });
|
||||
} catch (e) {
|
||||
addNotification({
|
||||
type: 'error',
|
||||
|
||||
+19
-3
@@ -31,12 +31,20 @@
|
||||
import EmptySheet from './layout/emptySheet.svelte';
|
||||
import CreateRow from './rows/create.svelte';
|
||||
import { onDestroy } from 'svelte';
|
||||
import { Empty as SuggestionsEmptySheet, tableColumnSuggestions } from '../(suggestions)';
|
||||
import {
|
||||
Review as ReviewColumns,
|
||||
Empty as SuggestionsEmptySheet,
|
||||
type SuggestedColumnSchema,
|
||||
tableColumnSuggestions
|
||||
} from '../(suggestions)';
|
||||
|
||||
export let data: PageData;
|
||||
|
||||
let showImportCSV = false;
|
||||
|
||||
let showSuggestionsModal = false;
|
||||
let columnSuggestionsSchema: SuggestedColumnSchema[] = [];
|
||||
|
||||
// todo: might need a type fix here.
|
||||
const filterColumns = writable<Column[]>([]);
|
||||
|
||||
@@ -216,8 +224,12 @@
|
||||
}
|
||||
}} />
|
||||
{/if}
|
||||
{:else if $tableColumnSuggestions.thinking}
|
||||
<SuggestionsEmptySheet />
|
||||
{:else if $tableColumnSuggestions.enabled && $tableColumnSuggestions.table && $tableColumnSuggestions.table.id === page.params.table}
|
||||
<SuggestionsEmptySheet
|
||||
onColumnsFinalized={(columns) => {
|
||||
showSuggestionsModal = true;
|
||||
columnSuggestionsSchema = columns;
|
||||
}} />
|
||||
{:else}
|
||||
<EmptySheet
|
||||
mode="rows"
|
||||
@@ -260,6 +272,10 @@
|
||||
bind:showSheet={$showRowCreateSheet.show}
|
||||
bind:existingData={$showRowCreateSheet.row} />
|
||||
|
||||
{#if showSuggestionsModal && columnSuggestionsSchema}
|
||||
<ReviewColumns bind:show={showSuggestionsModal} bind:columns={columnSuggestionsSchema} />
|
||||
{/if}
|
||||
|
||||
<style>
|
||||
:global(.small-button-dimensions) {
|
||||
width: 32px !important;
|
||||
|
||||
-1
@@ -410,7 +410,6 @@
|
||||
</Spreadsheet.Root>
|
||||
</SpreadsheetContainer>
|
||||
|
||||
<!-- TODO: terminologies -->
|
||||
{#if selectedColumns.length > 0}
|
||||
<div class="floating-action-bar">
|
||||
<FloatingActionBar>
|
||||
|
||||
+2
-1
@@ -149,7 +149,8 @@
|
||||
type: 'success',
|
||||
message: `Column ${key ?? data?.key} has been created`
|
||||
});
|
||||
trackEvent(Submit.ColumnCreate);
|
||||
|
||||
trackEvent(Submit.ColumnCreate, { type: 'manual' });
|
||||
|
||||
if (createMore) {
|
||||
init();
|
||||
|
||||
Reference in new issue
Block a user