Merge remote-tracking branch 'origin' into spatial-type-attributes

This commit is contained in:
ArnabChatterjee20k committed 2025-09-12 14:39:29 +05:30
commit bf83c00f75
13 files changed
+125 -43

No files matched your search

+1 -1
View File
@@ -144,7 +144,7 @@ function createFeedbackStore() {
message,
email,
customFields,
firstname: name || 'Unknown',
firstname: (name || 'Unknown').slice(0, 40),
metaFields: {
source: get(feedback).source,
orgId,
+2 -1
View File
@@ -220,7 +220,8 @@ function createPreferences() {
loadTeamPrefs: loadTeamPreferences,
getDisplayNames: (tableId: string) => {
return teamPreferences?.displayNames?.[tableId] ?? ['$id'];
const names = teamPreferences?.displayNames?.[tableId];
return Array.isArray(names) && names.length > 0 ? names : ['$id'];
},
setDisplayNames: async (
@@ -64,7 +64,7 @@
body: JSON.stringify({
subject: 'BAA Request',
email: email,
firstName: $user?.name ?? '',
firstName: ($user?.name ?? '').slice(0, 40),
message: `BAA request for ${$organization?.name ?? ''} (${$organization?.$id ?? ''})`,
tags: ['cloud'],
customFields: [
@@ -65,7 +65,7 @@
body: JSON.stringify({
subject: 'SOC-2 Request',
email: email,
firstName: $user?.name ?? '',
firstName: ($user?.name ?? '').slice(0, 40),
message: `SOC-2 request for ${$organization?.name ?? ''} (${$organization?.$id ?? ''})`,
tags: ['cloud'],
customFields: [
@@ -12,7 +12,7 @@
import { Dependencies } from '$lib/constants';
import type { Models } from '@appwrite.io/console';
import CreateTable from './createTable.svelte';
import { showCreate } from './store';
import { showCreateTable } from './store';
import { TablesPanel } from '$lib/commandCenter/panels';
import { canWriteTables, canWriteDatabases } from '$lib/stores/roles';
import { showCreateBackup, showCreatePolicy } from './backups/store';
@@ -25,7 +25,7 @@
const databaseId = page.params.database;
async function handleCreate(event: CustomEvent<Models.Table>) {
$showCreate = false;
$showCreateTable = false;
await invalidate(Dependencies.DATABASE);
await goto(
`${base}/project-${page.params.region}-${project}/databases/database-${databaseId}/table-${event.detail.$id}`
@@ -36,7 +36,7 @@
{
label: 'Create table',
callback() {
$showCreate = true;
$showCreateTable = true;
if (!page.url.pathname.endsWith(databaseId)) {
goto(
`${base}/project-${page.params.region}-${project}/databases/database-${databaseId}`
@@ -152,4 +152,4 @@
<slot />
<CreateTable bind:showCreate={$showCreate} on:created={handleCreate} />
<CreateTable bind:showCreate={$showCreateTable} on:created={handleCreate} />
@@ -2,7 +2,7 @@
import { EmptySearch, PaginationWithLimit, SearchQuery, ViewSelector } from '$lib/components';
import { Button } from '$lib/elements/forms';
import { Container } from '$lib/layout';
import { showCreate, tableViewColumns } from './store';
import { showCreateTable, tableViewColumns } from './store';
import Table from './table.svelte';
import Grid from './grid.svelte';
import type { PageData } from './$types';
@@ -33,7 +33,7 @@
hideView={!data.tables.total} />
{#if $canWriteTables}
<Button event="create_table" on:click={() => ($showCreate = true)}>
<Button event="create_table" on:click={() => ($showCreateTable = true)}>
<Icon icon={IconPlus} slot="start" size="s" />
Create table
</Button>
@@ -43,7 +43,7 @@
{#if data.tables.total}
{#if data.view === 'grid'}
<Grid {data} bind:showCreate={$showCreate} />
<Grid {data} bind:showCreate={$showCreateTable} />
{:else}
<Table {data} />
{/if}
@@ -77,13 +77,13 @@
href="https://appwrite.io/docs/products/databases/databases"
text
event="empty_documentation"
ariaLabel={`create table`}>Documentation</Button>
ariaLabel="create table">Documentation</Button>
{#if $canWriteTables}
<Button
secondary
on:click={() => {
$showCreate = true;
$showCreateTable = true;
}}>
Create table
</Button>
@@ -5,7 +5,7 @@ import { derived, writable } from 'svelte/store';
import { IconChartBar, IconCloudUpload, IconCog } from '@appwrite.io/pink-icons-svelte';
export const database = derived(page, ($page) => $page.data.database as Models.Database);
export const showCreate = writable(false);
export const showCreateTable = writable(false);
export const tableViewColumns = writable<Column[]>([
{ id: '$id', title: 'Table ID', type: 'string', width: 200 },
@@ -1,7 +1,7 @@
<script lang="ts">
import { base } from '$app/paths';
import { page } from '$app/state';
import { showCreate, databaseSubNavigationItems } from './store';
import { showCreateTable, databaseSubNavigationItems } from './store';
import type { PageData } from './$types';
import { showSubNavigation } from '$lib/stores/layout';
import {
@@ -137,7 +137,7 @@
<Button
compact
on:click={() => {
$showCreate = true;
$showCreateTable = true;
$showSubNavigation = false;
}}>
Create table
@@ -40,7 +40,7 @@
import { addSubPanel, registerCommands, updateCommandGroupRanks } from '$lib/commandCenter';
import CreateColumn from './createColumn.svelte';
import { CreateColumnPanel } from '$lib/commandCenter/panels';
import { database } from '../store';
import { database, showCreateTable } from '../store';
import { project } from '../../../store';
import { page } from '$app/state';
import { base } from '$app/paths';
@@ -100,11 +100,7 @@
{
label: 'Create row',
keys: page.url.pathname.endsWith($table.$id) ? ['t'] : ['t', 'd'],
callback() {
goto(
`${base}/project-${page.params.region}-${page.params.project}/databases/database-${$database?.$id}/table-${$table?.$id}/create`
);
},
callback: () => ($showCreateTable = true),
icon: IconPlus,
group: 'rows'
},
@@ -230,7 +230,6 @@
</SpreadsheetContainer>
{#if !$spreadsheetLoading}
<!-- Claude: Can this be truly centered without hacky left: xyz values? -->
<div
class="spreadsheet-fade-bottom"
data-collapsed-tabs={!$expandTabs}
@@ -7,7 +7,8 @@
import { type ComponentType, onMount } from 'svelte';
import { isRelationshipToMany } from '../../store';
import { IconPlus, IconRelationship, IconX } from '@appwrite.io/pink-icons-svelte';
import { Icon, Layout, Typography } from '@appwrite.io/pink-svelte';
import { Input, Icon, Layout, Typography } from '@appwrite.io/pink-svelte';
import { debounce } from '$lib/helpers/debounce';
type SelectOption = {
label: string;
@@ -33,7 +34,6 @@
let showInput = false;
let singleRel: string;
let search: string = null;
let loadingRelationships = false;
let newItemValue: string = '';
@@ -42,6 +42,23 @@
let limit = 10;
let offset = 0;
let searchNoResultsOption = undefined;
/**
* list of loaded rows to tune with searching!
*
* this is used when the view is not searching anything,
* therefore we don't have to make an API call again!
*
* Example:
* 1. initial rows are loaded -> cache the rows
* 2. user makes a search -> api call -> not results found
* 3. user clears the search -> this variable sets the rowsList back!
*
* `#3` allows us to not make a call to getRows again, saves time and bandwidth!
*/
let cachedRowsCopyList: Models.RowList<Models.Row>;
onMount(async () => {
if (isRelationshipToMany(column)) {
if (Array.isArray(value)) {
@@ -57,30 +74,43 @@
}
});
async function getRows(search: string = null) {
async function getRows() {
loadingRelationships = true;
// already includes the `$id`, dw!
const displayNames = preferences.getDisplayNames(column.relatedTable);
const queries = search
? [Query.select(displayNames), Query.startsWith('$id', search), Query.orderDesc('')]
: [Query.select(displayNames)];
const rows = await sdk
.forProject(page.params.region, page.params.project)
.tablesDB.listRows({
databaseId,
tableId: column.relatedTable,
queries
// limit `5` as `25` would look too much on sheet!
queries: [Query.select(displayNames), Query.limit(2)]
});
cachedRowsCopyList = rows;
loadingRelationships = false;
return rows;
}
function getAvailableOptions(excludeIndex?: number) {
async function searchRows(search: string = null) {
if (!search) return;
const displayNames = preferences.getDisplayNames(column.relatedTable);
const queries = [];
displayNames.forEach((name) => queries.push(Query.contains(name, [search])));
return await sdk.forProject(page.params.region, page.params.project).tablesDB.listRows({
databaseId,
tableId: column.relatedTable,
queries
});
}
function getAvailableOptions(excludeIndex?: number): SelectOption[] {
return options?.filter((option) => {
const otherItems =
excludeIndex !== undefined
@@ -109,13 +139,13 @@
if (newItemValue) {
relatedList = [...relatedList, newItemValue];
value = relatedList;
newItemValue = '';
newItemValue = null;
showInput = false;
}
}
function cancelAddItem() {
newItemValue = '';
newItemValue = null;
showInput = false;
}
@@ -166,8 +196,42 @@
return baseOptions;
}
const debouncedSearch = debounce(async (searchTerm: string) => {
const availableOptions = getAvailableOptions();
const includesItem = availableOptions
.filter((opt) => {
const label = String(opt.label ?? '').toLowerCase();
const value = String(opt.value ?? '').toLowerCase();
return (
label.includes(searchTerm.toLowerCase()) ||
value.includes(searchTerm.toLowerCase())
);
})
.filter(Boolean);
if (!includesItem.length) {
try {
searchNoResultsOption = {
disabled: true,
message: 'Searching...'
};
const searchResults = await searchRows(searchTerm);
if (searchResults) {
rowList = searchResults;
}
} finally {
searchNoResultsOption = undefined;
}
} else if (cachedRowsCopyList) {
rowList = cachedRowsCopyList;
}
}, 500);
// Reactive statements
$: getRows(search).then((res) => (rowList = res));
$: if (!newItemValue && !cachedRowsCopyList) {
getRows().then((response) => (rowList = response));
}
$: paginatedItems = editing
? relatedList
@@ -193,6 +257,13 @@
$: if (limit && !isRelationshipToMany(column) && limited) {
label = undefined;
}
$: if (newItemValue) {
debouncedSearch(newItemValue);
} else if (!newItemValue && cachedRowsCopyList) {
rowList = cachedRowsCopyList;
searchNoResultsOption = undefined;
}
</script>
{#if isRelationshipToMany(column)}
@@ -298,13 +369,14 @@
<!-- Input for adding new items -->
{#if showInput}
<Layout.Stack direction="row">
<InputSelect
<Input.ComboBox
{id}
required
placeholder={`Select ${column.key}`}
bind:value={newItemValue}
options={getAvailableOptions()}
on:change={addNewItem}
noResultsOption={searchNoResultsOption}
leadingIcon={!limited ? IconRelationship : undefined} />
<div style:padding-block-start="0.5rem">
@@ -328,20 +400,29 @@
</Layout.Stack>
{:else}
<Layout.Stack direction="row" alignItems="center" gap="s">
<InputSelect
<Input.ComboBox
{id}
{options}
autofocus={limited}
bind:value={singleRel}
bind:value={newItemValue}
required={column.required}
label={limited ? undefined : label}
placeholder={`Select ${column.key}`}
noResultsOption={searchNoResultsOption}
on:change={() => {
if (singleRel === null) {
if (newItemValue === null) {
value = null;
singleRel = null;
} else {
value = rowList.rows.find((row) => row.$id === singleRel);
const selectedRow = rowList.rows.find((row) => row.$id === newItemValue);
if (selectedRow) {
value = selectedRow;
singleRel = newItemValue;
}
}
newItemValue = null;
}}
leadingIcon={!limited ? IconRelationship : undefined} />
@@ -171,7 +171,10 @@
Before installing Git in a locally hosted Appwrite project, ensure your environment
variables are configured.
<svelte:fragment slot="actions">
<Button compact href="#" external>Learn more</Button>
<Button
compact
href="https://appwrite.io/docs/advanced/self-hosting/configuration/version-control"
external>Learn more</Button>
</svelte:fragment>
</Alert.Inline>
{:else}
+4 -2
View File
@@ -49,7 +49,7 @@
body: JSON.stringify({
email: $user.email,
subject: $supportData.subject,
firstName: $user?.name || 'Unknown',
firstName: ($user?.name || 'Unknown').slice(0, 40),
message: $supportData.message,
tags: ['cloud'],
customFields: [
@@ -136,12 +136,14 @@
label="Subject"
bind:value={$supportData.subject}
placeholder="What do you need help with?"
maxlength={128}
required />
<InputTextarea
id="message"
bind:value={$supportData.message}
placeholder="Type here..."
label="Tell us a bit more" />
label="Tell us a bit more"
maxlength={4096} />
<Layout.Stack direction="row" justifyContent="flex-end" gap="s">
<Button.Button
size="s"