From 72d7e33ecfee8e89b114610133071dec4b1c07b2 Mon Sep 17 00:00:00 2001 From: Darshan Date: Tue, 29 Jul 2025 18:48:41 +0530 Subject: [PATCH] fix: index and duplicates not working on the headers. --- package.json | 2 +- pnpm-lock.yaml | 10 ++++---- .../collection-[collection]/+layout.svelte | 17 ++++++++++++++ .../attributes/+page.svelte | 23 ++++--------------- .../createAttribute.svelte | 11 +++++---- .../indexes/createIndex.svelte | 8 +++---- .../spreadsheet.svelte | 20 +++++++++++++++- .../collection-[collection]/store.ts | 10 +++++++- vite.config.ts | 3 ++- 9 files changed, 68 insertions(+), 36 deletions(-) diff --git a/package.json b/package.json index 676ac5a03..7fca0c3e5 100644 --- a/package.json +++ b/package.json @@ -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@cc69c76", + "@appwrite.io/pink-svelte": "https://pkg.vc/-/@appwrite/@appwrite.io/pink-svelte@3d31cea", "@faker-js/faker": "^9.9.0", "@popperjs/core": "^2.11.8", "@sentry/sveltekit": "^8.38.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 1594c2808..397df19ce 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -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@cc69c76 - version: https://pkg.vc/-/@appwrite/@appwrite.io/pink-svelte@cc69c76(svelte@5.25.3) + specifier: https://pkg.vc/-/@appwrite/@appwrite.io/pink-svelte@3d31cea + version: https://pkg.vc/-/@appwrite/@appwrite.io/pink-svelte@3d31cea(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@cc69c76': - resolution: {tarball: https://pkg.vc/-/@appwrite/@appwrite.io/pink-svelte@cc69c76} + '@appwrite.io/pink-svelte@https://pkg.vc/-/@appwrite/@appwrite.io/pink-svelte@3d31cea': + resolution: {tarball: https://pkg.vc/-/@appwrite/@appwrite.io/pink-svelte@3d31cea} version: 2.0.0-RC.2 peerDependencies: svelte: ^4.0.0 @@ -3686,7 +3686,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@cc69c76(svelte@5.25.3)': + '@appwrite.io/pink-svelte@https://pkg.vc/-/@appwrite/@appwrite.io/pink-svelte@3d31cea(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 diff --git a/src/routes/(console)/project-[region]-[project]/databases/database-[database]/collection-[collection]/+layout.svelte b/src/routes/(console)/project-[region]-[project]/databases/database-[database]/collection-[collection]/+layout.svelte index 02f41b2d8..c84e13722 100644 --- a/src/routes/(console)/project-[region]-[project]/databases/database-[database]/collection-[collection]/+layout.svelte +++ b/src/routes/(console)/project-[region]-[project]/databases/database-[database]/collection-[collection]/+layout.svelte @@ -30,6 +30,7 @@ randomDataModalState, reorderItems, showCreateAttributeSheet, + showCreateIndexSheet, spreadsheetLoading } from './store'; import { addSubPanel, registerCommands, updateCommandGroupRanks } from '$lib/commandCenter'; @@ -50,7 +51,9 @@ import { generateFakeDocuments, generateAttributes } from '$lib/helpers/faker'; import { addNotification } from '$lib/stores/notifications'; import { sleep } from '$lib/helpers/promises'; + import CreateIndex from './indexes/createIndex.svelte'; + let createIndex: CreateIndex; let editDocument: EditDocument; let createAttribute: CreateAttribute; let selectedOption: Option['name'] = 'String'; @@ -288,6 +291,7 @@ + await createIndex.create() + }}> + + + diff --git a/src/routes/(console)/project-[region]-[project]/databases/database-[database]/collection-[collection]/attributes/+page.svelte b/src/routes/(console)/project-[region]-[project]/databases/database-[database]/collection-[collection]/attributes/+page.svelte index dfcab5bbb..683ecaa19 100644 --- a/src/routes/(console)/project-[region]-[project]/databases/database-[database]/collection-[collection]/attributes/+page.svelte +++ b/src/routes/(console)/project-[region]-[project]/databases/database-[database]/collection-[collection]/attributes/+page.svelte @@ -17,13 +17,13 @@ } from '@appwrite.io/pink-svelte'; import { isRelationship, isString } from '../document-[document]/attributes/store'; import FailedModal from '../failedModal.svelte'; - import CreateIndex from '../indexes/createIndex.svelte'; import { attributes, type Attributes, indexes, isCsvImportInProgress, - reorderItems + reorderItems, + showCreateIndexSheet } from '../store'; import Delete from './deleteAttribute.svelte'; import EditAttribute from './edit.svelte'; @@ -101,14 +101,12 @@ let showFailed = $state(false); let showDelete = $state(false); let selectedAttributes = $state([]); - let showCreateIndex = $state(false); let selectedAttribute: Attributes = $state(null); let columnsOrder = $state([]); const collectionId = page.params.collection; let showEdit = $state(false); - let createIndex: CreateIndex; let editAttribute: EditAttribute; const attributeFormatIcon = { @@ -300,9 +298,9 @@ leadingIcon={IconPlus} on:click={(event) => { toggle(event); - selectedAttribute = attribute; - showCreateIndex = true; showDropdown[index] = false; + $showCreateIndexSheet.show = true; + $showCreateIndexSheet.column = attribute.key; }}> Create index @@ -381,19 +379,6 @@ - await createIndex.create() - }}> - - - {#if showFailed} {/if} diff --git a/src/routes/(console)/project-[region]-[project]/databases/database-[database]/collection-[collection]/createAttribute.svelte b/src/routes/(console)/project-[region]-[project]/databases/database-[database]/collection-[collection]/createAttribute.svelte index 654ef91c2..e8108de43 100644 --- a/src/routes/(console)/project-[region]-[project]/databases/database-[database]/collection-[collection]/createAttribute.svelte +++ b/src/routes/(console)/project-[region]-[project]/databases/database-[database]/collection-[collection]/createAttribute.svelte @@ -14,6 +14,7 @@ let { direction = null, showCreate = false, + column = null, columns = $bindable(null), columnId = $bindable(null), columnsOrder = $bindable(null), @@ -21,6 +22,7 @@ onColumnsReorder = null }: { showCreate: boolean; + column?: Attributes; columnId?: string; columns?: Column[]; columnsOrder?: string[]; @@ -32,11 +34,12 @@ const databaseId = page.params.database; const collectionId = page.params.collection; - let key: string = $state(null); + let key: string = $state(column?.key ?? null); let data: Partial = $state({ - required: false, - array: false, - default: null + required: column?.required ?? false, + array: column?.array ?? false, + default: column?.default ?? null, + ...column }); let AttributeComponent = $derived( diff --git a/src/routes/(console)/project-[region]-[project]/databases/database-[database]/collection-[collection]/indexes/createIndex.svelte b/src/routes/(console)/project-[region]-[project]/databases/database-[database]/collection-[collection]/indexes/createIndex.svelte index cf958c777..8fc3a3675 100644 --- a/src/routes/(console)/project-[region]-[project]/databases/database-[database]/collection-[collection]/indexes/createIndex.svelte +++ b/src/routes/(console)/project-[region]-[project]/databases/database-[database]/collection-[collection]/indexes/createIndex.svelte @@ -10,13 +10,13 @@ import { sdk } from '$lib/stores/sdk'; import { IndexType } from '@appwrite.io/console'; import { isRelationship } from '../document-[document]/attributes/store'; - import { type Attributes, collection, indexes } from '../store'; + import { collection, indexes } from '../store'; import { Icon, Layout } from '@appwrite.io/pink-svelte'; import { IconPlus, IconX } from '@appwrite.io/pink-icons-svelte'; import { flags } from '$lib/flags'; export let showCreateIndex = false; - export let externalAttribute: Attributes = null; + export let externalAttributeKey: string = null; const databaseId = page.params.database; @@ -52,8 +52,8 @@ } function initialize() { - attributeList = externalAttribute - ? [{ value: externalAttribute.key, order: 'ASC', length: null }] + attributeList = externalAttributeKey + ? [{ value: externalAttributeKey, order: 'ASC', length: null }] : [{ value: '', order: 'ASC', length: null }]; selectedType = IndexType.Key; key = `index_${$indexes.length + 1}`; diff --git a/src/routes/(console)/project-[region]-[project]/databases/database-[database]/collection-[collection]/spreadsheet.svelte b/src/routes/(console)/project-[region]-[project]/databases/database-[database]/collection-[collection]/spreadsheet.svelte index f3fe4bce2..8d7fd5f4e 100644 --- a/src/routes/(console)/project-[region]-[project]/databases/database-[database]/collection-[collection]/spreadsheet.svelte +++ b/src/routes/(console)/project-[region]-[project]/databases/database-[database]/collection-[collection]/spreadsheet.svelte @@ -29,7 +29,8 @@ columnsOrder, columnsWidth, randomDataModalState, - spreadsheetLoading + spreadsheetLoading, + showCreateIndexSheet } from './store'; import RelationshipsModal from './relationshipsModal.svelte'; import type { Column, ColumnType } from '$lib/helpers/types'; @@ -383,6 +384,21 @@ sortState.set({ column: columnId, direction: 'desc' }); await sort([Query.orderDesc(columnId)]); } + + if (action === 'create-index') { + $showCreateIndexSheet.show = true; + $showCreateIndexSheet.column = columnId; + } + + if (action === 'duplicate-header') { + $showCreateAttributeSheet.title = `Duplicate column`; + $showCreateAttributeSheet.column = $attributes.find( + (attr) => attr.key === columnId + ); + $showCreateAttributeSheet.columns = $columns; + $showCreateAttributeSheet.columnsOrder = $columnsOrder; + $showCreateAttributeSheet.show = true; + } } else if (type === 'row') { if (action === 'update') { $databaseRowSheetOptions.show = true; @@ -464,7 +480,9 @@ variant="extra-compact" on:click={() => { $showCreateAttributeSheet.show = true; + $showCreateAttributeSheet.column = null; $showCreateAttributeSheet.columns = $columns; + $showCreateAttributeSheet.title = 'Insert column'; $showCreateAttributeSheet.columnsOrder = $columnsOrder; }}> diff --git a/src/routes/(console)/project-[region]-[project]/databases/database-[database]/collection-[collection]/store.ts b/src/routes/(console)/project-[region]-[project]/databases/database-[database]/collection-[collection]/store.ts index 9c324e8aa..672adab6e 100644 --- a/src/routes/(console)/project-[region]-[project]/databases/database-[database]/collection-[collection]/store.ts +++ b/src/routes/(console)/project-[region]-[project]/databases/database-[database]/collection-[collection]/store.ts @@ -81,7 +81,7 @@ export type ColumnDirection = { export type CreateAttribute = { show: boolean; - column?: string; + column?: Attributes; title: string; direction?: ColumnDirection; onDone?: () => void; @@ -99,6 +99,14 @@ export const showCreateAttributeSheet = writable({ columnsOrder: null }); +export const showCreateIndexSheet = writable<{ + show: boolean; + column?: string; +}>({ + show: false, + column: null +}); + export function reorderItems( items: T[], order: string[] = [] diff --git a/vite.config.ts b/vite.config.ts index d0a9f9bf0..8860ffecf 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -35,7 +35,8 @@ export default defineConfig({ ] }, server: { - port: 3000 + port: 3000, + allowedHosts: ['exchange-irc-incorporate-drilling.trycloudflare.com'] }, test: { workspace: [