Skip to content

use new table virtualization #2033

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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.pr.new/appwrite/pink/@appwrite.io/pink-svelte@ee1b778",
"@appwrite.io/pink-svelte": "https://pkg.vc/-/@appwrite/@appwrite.io/pink-svelte@3228c15",
"@popperjs/core": "^2.11.8",
"@sentry/sveltekit": "^8.38.0",
"@stripe/stripe-js": "^3.5.0",
Expand Down
35 changes: 25 additions & 10 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src/lib/components/columnSelector.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
} = $props();

let maxHeight = $state('none');
let containerRef;
let containerRef: HTMLDivElement = $state();

const calcMaxHeight = () => {
if (containerRef) {
Expand Down Expand Up @@ -67,7 +67,7 @@
calcMaxHeight();
});

let selectedColumnsNumber = $derived(
const selectedColumnsNumber = $derived(
$columns.reduce((acc, column) => {
if (column.hide === true) return acc;

Expand Down
3 changes: 2 additions & 1 deletion src/lib/helpers/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ export type TableRootProp = {
selectedAll: boolean;
selectedNone: boolean;
selectedSome: boolean;
columns: Record<PinkColumn['id'], PinkColumn>;
columns: Array<PinkColumn> | number;
columnsMap: Record<PinkColumn['id'], PinkColumn>;
toggle: (id: string) => void;
toggleAll: () => void;
addAvailableId: (id: string) => void;
Expand Down
2 changes: 1 addition & 1 deletion src/lib/stores/preferences.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ function createPreferences() {
);
},
getCustomCollectionColumns: (collectionId: string): Preferences['columns'] => {
return preferences?.collections?.[collectionId] ?? [];
return preferences?.collections?.[collectionId] ?? null;
},
setLimit: (limit: Preferences['limit']) =>
updateAndSync((n) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import CreateAttribute from './createAttribute.svelte';
import { collection, columns, isCsvImportInProgress } from './store';
import Table from './table.svelte';
import { writable } from 'svelte/store';
import FilePicker from '$lib/components/filePicker.svelte';
import { page } from '$app/state';
import { sdk } from '$lib/stores/sdk';
Expand All @@ -32,28 +31,22 @@
let showCreateAttribute = false;
let selectedAttribute: Option['name'] = null;

const filterColumns = writable<Column[]>([]);

$: selected = preferences.getCustomCollectionColumns(page.params.collection);
$: columns.set(
$collection.attributes.map((attribute) => ({

$: columns.set([
{ id: '$id', width: 200, title: 'Document ID', type: 'string' },
...$collection.attributes.map<Column>((attribute) => ({
id: attribute.key,
title: attribute.key,
type: attribute.type as ColumnType,
show: selected?.includes(attribute.key) ?? true,
hide: !(selected?.includes(attribute.key) ?? true),
array: attribute?.array,
width: { min: 168 },
format: 'format' in attribute && attribute?.format === 'enum' ? attribute.format : null,
elements: 'elements' in attribute ? attribute.elements : null
}))
);
$: filterColumns.set([
...$columns,
...['$id', '$createdAt', '$updatedAt'].map((id) => ({
id,
title: id,
show: true,
type: (id === '$id' ? 'string' : 'datetime') as ColumnType
}))
})),
{ id: '$created', width: 200, title: 'Created', type: 'datetime' },
{ id: '$updated', width: 200, title: 'Updated', type: 'datetime' }
]);

$: hasAttributes = !!$collection.attributes.length;
Expand Down Expand Up @@ -99,7 +92,7 @@
disabled={!(hasAttributes && hasValidAttributes)}
analyticsSource="database_documents" />
<Layout.Stack direction="row" alignItems="center" justifyContent="flex-end">
<ViewSelector view={data.view} {columns} hideView />
<ViewSelector view={data.view} {columns} hideView isCustomCollection />
{#if flags.showCsvImport(data)}
<Button
secondary
Expand Down Expand Up @@ -133,7 +126,7 @@

{#if hasAttributes && hasValidAttributes}
{#if data.documents.total}
<Table {data} />
<Table {data} {columns} />

<PaginationWithLimit
name="Documents"
Expand Down
Loading