mirror of
https://github.com/appwrite/console.git
synced 2026-06-06 19:27:48 +00:00
Fix more errors
This commit is contained in:
+16
-16
@@ -1,8 +1,8 @@
|
||||
<script module lang="ts">
|
||||
import { DatabasesIndexType, OrderBy } from '@appwrite.io/console';
|
||||
import { TablesDBIndexType, OrderBy } from '@appwrite.io/console';
|
||||
export type CreateIndexesCallbackType = {
|
||||
key: string;
|
||||
type: DatabasesIndexType;
|
||||
type: TablesDBIndexType;
|
||||
fields: string[];
|
||||
lengths: (number | null)[];
|
||||
orders: OrderBy[];
|
||||
@@ -40,14 +40,14 @@
|
||||
|
||||
let key = $state('');
|
||||
let initializedForOpen = $state(false);
|
||||
let selectedType = $state<DatabasesIndexType>(DatabasesIndexType.Key);
|
||||
let selectedType = $state<TablesDBIndexType>(TablesDBIndexType.Key);
|
||||
|
||||
const { dependencies, terminology } = getTerminologies();
|
||||
|
||||
const fieldOptions = $derived(
|
||||
entity.fields
|
||||
.filter((field) => {
|
||||
if (selectedType === DatabasesIndexType.Spatial) {
|
||||
if (selectedType === TablesDBIndexType.Spatial) {
|
||||
// keep only spatial
|
||||
return isSpatialType(field);
|
||||
}
|
||||
@@ -69,13 +69,13 @@
|
||||
|
||||
const types = $derived(
|
||||
[
|
||||
{ value: DatabasesIndexType.Key, label: 'Key' },
|
||||
{ value: DatabasesIndexType.Unique, label: 'Unique' },
|
||||
{ value: DatabasesIndexType.Fulltext, label: 'Fulltext' },
|
||||
{ value: DatabasesIndexType.Spatial, label: 'Spatial' }
|
||||
{ value: TablesDBIndexType.Key, label: 'Key' },
|
||||
{ value: TablesDBIndexType.Unique, label: 'Unique' },
|
||||
{ value: TablesDBIndexType.Fulltext, label: 'Fulltext' },
|
||||
{ value: TablesDBIndexType.Spatial, label: 'Spatial' }
|
||||
].filter((type) => {
|
||||
if (
|
||||
type.value === DatabasesIndexType.Spatial &&
|
||||
type.value === TablesDBIndexType.Spatial &&
|
||||
!$regionalConsoleVariables?.supportForSpatials
|
||||
)
|
||||
return false;
|
||||
@@ -85,7 +85,7 @@
|
||||
|
||||
// order options derived from selected type
|
||||
let orderOptions = $derived.by(() =>
|
||||
selectedType === DatabasesIndexType.Spatial
|
||||
selectedType === TablesDBIndexType.Spatial
|
||||
? [
|
||||
{ value: OrderBy.Asc, label: 'ASC' },
|
||||
{ value: OrderBy.Desc, label: 'DESC' },
|
||||
@@ -102,7 +102,7 @@
|
||||
$effect(() => {
|
||||
const firstField = entity.fields.find((field) => field.key === fieldList.at(0)?.value);
|
||||
if (
|
||||
selectedType === DatabasesIndexType.Spatial &&
|
||||
selectedType === TablesDBIndexType.Spatial &&
|
||||
firstField &&
|
||||
!isSpatialType(firstField)
|
||||
) {
|
||||
@@ -126,7 +126,7 @@
|
||||
const isSpatial = field.length && isSpatialType(field[0]);
|
||||
const order = isSpatial ? null : OrderBy.Asc;
|
||||
|
||||
selectedType = isSpatial ? DatabasesIndexType.Spatial : DatabasesIndexType.Key;
|
||||
selectedType = isSpatial ? TablesDBIndexType.Spatial : TablesDBIndexType.Key;
|
||||
|
||||
fieldList = externalFieldKey
|
||||
? [{ value: externalFieldKey, order, length: null }]
|
||||
@@ -136,7 +136,7 @@
|
||||
}
|
||||
|
||||
const addFieldDisabled = $derived(
|
||||
selectedType === DatabasesIndexType.Spatial ||
|
||||
selectedType === TablesDBIndexType.Spatial ||
|
||||
!fieldList.at(-1)?.value ||
|
||||
(!fieldList.at(-1)?.order && fieldList.at(-1)?.order !== null)
|
||||
);
|
||||
@@ -170,7 +170,7 @@
|
||||
if (
|
||||
!key ||
|
||||
!selectedType ||
|
||||
(selectedType !== DatabasesIndexType.Spatial && addFieldDisabled)
|
||||
(selectedType !== TablesDBIndexType.Spatial && addFieldDisabled)
|
||||
) {
|
||||
addNotification({
|
||||
type: 'error',
|
||||
@@ -250,7 +250,7 @@
|
||||
required
|
||||
options={[
|
||||
// allow system fields only for non-spatial index types
|
||||
...(selectedType === DatabasesIndexType.Spatial
|
||||
...(selectedType === TablesDBIndexType.Spatial
|
||||
? []
|
||||
: [
|
||||
{ value: '$id', label: '$id', leadingIcon: IconFingerPrint },
|
||||
@@ -280,7 +280,7 @@
|
||||
bind:value={field.order}
|
||||
placeholder="Select order" />
|
||||
|
||||
{#if selectedType === DatabasesIndexType.Key}
|
||||
{#if selectedType === TablesDBIndexType.Key}
|
||||
<InputNumber
|
||||
id={`length-${index}`}
|
||||
label={index === 0 ? 'Length' : undefined}
|
||||
|
||||
+9
-9
@@ -6,7 +6,7 @@
|
||||
import { Modal } from '$lib/components';
|
||||
import { type Entity, SideSheet } from '$database/(entity)';
|
||||
import { isSmallViewport } from '$lib/stores/viewport';
|
||||
import { DatabasesIndexType, OrderBy } from '@appwrite.io/console';
|
||||
import { TablesDBIndexType, OrderBy } from '@appwrite.io/console';
|
||||
import { capitalize } from '$lib/helpers/string';
|
||||
import { type Columns } from '../table-[table]/store';
|
||||
import { isRelationship } from '../table-[table]/rows/store';
|
||||
@@ -68,7 +68,7 @@
|
||||
|
||||
indexes = mockSuggestions.columns.slice(0, 3).map((column, index) => ({
|
||||
key: column.name,
|
||||
type: DatabasesIndexType.Key,
|
||||
type: TablesDBIndexType.Key,
|
||||
fields: [column.name],
|
||||
orders: index === 2 ? OrderBy.Desc : OrderBy.Asc,
|
||||
lengths: []
|
||||
@@ -85,7 +85,7 @@
|
||||
indexes = suggestions.indexes.map((index) => {
|
||||
return {
|
||||
key: index.columns[0],
|
||||
type: index.type as DatabasesIndexType,
|
||||
type: index.type as TablesDBIndexType,
|
||||
orders: (index.orders?.[0] as OrderBy) || OrderBy.Asc,
|
||||
fields: index.columns,
|
||||
lengths: index.lengths ?? []
|
||||
@@ -113,7 +113,7 @@
|
||||
if (indexes.length < MAX_INDEXES) {
|
||||
indexes.push({
|
||||
key: '',
|
||||
type: DatabasesIndexType.Key,
|
||||
type: TablesDBIndexType.Key,
|
||||
orders: OrderBy.Asc,
|
||||
fields: [],
|
||||
lengths: null
|
||||
@@ -134,9 +134,9 @@
|
||||
}
|
||||
}
|
||||
|
||||
function getOrderOptions(selectedType: DatabasesIndexType) {
|
||||
function getOrderOptions(selectedType: TablesDBIndexType) {
|
||||
const base = [OrderBy.Asc, OrderBy.Desc];
|
||||
const values = selectedType === DatabasesIndexType.Spatial ? [...base, null] : base;
|
||||
const values = selectedType === TablesDBIndexType.Spatial ? [...base, null] : base;
|
||||
|
||||
return values.map((order) => ({
|
||||
label: order ? capitalize(String(order)) : 'None',
|
||||
@@ -166,7 +166,7 @@
|
||||
|
||||
// prepare lengths array
|
||||
let lengths: (number | null)[];
|
||||
if (index.type === DatabasesIndexType.Key) {
|
||||
if (index.type === TablesDBIndexType.Key) {
|
||||
// only validate if it's a key index
|
||||
lengths = index.fields.map((columnKey, i) => {
|
||||
const maxSize = columnMap.get(columnKey);
|
||||
@@ -293,10 +293,10 @@
|
||||
}
|
||||
|
||||
const typeOptions = $derived(
|
||||
Object.values(DatabasesIndexType)
|
||||
Object.values(TablesDBIndexType)
|
||||
.filter((type) => {
|
||||
if (
|
||||
type === DatabasesIndexType.Spatial &&
|
||||
type === TablesDBIndexType.Spatial &&
|
||||
!$regionalConsoleVariables?.supportForSpatials
|
||||
)
|
||||
return false;
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
import { writable } from 'svelte/store';
|
||||
import { DatabasesIndexType, OrderBy } from '@appwrite.io/console';
|
||||
import { TablesDBIndexType, OrderBy } from '@appwrite.io/console';
|
||||
import { columnOptions } from '../table-[table]/columns/store';
|
||||
|
||||
export type TableColumnSuggestions = {
|
||||
@@ -34,7 +34,7 @@ export type IndexOrder = OrderBy | null;
|
||||
|
||||
export type SuggestedIndexSchema = {
|
||||
key: string;
|
||||
type: DatabasesIndexType;
|
||||
type: TablesDBIndexType;
|
||||
orders: IndexOrder;
|
||||
fields: string[];
|
||||
lengths?: number[] | undefined;
|
||||
|
||||
Reference in New Issue
Block a user