Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
73bb192
feat: file tokens.
ItzNotABug Feb 19, 2025
d8706a8
Merge branch 'feat-pink-v2' into file-tokens
ItzNotABug Feb 19, 2025
5bd9322
use: confirm component.
ItzNotABug Feb 19, 2025
6748e4a
ci: empty commit
ItzNotABug Feb 20, 2025
aa34f74
Merge branch 'feat-pink-v2' into file-tokens
ItzNotABug Feb 20, 2025
a76bfb0
fix: lock file.
ItzNotABug Feb 20, 2025
35fbdca
fix: import.
ItzNotABug Feb 20, 2025
d453722
fix: focus and variable binding issues.
ItzNotABug Feb 20, 2025
ee25e03
merge `feat-pink-v2` branch.
ItzNotABug Feb 27, 2025
218ebc4
update: components, refactor old ones.
ItzNotABug Feb 27, 2025
3648c75
Merge branch 'feat-pink-v2' into file-tokens
ItzNotABug Feb 28, 2025
1b55303
update: add copy preview url from token.
ItzNotABug Mar 4, 2025
c78ada8
fix: url.
ItzNotABug Mar 5, 2025
5fdfceb
Merge branch 'feat-pink-v2' into 'file-tokens'.
ItzNotABug Mar 5, 2025
57e2db0
Merge branch 'feat-pink-v2' into 'file-tokens'.
ItzNotABug Mar 5, 2025
05ac353
Merge branch 'feat-pink-v2' into 'file-tokens'.
ItzNotABug Mar 19, 2025
8680840
update: tables.
ItzNotABug Mar 19, 2025
aae9382
Merge branch 'feat-pink-v2' into 'file-tokens'.
ItzNotABug Apr 23, 2025
3c68c37
fix: table missing dev key data.
ItzNotABug Apr 23, 2025
462f2e4
update: misc.
ItzNotABug Apr 24, 2025
7024d24
misc: fixes.
ItzNotABug Apr 25, 2025
7e061fd
address ui changes.
ItzNotABug May 1, 2025
c6f0d3a
remove: import.
ItzNotABug May 1, 2025
2639c7f
update: file sharing via token in the url.
ItzNotABug May 6, 2025
1805205
change: misc.
ItzNotABug May 7, 2025
fcfba52
Merge branch 'feat-pink-v2' into 'file-tokens'.
ItzNotABug May 8, 2025
5095bd2
ran: lint.
ItzNotABug May 8, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/lib/actions/analytics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,9 @@ export enum Submit {
FileCreate = 'submit_file_create',
FileDelete = 'submit_file_delete',
FileUpdatePermissions = 'submit_file_update_permissions',
FileTokenCreate = 'submit_file_token',
FileTokenDelete = 'submit_file_delete',
FileTokenUpdate = 'submit_file_update_expiry',
BudgetCapUpdate = 'submit_budget_cap_update',
BudgetAlertsUpdate = 'submit_budget_alert_conditions_update',
CreditRedeem = 'submit_credit_redeem',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script lang="ts">
import { Helper, InputDateTime, InputSelect } from '$lib/elements/forms';
import { InputDateTime, InputSelect } from '$lib/elements/forms';
import { isSameDay, isValidDate, toLocaleDate } from '$lib/helpers/date';

function incrementToday(value: number, type: 'day' | 'month' | 'year'): string {
Expand Down Expand Up @@ -47,6 +47,9 @@
];

export let value: string | null = null;
export let dateSelectorLabel: string | undefined = undefined;
export let selectorLabel: string | undefined = 'Expiration Date';
export let resourceType: string | 'key' | 'token' | undefined = 'key';

function initExpirationSelect() {
if (value === null || !isValidDate(value)) return null;
Expand All @@ -65,6 +68,10 @@
}
let expirationSelect = initExpirationSelect();
let expirationCustom: string | null = value ?? null;
$: helper =
expirationSelect !== 'custom' && expirationSelect !== null
? `Your ${resourceType} will expire in ${toLocaleDate(value)}`
: null;

$: {
if (!isSameDay(new Date(expirationSelect), new Date(value))) {
Expand All @@ -73,13 +80,8 @@
}
</script>

<InputSelect bind:value={expirationSelect} {options} id="preset" label="Expiration date">
<svelte:fragment slot="helper">
{#if expirationSelect !== 'custom' && expirationSelect !== null}
<Helper type="neutral">Your key will expire in {toLocaleDate(value)}</Helper>
{/if}
</svelte:fragment>
<InputSelect bind:value={expirationSelect} {options} id="preset" label={selectorLabel} {helper}>
</InputSelect>
{#if expirationSelect === 'custom'}
<InputDateTime required id="expire" label="" bind:value={expirationCustom} />
<InputDateTime required id="expire" label={dateSelectorLabel} bind:value={expirationCustom} />
{/if}
1 change: 1 addition & 0 deletions src/lib/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,4 @@ export { default as BottomSheet } from './bottom-sheet/index';
export { default as Confirm } from './confirm.svelte';
export { default as UsageCard } from './usageCard.svelte';
export { default as ViewToggle } from './viewToggle.svelte';
export { default as ExpirationInput } from './expirationInput.svelte';
46 changes: 34 additions & 12 deletions src/lib/components/permissions/actions.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -12,38 +12,60 @@
export let showTeam: boolean;
export let showLabel: boolean;
export let showCustom: boolean;
export let hideOnClick: boolean = false;
export let groups: Writable<Map<string, Permission>>;

const dispatch = createEventDispatcher();
</script>

<Popover let:toggle padding="none" placement="bottom-start">
<slot {toggle} />
<svelte:fragment slot="tooltip">
<svelte:fragment slot="tooltip" let:hide>
<ActionMenu.Root>
<ActionMenu.Item.Button
disabled={$groups.has('any')}
on:click={() => dispatch('create', ['any'])}>
on:click={(e) => {
if (hideOnClick) hide(e);
dispatch('create', ['any']);
}}>
Any
</ActionMenu.Item.Button>
<ActionMenu.Item.Button
disabled={$groups.has('guests')}
on:click={() => dispatch('create', ['guests'])}>
on:click={(e) => {
if (hideOnClick) hide(e);
dispatch('create', ['guests']);
}}>
All guests
</ActionMenu.Item.Button>
<ActionMenu.Item.Button
disabled={$groups.has('users')}
on:click={() => dispatch('create', ['users'])}>
on:click={(e) => {
if (hideOnClick) hide(e);
dispatch('create', ['users']);
}}>
All users
</ActionMenu.Item.Button>
<ActionMenu.Item.Button on:click={() => (showUser = true)}
>Select users</ActionMenu.Item.Button>
<ActionMenu.Item.Button on:click={() => (showTeam = true)}
>Select teams</ActionMenu.Item.Button>
<ActionMenu.Item.Button on:click={() => (showLabel = true)}
>Label</ActionMenu.Item.Button>
<ActionMenu.Item.Button on:click={() => (showCustom = true)}
>Custom permission</ActionMenu.Item.Button>
<ActionMenu.Item.Button
on:click={(e) => {
showUser = true;
if (hideOnClick) hide(e);
}}>Select users</ActionMenu.Item.Button>
<ActionMenu.Item.Button
on:click={(e) => {
showTeam = true;
if (hideOnClick) hide(e);
}}>Select teams</ActionMenu.Item.Button>
<ActionMenu.Item.Button
on:click={(e) => {
showLabel = true;
if (hideOnClick) hide(e);
}}>Label</ActionMenu.Item.Button>
<ActionMenu.Item.Button
on:click={(e) => {
showCustom = true;
if (hideOnClick) hide(e);
}}>Custom permission</ActionMenu.Item.Button>
</ActionMenu.Root>
</svelte:fragment>
</Popover>
Expand Down
13 changes: 8 additions & 5 deletions src/lib/components/permissions/permissions.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import type { PinkColumn } from '$lib/helpers/types';

export let withCreate = false;
export let hideOnClick = false;
export let permissions: string[] = [];

let showUser = false;
Expand Down Expand Up @@ -127,11 +128,11 @@
}

const columns: PinkColumn[] = [
{ id: 'role', width: { min: 100 } },
{ id: 'create', width: { min: 100 }, hide: !withCreate },
{ id: 'read', width: { min: 100 } },
{ id: 'update', width: { min: 100 } },
{ id: 'delete', width: { min: 100 } },
{ id: 'role', width: { min: 80 } },
{ id: 'create', width: { min: 80 }, hide: !withCreate },
{ id: 'read', width: { min: 80 } },
{ id: 'update', width: { min: 80 } },
{ id: 'delete', width: { min: 80 } },
{ id: 'action', width: 40 }
];
</script>
Expand Down Expand Up @@ -195,6 +196,7 @@
bind:showTeam
bind:showUser
{groups}
{hideOnClick}
on:create={create}
let:toggle>
<Button secondary on:click={toggle}>
Expand All @@ -213,6 +215,7 @@
bind:showTeam
bind:showUser
{groups}
{hideOnClick}
on:create={create}
let:toggle>
<Button compact icon on:click={toggle}>
Expand Down
1 change: 1 addition & 0 deletions src/lib/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export enum Dependencies {
DOCUMENTS = 'dependency:documents',
BUCKET = 'dependency:bucket',
FILE = 'dependency:file',
FILE_TOKENS = 'dependency:file_tokens',
FILES = 'dependency:files',
FUNCTION = 'dependency:function',
FUNCTION_DOMAINS = 'dependency:function_domains',
Expand Down
77 changes: 40 additions & 37 deletions src/lib/elements/forms/inputDateTime.svelte
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
<script lang="ts">
import { Input } from '@appwrite.io/pink-svelte';
import { onMount } from 'svelte';
import { Input, Layout, Selector } from '@appwrite.io/pink-svelte';

export let label: string = undefined;
export let id: string;
export let name: string = id;
export let helper: string = undefined;
export let value = '';
export let placeholder = '';
export let label: string;
export let value: string;
export let required = false;
export let nullable = false;
export let disabled = false;
Expand All @@ -16,43 +14,48 @@
export let step: number | 'any' = 0.001;

let error: string;
let element: HTMLInputElement;

function handleInvalid(event: Event) {
event.preventDefault();

const inputNode = event.currentTarget as HTMLInputElement;

if (inputNode.validity.valueMissing) {
error = 'This field is required';
return;
onMount(() => {
if (element && autofocus) {
element.focus();
}
});

let prevValue = '';
function handleNullChange(e: CustomEvent<boolean>) {
const isNull = e.detail;
if (isNull) {
prevValue = value;
value = null;
} else {
value = prevValue;
}

error = inputNode.validationMessage;
}

$: if (value) {
error = null;
}
</script>

<Input.DateTime
{id}
{name}
{placeholder}
{disabled}
{required}
{label}
{step}
{nullable}
{readonly}
autofocus={autofocus || undefined}
autocomplete={autocomplete ? 'on' : 'off'}
helper={error || helper}
state={error ? 'error' : 'default'}
on:invalid={handleInvalid}
on:input
bind:value>
<slot name="start" slot="start" />
<slot name="info" slot="info" />
<slot name="end" slot="end" />
</Input.DateTime>
<Layout.Stack gap="s" direction="row">
<Input.DateTime
{id}
{label}
{disabled}
{readonly}
{required}
{value}
{step}
helper={error}
autocomplete={autocomplete ? 'on' : 'off'}>
{#if nullable}
<Selector.Checkbox
size="s"
slot="end"
label="NULL"
checked={value === null}
on:change={handleNullChange} />
{/if}
</Input.DateTime>
</Layout.Stack>
3 changes: 2 additions & 1 deletion src/lib/elements/forms/inputSelect.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
export let id: string;
export let label: string | undefined = undefined;
export let value: string | number | boolean | null;
export let helper: string | undefined = undefined;
export let optionalText: string | number | boolean | null | undefined = undefined;
export let placeholder = '';
export let required = false;
Expand Down Expand Up @@ -54,8 +55,8 @@
{placeholder}
{disabled}
{isSearchable}
helper={error ?? helper}
{required}
helper={error}
state={error ? 'error' : 'default'}
on:invalid={handleInvalid}
on:input
Expand Down
10 changes: 8 additions & 2 deletions src/lib/helpers/date.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,17 @@ if (browser) {
dayjs.extend(relativeTime);
}

export const toLocaleDate = (datetime: string) => {
export const toLocaleDate = (datetime: string, format: 'dd mm yyyy' | 'default' = 'default') => {
const date = new Date(datetime);

if (isNaN(date.getTime())) {
return 'n/a';
}

if (format === 'dd mm yyyy') {
return `${date.getDate().toString().padStart(2, '0')} ${date.toLocaleString('en', { month: 'short' })} ${date.getFullYear()}`;
}

const options: Intl.DateTimeFormatOptions = {
year: 'numeric',
month: 'short',
Expand All @@ -33,6 +37,7 @@ export const toLocaleDate = (datetime: string) => {

export const toLocaleDateTime = (
datetime: string | number,
is12HourFormat: boolean = false,
timeZone: string | undefined = undefined
) => {
const date = new Date(datetime);
Expand All @@ -48,7 +53,8 @@ export const toLocaleDateTime = (
day: 'numeric',
hour: 'numeric',
minute: 'numeric',
hourCycle: 'h23'
hourCycle: is12HourFormat ? 'h12' : 'h23',
...(is12HourFormat && { hour12: true })
};

return date.toLocaleDateString('en', options);
Expand Down
4 changes: 3 additions & 1 deletion src/lib/stores/sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ import {
Teams,
Users,
Vcs,
Sites
Sites,
Tokens
} from '@appwrite.io/console';
import { Billing } from '../sdk/billing';
import { Backups } from '../sdk/backups';
Expand Down Expand Up @@ -56,6 +57,7 @@ const sdkForProject = {
project: new Project(clientProject),
projectApi: new ProjectApi(clientProject),
storage: new Storage(clientProject),
tokens: new Tokens(clientProject),
teams: new Teams(clientProject),
users: new Users(clientProject),
vcs: new Vcs(clientProject),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,14 @@
<svelte:fragment slot="title">Reset email template?</svelte:fragment>

<Layout.Stack>
<p class="text">
Are you sure you want to reset the email template?
<b>Default values will be set in all inputs.</b>
</p>
<p class="text">
Are you sure you want to reset the email template?
<b>Default values will be set in all inputs.</b>
</p>

{#if error}
<Alert.Inline status="warning">{error}</Alert.Inline>
{/if}
{#if error}
<Alert.Inline status="warning">{error}</Alert.Inline>
{/if}
</Layout.Stack>

<svelte:fragment slot="footer">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import { sdk } from '$lib/stores/sdk';
import { Alert } from '@appwrite.io/pink-svelte';
import { project } from '../../../store';
import ExpirationInput from '../expirationInput.svelte';
import { ExpirationInput } from '$lib/components';
import { key } from './store';

let expiration = $key.expire;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import { InputText } from '$lib/elements/forms/index.js';
import { Wizard } from '$lib/layout';
import { Fieldset, Layout, Typography } from '@appwrite.io/pink-svelte';
import ExpirationInput from '../expirationInput.svelte';
import { ExpirationInput } from '$lib/components';
import Scopes from '../scopes.svelte';
import Button from '$lib/elements/forms/button.svelte';
import Form from '$lib/elements/forms/form.svelte';
Expand Down
Loading
Loading