update: design review fixes.

This commit is contained in:
Darshan committed 2025-08-20 10:19:26 +05:30
1 parent a18ac7b23c
commit a0cf575456
28 files changed
+311 -205

No files matched your search

+1 -1
View File
@@ -26,7 +26,7 @@
"@appwrite.io/pink-icons": "0.25.0",
"@appwrite.io/pink-icons-svelte": "^2.0.0-RC.1",
"@appwrite.io/pink-legacy": "^1.0.3",
"@appwrite.io/pink-svelte": "https://pkg.vc/-/@appwrite/@appwrite.io/pink-svelte@9f28c76",
"@appwrite.io/pink-svelte": "https://pkg.vc/-/@appwrite/@appwrite.io/pink-svelte@59e81f6",
"@faker-js/faker": "^9.9.0",
"@popperjs/core": "^2.11.8",
"@sentry/sveltekit": "^8.38.0",
+5 -5
View File
@@ -24,8 +24,8 @@ importers:
specifier: ^1.0.3
version: 1.0.3
'@appwrite.io/pink-svelte':
specifier: https://pkg.vc/-/@appwrite/@appwrite.io/pink-svelte@9f28c76
version: https://pkg.vc/-/@appwrite/@appwrite.io/pink-svelte@9f28c76(svelte@5.25.3)
specifier: https://pkg.vc/-/@appwrite/@appwrite.io/pink-svelte@36dc3f2
version: https://pkg.vc/-/@appwrite/@appwrite.io/pink-svelte@36dc3f2(svelte@5.25.3)
'@faker-js/faker':
specifier: ^9.9.0
version: 9.9.0
@@ -284,8 +284,8 @@ packages:
'@appwrite.io/pink-legacy@1.0.3':
resolution: {integrity: sha512-GGde5fmPhs+s6/3aFeMPc/kKADG/gTFkYQSy6oBN8pK0y0XNCLrZZgBv+EBbdhwdtqVEWXa0X85Mv9w7jcIlwQ==}
'@appwrite.io/pink-svelte@https://pkg.vc/-/@appwrite/@appwrite.io/pink-svelte@9f28c76':
resolution: {tarball: https://pkg.vc/-/@appwrite/@appwrite.io/pink-svelte@9f28c76}
'@appwrite.io/pink-svelte@https://pkg.vc/-/@appwrite/@appwrite.io/pink-svelte@36dc3f2':
resolution: {tarball: https://pkg.vc/-/@appwrite/@appwrite.io/pink-svelte@36dc3f2}
version: 2.0.0-RC.2
peerDependencies:
svelte: ^4.0.0
@@ -3828,7 +3828,7 @@ snapshots:
'@appwrite.io/pink-icons': 1.0.0
the-new-css-reset: 1.11.3
'@appwrite.io/pink-svelte@https://pkg.vc/-/@appwrite/@appwrite.io/pink-svelte@9f28c76(svelte@5.25.3)':
'@appwrite.io/pink-svelte@https://pkg.vc/-/@appwrite/@appwrite.io/pink-svelte@36dc3f2(svelte@5.25.3)':
dependencies:
'@appwrite.io/pink-icons-svelte': 2.0.0-RC.1(svelte@5.25.3)
'@floating-ui/dom': 1.6.13
+52 -26
View File
@@ -11,6 +11,10 @@
import { Layout, Typography } from '@appwrite.io/pink-svelte';
import { type Models, type Payload, Query } from '@appwrite.io/console';
// re-render the key for sheet UI.
import { hash } from '$lib/helpers/string';
import { spreadsheetRenderKey } from '$routes/(console)/project-[region]-[project]/databases/database-[database]/table-[table]/store';
type ImportItem = {
status: string;
table?: string;
@@ -58,6 +62,7 @@
if (isSuccess) {
await invalidate(Dependencies.ROWS);
$spreadsheetRenderKey = hash(Date.now().toString());
}
}
@@ -75,7 +80,10 @@
try {
const table = await sdk
.forProject(page.params.region, page.params.project)
.grids.getTable(databaseId, tableId);
.grids.getTable({
databaseId,
tableId
});
tableName = table.name;
} catch {
tableName = null;
@@ -142,10 +150,12 @@
onMount(() => {
sdk.forProject(page.params.region, page.params.project)
.migrations.list([
Query.equal('source', 'CSV'),
Query.equal('status', ['pending', 'processing'])
])
.migrations.list({
queries: [
Query.equal('source', 'CSV'),
Query.equal('status', ['pending', 'processing'])
]
})
.then((migrations) => {
migrations.migrations.forEach(updateOrAddItem);
});
@@ -186,36 +196,52 @@
</button>
</header>
{#each [...$importItems.entries()] as [key, value] (key)}
<div class="upload-box-content" class:is-open={isOpen}>
<ul class="upload-box-list">
<li class="upload-box-item">
<section class="progress-bar u-width-full-line">
<div
class="progress-bar-top-line u-flex u-gap-8 u-main-space-between">
<Typography.Text>
{@html text(value.status, value.table)}
</Typography.Text>
</div>
<div
class="progress-bar-container"
class:is-danger={value.status === 'failed'}
style="--graph-size:{graphSize(value.status)}%">
</div>
</section>
</li>
</ul>
</div>
{/each}
<div class="upload-box-content-list">
{#each [...$importItems.entries()] as [key, value] (key)}
<div class="upload-box-content" class:is-open={isOpen}>
<ul class="upload-box-list">
<li class="upload-box-item">
<section class="progress-bar u-width-full-line">
<div
class="progress-bar-top-line u-flex u-gap-8 u-main-space-between">
<Typography.Text>
{@html text(value.status, value.table)}
</Typography.Text>
</div>
<div
class="progress-bar-container"
class:is-danger={value.status === 'failed'}
style="--graph-size:{graphSize(value.status)}%">
</div>
</section>
</li>
</ul>
</div>
{/each}
</div>
</section>
</Layout.Stack>
{/if}
<style lang="scss">
.upload-box {
display: flex;
max-height: 320px;
flex-direction: column;
}
.upload-box-header {
flex-shrink: 0;
}
.upload-box-title {
font-size: 11px;
}
.upload-box-content-list {
overflow-y: auto;
}
.upload-box-content {
width: 304px;
}
+8 -2
View File
@@ -59,9 +59,15 @@ function initQueries(initialValue = new Map<TagValue, string>()) {
}
function apply() {
const queryParam = mapToQueryParams(get(queries));
const usableQueries = get(queries);
const currentLocation = window.location.pathname;
goto(`${currentLocation}?query=${queryParam}`, { noScroll: true });
if (usableQueries.size) {
const queryParam = mapToQueryParams(get(queries));
goto(`${currentLocation}?query=${queryParam}`, { noScroll: true });
} else {
goto(currentLocation, { noScroll: true });
}
}
return {
+5 -1
View File
@@ -23,7 +23,11 @@
];
</script>
<Container expanded={databasesScreen} slotSpacing={databasesScreen} {databasesScreen}>
<Container
{databasesScreen}
{insideSideSheet}
expanded={databasesScreen && !insideSideSheet}
slotSpacing={databasesScreen && !insideSideSheet}>
{#if logs.total}
<div>
<Table.Root {columns} let:root>
+6
View File
@@ -7,6 +7,7 @@
export let slotSpacing = false;
export let overlapCover = false;
export let paddingInlineEnd = true;
export let insideSideSheet = false;
export let databasesScreen = false;
export let expandHeightButton = false;
export let size: 'small' | 'medium' | 'large' | 'xl' | 'xxl' | 'xxxl' = null;
@@ -22,6 +23,7 @@
class:expanded
class:slotSpacing
class:databasesScreen
class:insideSideSheet
class:expandHeightButton
class="console-container"
class:paddingInlineEnd={!paddingInlineEnd}>
@@ -39,6 +41,10 @@
:global(.console-container) {
margin-block: var(--base-32);
&.insideSideSheet {
margin-block: var(--base-20);
}
&.expanded {
max-width: unset;
margin-inline: 2.75rem;
+1 -1
View File
@@ -11,7 +11,7 @@
Button,
Badge
} from '@appwrite.io/pink-svelte';
import { isSmallViewport, isTabletViewport } from '$lib/stores/viewport';
import { isSmallViewport } from '$lib/stores/viewport';
import { page } from '$app/state';
const currentYear = new Date().getFullYear();
@@ -21,7 +21,6 @@
export let data: PageData;
let showCreate = false;
let isCreationDisabled = false;
const project = page.params.project;
async function handleCreate(event: CustomEvent<Models.Database>) {
@@ -38,7 +37,7 @@
showCreate = true;
},
keys: ['c'],
disabled: showCreate || isCreationDisabled || !$canWriteDatabases,
disabled: showCreate || !$canWriteDatabases,
icon: IconPlus,
group: 'databases',
rank: 10
@@ -58,10 +57,7 @@
hideColumns={!data.databases.total}
hideView={!data.databases.total} />
{#if $canWriteDatabases}
<Button
on:click={() => (showCreate = true)}
event="create_database"
disabled={isCreationDisabled}>
<Button event="create_database" on:click={() => (showCreate = true)}>
<Icon icon={IconPlus} slot="start" size="s" />
Create database
</Button>
@@ -25,8 +25,8 @@
let id: string = null;
let showCustomId = false;
const trackEvents = (policies) => {
policies.forEach((policy) => {
const trackEvents = (policies: UserBackupPolicy[]) => {
policies.forEach((policy: UserBackupPolicy) => {
let actualDay = null;
const monthlyBackupFrequency = policy.monthlyBackupFrequency;
switch (monthlyBackupFrequency) {
@@ -48,7 +48,9 @@
policy: policy.default ? 'preset' : 'custom'
};
if (actualDay) message['monthlyInterval'] = actualDay;
if (actualDay) {
message['monthlyInterval'] = actualDay;
}
trackEvent('submit_policy_submit', message);
});
@@ -81,7 +83,10 @@
const databaseId = id ? id : ID.unique();
const database = await sdk
.forProject(page.params.region, page.params.project)
.grids.createDatabase(databaseId, name);
.grids.createDatabase({
databaseId,
name
});
await createPolicies(databaseId);
@@ -12,8 +12,8 @@ export const load: LayoutLoad = async ({ params, depends }) => {
header: Header,
breadcrumbs: Breadcrumbs,
subNavigation: SubNavigation,
database: await sdk
.forProject(params.region, params.project)
.grids.getDatabase(params.database)
database: await sdk.forProject(params.region, params.project).grids.getDatabase({
databaseId: params.database
})
};
};
@@ -1,20 +1,45 @@
<script lang="ts">
import { PaginationWithLimit } from '$lib/components';
import { EmptySearch, PaginationWithLimit, SearchQuery, ViewSelector } from '$lib/components';
import { Button } from '$lib/elements/forms';
import { Container } from '$lib/layout';
import { showCreate } from './store';
import { showCreate, tableViewColumns } from './store';
import Table from './table.svelte';
import Grid from './grid.svelte';
import type { PageData } from './$types';
import { Card, Empty } from '@appwrite.io/pink-svelte';
import { Card, Empty, Icon, Layout } from '@appwrite.io/pink-svelte';
import { base } from '$app/paths';
import { app } from '$lib/stores/app';
import { canWriteTables } from '$lib/stores/roles';
import { IconPlus } from '@appwrite.io/pink-icons-svelte';
import { page } from '$app/state';
export let data: PageData;
const databaseId = page.params.database;
</script>
<Container expanded slotSpacing paddingInlineEnd={false}>
<Container paddingInlineEnd={false}>
<Layout.Stack direction="row" justifyContent="space-between">
<Layout.Stack direction="row" alignItems="center">
<SearchQuery placeholder="Search by name or ID" />
</Layout.Stack>
<Layout.Stack direction="row" alignItems="center" justifyContent="flex-end">
<ViewSelector
view={data.view}
columns={tableViewColumns}
hideColumns={!data.tables.total}
hideView={!data.tables.total} />
{#if $canWriteTables}
<Button event="create_table" on:click={() => ($showCreate = true)}>
<Icon icon={IconPlus} slot="start" size="s" />
Create table
</Button>
{/if}
</Layout.Stack>
</Layout.Stack>
{#if data.tables.total}
{#if data.view === 'grid'}
<Grid {data} bind:showCreate={$showCreate} />
@@ -27,6 +52,14 @@
limit={data.limit}
offset={data.offset}
total={data.tables.total} />
{:else if data.search}
<EmptySearch target="tables" hidePagination>
<Button
size="s"
secondary
href={`${base}/project-${page.params.region}-${page.params.project}/databases/database-${databaseId}`}
>Clear Search</Button>
</EmptySearch>
{:else}
<Card.Base padding="none">
<Empty
@@ -6,25 +6,34 @@ import { CARD_LIMIT, Dependencies } from '$lib/constants';
export const load: PageLoad = async ({ params, url, route, depends }) => {
depends(Dependencies.TABLES);
const page = getPage(url);
const search = getSearch(url);
const limit = getLimit(url, route, CARD_LIMIT);
const view = getView(url, route, View.Grid);
const offset = pageToOffset(page, limit);
const tables = await sdk
.forProject(params.region, params.project)
.grids.listTables(
params.database,
[Query.limit(limit), Query.offset(offset), Query.orderDesc('')],
search || undefined
);
const grids = sdk.forProject(params.region, params.project).grids;
const [tables, tablesForSubNavigation] = await Promise.all([
grids.listTables({
databaseId: params.database,
queries: [Query.limit(limit), Query.offset(offset), Query.orderDesc('')],
search: search || undefined
}),
grids.listTables({
databaseId: params.database,
queries: [Query.orderDesc('')]
})
]);
return {
offset,
limit,
search,
view,
tables
tables,
tablesForSubNavigation
};
};
@@ -23,7 +23,7 @@
let tableId = $derived(page.params.table);
let databaseId = $derived(page.params.database);
const tables = $derived(data.tables);
const tables = $derived(data.tablesForSubNavigation);
const sortedTables = $derived.by(() =>
tables?.tables?.slice().sort((a, b) => a.name.localeCompare(b.name))
@@ -28,7 +28,7 @@
databaseColumnSheetOptions,
databaseRowSheetOptions,
randomDataModalState,
showCreateAttributeSheet,
showCreateColumnSheet,
showCreateIndexSheet,
spreadsheetLoading,
rowActivitySheet,
@@ -50,7 +50,7 @@
import EditRow from './rows/edit.svelte';
import EditRelatedRow from './rows/editRelated.svelte';
import EditColumn from './columns/edit.svelte';
import RowActivity from './rowActivity.svelte';
import RowActivity from './rows/activity.svelte';
import EditRowPermissions from './rows/editPermissions.svelte';
import { Dialog, Layout, Typography } from '@appwrite.io/pink-svelte';
import { Button, Seekbar } from '$lib/elements/forms';
@@ -312,8 +312,8 @@
<SideSheet
closeOnBlur
title={$showCreateAttributeSheet.title}
bind:show={$showCreateAttributeSheet.show}
title={$showCreateColumnSheet.title}
bind:show={$showCreateColumnSheet.show}
submit={{
text: 'Create',
onClick: async () => {
@@ -324,11 +324,10 @@
<CreateColumn
bind:selectedOption
bind:this={createColumn}
column={$showCreateAttributeSheet.column}
showCreate={$showCreateAttributeSheet.show}
direction={$showCreateAttributeSheet.direction}
columns={$showCreateAttributeSheet.columns}
columnsOrder={$showCreateAttributeSheet.columnsOrder}
column={$showCreateColumnSheet.column}
columns={$showCreateColumnSheet.columns}
direction={$showCreateColumnSheet.direction}
columnsOrder={$showCreateColumnSheet.columnsOrder}
onColumnsReorder={(newOrder) => {
columnsOrder.set(newOrder);
// columns.set(reorderItems($columns, $columnsOrder));
@@ -8,7 +8,7 @@ import { Query } from '@appwrite.io/console';
export const load: LayoutLoad = async ({ params, depends }) => {
depends(Dependencies.TABLE);
const [table, tables] = await Promise.all([
const [table, tablesForSubNavigation] = await Promise.all([
sdk.forProject(params.region, params.project).grids.getTable({
databaseId: params.database,
tableId: params.table
@@ -24,6 +24,6 @@ export const load: LayoutLoad = async ({ params, depends }) => {
header: Header,
breadcrumbs: Breadcrumbs,
table,
tables
tablesForSubNavigation
};
};
@@ -1,5 +1,4 @@
<script lang="ts">
import { EmptySearch } from '$lib/components';
import { Filters, hasPageQueries, queries } from '$lib/components/filters';
import ViewSelector from '$lib/components/viewSelector.svelte';
import { Button } from '$lib/elements/forms';
@@ -13,8 +12,8 @@
table,
tableColumns,
isCsvImportInProgress,
showRecordsCreateSheet,
showCreateAttributeSheet,
showRowCreateSheet,
showCreateColumnSheet,
type Columns,
randomDataModalState,
expandTabs
@@ -92,7 +91,7 @@
}
}
onDestroy(() => ($showCreateAttributeSheet.show = false));
onDestroy(() => ($showCreateColumnSheet.show = false));
</script>
{#key page.params.table}
@@ -127,17 +126,18 @@
{#if !$isSmallViewport}
<Button
secondary
event="create_row"
disabled={!(hasColumns && hasValidColumns)}
on:click={() => ($showRecordsCreateSheet.show = true)}
event="create_row">
on:click={() => ($showRowCreateSheet.show = true)}>
<Icon icon={IconPlus} slot="start" size="s" />
Create row
</Button>
<Button
icon
size="s"
secondary
disabled={!(hasColumns && hasValidColumns)}
class="small-button-dimensions"
on:click={() => {
$expandTabs = !$expandTabs;
preferences.setKey('tableHeaderExpanded', $expandTabs);
@@ -152,7 +152,7 @@
secondary
event="create_row"
disabled={!(hasColumns && hasValidColumns)}
on:click={() => ($showRecordsCreateSheet.show = true)}>
on:click={() => ($showRowCreateSheet.show = true)}>
<Icon icon={IconPlus} slot="start" size="s" />
Create row
</Button>
@@ -164,29 +164,24 @@
{#if hasColumns && hasValidColumns}
{#if data.rows.total}
<Divider />
<SpreadSheet {data} bind:showRecordsCreateSheet={$showRecordsCreateSheet} />
<SpreadSheet {data} bind:showRowCreateSheet={$showRowCreateSheet} />
{:else if $hasPageQueries}
<EmptySearch hidePages>
<div class="common-section">
<div class="u-text-center common-section">
<b class="body-text-2 u-bold">Sorry, we couldn't find any rows.</b>
<p>There are no rows that match your filters.</p>
</div>
<div class="u-flex common-section u-main-center">
<Button
secondary
on:click={() => {
queries.clearAll();
queries.apply();
trackEvent(Submit.FilterClear, {
source: 'database_rows'
});
}}>
Clear filters
</Button>
</div>
</div>
</EmptySearch>
<EmptySheet
mode="rows-filtered"
title="There are no rows that match your filters"
customColumns={createTableColumns($table.columns, selected)}
actions={{
primary: {
text: 'Clear filters',
onClick: () => {
queries.clearAll();
queries.apply();
trackEvent(Submit.FilterClear, {
source: 'database_rows'
});
}
}
}} />
{:else}
<EmptySheet
mode="rows"
@@ -196,7 +191,7 @@
primary: {
text: 'Create rows',
onClick: () => {
$showRecordsCreateSheet.show = true;
$showRowCreateSheet.show = true;
}
},
random: {
@@ -215,7 +210,7 @@
primary: {
text: 'Create column',
onClick: async () => {
$showCreateAttributeSheet.show = true;
$showCreateColumnSheet.show = true;
}
},
random: {
@@ -243,5 +238,12 @@
<CreateRow
table={$table}
bind:showSheet={$showRecordsCreateSheet.show}
bind:existingData={$showRecordsCreateSheet.row} />
bind:showSheet={$showRowCreateSheet.show}
bind:existingData={$showRowCreateSheet.row} />
<style>
:global(.small-button-dimensions) {
width: 32px !important;
height: 32px !important;
}
</style>
@@ -30,13 +30,11 @@ export const load: PageLoad = async ({ params, depends, url, route, parent }) =>
view,
query,
currentSort,
rows: await sdk
.forProject(params.region, params.project)
.grids.listRows(
params.database,
params.table,
buildGridQueries(limit, offset, parsedQueries, table)
)
rows: await sdk.forProject(params.region, params.project).grids.listRows({
databaseId: params.database,
tableId: params.table,
queries: buildGridQueries(limit, offset, parsedQueries, table)
})
};
};
@@ -41,13 +41,13 @@
IconLockClosed,
IconFingerPrint
} from '@appwrite.io/pink-icons-svelte';
import { type ComponentProps, onDestroy, onMount, tick } from 'svelte';
import { type ComponentProps, onDestroy, onMount } from 'svelte';
import { Click, trackEvent } from '$lib/actions/analytics';
import CsvDisabled from '../csvDisabled.svelte';
import { isSmallViewport } from '$lib/stores/viewport';
import SideSheet from '../layout/sidesheet.svelte';
import SpreadsheetContainer from '../layout/spreadsheet.svelte';
import { showCreateAttributeSheet } from '../store';
import { showCreateColumnSheet } from '../store';
import { type Models } from '@appwrite.io/console';
import { preferences } from '$lib/stores/preferences';
import { page } from '$app/state';
@@ -61,7 +61,7 @@
name: 'ID',
selectable: false,
system: true
} as Models.AttributeString & {
} as Models.ColumnString & {
name: string;
selectable: boolean;
system: boolean;
@@ -74,7 +74,7 @@
name: 'createdAt',
selectable: false,
system: true
} as Models.AttributeDatetime & {
} as Models.ColumnDatetime & {
name: string;
selectable: boolean;
system: boolean;
@@ -86,7 +86,7 @@
name: 'updatedAt',
selectable: false,
system: true
} as Models.AttributeDatetime & {
} as Models.ColumnDatetime & {
name: string;
selectable: boolean;
system: boolean;
@@ -153,7 +153,7 @@
}
}
onDestroy(() => ($showCreateAttributeSheet.show = false));
onDestroy(() => ($showCreateColumnSheet.show = false));
$effect(() => {
if (!$showCreateIndexSheet.show && $showCreateIndexSheet.column) {
@@ -178,7 +178,7 @@
size="s"
secondary
disabled={$isCsvImportInProgress}
on:click={() => ($showCreateAttributeSheet.show = true)}
on:click={() => ($showCreateColumnSheet.show = true)}
event="create_attribute">
<Icon icon={IconPlus} slot="start" size="s" />
Create column
@@ -202,7 +202,7 @@
{ id: 'default', width: { min: 200 } },
{ id: 'actions', width: 40, isAction: true }
]}
bottomActionClick={() => ($showCreateAttributeSheet.show = true)}>
bottomActionClick={() => ($showCreateColumnSheet.show = true)}>
<svelte:fragment slot="header" let:root>
<Spreadsheet.Header.Cell column="key" {root}>Column name</Spreadsheet.Header.Cell>
<Spreadsheet.Header.Cell column="indexed" {root}>Indexed</Spreadsheet.Header.Cell>
@@ -77,6 +77,7 @@
onSubmit={handleDelete}
title="Delete column"
bind:error
confirmDeletion
disabled={isDeleteBtnDisabled}>
{#if selectedColumns.length === 1}
<p>
@@ -10,10 +10,10 @@
import { option, columnOptions, type Option } from './columns/store';
import type { Column } from '$lib/helpers/types';
import { preferences } from '$lib/stores/preferences';
import { onMount } from 'svelte';
let {
direction = null,
showCreate = false,
column = null,
columns = $bindable(null),
columnId = $bindable(null),
@@ -21,7 +21,6 @@
selectedOption = $bindable('String'),
onColumnsReorder = null
}: {
showCreate: boolean;
column?: Columns;
columnId?: string;
columns?: Column[];
@@ -46,6 +45,20 @@
columnOptions.find((option) => option.name === selectedOption).component
);
function init() {
key = null;
$option = null;
data = {
required: false,
array: false,
default: null
};
/* default to string */
selectedOption = 'String';
$option = columnOptions[0];
}
function insertColumnInOrder() {
if (!key) return;
@@ -144,6 +157,8 @@
}
}
onMount(init);
$effect(() => {
columnId; /* silences lint check, variable not read */
@@ -151,18 +166,6 @@
if (selectedOption) {
$option = columnOptions.find((option) => option.name === selectedOption);
}
// cleanup
if (!showCreate) {
key = null;
$option = null;
selectedOption = null;
data = {
required: false,
array: false,
default: null
};
}
});
</script>
@@ -122,6 +122,7 @@
&.collapsed {
opacity: 0;
pointer-events: none;
& :global([role='tab']) {
cursor: default;
@@ -32,7 +32,7 @@
import SpreadsheetContainer from '../layout/spreadsheet.svelte';
import SideSheet from '../layout/sidesheet.svelte';
import type { PageData } from './$types';
import { showCreateAttributeSheet } from '../store';
import { showCreateColumnSheet } from '../store';
import { isSmallViewport } from '$lib/stores/viewport';
let {
@@ -74,7 +74,7 @@
}
}
onDestroy(() => ($showCreateAttributeSheet.show = false));
onDestroy(() => ($showCreateColumnSheet.show = false));
const emptyCellsLimit = $derived($isSmallViewport ? 14 : 17);
const emptyCellsCount = $derived(
@@ -165,10 +165,11 @@
<Button text icon ariaLabel="more options" on:click={toggle}>
<Icon icon={IconDotsHorizontal} size="s" />
</Button>
<ActionMenu.Root slot="tooltip">
<ActionMenu.Root slot="tooltip" let:toggle>
<ActionMenu.Item.Button
leadingIcon={IconEye}
on:click={() => {
toggle();
selectedIndex = index;
showOverview = true;
}}>Overview</ActionMenu.Item.Button>
@@ -181,8 +182,9 @@
status="danger"
leadingIcon={IconTrash}
on:click={() => {
selectedIndex = index;
toggle();
showDelete = true;
selectedIndex = index;
trackEvent(Click.DatabaseIndexDelete);
}}>Delete</ActionMenu.Item.Button>
</ActionMenu.Root>
@@ -224,7 +226,7 @@
primary: {
text: 'Create columns',
onClick: async () => {
$showCreateAttributeSheet.show = true;
$showCreateColumnSheet.show = true;
}
}
}} />
@@ -14,14 +14,14 @@
import {
tableColumns,
columnsOrder,
showCreateAttributeSheet,
showCreateColumnSheet,
spreadsheetLoading,
expandTabs
} from '../store';
import { onMount } from 'svelte';
import SpreadsheetContainer from './spreadsheet.svelte';
type Mode = 'rows' | 'indexes';
type Mode = 'rows' | 'rows-filtered' | 'indexes';
interface Action {
text?: string;
@@ -165,10 +165,10 @@
style:cursor={columnActionsById ? 'pointer' : null}
onclick={() => {
if (columnActionsById && mode === 'rows') {
$showCreateAttributeSheet.show = true;
$showCreateAttributeSheet.title = 'Create column';
$showCreateAttributeSheet.columns = $tableColumns;
$showCreateAttributeSheet.columnsOrder = $columnsOrder;
$showCreateColumnSheet.show = true;
$showCreateColumnSheet.title = 'Create column';
$showCreateColumnSheet.columns = $tableColumns;
$showCreateColumnSheet.columnsOrder = $columnsOrder;
}
}}>
<Spreadsheet.Header.Cell
@@ -176,12 +176,7 @@
column={column.id}
icon={column.icon ?? undefined}>
{#if column.isAction}
<Button.Button
icon
variant="extra-compact"
on:click={() => {
console.log('dank');
}}>
<Button.Button icon variant="extra-compact">
<Icon icon={IconPlus} color="--fgcolor-neutral-primary" />
</Button.Button>
{:else if column.id === 'actions' || column.id === 'empty'}
@@ -217,6 +212,7 @@
</SpreadsheetContainer>
{#if !$spreadsheetLoading}
<!-- Claude: Can this be truly centered without hacky left: xyz values? -->
<div
class="spreadsheet-fade-bottom"
data-collapsed-tabs={!$expandTabs}
@@ -228,26 +224,36 @@
{#if showActions}
<Layout.Stack
inline
gap="s"
alignItems="center"
direction={$isSmallViewport ? 'column' : 'row'}
gap="s">
<Button.Button
icon
size="s"
variant="secondary"
disabled={actions?.primary?.disabled}
onclick={actions?.primary?.onClick}>
<Icon icon={IconPlus} size="s" />
{actions?.primary?.text ?? `Create ${mode}`}
</Button.Button>
direction={$isSmallViewport ? 'column' : 'row'}>
{#if mode !== 'rows-filtered'}
<Button.Button
icon
size="s"
variant="secondary"
disabled={actions?.primary?.disabled}
onclick={actions?.primary?.onClick}>
<Icon icon={IconPlus} size="s" />
{actions?.primary?.text ?? `Create ${mode}`}
</Button.Button>
{#if mode === 'rows'}
{#if mode === 'rows'}
<Button.Button
size="s"
variant="secondary"
disabled={actions?.random?.disabled}
onclick={actions?.random?.onClick}>
{actions?.random?.text ?? `Generate sample data`}
</Button.Button>
{/if}
{:else}
<Button.Button
size="s"
variant="secondary"
disabled={actions?.random?.disabled}
onclick={actions?.random?.onClick}>
{actions?.random?.text ?? `Generate sample data`}
disabled={actions?.primary?.disabled}
onclick={actions?.primary?.onClick}>
{actions?.primary?.text}
</Button.Button>
{/if}
</Layout.Stack>
@@ -334,10 +340,12 @@
.empty-actions {
bottom: 30%;
position: fixed;
transform: translateX(-40%);
@media (min-width: 1024px) {
left: 50%;
bottom: 40%;
transform: unset !important;
}
}
</style>
@@ -1,7 +1,7 @@
<script lang="ts">
import { debounce } from '$lib/helpers/debounce';
import { scrollStore, sheetHeightStore } from '../store';
import { onMount, onDestroy, type Snippet } from 'svelte';
import { onMount, onDestroy, type Snippet, tick } from 'svelte';
let {
children
@@ -36,7 +36,7 @@
function initSpreadsheetGridContainer(): boolean {
if (spreadsheetGridContainer) return true;
spreadsheetGridContainer = spreadsheetWrapper.querySelector('.spreadsheet-container');
spreadsheetGridContainer = spreadsheetWrapper?.querySelector('.spreadsheet-container');
return !!spreadsheetGridContainer;
}
@@ -100,7 +100,8 @@
}
}
onMount(() => {
onMount(async () => {
await tick();
addObservers();
resizeSheet();
});
@@ -3,7 +3,7 @@
import { page } from '$app/state';
import { sdk } from '$lib/stores/sdk';
import { Activity } from '$lib/layout';
import { rowActivitySheet } from './store';
import { rowActivitySheet } from '../store';
import { pageToOffset } from '$lib/helpers/load';
import { type Models, Query } from '@appwrite.io/console';
import { Skeleton } from '@appwrite.io/pink-svelte';
@@ -21,7 +21,7 @@
}: {
showSheet: boolean;
table: Models.Table;
existingData: Models.Document | null;
existingData: Models.Row | null;
} = $props();
let isSubmitting = $state(false);
@@ -39,11 +39,13 @@
const initial = {
id: null,
row: availableColumns.reduce((acc, attr) => {
acc[attr.key] = attr.array ? [] : null;
row: existingData
? existingData
: availableColumns.reduce((acc, attr) => {
acc[attr.key] = attr.array ? [] : null;
return acc;
}, {}),
return acc;
}, {}),
permissions: [],
columns: availableColumns
};
@@ -19,7 +19,7 @@
databaseColumnSheetOptions,
databaseRowSheetOptions,
sortState,
showCreateAttributeSheet,
showCreateColumnSheet,
reorderItems,
columnsOrder,
columnsWidth,
@@ -82,7 +82,7 @@
import { abbreviateNumber } from '$lib/helpers/numbers';
export let data: PageData;
export let showRecordsCreateSheet: {
export let showRowCreateSheet: {
show: boolean;
row: Models.Row | null;
};
@@ -133,7 +133,7 @@
}
});
onDestroy(() => ($showCreateAttributeSheet.show = false));
onDestroy(() => ($showCreateColumnSheet.show = false));
function makeTableColumns() {
const selectedColumnsToHide = preferences.getCustomTableColumns(tableId);
@@ -439,11 +439,11 @@
if (action === 'column-left' || action === 'column-right') {
const { to, neighbour } = $databaseColumnSheetOptions.direction;
$showCreateAttributeSheet.title = `Create column to the ${to} of ${neighbour}`;
$showCreateAttributeSheet.direction = $databaseColumnSheetOptions.direction;
$showCreateAttributeSheet.columns = $tableColumns;
$showCreateAttributeSheet.columnsOrder = $columnsOrder;
$showCreateAttributeSheet.show = true;
$showCreateColumnSheet.title = `Create column to the ${to} of ${neighbour}`;
$showCreateColumnSheet.direction = $databaseColumnSheetOptions.direction;
$showCreateColumnSheet.columns = $tableColumns;
$showCreateColumnSheet.columnsOrder = $columnsOrder;
$showCreateColumnSheet.show = true;
}
if (action === 'delete') {
@@ -464,11 +464,11 @@
}
if (action === 'duplicate-header') {
$showCreateAttributeSheet.title = `Duplicate column`;
$showCreateAttributeSheet.column = $columns.find((attr) => attr.key === columnId);
$showCreateAttributeSheet.columns = $tableColumns;
$showCreateAttributeSheet.columnsOrder = $columnsOrder;
$showCreateAttributeSheet.show = true;
$showCreateColumnSheet.title = `Duplicate column`;
$showCreateColumnSheet.column = $columns.find((attr) => attr.key === columnId);
$showCreateColumnSheet.columns = $tableColumns;
$showCreateColumnSheet.columnsOrder = $columnsOrder;
$showCreateColumnSheet.show = true;
}
} else if (type === 'row') {
if (action === 'update') {
@@ -478,8 +478,8 @@
}
if (action === 'duplicate-row') {
showRecordsCreateSheet.row = row;
showRecordsCreateSheet.show = true;
showRowCreateSheet.row = row;
showRowCreateSheet.show = true;
}
if (action === 'permissions') {
@@ -675,7 +675,7 @@
loading={$spreadsheetLoading}
emptyCells={emptyCellsCount}
rowCount={$paginatedRows.virtualLength}
bottomActionClick={() => (showRecordsCreateSheet.show = true)}
bottomActionClick={() => (showRowCreateSheet.show = true)}
on:columnsSwap={(order) => saveColumnsOrder(order.detail)}
on:columnsResize={(resize) => saveColumnsWidth(resize.detail)}
bind:currentPage
@@ -700,11 +700,11 @@
icon
variant="extra-compact"
on:click={() => {
$showCreateAttributeSheet.show = true;
$showCreateAttributeSheet.column = null;
$showCreateAttributeSheet.title = 'Create column';
$showCreateAttributeSheet.columns = $tableColumns;
$showCreateAttributeSheet.columnsOrder = $columnsOrder;
$showCreateColumnSheet.show = true;
$showCreateColumnSheet.column = null;
$showCreateColumnSheet.title = 'Create column';
$showCreateColumnSheet.columns = $tableColumns;
$showCreateColumnSheet.columnsOrder = $columnsOrder;
}}>
<Icon icon={IconPlus} color="--fgcolor-neutral-primary" />
</Button.Button>
@@ -822,7 +822,10 @@
{displayValue}
</Link.Button>
{:else}
<Badge variant="secondary" content="-" size="xs" />
<Badge
variant="secondary"
content="NULL"
size="xs" />
{/if}
{:else}
<Badge variant="secondary" content="NULL" size="xs" />
@@ -76,7 +76,7 @@ export const databaseRelatedRowSheetOptions = writable<
tableId: null
});
export const showRecordsCreateSheet = writable({
export const showRowCreateSheet = writable({
show: false,
row: null
});
@@ -96,7 +96,7 @@ export type ColumnDirection = {
to: 'left' | 'right';
};
export type CreateAttribute = {
export type CreateColumn = {
show: boolean;
column?: Columns;
title: string;
@@ -106,7 +106,7 @@ export type CreateAttribute = {
columnsOrder?: string[];
};
export const showCreateAttributeSheet = writable<CreateAttribute>({
export const showCreateColumnSheet = writable<CreateColumn>({
show: false,
column: null,
title: 'Create column',
@@ -150,10 +150,11 @@ export const randomDataModalState = writable({
export const spreadsheetLoading = writable(false);
// noinspection JSUnusedGlobalSymbols
export enum Deletion {
'setNull' = 'Set row ID as NULL in all related rows',
'cascade' = 'All related rows will be deleted',
'restrict' = 'Row can not be deleted'
setNull = 'Set row ID as NULL in all related rows',
cascade = 'All related rows will be deleted',
restrict = 'Row can not be deleted'
}
export const scrollStore = writable(null);