diff --git a/package-lock.json b/package-lock.json index 4b75ed1bd..37d66f466 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8,7 +8,7 @@ "dependencies": { "@analytics/google-analytics": "^1.0.5", "@appwrite.io/console": "0.1.0-preview-0.1", - "@appwrite.io/pink": "^0.0.6-rc.6", + "@appwrite.io/pink": "^0.0.6-rc.7", "@popperjs/core": "^2.11.6", "@sentry/svelte": "^7.44.2", "@sentry/tracing": "^7.44.2", @@ -155,9 +155,9 @@ } }, "node_modules/@appwrite.io/pink": { - "version": "0.0.6-rc.6", - "resolved": "https://registry.npmjs.org/@appwrite.io/pink/-/pink-0.0.6-rc.6.tgz", - "integrity": "sha512-mSOUI2UxRqO3MS4ZXz9bdyAt0VFGRhOwWYGXw+oFfYPjmu6GSKnLEQwjF37DeuArEGRNriTiOFrKqXO0HW0odA==", + "version": "0.0.6-rc.7", + "resolved": "https://registry.npmjs.org/@appwrite.io/pink/-/pink-0.0.6-rc.7.tgz", + "integrity": "sha512-3I+DG4HiysIRJF9ksr+aWMmazUtZ6KrivISu3k+pIX7MjyDhN5la6LVNKgU3d8WWstbHCHoEq5+FYyjsYWWIpA==", "dependencies": { "@appwrite.io/pink-icons": "*", "normalize.css": "^8.0.1", diff --git a/package.json b/package.json index a021b5e8f..4790cb235 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ "dependencies": { "@analytics/google-analytics": "^1.0.5", "@appwrite.io/console": "0.1.0-preview-0.1", - "@appwrite.io/pink": "^0.0.6-rc.6", + "@appwrite.io/pink": "^0.0.6-rc.7", "@popperjs/core": "^2.11.6", "@sentry/svelte": "^7.44.2", "@sentry/tracing": "^7.44.2", diff --git a/src/lib/components/clickableList.svelte b/src/lib/components/clickableList.svelte new file mode 100644 index 000000000..733607b9b --- /dev/null +++ b/src/lib/components/clickableList.svelte @@ -0,0 +1,3 @@ + diff --git a/src/lib/components/clickableListItem.svelte b/src/lib/components/clickableListItem.svelte new file mode 100644 index 000000000..00308d47a --- /dev/null +++ b/src/lib/components/clickableListItem.svelte @@ -0,0 +1,14 @@ + + +
  • + +
    + +
    +
    +

    +
    +
    +
  • diff --git a/src/lib/components/empty.svelte b/src/lib/components/empty.svelte index 8591b4299..ab7d091a4 100644 --- a/src/lib/components/empty.svelte +++ b/src/lib/components/empty.svelte @@ -41,7 +41,7 @@
    Create your first {target} to get started. -

    +

    Need a hand? Check out our documentation.

    diff --git a/src/lib/components/feedbackGeneral.svelte b/src/lib/components/feedbackGeneral.svelte index b50258c44..de4f3b2c8 100644 --- a/src/lib/components/feedbackGeneral.svelte +++ b/src/lib/components/feedbackGeneral.svelte @@ -36,7 +36,7 @@
    -

    How can we improve?

    +

    How can we improve?

    - - {#each $columns as column} - - {/each} - - +
    + {#if !hideColumns && view === View.Table} + {#if $columns?.length} + + + + {#each $columns as column} + + {/each} + + + {/if} {/if} -{/if} +
    {#if !hideView} -
    +
      {#key $page.url}
    • @@ -111,7 +116,7 @@ type="button" class:is-selected={view === View.Table} use:tooltip={{ - content: 'Column View' + content: 'List View' }}>
    • @@ -95,33 +115,44 @@
      - (hasFocus = true)} - on:click={() => (hasFocus = true)} - on:input={handleInput} - on:keydown={handleKeydown} /> + {#if $$slots.output && selectedOption} +
      { + if (interactiveOutput) hasFocus = !hasFocus; + }}> + +
      + {:else} + (hasFocus = true)} + on:click={() => (hasFocus = true)} + on:input={handleInput} + on:keydown={handleKeydown} /> + {/if}
      - + {#if showClearBtn} + + {/if} @@ -136,11 +167,11 @@ class:is-selected={selected === i} type="button" on:click|preventDefault={() => { - value = option.value; - search = option.label; - hasFocus = false; + selectOption(option); }}> - {option.label} + + {option.label} +
    • {:else} diff --git a/src/lib/elements/forms/inputTextarea.svelte b/src/lib/elements/forms/inputTextarea.svelte index 533156d25..28d39f3c5 100644 --- a/src/lib/elements/forms/inputTextarea.svelte +++ b/src/lib/elements/forms/inputTextarea.svelte @@ -65,6 +65,8 @@ {required} {maxlength} class="input-text" + class:u-padding-block-end-32={maxlength} + style={maxlength ? '--amount-of-buttons: 0.25' : ''} bind:value bind:this={element} on:invalid={handleInvalid} diff --git a/src/lib/elements/index.ts b/src/lib/elements/index.ts index 2ebcd3892..ffd1477bb 100644 --- a/src/lib/elements/index.ts +++ b/src/lib/elements/index.ts @@ -1 +1,2 @@ export { default as Pill } from './pill.svelte'; +export { default as SelectSearchItem } from './selectSearchItem.svelte'; diff --git a/src/lib/elements/selectSearchItem.svelte b/src/lib/elements/selectSearchItem.svelte new file mode 100644 index 000000000..1317a4f15 --- /dev/null +++ b/src/lib/elements/selectSearchItem.svelte @@ -0,0 +1,27 @@ + + +
      + + + + {#if data?.length} + e ?? 'null').join(' | ') + }}> + {#each data as item, i} + {#if i} + | + {/if} + {item} + {/each} + + {/if} +
      diff --git a/src/lib/elements/table/cellHead.svelte b/src/lib/elements/table/cellHead.svelte index ea69e6289..6a7f9c865 100644 --- a/src/lib/elements/table/cellHead.svelte +++ b/src/lib/elements/table/cellHead.svelte @@ -9,7 +9,7 @@ class:is-only-desktop={onlyDesktop} class="table-thead-col" role="columnheader"> - +
    diff --git a/src/lib/helpers/array.ts b/src/lib/helpers/array.ts index 4527291b4..096d65d6f 100644 --- a/src/lib/helpers/array.ts +++ b/src/lib/helpers/array.ts @@ -5,6 +5,9 @@ export function intersection(arr1: unknown[], arr2: unknown[]) { } export function difference(arr1: unknown[], arr2: unknown[]) { + if (!Array.isArray(arr1) || !Array.isArray(arr2)) { + return Array.isArray(arr1) ? arr1 : Array.isArray(arr2) ? arr2 : []; + } const set = new Set(arr2); const difference = new Set(arr1.filter((elem) => !set.has(elem))); return Array.from(difference); diff --git a/src/lib/layout/gridHeader.svelte b/src/lib/layout/gridHeader.svelte new file mode 100644 index 000000000..81b9b42d1 --- /dev/null +++ b/src/lib/layout/gridHeader.svelte @@ -0,0 +1,30 @@ + + +
    + {title} +
    + +
    + +
    +
    +
    diff --git a/src/lib/layout/index.ts b/src/lib/layout/index.ts index 71d340ea2..2172f7e0a 100644 --- a/src/lib/layout/index.ts +++ b/src/lib/layout/index.ts @@ -15,3 +15,4 @@ export { default as Unauthenticated } from './unauthenticated.svelte'; export { default as Usage, type UsagePeriods } from './usage.svelte'; export { default as Activity } from './activity.svelte'; export { default as Progress } from './progress.svelte'; +export { default as GridHeader } from './gridHeader.svelte'; diff --git a/src/lib/layout/logs.svelte b/src/lib/layout/logs.svelte index f5da38f24..fcaabd80f 100644 --- a/src/lib/layout/logs.svelte +++ b/src/lib/layout/logs.svelte @@ -49,7 +49,7 @@ {#if $log.data}
    -

    Function ID: {$log.func.$id}

    +

    Function ID: {$log.func.$id}

    -

    Deployment ID:

    +

    Deployment ID:

    {$log.data.$id} @@ -145,7 +145,7 @@
    -

    Execution ID:

    +

    Execution ID:

    {$log.data.$id} diff --git a/src/lib/layout/wizard.svelte b/src/lib/layout/wizard.svelte index c655ffc2f..72321a84b 100644 --- a/src/lib/layout/wizard.svelte +++ b/src/lib/layout/wizard.svelte @@ -95,7 +95,7 @@
    -
    {title}
    +
    {title}
    -
    -
    + + + {#if data.databases.total} {#if data.view === 'grid'} diff --git a/src/routes/console/project-[project]/databases/database-[database]/+page.svelte b/src/routes/console/project-[project]/databases/database-[database]/+page.svelte index c9460e502..6fd64600e 100644 --- a/src/routes/console/project-[project]/databases/database-[database]/+page.svelte +++ b/src/routes/console/project-[project]/databases/database-[database]/+page.svelte @@ -1,7 +1,7 @@ -
    - Collections -
    - - - -
    -
    + + + {#if data.collections.total} {#if data.view === 'grid'} diff --git a/src/routes/console/project-[project]/databases/database-[database]/collection-[collection]/+page.svelte b/src/routes/console/project-[project]/databases/database-[database]/collection-[collection]/+page.svelte index a3fdab06a..232e0be6d 100644 --- a/src/routes/console/project-[project]/databases/database-[database]/collection-[collection]/+page.svelte +++ b/src/routes/console/project-[project]/databases/database-[database]/collection-[collection]/+page.svelte @@ -1,6 +1,6 @@ -
    - Documents -
    - - -
    -
    + + + {#if hasAttributes && hasValidAttributes} {#if data.documents.total} @@ -72,7 +74,7 @@ (showCreateDropdown = true)}>
    Create your first attribute to get started. -

    +

    Need a hand? Check out our documentation.

    diff --git a/src/routes/console/project-[project]/databases/database-[database]/collection-[collection]/attributes/+page.svelte b/src/routes/console/project-[project]/databases/database-[database]/collection-[collection]/attributes/+page.svelte index e5410eec5..68e7abaa3 100644 --- a/src/routes/console/project-[project]/databases/database-[database]/collection-[collection]/attributes/+page.svelte +++ b/src/routes/console/project-[project]/databases/database-[database]/collection-[collection]/attributes/+page.svelte @@ -1,4 +1,6 @@ @@ -54,7 +67,7 @@
    - {#if option.icon === 'relationship'} + {#if isRelationship(attribute)}
    - {attribute.key} + {attribute.key}
    {#if attribute.status !== 'available'} - {`${attribute.type}${attribute.array ? '[]' : ''}`} + {#if 'format' in attribute} + {attribute.format} + {:else} + {attribute.type} + {#if isRelationship(attribute)} + + with {attribute?.key} + + {/if} + {/if} + + {attribute.array ? '[]' : ''} + {attribute?.default !== null && attribute?.default !== undefined @@ -114,16 +144,17 @@ }}> Edit - - { - selectedAttribute = attribute; - showCreateIndex = true; - showDropdown[index] = false; - }}> - Create Index - + {#if !isRelationship(attribute)} + { + selectedAttribute = attribute; + showCreateIndex = true; + showDropdown[index] = false; + }}> + Create Index + + {/if} { @@ -146,7 +177,7 @@ (showEmptyCreateDropdown = true)}>
    Create your first attribute to get started. -

    +

    Need a hand? Check out our documentation.

    diff --git a/src/routes/console/project-[project]/databases/database-[database]/collection-[collection]/attributes/deleteAttribute.svelte b/src/routes/console/project-[project]/databases/database-[database]/collection-[collection]/attributes/deleteAttribute.svelte index c0f682b9c..c9981b515 100644 --- a/src/routes/console/project-[project]/databases/database-[database]/collection-[collection]/attributes/deleteAttribute.svelte +++ b/src/routes/console/project-[project]/databases/database-[database]/collection-[collection]/attributes/deleteAttribute.svelte @@ -10,12 +10,12 @@ import { sdk } from '$lib/stores/sdk'; import { Dependencies } from '$lib/constants'; import { Submit, trackEvent, trackError } from '$lib/actions/analytics'; + import { isRelationship } from '../document-[document]/attributes/store'; export let showDelete = false; export let selectedAttribute: Attributes; const databaseId = $page.params.database; - let checked = selectedAttribute?.type !== 'relationship'; - + let checked = false; async function handleDelete() { try { await sdk.forProject.databases.deleteAttribute( @@ -43,7 +43,7 @@ } $: isDeleteBtnDisabled = - selectedAttribute?.type === 'relationship' && selectedAttribute?.twoWay && !checked; + isRelationship(selectedAttribute) && selectedAttribute?.twoWay && !checked; Delete Attribute

    - Are you sure you want to delete '{selectedAttribute?.key}' from {$collection?.name}? + Are you sure you want to delete {selectedAttribute?.key} from + {$collection?.name}?

    - {#if selectedAttribute?.type === 'relationship' && selectedAttribute?.twoWay} + {#if isRelationship(selectedAttribute) && selectedAttribute?.twoWay}

    - Are you sure you want to delete reviews from Movie? This is a two way relationship - and the corresponding relationship will also be deleted. + This is a two way relationship and the corresponding relationship will also be + deleted.

    This action is irreversible.

    - Delete relationship between {selectedAttribute.key} to {selectedAttribute.twoWayKey} + Delete relationship between {selectedAttribute.key} to + {selectedAttribute.twoWayKey}
    {/if} diff --git a/src/routes/console/project-[project]/databases/database-[database]/collection-[collection]/attributes/edit.svelte b/src/routes/console/project-[project]/databases/database-[database]/collection-[collection]/attributes/edit.svelte index 0a6012589..846e3dd79 100644 --- a/src/routes/console/project-[project]/databases/database-[database]/collection-[collection]/attributes/edit.svelte +++ b/src/routes/console/project-[project]/databases/database-[database]/collection-[collection]/attributes/edit.svelte @@ -16,11 +16,18 @@ const databaseId = $page.params.database; const collectionId = $page.params.collection; - let updateButtonDisabled = true; let error: string; - let currentAttr: string; + let currentAttr: Attributes; - $: option = options.find((option) => option?.type === selectedAttribute?.type) as Option; + $: option = options.find((option) => { + if (selectedAttribute) { + if ('format' in selectedAttribute) { + return option?.format === selectedAttribute?.format; + } else { + return option?.type === selectedAttribute?.type; + } + } + }) as Option; async function submit() { try { @@ -33,7 +40,7 @@ } addNotification({ type: 'success', - message: `Attribute ${selectedAttribute.key} has been created` + message: `Attribute ${selectedAttribute.key} has been updated` }); showEdit = false; trackEvent(Submit.AttributeUpdate); @@ -43,12 +50,14 @@ } } - $: updateButtonDisabled = JSON.stringify(selectedAttribute) === currentAttr; - $: if (showEdit) { - currentAttr ??= JSON.stringify(selectedAttribute); + currentAttr ??= { ...selectedAttribute }; error = null; } + + function shouldBeDisabled(oldAttr: Attributes, newAttr: Attributes) { + return JSON.stringify(oldAttr) === JSON.stringify(newAttr); + } {#if selectedAttribute} @@ -56,7 +65,7 @@
    {option?.name} - {#if option.type === 'relationship'} + {#if option?.type === 'relationship'}
    Beta
    @@ -73,7 +82,7 @@ bind:value={selectedAttribute.key} autofocus required - disabled /> + readonly />
    {/if} - (option = null)} /> + {#if option} + (option = null)} /> + {/if} - + {/if} diff --git a/src/routes/console/project-[project]/databases/database-[database]/collection-[collection]/attributes/relationship.svelte b/src/routes/console/project-[project]/databases/database-[database]/collection-[collection]/attributes/relationship.svelte index dd2328972..dbc894378 100644 --- a/src/routes/console/project-[project]/databases/database-[database]/collection-[collection]/attributes/relationship.svelte +++ b/src/routes/console/project-[project]/databases/database-[database]/collection-[collection]/attributes/relationship.svelte @@ -44,27 +44,26 @@ import arrowOne from './arrow-one.svg'; import arrowTwo from './arrow-two.svg'; import { camelize } from '$lib/helpers/string'; + import { SelectSearchItem } from '$lib/elements'; + import { isRelationshipToMany } from '../document-[document]/attributes/store'; // Props - export let data: Partial; + export let data: Models.AttributeRelationship & { side: string }; export let editing = false; // Constants const databaseId = $page.params.database; - const oneWay = [ + const relationshipType = [ { value: 'oneToOne', label: 'One to one' }, - { value: 'oneToMany', label: 'One to many' } - ]; - const twoWay = [ - ...oneWay, + { value: 'oneToMany', label: 'One to many' }, { value: 'manyToOne', label: 'Many to one' }, { value: 'manyToMany', label: 'Many to many' } ]; const deleteOptions = [ - { value: 'setNull', label: 'Null' }, - { value: 'cascade', label: 'Cascade' }, - { value: 'restrict', label: 'Restrict' } + { value: 'setNull', label: 'Set NULL - set document ID as NULL in all related documents' }, + { value: 'cascade', label: 'Cascade - delete all related documents' }, + { value: 'restrict', label: 'Restrict - document can not be deleted' } ]; // Variables @@ -87,32 +86,36 @@ } } + function updateKeyName() { + if (!editing) { + const collection = collectionList.collections.find( + (n) => n.$id === data.relatedCollection + ); + data.key = camelize(collection.name); + } + } + onMount(async () => { collectionList = await getCollections(); - - if (editing) { - way = data.twoWay ? 'two' : 'one'; - search = data.relatedCollection; - } }); // Reactive statements $: getCollections(search).then((res) => (collectionList = res)); $: collections = collectionList?.collections?.filter((n) => n.$id !== $collection.$id) ?? []; + $: isToMany = isRelationshipToMany(data); - $: if (data?.relatedCollection && !data.key) { - const collection = collectionList.collections.find((n) => n.$id === data.relatedCollection); - data.key = camelize(collection.name); - } - $: if (way === 'two' && !data.twoWayKey) { - data.twoWayKey = camelize($collection.name); - } - - $: if (way === 'two') { - data.twoWay = true; + $: if (editing) { + way = data.twoWay ? 'two' : 'one'; } else { - data.twoWay = false; + if (way === 'two') { + data.twoWay = true; + if (!data.twoWayKey) { + data.twoWayKey = camelize($collection.name); + } + } else { + data.twoWay = false; + } } @@ -121,13 +124,23 @@ class="grid-box" style="--p-grid-item-size:16em; --p-grid-item-size-small-screens:16rem; --grid-gap: 0.5rem;">
  • - + One-way relationship One Relation attribute within this collection
  • - + Two-way relationship One Relation attribute within this collection and another within the related collection @@ -142,9 +155,23 @@ bind:search bind:value={data.relatedCollection} required + interactiveOutput={!editing} placeholder="Select a collection" disabled={editing} - options={collections?.map((n) => ({ value: n.$id, label: n.name })) ?? []} /> + options={collections?.map((n) => ({ value: n.$id, label: n.$id, data: [n.name] })) ?? []} + on:select={updateKeyName} + let:option={o}> + + {o.label} + + + + + {o.label} + + + + {#if data?.relatedCollection}
    @@ -154,9 +181,10 @@ placeholder="Enter Key" bind:value={data.key} autofocus + readonly={editing} required /> -
    +