Skip to content

Commit

Permalink
Merge pull request #1334 from appwrite/1.6.1
Browse files Browse the repository at this point in the history
1.6.1
  • Loading branch information
abnegate authored Sep 9, 2024
2 parents 9d56081 + 562b717 commit b96b92f
Show file tree
Hide file tree
Showing 17 changed files with 2,051 additions and 786 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -153,3 +153,4 @@ dist

# Sentry Config File
.sentryclirc
.idea
1,791 changes: 1,458 additions & 333 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"e2e:ui": "playwright test tests/e2e --ui"
},
"dependencies": {
"@appwrite.io/console": "1.0.1",
"@appwrite.io/console": "1.1.0",
"@appwrite.io/pink": "0.25.0",
"@appwrite.io/pink-icons": "0.25.0",
"@popperjs/core": "^2.11.8",
Expand Down
844 changes: 427 additions & 417 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,16 @@
export async function updateBoolean(
databaseId: string,
collectionId: string,
data: Partial<Models.AttributeBoolean>
data: Partial<Models.AttributeBoolean>,
originalKey?: string
) {
await sdk.forProject.databases.updateBooleanAttribute(
databaseId,
collectionId,
data.key,
data.required,
data.default
data.default,
data.key !== originalKey ? data.key : undefined
);
}
</script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,16 @@
export async function updateDatetime(
databaseId: string,
collectionId: string,
data: Partial<Models.AttributeDatetime>
data: Partial<Models.AttributeDatetime>,
originalKey?: string
) {
await sdk.forProject.databases.updateDatetimeAttribute(
databaseId,
collectionId,
data.key,
data.required,
data.default
data.default,
data.key !== originalKey ? data.key : undefined
);
}
</script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
const databaseId = $page.params.database;
const collectionId = $page.params.collection;
let originalKey = '';
let error: string;
let currentAttr: Attributes;
Expand All @@ -32,7 +33,7 @@
async function submit() {
try {
await option.update(databaseId, collectionId, selectedAttribute);
await option.update(databaseId, collectionId, selectedAttribute, originalKey);
await invalidate(Dependencies.COLLECTION);
if (!$page.url.pathname.includes('attributes')) {
await goto(
Expand All @@ -53,7 +54,10 @@
$: if (showEdit) {
currentAttr ??= { ...selectedAttribute };
originalKey = currentAttr.key;
error = null;
} else {
currentAttr = null;
}
</script>

Expand All @@ -76,8 +80,7 @@
label="Attribute Key"
placeholder="Enter Key"
bind:value={selectedAttribute.key}
autofocus
readonly />
autofocus />
{/if}
{#if option}
<svelte:component
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,16 @@
export async function updateEmail(
databaseId: string,
collectionId: string,
data: Partial<Models.AttributeEmail>
data: Partial<Models.AttributeEmail>,
originalKey?: string
) {
await sdk.forProject.databases.updateEmailAttribute(
databaseId,
collectionId,
data.key,
data.required,
data.default
data.default,
data.key !== originalKey ? data.key : undefined
);
}
</script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,17 @@
export async function updateEnum(
databaseId: string,
collectionId: string,
data: Partial<Models.AttributeEnum>
data: Partial<Models.AttributeEnum>,
originalKey?: string
) {
await sdk.forProject.databases.updateEnumAttribute(
databaseId,
collectionId,
data.key,
data.elements,
data.required,
data.default
data.default,
data.key !== originalKey ? data.key : undefined
);
}
</script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
export async function updateFloat(
databaseId: string,
collectionId: string,
data: Partial<Models.AttributeFloat>
data: Partial<Models.AttributeFloat>,
originalKey?: string
) {
await sdk.forProject.databases.updateFloatAttribute(
databaseId,
Expand All @@ -32,7 +33,8 @@
data.required,
data.min,
data.max,
data.default
data.default,
data.key !== originalKey ? data.key : undefined
);
}
</script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
export async function updateInteger(
databaseId: string,
collectionId: string,
data: Partial<Models.AttributeInteger>
data: Partial<Models.AttributeInteger>,
originalKey?: string
) {
await sdk.forProject.databases.updateIntegerAttribute(
databaseId,
Expand All @@ -32,7 +33,8 @@
data.required,
data.min,
data.max,
data.default
data.default,
data.key !== originalKey ? data.key : undefined
);
}
</script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,16 @@
export async function updateIp(
databaseId: string,
collectionId: string,
data: Partial<Models.AttributeIp>
data: Partial<Models.AttributeIp>,
originalKey?: string
) {
await sdk.forProject.databases.updateIpAttribute(
databaseId,
collectionId,
data.key,
data.required,
data.default
data.default,
data.key !== originalKey ? data.key : undefined
);
}
</script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,19 @@
export async function updateRelationship(
databaseId: string,
collectionId: string,
data: Partial<Models.AttributeRelationship>
data: Partial<Models.AttributeRelationship>,
originalKey?: string
) {
if (!isValueOfStringEnum(RelationMutate, data.onDelete)) {
throw new Error(`Invalid on delete: ${data.onDelete}`);
}
await sdk.forProject.databases.updateRelationshipAttribute(
databaseId,
collectionId,
data.key,
data.onDelete
originalKey,
data.onDelete,
data.key !== originalKey ? data.key : undefined
);
}
</script>
Expand Down Expand Up @@ -187,7 +190,6 @@
placeholder="Enter Key"
bind:value={data.key}
autofocus
readonly={editing}
required />

<div class="u-flex u-gap-4 u-margin-block-start-8 u-small u-cross-center">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,12 @@ export type Option = {
key: string,
data: Partial<Attributes>
) => Promise<void>;
update: (databaseId: string, collectionId: string, data: Partial<Attributes>) => Promise<void>;
update: (
databaseId: string,
collectionId: string,
data: Partial<Attributes>,
originalKey: string
) => Promise<void>;
format?: 'email' | 'ip' | 'url' | 'enum';
icon: string;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,17 @@
export async function updateString(
databaseId: string,
collectionId: string,
data: Partial<Models.AttributeString>
data: Partial<Models.AttributeString>,
originalKey?: string
) {
await sdk.forProject.databases.updateStringAttribute(
databaseId,
collectionId,
data.key,
originalKey,
data.required,
data.default
data.default,
data.size,
data.key !== originalKey ? data.key : undefined
);
}
</script>
Expand Down Expand Up @@ -69,13 +72,7 @@
$: handleDefaultState($required || $array);
</script>

<InputNumber
id="size"
label="Size"
placeholder="Enter size"
bind:value={data.size}
required={!editing}
readonly={editing} />
<InputNumber id="size" label="Size" placeholder="Enter size" bind:value={data.size} />
{#if data.size >= 50}
<InputTextarea
id="default"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,16 @@
export async function updateUrl(
databaseId: string,
collectionId: string,
data: Partial<Models.AttributeUrl>
data: Partial<Models.AttributeUrl>,
originalKey?: string
) {
await sdk.forProject.databases.updateUrlAttribute(
databaseId,
collectionId,
data.key,
data.required,
data.default
data.default,
data.key !== originalKey ? data.key : undefined
);
}
</script>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
<script context="module" lang="ts">
import { sdk } from '$lib/stores/sdk';
import type { Models } from '@appwrite.io/console';
export async function submitString(
databaseId: string,
collectionId: string,
key: string,
data: Partial<Models.AttributeString>
) {
await sdk.forProject.databases.createStringAttribute(
databaseId,
collectionId,
key,
data.size,
data.required,
data.default,
data.array
);
}
export async function updateString(
databaseId: string,
collectionId: string,
data: Partial<Models.AttributeString>,
originalKey?: string
) {
await sdk.forProject.databases.updateStringAttribute(
databaseId,
collectionId,
originalKey,
data.required,
data.default,
data.size,
data.key !== originalKey ? data.key : undefined
);
}
</script>

<script lang="ts">
import { InputChoice, InputNumber, InputText, InputTextarea } from '$lib/elements/forms';
import { createConservative } from '$lib/helpers/stores';
export let data: Partial<Models.AttributeString> = {
required: false,
size: 0,
default: null,
array: false
};
export let editing = false;
let savedDefault = data.default;
function handleDefaultState(hideDefault: boolean) {
if (hideDefault) {
savedDefault = data.default;
data.default = null;
} else {
data.default = savedDefault;
}
}
const {
stores: { required, array },
listen
} = createConservative<Partial<Models.AttributeString>>({
required: false,
array: false,
...data
});
$: listen(data);
$: handleDefaultState($required || $array);
</script>

<InputNumber
id="size"
label="Size"
placeholder="Enter size"
bind:value={data.size}
required={!editing}
readonly={editing} />
{#if data.size >= 50}
<InputTextarea
id="default"
label="Default"
placeholder="Enter string"
disabled={data.required || data.array}
nullable={!data.required && !data.array}
maxlength={data.size}
bind:value={data.default} />
{:else}
<InputText
id="default"
label="Default"
placeholder="Enter string"
disabled={data.required || data.array}
nullable={!data.required && !data.array}
maxlength={data.size}
bind:value={data.default} />
{/if}
<InputChoice id="required" label="Required" bind:value={data.required} disabled={data.array}>
Indicate whether this is a required attribute
</InputChoice>
<InputChoice id="array" label="Array" bind:value={data.array} disabled={data.required || editing}>
Indicate whether this attribute should act as an array, with the default value set as an empty
array.
</InputChoice>

0 comments on commit b96b92f

Please sign in to comment.