rename: vars.

This commit is contained in:
Darshan
2025-06-19 10:03:33 +05:30
parent 9436b2b594
commit 29530da2f6
16 changed files with 52 additions and 52 deletions
+1 -1
View File
@@ -1,5 +1,5 @@
PUBLIC_CONSOLE_MODE=self-hosted
PUBLIC_CONSOLE_FEATURE_FLAGS=sites,csv-import,attribute-encrypt,index-lengths
PUBLIC_CONSOLE_FEATURE_FLAGS=sites,csv-import,column-encrypt,index-lengths
PUBLIC_APPWRITE_MULTI_REGION=false
PUBLIC_APPWRITE_ENDPOINT=http://localhost/v1
PUBLIC_STRIPE_KEY=
+3 -3
View File
@@ -79,7 +79,7 @@ jobs:
labels: ${{ steps.meta.outputs.labels }}
build-args: |
"PUBLIC_CONSOLE_MODE=cloud"
"PUBLIC_CONSOLE_FEATURE_FLAGS=sites,csv-import,attribute-encrypt,index-lengths"
"PUBLIC_CONSOLE_FEATURE_FLAGS=sites,csv-import,column-encrypt,index-lengths"
"PUBLIC_APPWRITE_MULTI_REGION=true"
"PUBLIC_GROWTH_ENDPOINT=${{ secrets.PUBLIC_GROWTH_ENDPOINT }}"
"PUBLIC_STRIPE_KEY=${{ secrets.PUBLIC_STRIPE_KEY_STAGE }}"
@@ -118,7 +118,7 @@ jobs:
build-args: |
"PUBLIC_CONSOLE_MODE=self-hosted"
"PUBLIC_APPWRITE_MULTI_REGION=false"
"PUBLIC_CONSOLE_FEATURE_FLAGS=sites,csv-import,attribute-encrypt,index-lengths"
"PUBLIC_CONSOLE_FEATURE_FLAGS=sites,csv-import,column-encrypt,index-lengths"
"PUBLIC_GROWTH_ENDPOINT=${{ secrets.PUBLIC_GROWTH_ENDPOINT }}"
publish-cloud-no-regions:
@@ -156,6 +156,6 @@ jobs:
build-args: |
"PUBLIC_CONSOLE_MODE=cloud"
"PUBLIC_APPWRITE_MULTI_REGION=false"
"PUBLIC_CONSOLE_FEATURE_FLAGS=sites,csv-import,attribute-encrypt,index-lengths"
"PUBLIC_CONSOLE_FEATURE_FLAGS=sites,csv-import,column-encrypt,index-lengths"
"PUBLIC_STRIPE_KEY=${{ secrets.PUBLIC_STRIPE_KEY_STAGE }}"
"PUBLIC_GROWTH_ENDPOINT=${{ secrets.PUBLIC_GROWTH_ENDPOINT }}"
@@ -1,11 +1,11 @@
<script lang="ts">
import { initCreateColumn } from '$routes/(console)/project-[region]-[project]/databases/database-[database]/table-[table]/+layout.svelte';
import { attributeOptions } from '$routes/(console)/project-[region]-[project]/databases/database-[database]/table-[table]/columns/store';
import { columnOptions } from '$routes/(console)/project-[region]-[project]/databases/database-[database]/table-[table]/columns/store';
import Template from './template.svelte';
let search = '';
let options = attributeOptions.map((option) => {
let options = columnOptions.map((option) => {
return {
label: option.name,
icon: option.icon,
+2 -2
View File
@@ -117,9 +117,9 @@
}
function backupName(item: BackupArchive | BackupRestoration, key: string) {
const attribute = key === 'archives' ? '$createdAt' : 'startedAt';
const column = key === 'archives' ? '$createdAt' : 'startedAt';
return toLocaleDate(item[attribute]);
return toLocaleDate(item[column]);
}
onMount(() => {
+10 -10
View File
@@ -12,8 +12,8 @@ export type TagValue = {
};
export type Operator = {
toTag: (attribute: string, input?: string | number | string[], type?: string) => TagValue;
toQuery: (attribute: string, input?: string | number | string[]) => string;
toTag: (column: string, input?: string | number | string[], type?: string) => TagValue;
toQuery: (column: string, input?: string | number | string[]) => string;
types: ColumnType[];
hideInput?: boolean;
};
@@ -134,7 +134,7 @@ export enum ValidTypes {
const operatorsDefault = new Map<
ValidOperators,
{
query: (attr: string, input: string | number | string[]) => string;
query: (col: string, input: string | number | string[]) => string;
types: ColumnType[];
hideInput?: boolean;
}
@@ -249,8 +249,8 @@ export function generateDefaultOperators() {
operatorsDefault.forEach((operator, operatorName) => {
operators[operatorName] = {
toQuery: operator.query,
toTag: (attribute, input = null, type = null) => {
return generateTag(attribute, operatorName, input, type);
toTag: (column, input = null, type = null) => {
return generateTag(column, operatorName, input, type);
},
types: operator.types,
hideInput: operator.hideInput
@@ -259,24 +259,24 @@ export function generateDefaultOperators() {
return operators;
}
export function generateTag(attribute: string, operatorName: string, input = null, type = null) {
export function generateTag(column: string, operatorName: string, input = null, type = null) {
if (input === null) {
return {
value: '',
tag: `**${attribute}** ${operatorName}`
tag: `**${column}** ${operatorName}`
};
} else if (Array.isArray(input) && input.length > 2) {
return {
value: input,
tag: `**${attribute}** ${operatorName} **${formatArray(input)}** `
tag: `**${column}** ${operatorName} **${formatArray(input)}** `
};
} else if (type === ValidTypes.Datetime) {
return {
value: input,
tag: `**${attribute}** ${operatorName} **${toLocaleDateTime(input.toString())}**`
tag: `**${column}** ${operatorName} **${toLocaleDateTime(input.toString())}**`
};
} else {
return { value: input, tag: `**${attribute}** ${operatorName} **${input}**` };
return { value: input, tag: `**${column}** ${operatorName} **${input}**` };
}
}
+1 -1
View File
@@ -21,6 +21,6 @@ function isFlagEnabled(name: string) {
export const flags = {
showSites: isFlagEnabled('sites'),
showCsvImport: isFlagEnabled('csv-import'),
showAttributeEncrypt: isFlagEnabled('attribute-encrypt'),
showAttributeEncrypt: isFlagEnabled('column-encrypt'),
showIndexLengths: isFlagEnabled('index-lengths')
};
@@ -12,7 +12,7 @@
import CreateColumnDropdown from './columns/createColumnDropdown.svelte';
import type { Option } from './columns/store';
import CreateColumn from './createColumn.svelte';
import { collection, columns, isCsvImportInProgress } from './store';
import { collection, tableColumns, isCsvImportInProgress } from './store';
import Table from './table.svelte';
import { writable } from 'svelte/store';
import FilePicker from '$lib/components/filePicker.svelte';
@@ -35,7 +35,7 @@
const filterColumns = writable<Column[]>([]);
$: selected = preferences.getCustomCollectionColumns(page.params.table);
$: columns.set(
$: tableColumns.set(
$collection.attributes.map((attribute) => ({
id: attribute.key,
title: attribute.key,
@@ -47,7 +47,7 @@
}))
);
$: filterColumns.set([
...$columns,
...$tableColumns,
...['$id', '$createdAt', '$updatedAt'].map((id) => ({
id,
title: id,
@@ -95,11 +95,11 @@
<Layout.Stack direction="row" justifyContent="space-between">
<Filters
query={data.query}
{columns}
columns={tableColumns}
disabled={!(hasAttributes && hasValidAttributes)}
analyticsSource="database_rows" />
<Layout.Stack direction="row" alignItems="center" justifyContent="flex-end">
<ViewSelector view={data.view} {columns} hideView />
<ViewSelector view={data.view} columns={tableColumns} hideView />
{#if flags.showCsvImport(data)}
<Button
secondary
@@ -20,11 +20,11 @@
import { isRelationship, isString } from '../row-[row]/columns/store';
import FailedModal from '../failedModal.svelte';
import CreateIndex from '../indexes/createIndex.svelte';
import { attributes, type Attributes, isCsvImportInProgress } from '../store';
import { columns, type Attributes, isCsvImportInProgress } from '../store';
import CreateColumnDropdown from './createColumnDropdown.svelte';
import Delete from './deleteColumn.svelte';
import Edit from './edit.svelte';
import { attributeOptions, type Option } from './store';
import { columnOptions, type Option } from './store';
import {
IconArrowSmRight,
IconDotsHorizontal,
@@ -82,7 +82,7 @@
{/if}
</Layout.Stack>
{#if $attributes.length}
{#if $columns.length}
<Table.Root
let:root
columns={[
@@ -97,8 +97,8 @@
<Table.Header.Cell column="default" {root}>Default value</Table.Header.Cell>
<Table.Header.Cell column="actions" {root} />
</svelte:fragment>
{#each $attributes as attribute, index}
{@const option = attributeOptions.find((option) => option.type === attribute.type)}
{#each $columns as attribute, index}
{@const option = columnOptions.find((option) => option.type === attribute.type)}
<Table.Row.Base {root}>
<Table.Cell column="key" {root}>
<Layout.Stack direction="row" alignItems="center">
@@ -1,7 +1,7 @@
<script lang="ts">
import { Button } from '$lib/elements/forms';
import { ActionMenu, Icon, Popover } from '@appwrite.io/pink-svelte';
import { attributeOptions, type Option } from './store';
import { columnOptions, type Option } from './store';
import { IconPlus } from '@appwrite.io/pink-icons-svelte';
import CsvDisabled from '../csvDisabled.svelte';
import { isCsvImportInProgress } from '../store';
@@ -26,7 +26,7 @@
</Button>
</slot>
<ActionMenu.Root slot="tooltip">
{#each attributeOptions as attribute}
{#each columnOptions as attribute}
<ActionMenu.Item.Button
leadingIcon={attribute.icon}
on:click={() => {
@@ -9,7 +9,7 @@
import deepEqual from 'deep-equal';
import { addNotification } from '$lib/stores/notifications';
import type { Attributes } from '../store';
import { attributeOptions, type Option } from './store';
import { columnOptions, type Option } from './store';
export let showEdit = false;
export let selectedAttribute: Attributes;
@@ -21,7 +21,7 @@
let error: string;
let currentAttr: Attributes;
$: option = attributeOptions.find((option) => {
$: option = columnOptions.find((option) => {
if (selectedAttribute) {
if ('format' in selectedAttribute && selectedAttribute.format) {
return option?.format === selectedAttribute?.format;
@@ -53,7 +53,7 @@
}
$: onShow(showEdit);
$: title = `Update ${attributeOptions.find((v) => v.name === option.name)?.sentenceName ?? ''} attribute`;
$: title = `Update ${columnOptions.find((v) => v.name === option.name)?.sentenceName ?? ''} attribute`;
function onShow(show: boolean) {
if (show) {
@@ -55,7 +55,7 @@ export type Option = {
icon: ComponentType;
};
export const attributeOptions: Option[] = [
export const columnOptions: Option[] = [
{
name: 'String',
sentenceName: 'string',
@@ -2,7 +2,7 @@
import { Modal } from '$lib/components';
import {
option,
attributeOptions,
columnOptions,
type Option
} from '$routes/(console)/project-[region]-[project]/databases/database-[database]/table-[table]/columns/store';
import { Button, InputText } from '$lib/elements/forms';
@@ -55,7 +55,7 @@
}
$: if (selectedOption) {
$option = attributeOptions.find((option) => option.name === selectedOption);
$option = columnOptions.find((option) => option.name === selectedOption);
}
$: if (!showCreate) {
@@ -70,7 +70,7 @@
};
}
$: title = `Create ${attributeOptions.find((option) => option.name === selectedOption)?.sentenceName ?? ''} column`;
$: title = `Create ${columnOptions.find((option) => option.name === selectedOption)?.sentenceName ?? ''} column`;
</script>
<Modal {error} bind:show={showCreate} onSubmit={submit} {title}>
@@ -8,7 +8,7 @@
import { addNotification } from '$lib/stores/notifications';
import { sdk } from '$lib/stores/sdk';
import { Alert, Layout, Selector, Table } from '@appwrite.io/pink-svelte';
import { attributes, collection } from '../store';
import { columns, collection } from '../store';
import { isRelationship, isRelationshipToMany } from './columns/store';
import type { Models } from '@appwrite.io/console';
@@ -45,7 +45,7 @@
'restrict' = 'Row cannot be deleted'
}
$: relAttributes = $attributes?.filter(
$: relAttributes = $columns?.filter(
(attribute) =>
isRelationship(attribute) &&
// One-to-One are always included
@@ -7,7 +7,7 @@
import { last, symmetricDifference } from '$lib/helpers/array';
import { addNotification } from '$lib/stores/notifications';
import type { Models } from '@appwrite.io/console';
import { attributes } from '../store';
import { columns } from '../store';
import { preferences } from '$lib/stores/preferences';
import { page } from '$app/state';
import { Icon, Layout } from '@appwrite.io/pink-svelte';
@@ -35,7 +35,7 @@
}
}
$: options = ($attributes as Models.AttributeString[])
$: options = ($columns as Models.AttributeString[])
.filter(
(attr) =>
attr.type === 'string' && !attr?.array && !names?.some((name) => name === attr.key)
@@ -19,12 +19,12 @@ type Collection = Omit<Models.Collection, 'attributes'> & {
};
export const collection = derived(page, ($page) => $page.data.collection as Collection);
export const attributes = derived(
export const columns = derived(
page,
($page) => $page.data.collection.attributes as Attributes[]
);
export const indexes = derived(page, ($page) => $page.data.collection.indexes as Models.Index[]);
export const columns = writable<Column[]>([]);
export const tableColumns = writable<Column[]>([]);
export const isCsvImportInProgress = writable(false);
@@ -14,7 +14,7 @@
import type { PageData } from './$types';
import { isRelationship, isRelationshipToMany, isString } from './row-[row]/columns/store';
import RelationshipsModal from './relationshipsModal.svelte';
import { attributes, collection, columns } from './store';
import { columns, collection, tableColumns } from './store';
import type { ColumnType } from '$lib/helpers/types';
import {
Tooltip,
@@ -49,7 +49,7 @@
function updateMaxWidth() {
const tableCells = Array.from(document.querySelectorAll('.less-width-truncated'));
const visibleColumnsCount = $columns.filter((col) => !col.hide).length;
const visibleColumnsCount = $tableColumns.filter((col) => !col.hide).length;
const newMaxWidth = Math.max(50 - (visibleColumnsCount - 1) * 5, 25);
tableCells.forEach((cell) => {
@@ -99,7 +99,7 @@
$: selected = preferences.getCustomCollectionColumns(page.params.table);
$: {
columns.set(
tableColumns.set(
$collection.attributes.map((attribute) => ({
id: attribute.key,
title: attribute.key,
@@ -151,7 +151,7 @@
'restrict' = 'Row cannot be deleted'
}
$: relAttributes = $attributes?.filter(
$: relAttributes = $columns?.filter(
(attribute) =>
isRelationship(attribute) &&
// One-to-One are always included
@@ -175,13 +175,13 @@
bind:selectedRows
columns={[
{ id: '$id', width: 200 },
...$columns,
...$tableColumns,
{ id: '$created', width: 200 },
{ id: '$updated', width: 200 }
]}>
<svelte:fragment slot="header" let:root>
<Table.Header.Cell column="$id" {root}>Document ID</Table.Header.Cell>
{#each $columns as column}
{#each $tableColumns as column}
<Table.Header.Cell column={column.id} {root}>{column.title}</Table.Header.Cell>
{/each}
<Table.Header.Cell column="$created" {root}>Created</Table.Header.Cell>
@@ -200,8 +200,8 @@
{/key}
</Table.Cell>
{#each $columns as { id } (id)}
{@const attr = $attributes.find((n) => n.key === id)}
{#each $tableColumns as { id } (id)}
{@const attr = $columns.find((n) => n.key === id)}
{#if attr}
<Table.Cell column={id} {root}>
{#if isRelationship(attr)}