Skip to content

Commit fecbdaf

Browse files
committed
Merge feat-documentsdb into feat-vectordb
2 parents 902ea0a + 45956d4 commit fecbdaf

File tree

8 files changed

+80
-25
lines changed

8 files changed

+80
-25
lines changed

src/lib/commandCenter/panels/createColumn.svelte

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
<script lang="ts">
22
import { initCreateColumn } from '$routes/(console)/project-[region]-[project]/databases/database-[database]/table-[table]/+layout.svelte';
3-
import { columnOptions } from '$routes/(console)/project-[region]-[project]/databases/database-[database]/table-[table]/columns/store';
3+
import { getSupportedColumns } from '$routes/(console)/project-[region]-[project]/databases/database-[database]/table-[table]/columns/store';
4+
import { regionalConsoleVariables } from '$routes/(console)/project-[region]-[project]/store';
45
import Template from './template.svelte';
56
67
let search = '';
78
8-
let options = columnOptions.map((option) => {
9+
$: options = getSupportedColumns($regionalConsoleVariables).map((option) => {
910
return {
1011
label: option.name,
1112
icon: option.icon,

src/routes/(console)/project-[region]-[project]/databases/database-[database]/(entity)/views/indexes/create.svelte

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import { type Entity, getTerminologies } from '$database/(entity)';
2525
import { resolveRoute, withPath } from '$lib/stores/navigation';
2626
import { columnOptions as baseColumnOptions } from '$database/table-[table]/columns/store';
27+
import { regionalConsoleVariables } from '$routes/(console)/project-[region]-[project]/store';
2728
2829
let {
2930
entity,
@@ -66,12 +67,21 @@
6667
length: number | null;
6768
}> = $state([{ value: '', order: null, length: null }]);
6869
69-
const types = [
70-
{ value: DatabasesIndexType.Key, label: 'Key' },
71-
{ value: DatabasesIndexType.Unique, label: 'Unique' },
72-
{ value: DatabasesIndexType.Fulltext, label: 'Fulltext' },
73-
{ value: DatabasesIndexType.Spatial, label: 'Spatial' }
74-
];
70+
const types = $derived(
71+
[
72+
{ value: DatabasesIndexType.Key, label: 'Key' },
73+
{ value: DatabasesIndexType.Unique, label: 'Unique' },
74+
{ value: DatabasesIndexType.Fulltext, label: 'Fulltext' },
75+
{ value: DatabasesIndexType.Spatial, label: 'Spatial' }
76+
].filter((type) => {
77+
if (
78+
type.value === DatabasesIndexType.Spatial &&
79+
!$regionalConsoleVariables?.supportForSpatials
80+
)
81+
return false;
82+
return true;
83+
})
84+
);
7585
7686
// order options derived from selected type
7787
let orderOptions = $derived.by(() =>

src/routes/(console)/project-[region]-[project]/databases/database-[database]/(suggestions)/empty.svelte

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
mapSuggestedColumns,
2929
type SuggestedColumnSchema,
3030
entityColumnSuggestions,
31-
basicColumnOptions,
3231
mockSuggestions,
3332
showIndexesSuggestions
3433
} from './store';
@@ -38,14 +37,15 @@
3837
import { invalidate } from '$app/navigation';
3938
import { Dependencies } from '$lib/constants';
4039
import { isWithinSafeRange } from '$lib/helpers/numbers';
41-
import { columnOptions } from '../table-[table]/columns/store';
40+
import { columnOptions, getSupportedColumns } from '../table-[table]/columns/store';
4241
import Options from './options.svelte';
4342
import { InputSelect, InputText } from '$lib/elements/forms';
4443
import { isCloud, VARS } from '$lib/system';
4544
import { fade } from 'svelte/transition';
4645
4746
import IconAINotification from './icon/aiNotification.svelte';
4847
import type { Models } from '@appwrite.io/console';
48+
import { regionalConsoleVariables } from '$routes/(console)/project-[region]-[project]/store';
4949
5050
let {
5151
userColumns = [],
@@ -56,6 +56,7 @@
5656
} = $props();
5757
5858
const tableId = page.params.table;
59+
const supportedColumns = $derived(getSupportedColumns($regionalConsoleVariables));
5960
const minimumUserColumnWidth = 168;
6061
6162
function getUserColumnWidth(
@@ -1359,7 +1360,7 @@
13591360
</Spreadsheet.Header.Cell>
13601361
{:else}
13611362
{@const columnObj = getColumn(column.id)}
1362-
{@const columnIcon = basicColumnOptions.find(
1363+
{@const columnIcon = columnOptions.find(
13631364
(col) => col.type === columnObj?.type
13641365
)?.icon}
13651366
{@const columnIconColor = !columnObj?.type
@@ -1516,7 +1517,7 @@
15161517
});
15171518
}
15181519
}}
1519-
options={basicColumnOptions.map((col) => {
1520+
options={supportedColumns.map((col) => {
15201521
return {
15211522
label: col.name,
15221523
value: col.name,
@@ -1835,7 +1836,7 @@
18351836
gap="none"
18361837
direction="column"
18371838
class="filter-modal-actions-menu variant">
1838-
{#each basicColumnOptions as option}
1839+
{#each supportedColumns as option}
18391840
<ActionMenu.Item.Button
18401841
on:click={() => {
18411842
toggle();

src/routes/(console)/project-[region]-[project]/databases/database-[database]/(suggestions)/indexes.svelte

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import { capitalize } from '$lib/helpers/string';
1111
import type { Columns } from '$database/store';
1212
import { isRelationship } from '../table-[table]/rows/store';
13+
import { regionalConsoleVariables } from '$routes/(console)/project-[region]-[project]/store';
1314
import { VARS } from '$lib/system';
1415
import { sleep } from '$lib/helpers/promises';
1516
import { sdk } from '$lib/stores/sdk';
@@ -291,10 +292,21 @@
291292
return false; // close the sheet!
292293
}
293294
294-
const typeOptions = Object.values(DatabasesIndexType).map((type) => ({
295-
label: capitalize(type),
296-
value: type
297-
}));
295+
const typeOptions = $derived(
296+
Object.values(DatabasesIndexType)
297+
.filter((type) => {
298+
if (
299+
type === DatabasesIndexType.Spatial &&
300+
!$regionalConsoleVariables?.supportForSpatials
301+
)
302+
return false;
303+
return true;
304+
})
305+
.map((type) => ({
306+
label: capitalize(type),
307+
value: type
308+
}))
309+
);
298310
299311
onMount(() => showIndexesSuggestions.set(false));
300312

src/routes/(console)/project-[region]-[project]/databases/database-[database]/table-[table]/columns/createColumnDropdown.svelte

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
<script lang="ts">
22
import { Button } from '$lib/elements/forms';
33
import { ActionMenu, Icon, Popover } from '@appwrite.io/pink-svelte';
4-
import { columnOptions, type Option } from './store';
4+
import { getSupportedColumns, type Option } from './store';
55
import { IconPlus } from '@appwrite.io/pink-icons-svelte';
66
import { isTablesCsvImportInProgress } from '../store';
77
import { CsvDisabled } from '$database/(entity)';
8+
import { regionalConsoleVariables } from '$routes/(console)/project-[region]-[project]/store';
89
910
export let showCreate = false;
1011
export let selectedOption: Option['name'] = null;
12+
13+
$: options = getSupportedColumns($regionalConsoleVariables);
1114
</script>
1215

1316
{#if $isTablesCsvImportInProgress}
@@ -26,7 +29,7 @@
2629
</Button>
2730
</slot>
2831
<ActionMenu.Root slot="tooltip">
29-
{#each columnOptions as column}
32+
{#each options as column}
3033
<ActionMenu.Item.Button
3134
leadingIcon={column.icon}
3235
on:click={() => {

src/routes/(console)/project-[region]-[project]/databases/database-[database]/table-[table]/columns/store.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import Point, { submitPoint, updatePoint } from './point.svelte';
1717
import Line, { submitLine, updateLine } from './line.svelte';
1818
import Polygon, { submitPolygon, updatePolygon } from './polygon.svelte';
1919
import type { Columns } from '$database/store';
20+
import type { Models } from '@appwrite.io/console';
2021
import Relationship, { submitRelationship, updateRelationship } from './relationship.svelte';
2122
import {
2223
IconCalendar,
@@ -248,3 +249,12 @@ export const columnOptions: Option[] = [
248249
];
249250

250251
export const option = writable<Option>();
252+
253+
export function getSupportedColumns(consoleVariables: Models.ConsoleVariables): Option[] {
254+
const spatialTypes: Set<Option['type']> = new Set(['point', 'linestring', 'polygon']);
255+
return columnOptions.filter((col) => {
256+
if (col.type === 'relationship' && !consoleVariables?.supportForRelationships) return false;
257+
if (spatialTypes.has(col.type) && !consoleVariables?.supportForSpatials) return false;
258+
return true;
259+
});
260+
}

src/routes/(console)/project-[region]-[project]/databases/database-[database]/table-[table]/createColumn.svelte

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,13 @@
66
import { InputSelect, InputText } from '$lib/elements/forms';
77
import { addNotification } from '$lib/stores/notifications';
88
import { Submit, trackError, trackEvent } from '$lib/actions/analytics';
9-
import { option, columnOptions, type Option } from '$database/table-[table]/columns/store';
9+
import {
10+
option,
11+
getSupportedColumns,
12+
type Option
13+
} from '$database/table-[table]/columns/store';
1014
import type { Column } from '$lib/helpers/types';
15+
import { regionalConsoleVariables } from '$routes/(console)/project-[region]-[project]/store';
1116
import { preferences } from '$lib/stores/preferences';
1217
import { onMount } from 'svelte';
1318
@@ -52,8 +57,10 @@
5257
...column
5358
} as Partial<Columns>);
5459
60+
let availableOptions = $derived(getSupportedColumns($regionalConsoleVariables));
5561
let ColumnComponent = $derived(
56-
columnOptions.find((option) => option.name === selectedOption).component
62+
(availableOptions.find((option) => option.name === selectedOption) ?? availableOptions[0])
63+
.component
5764
);
5865
5966
function init() {
@@ -68,7 +75,7 @@
6875
6976
/* default to text */
7077
selectedOption = 'Text';
71-
$option = columnOptions[0];
78+
$option = availableOptions[0];
7279
}
7380
7481
function insertColumnInOrder() {
@@ -184,7 +191,15 @@
184191
185192
// correct view
186193
if (selectedOption) {
187-
$option = columnOptions.find((option) => option.name === selectedOption);
194+
const resolved =
195+
availableOptions.find((option) => option.name === selectedOption) ??
196+
availableOptions[0];
197+
198+
$option = resolved;
199+
200+
if (resolved && resolved.name !== selectedOption) {
201+
selectedOption = resolved.name;
202+
}
188203
}
189204
});
190205
</script>
@@ -221,7 +236,7 @@
221236
id="type"
222237
label="Type"
223238
bind:value={selectedOption}
224-
options={columnOptions.map((attr) => {
239+
options={availableOptions.map((attr) => {
225240
return {
226241
label: attr.name,
227242
value: attr.name,

src/routes/(console)/project-[region]-[project]/databases/database-[database]/table-[table]/spreadsheet.svelte

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import { addNotification } from '$lib/stores/notifications';
99
import { preferences } from '$lib/stores/preferences';
1010
import { sdk } from '$lib/stores/sdk';
11+
import { regionalConsoleVariables } from '$routes/(console)/project-[region]-[project]/store';
1112
import { type Models, Query } from '@appwrite.io/console';
1213
import { type ComponentType, onDestroy, onMount } from 'svelte';
1314
import type { PageData } from './$types';
@@ -967,7 +968,9 @@
967968
select={rowSelection}
968969
hoverEffect
969970
showSelectOnHover
970-
valueWithoutHover={row.$sequence}>
971+
valueWithoutHover={$regionalConsoleVariables?.supportForIntegerIds
972+
? row?.$sequence
973+
: undefined}>
971974
{#each $tableColumns as { id: columnId, isEditable, hide } (columnId)}
972975
{@const rowColumn = $columns.find((col) => col.key === columnId)}
973976
{#if columnId === '$id' && !hide}

0 commit comments

Comments
 (0)