Merge pull request #330 from appwrite/feat-team-prefs

feat: team preferences
This commit is contained in:
Torsten Dittmann
2023-03-27 14:13:13 +02:00
committed by GitHub
134 changed files with 398 additions and 244 deletions
+10 -11
View File
@@ -6,11 +6,10 @@
"packages": {
"": {
"name": "@appwrite/console",
"version": "0.0.1",
"dependencies": {
"@analytics/google-analytics": "^1.0.5",
"@appwrite.io/console": "0.1.0-preview-0.0",
"@appwrite.io/pink": "0.0.6-rc.2",
"@aw-labs/appwrite-console": "^13.1.0",
"@popperjs/core": "^2.11.6",
"@sentry/svelte": "^7.44.2",
"@sentry/tracing": "^7.44.2",
@@ -147,6 +146,15 @@
"resolved": "https://registry.npmjs.org/@analytics/type-utils/-/type-utils-0.6.0.tgz",
"integrity": "sha512-1Yw7u/COtxx06BfwlI+kVhsa/upKYzmCNrT4c8QDeCY2KMYlnijkUjtHiPU08HxyTIVB5j6d75O0YWVIHwQS8g=="
},
"node_modules/@appwrite.io/console": {
"version": "0.1.0-preview-0.0",
"resolved": "https://registry.npmjs.org/@appwrite.io/console/-/console-0.1.0-preview-0.0.tgz",
"integrity": "sha512-ROCZICle2N/76UMXRm40fIDhjPrxplqa8SCuiCSDu68P4x54lybOw/8ecpwHspq/yIxlQ5LYsyJ4U8Fw76JyIg==",
"dependencies": {
"cross-fetch": "3.1.5",
"isomorphic-form-data": "2.0.0"
}
},
"node_modules/@appwrite.io/pink": {
"version": "0.0.6-rc.2",
"resolved": "https://registry.npmjs.org/@appwrite.io/pink/-/pink-0.0.6-rc.2.tgz",
@@ -162,15 +170,6 @@
"resolved": "https://registry.npmjs.org/@appwrite.io/pink-icons/-/pink-icons-0.0.5.tgz",
"integrity": "sha512-Ej9usq4C9pwrqCvSNvRnFJ1jPF1+iXq2+edBbuttF1f30jFlOXol/Z7gkDR1ofwtWUBFs2X+181dIPLJHICq+A=="
},
"node_modules/@aw-labs/appwrite-console": {
"version": "13.1.0",
"resolved": "https://registry.npmjs.org/@aw-labs/appwrite-console/-/appwrite-console-13.1.0.tgz",
"integrity": "sha512-1FyKke5b3vx+D3VfNYd3YnFhzUOlsj9bD+KTRLWA4WRItb55thFVZJMWQQ4XnZtDiLPuJAn2XjbMSfMr+9XYwg==",
"dependencies": {
"cross-fetch": "3.1.5",
"isomorphic-form-data": "2.0.0"
}
},
"node_modules/@babel/code-frame": {
"version": "7.18.6",
"resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.18.6.tgz",
+1 -1
View File
@@ -19,8 +19,8 @@
},
"dependencies": {
"@analytics/google-analytics": "^1.0.5",
"@appwrite.io/console": "0.1.0-preview-0.0",
"@appwrite.io/pink": "0.0.6-rc.2",
"@aw-labs/appwrite-console": "^13.1.0",
"@popperjs/core": "^2.11.6",
"@sentry/svelte": "^7.44.2",
"@sentry/tracing": "^7.44.2",
+1 -1
View File
@@ -2,7 +2,7 @@ import { page } from '$app/stores';
import { user } from '$lib/stores/user';
import { ENV, MODE, VARS } from '$lib/system';
import googleAnalytics from '@analytics/google-analytics';
import { AppwriteException } from '@aw-labs/appwrite-console';
import { AppwriteException } from '@appwrite.io/console';
import Analytics from 'analytics';
import { get } from 'svelte/store';
+4 -2
View File
@@ -1,7 +1,7 @@
<script lang="ts">
import { tooltip } from '$lib/actions/tooltip';
import { sdk } from '$lib/stores/sdk';
import type { Models } from '@aw-labs/appwrite-console';
import type { Models } from '@appwrite.io/console';
import { tick } from 'svelte';
import { AvatarInitials } from '../';
import Output from '../output.svelte';
@@ -14,7 +14,9 @@
async function getData(
permission: string
): Promise<Partial<Models.User<Record<string, unknown>> & Models.Team>> {
): Promise<
Partial<Models.User<Record<string, unknown>> & Models.Team<Record<string, unknown>>>
> {
const role = permission.split(':')[0];
const id = permission.split(':')[1].split('/')[0];
if (role === 'user') {
+2 -2
View File
@@ -2,7 +2,7 @@
import { Button, InputSearch } from '$lib/elements/forms';
import { createEventDispatcher } from 'svelte';
import { sdk } from '$lib/stores/sdk';
import { Query, type Models } from '@aw-labs/appwrite-console';
import { Query, type Models } from '@appwrite.io/console';
import { AvatarInitials, EmptySearch, Modal, PaginationInline } from '..';
import type { Writable } from 'svelte/store';
import type { Permission } from './permissions.svelte';
@@ -14,7 +14,7 @@
let search = '';
let offset = 0;
let results: Models.TeamList;
let results: Models.TeamList<Record<string, unknown>>;
let selected: Set<string> = new Set();
let hasSelection = false;
+1 -1
View File
@@ -3,7 +3,7 @@
import { createEventDispatcher } from 'svelte';
import { AvatarInitials, EmptySearch, Modal, PaginationInline } from '..';
import { sdk } from '$lib/stores/sdk';
import { Query, type Models } from '@aw-labs/appwrite-console';
import { Query, type Models } from '@appwrite.io/console';
import type { Writable } from 'svelte/store';
import type { Permission } from './permissions.svelte';
+1 -1
View File
@@ -11,7 +11,7 @@
} from '$lib/elements/table';
import { Container } from '$lib/layout';
import { toLocaleDateTime } from '$lib/helpers/date';
import type { Models } from '@aw-labs/appwrite-console';
import type { Models } from '@appwrite.io/console';
export let logs: Models.LogList;
export let offset = 0;
+1 -1
View File
@@ -9,7 +9,7 @@
import { sdk } from '$lib/stores/sdk';
import { page } from '$app/stores';
import { calculateTime } from '$lib/helpers/timeConversion';
import type { Models } from '@aw-labs/appwrite-console';
import type { Models } from '@appwrite.io/console';
let selectedTab: string;
let rawData: string;
+1 -1
View File
@@ -16,7 +16,7 @@
import { BarChart, LineChart } from '$lib/charts';
import { Card, SecondaryTabs, SecondaryTabsItem, Heading, Tiles } from '$lib/components';
import { Colors } from '$lib/charts/config';
import type { Models } from '@aw-labs/appwrite-console';
import type { Models } from '@appwrite.io/console';
import { page } from '$app/stores';
type MetricMetadata = {
+1 -1
View File
@@ -1,4 +1,4 @@
import type { Models, Payload } from '@aw-labs/appwrite-console';
import type { Models, Payload } from '@appwrite.io/console';
import { Service } from './service';
export class Project extends Service {
+1 -1
View File
@@ -1,4 +1,4 @@
import type { Client, Payload } from '@aw-labs/appwrite-console';
import type { Client, Payload } from '@appwrite.io/console';
export class Service {
static CHUNK_SIZE = 5 * 1024 * 1024; // 5MB
+1 -1
View File
@@ -1,5 +1,5 @@
import { writable } from 'svelte/store';
import type { Models } from '@aw-labs/appwrite-console';
import type { Models } from '@appwrite.io/console';
export type AuthMethod = {
label: string;
+1 -1
View File
@@ -1,4 +1,4 @@
import type { Models } from '@aw-labs/appwrite-console';
import type { Models } from '@appwrite.io/console';
import { writable } from 'svelte/store';
export const log = writable<{
+1 -1
View File
@@ -1,5 +1,5 @@
import { writable } from 'svelte/store';
import type { Models } from '@aw-labs/appwrite-console';
import type { Models } from '@appwrite.io/console';
import type { SvelteComponent } from 'svelte';
import Apple from '../../routes/console/project-[project]/auth/appleOAuth.svelte';
import Microsoft from '../../routes/console/project-[project]/auth/microsoftOAuth.svelte';
+6 -3
View File
@@ -1,12 +1,15 @@
import { page } from '$app/stores';
import { derived, writable } from 'svelte/store';
import type { Models } from '@aw-labs/appwrite-console';
import type { Models } from '@appwrite.io/console';
export const newOrgModal = writable<boolean>(false);
export const newMemberModal = writable<boolean>(false);
export const organizationList = derived(
page,
($page) => $page.data.organizations as Models.TeamList
($page) => $page.data.organizations as Models.TeamList<Record<string, unknown>>
);
export const organization = derived(
page,
($page) => $page.data?.organization as Models.Team<Record<string, unknown>>
);
export const organization = derived(page, ($page) => $page.data.organization as Models.Team);
export const members = derived(page, ($page) => $page.data.members as Models.MembershipList);
+1 -1
View File
@@ -1,5 +1,5 @@
import { writable } from 'svelte/store';
import type { Models } from '@aw-labs/appwrite-console';
import type { Models } from '@appwrite.io/console';
export type Service = {
label: string;
+1 -1
View File
@@ -1,4 +1,4 @@
import type { Models } from '@aw-labs/appwrite-console';
import type { Models } from '@appwrite.io/console';
import { writable } from 'svelte/store';
export const user = writable<Models.User<Record<string, unknown>>>();
+1 -1
View File
@@ -13,7 +13,7 @@ import {
Storage,
Teams,
Users
} from '@aw-labs/appwrite-console';
} from '@appwrite.io/console';
const endpoint = VARS.APPWRITE_ENDPOINT ?? `${globalThis?.location?.origin}/v1`;
+1 -1
View File
@@ -1,4 +1,4 @@
import type { Models } from '@aw-labs/appwrite-console';
import type { Models } from '@appwrite.io/console';
import { writable } from 'svelte/store';
import { sdk } from './sdk';
+1 -1
View File
@@ -1,6 +1,6 @@
import { page } from '$app/stores';
import { derived } from 'svelte/store';
import type { Models } from '@aw-labs/appwrite-console';
import type { Models } from '@appwrite.io/console';
export const user = derived(
page,
+1 -1
View File
@@ -2,7 +2,7 @@
import { goto } from '$app/navigation';
import { page } from '$app/stores';
import { Heading } from '$lib/components';
import { Account, Client } from '@aw-labs/appwrite-console';
import { Account, Client } from '@appwrite.io/console';
import { onMount } from 'svelte';
const client = new Client();
+1 -1
View File
@@ -1,4 +1,4 @@
import { Query } from '@aw-labs/appwrite-console';
import { Query } from '@appwrite.io/console';
import { sdk } from '$lib/stores/sdk';
import { getLimit, getPage, pageToOffset } from '$lib/helpers/load';
import { PAGE_LIMIT } from '$lib/constants';
@@ -1,4 +1,4 @@
import { Query } from '@aw-labs/appwrite-console';
import { Query } from '@appwrite.io/console';
import { sdk } from '$lib/stores/sdk';
import { getLimit, getPage, pageToOffset } from '$lib/helpers/load';
import { CARD_LIMIT } from '$lib/constants';
@@ -15,7 +15,7 @@
import { sdk } from '$lib/stores/sdk';
import { goto, invalidate } from '$app/navigation';
import { Dependencies } from '$lib/constants';
import type { Models } from '@aw-labs/appwrite-console';
import type { Models } from '@appwrite.io/console';
import type { PageData } from './$types';
import { Submit, trackEvent } from '$lib/actions/analytics';
import { base } from '$app/paths';
+1 -1
View File
@@ -8,7 +8,7 @@
import { goto, invalidate } from '$app/navigation';
import { Dependencies } from '$lib/constants';
import { Submit, trackEvent, trackError } from '$lib/actions/analytics';
import { ID } from '@aw-labs/appwrite-console';
import { ID } from '@appwrite.io/console';
export let show = false;
+1 -1
View File
@@ -10,7 +10,7 @@
import { Container } from '$lib/layout';
import { addNotification } from '$lib/stores/notifications';
import { sdk } from '$lib/stores/sdk';
import { ID } from '@aw-labs/appwrite-console';
import { ID } from '@appwrite.io/console';
let name: string;
let id: string;
@@ -1,4 +1,4 @@
import { Query } from '@aw-labs/appwrite-console';
import { Query } from '@appwrite.io/console';
import { sdk } from '$lib/stores/sdk';
import { getLimit, getPage, pageToOffset } from '$lib/helpers/load';
import { CARD_LIMIT } from '$lib/constants';
@@ -21,9 +21,11 @@
try {
const team = await sdk.forConsole.teams.createMembership(
$organization.$id,
email,
['owner'],
url,
email,
undefined,
undefined,
name
);
invalidate(Dependencies.ACCOUNT);
@@ -6,7 +6,7 @@
import { InputText, Button, FormList } from '$lib/elements/forms';
import { addNotification } from '$lib/stores/notifications';
import { sdk } from '$lib/stores/sdk';
import { ID } from '@aw-labs/appwrite-console';
import { ID } from '@appwrite.io/console';
import { createEventDispatcher } from 'svelte';
export let show = false;
@@ -5,7 +5,7 @@
import { Button } from '$lib/elements/forms';
import { addNotification } from '$lib/stores/notifications';
import { sdk } from '$lib/stores/sdk';
import type { Models } from '@aw-labs/appwrite-console';
import type { Models } from '@appwrite.io/console';
import { createEventDispatcher } from 'svelte';
import { user } from '$lib/stores/user';
import { Submit, trackEvent, trackError } from '$lib/actions/analytics';
@@ -19,7 +19,7 @@
import { addNotification } from '$lib/stores/notifications';
import { members, newMemberModal, organization } from '$lib/stores/organization';
import { sdk } from '$lib/stores/sdk';
import type { Models } from '@aw-labs/appwrite-console';
import type { Models } from '@appwrite.io/console';
import type { PageData } from './$types';
import Delete from '../deleteMember.svelte';
@@ -33,9 +33,11 @@
try {
await sdk.forConsole.teams.createMembership(
$organization.$id,
member.userEmail,
member.roles,
url,
member.userEmail,
undefined,
undefined,
member.userName
);
addNotification({
@@ -1,7 +1,7 @@
import { PAGE_LIMIT } from '$lib/constants';
import { getLimit, getPage, pageToOffset } from '$lib/helpers/load';
import { sdk } from '$lib/stores/sdk';
import { Query } from '@aw-labs/appwrite-console';
import { Query } from '@appwrite.io/console';
import type { PageLoad } from './$types';
export const load: PageLoad = async ({ url, params, route }) => {
@@ -20,7 +20,7 @@
async function updateName() {
try {
await sdk.forConsole.teams.update($organization.$id, name);
await sdk.forConsole.teams.updateName($organization.$id, name);
await invalidate(Dependencies.ORGANIZATION);
addNotification({
message: 'Name has been updated',
@@ -1,13 +1,11 @@
<script lang="ts">
import { UploadBox } from '$lib/components';
import { sdk } from '$lib/stores/sdk';
import { onDestroy, onMount } from 'svelte';
import { onMount } from 'svelte';
import { stats } from './store';
let unsubscribe: { (): void };
onMount(() => {
unsubscribe = sdk.forConsole.client.subscribe(['project', 'console'], (response) => {
onMount(async () => {
return sdk.forConsole.client.subscribe(['project', 'console'], (response) => {
if (response.events.includes('stats.connections')) {
for (const [projectId, value] of Object.entries(response.payload)) {
stats.add(projectId, [new Date(response.timestamp).toISOString(), value]);
@@ -15,12 +13,6 @@
}
});
});
onDestroy(() => {
if (unsubscribe) {
unsubscribe();
}
});
</script>
<slot />
@@ -25,7 +25,7 @@
import { base } from '$app/paths';
import { goto } from '$app/navigation';
import Create from './createUser.svelte';
import type { Models } from '@aw-labs/appwrite-console';
import type { Models } from '@appwrite.io/console';
import type { PageData } from './$types';
export let data: PageData;
@@ -1,4 +1,4 @@
import { Query } from '@aw-labs/appwrite-console';
import { Query } from '@appwrite.io/console';
import { sdk } from '$lib/stores/sdk';
import { getLimit, getPage, getSearch, pageToOffset } from '$lib/helpers/load';
import { PAGE_LIMIT } from '$lib/constants';
@@ -5,7 +5,7 @@
import { InputText, Button, FormList } from '$lib/elements/forms';
import { addNotification } from '$lib/stores/notifications';
import { sdk } from '$lib/stores/sdk';
import { ID } from '@aw-labs/appwrite-console';
import { ID } from '@appwrite.io/console';
import { createEventDispatcher } from 'svelte';
export let showCreate = false;
@@ -12,7 +12,7 @@
} from '$lib/elements/forms';
import { addNotification } from '$lib/stores/notifications';
import { sdk } from '$lib/stores/sdk';
import { ID } from '@aw-labs/appwrite-console';
import { ID } from '@appwrite.io/console';
import { createEventDispatcher } from 'svelte';
export let showCreate = false;
@@ -23,7 +23,7 @@
import { toLocaleDateTime } from '$lib/helpers/date';
import { Container } from '$lib/layout';
import { base } from '$app/paths';
import type { Models } from '@aw-labs/appwrite-console';
import type { Models } from '@appwrite.io/console';
import type { PageData } from './$types';
export let data: PageData;
@@ -31,7 +31,7 @@
let showCreate = false;
const project = $page.params.project;
const teamCreated = async (event: CustomEvent<Models.Team>) => {
const teamCreated = async (event: CustomEvent<Models.Team<Record<string, unknown>>>) => {
await goto(`${base}/console/project-${project}/auth/teams/team-${event.detail.$id}`);
};
</script>
@@ -1,4 +1,4 @@
import { Query } from '@aw-labs/appwrite-console';
import { Query } from '@appwrite.io/console';
import { sdk } from '$lib/stores/sdk';
import { getLimit, getPage, getSearch, pageToOffset } from '$lib/helpers/load';
import { PAGE_LIMIT } from '$lib/constants';
@@ -1,42 +1,11 @@
<script lang="ts">
import { onMount } from 'svelte';
import { page } from '$app/stores';
import { CardGrid, Box, Heading, AvatarInitials } from '$lib/components';
import { CardGrid, Heading, AvatarInitials } from '$lib/components';
import { Container } from '$lib/layout';
import { Button, InputText, Form } from '$lib/elements/forms';
import { sdk } from '$lib/stores/sdk';
import { toLocaleDateTime } from '$lib/helpers/date';
import { addNotification } from '$lib/stores/notifications';
import { team } from './store';
import { Dependencies } from '$lib/constants';
import { invalidate } from '$app/navigation';
import DeleteTeam from './deleteTeam.svelte';
import { Submit, trackEvent, trackError } from '$lib/actions/analytics';
let showDelete = false;
let teamName: string = null;
onMount(async () => {
teamName ??= $team.name;
});
async function updateName() {
try {
await sdk.forProject.teams.update($page.params.team, teamName);
invalidate(Dependencies.TEAM);
addNotification({
message: 'Name has been updated',
type: 'success'
});
trackEvent(Submit.TeamUpdateName);
} catch (error) {
addNotification({
message: error.message,
type: 'error'
});
trackError(error, Submit.TeamUpdateName);
}
}
import UpdatePrefs from './updatePrefs.svelte';
import UpdateName from './updateName.svelte';
import DangerZone from './dangerZone.svelte';
</script>
<Container>
@@ -54,54 +23,7 @@
</div>
</svelte:fragment>
</CardGrid>
<Form onSubmit={updateName}>
<CardGrid>
<Heading tag="h6" size="7">Name</Heading>
<svelte:fragment slot="aside">
<ul>
<InputText
id="name"
label="Name"
placeholder="Enter team name"
autocomplete={false}
bind:value={teamName} />
</ul>
</svelte:fragment>
<svelte:fragment slot="actions">
<Button submit disabled={teamName === $team.name || !teamName}>Update</Button>
</svelte:fragment>
</CardGrid>
</Form>
<CardGrid danger>
<div>
<Heading tag="h6" size="7">Delete Team</Heading>
</div>
<p>
The team will be permanently deleted, including all data associated with this team. This
action is irreversible.
</p>
<svelte:fragment slot="aside">
<Box>
<svelte:fragment slot="image">
<AvatarInitials size={48} name={$team.name} />
</svelte:fragment>
<svelte:fragment slot="title">
<h6 class="u-bold u-trim-1">{$team.name}</h6>
<span>{$team.total} Members</span>
</svelte:fragment>
</Box>
</svelte:fragment>
<svelte:fragment slot="actions">
<Button secondary on:click={() => (showDelete = true)} event="delete_team">
Delete
</Button>
</svelte:fragment>
</CardGrid>
<UpdateName />
<UpdatePrefs />
<DangerZone />
</Container>
<DeleteTeam team={$team} bind:showDelete />
@@ -1,4 +1,4 @@
import { Query } from '@aw-labs/appwrite-console';
import { Query } from '@appwrite.io/console';
import { sdk } from '$lib/stores/sdk';
import { getLimit, getPage, pageToOffset } from '$lib/helpers/load';
import { PAGE_LIMIT } from '$lib/constants';
@@ -21,9 +21,11 @@
try {
const user = await sdk.forProject.teams.createMembership(
teamId,
email,
roles,
url,
email,
undefined,
undefined,
name
);
addNotification({
@@ -0,0 +1,35 @@
<script lang="ts">
import { AvatarInitials, Box, CardGrid, Heading } from '$lib/components';
import { Button } from '$lib/elements/forms';
import DeleteTeam from './deleteTeam.svelte';
import { team } from './store';
let showDelete = false;
</script>
<CardGrid danger>
<div>
<Heading tag="h6" size="7">Delete Team</Heading>
</div>
<p>
The team will be permanently deleted, including all data associated with this team. This
action is irreversible.
</p>
<svelte:fragment slot="aside">
<Box>
<svelte:fragment slot="image">
<AvatarInitials size={48} name={$team.name} />
</svelte:fragment>
<svelte:fragment slot="title">
<h6 class="u-bold u-trim-1">{$team.name}</h6>
<span>{$team.total} Members</span>
</svelte:fragment>
</Box>
</svelte:fragment>
<svelte:fragment slot="actions">
<Button secondary on:click={() => (showDelete = true)} event="delete_team">Delete</Button>
</svelte:fragment>
</CardGrid>
<DeleteTeam team={$team} bind:showDelete />
@@ -7,7 +7,7 @@
import { Button } from '$lib/elements/forms';
import { addNotification } from '$lib/stores/notifications';
import { sdk } from '$lib/stores/sdk';
import type { Models } from '@aw-labs/appwrite-console';
import type { Models } from '@appwrite.io/console';
import { createEventDispatcher } from 'svelte';
const dispatch = createEventDispatcher();
@@ -7,10 +7,10 @@
import { Button } from '$lib/elements/forms';
import { addNotification } from '$lib/stores/notifications';
import { sdk } from '$lib/stores/sdk';
import type { Models } from '@aw-labs/appwrite-console';
import type { Models } from '@appwrite.io/console';
export let showDelete = false;
export let team: Models.Team;
export let team: Models.Team<Record<string, unknown>>;
const deleteTeam = async () => {
try {
@@ -19,7 +19,7 @@
} from '$lib/elements/table';
import { Button } from '$lib/elements/forms';
import { Container } from '$lib/layout';
import type { Models } from '@aw-labs/appwrite-console';
import type { Models } from '@appwrite.io/console';
import { invalidate } from '$app/navigation';
import { base } from '$app/paths';
import { toLocaleDateTime } from '$lib/helpers/date';
@@ -1,4 +1,4 @@
import { Query } from '@aw-labs/appwrite-console';
import { Query } from '@appwrite.io/console';
import { sdk } from '$lib/stores/sdk';
import { getLimit, getPage, getSearch, pageToOffset } from '$lib/helpers/load';
import { Dependencies, PAGE_LIMIT } from '$lib/constants';
@@ -1,5 +1,8 @@
import { derived } from 'svelte/store';
import { page } from '$app/stores';
import type { Models } from '@aw-labs/appwrite-console';
import type { Models } from '@appwrite.io/console';
export const team = derived(page, ($page) => $page.data.team as Models.Team);
export const team = derived(
page,
($page) => $page.data.team as Models.Team<Record<string, unknown>>
);
@@ -0,0 +1,57 @@
<script lang="ts">
import { invalidate } from '$app/navigation';
import { page } from '$app/stores';
import { Submit, trackError, trackEvent } from '$lib/actions/analytics';
import { CardGrid, Heading } from '$lib/components';
import { Dependencies } from '$lib/constants';
import { Button, Form, InputText } from '$lib/elements/forms';
import { addNotification } from '$lib/stores/notifications';
import { sdk } from '$lib/stores/sdk';
import { onMount } from 'svelte';
import { team } from './store';
let teamName: string = null;
onMount(async () => {
teamName ??= $team.name;
});
async function updateName() {
try {
await sdk.forProject.teams.updateName($page.params.team, teamName);
invalidate(Dependencies.TEAM);
addNotification({
message: 'Name has been updated',
type: 'success'
});
trackEvent(Submit.TeamUpdateName);
} catch (error) {
addNotification({
message: error.message,
type: 'error'
});
trackError(error, Submit.TeamUpdateName);
}
}
</script>
<Form onSubmit={updateName}>
<CardGrid>
<Heading tag="h6" size="7">Name</Heading>
<svelte:fragment slot="aside">
<ul>
<InputText
id="name"
label="Name"
placeholder="Enter team name"
autocomplete={false}
bind:value={teamName} />
</ul>
</svelte:fragment>
<svelte:fragment slot="actions">
<Button submit disabled={teamName === $team.name || !teamName}>Update</Button>
</svelte:fragment>
</CardGrid>
</Form>
@@ -0,0 +1,135 @@
<script lang="ts">
import { invalidate } from '$app/navigation';
import { Submit, trackEvent, trackError } from '$lib/actions/analytics';
import { CardGrid, Heading } from '$lib/components';
import { Dependencies } from '$lib/constants';
import { Button, Form } from '$lib/elements/forms';
import { addNotification } from '$lib/stores/notifications';
import { sdk } from '$lib/stores/sdk';
import { onMount } from 'svelte';
import { team } from './store';
$: if (prefs) {
if (JSON.stringify(prefs) !== JSON.stringify(Object.entries($team.prefs))) {
if (!!prefs[prefs.length - 1][0] && !!prefs[prefs.length - 1][1]) {
arePrefsDisabled = false;
} else {
arePrefsDisabled = true;
}
} else {
arePrefsDisabled = true;
}
}
let prefs: [string, unknown][] = null;
let arePrefsDisabled = true;
onMount(async () => {
prefs = Object.entries($team.prefs);
if (!prefs?.length) {
prefs.push(['', '']);
}
});
async function updatePrefs() {
try {
let updatedPrefs = Object.fromEntries(prefs);
await sdk.forProject.teams.updatePrefs($team.$id, updatedPrefs);
invalidate(Dependencies.TEAM);
arePrefsDisabled = true;
addNotification({
message: 'Preferences have been updated',
type: 'success'
});
trackEvent(Submit.UserUpdatePreferences);
} catch (error) {
addNotification({
message: error.message,
type: 'error'
});
trackError(error, Submit.UserUpdatePreferences);
}
}
</script>
<Form onSubmit={updatePrefs}>
<CardGrid>
<Heading tag="h6" size="7">Team Preferences</Heading>
<p>
You can update your team's preferences by storing shared information on the teams's
objects so they can easily be shared across members.
</p>
<svelte:fragment slot="aside">
<form class="form u-grid u-gap-16">
<ul class="form-list">
{#if prefs}
{#each prefs as [key, value], index}
<li class="form-item is-multiple">
<div class="form-item-part u-stretch">
<label class="label" for={`key-${index}`}>Key</label>
<div class="input-text-wrapper">
<input
id={`key-${key}`}
placeholder="Enter key"
type="text"
class="input-text"
bind:value={key} />
</div>
</div>
<div class="form-item-part u-stretch">
<label class="label" for={`value-${index}`}> Value </label>
<div class="input-text-wrapper">
<input
id={`value-${value}`}
placeholder="Enter value"
type="text"
class="input-text"
bind:value />
</div>
</div>
<div class="form-item-part u-cross-child-end">
<Button
text
disabled={(!key || !value) && index === 0}
on:click={() => {
if (index === 0) {
prefs = [['', '']];
} else {
prefs.splice(index, 1);
prefs = prefs;
}
}}>
<span class="icon-x" aria-hidden="true" />
</Button>
</div>
</li>
{/each}
{/if}
</ul>
<Button
noMargin
text
disabled={prefs?.length &&
prefs[prefs.length - 1][0] &&
prefs[prefs.length - 1][1]
? false
: true}
on:click={() => {
if (prefs[prefs.length - 1][0] && prefs[prefs.length - 1][1]) {
prefs.push(['', '']);
prefs = prefs;
}
}}>
<span class="icon-plus" aria-hidden="true" />
<span class="text">Add Preference</span>
</Button>
</form>
</svelte:fragment>
<svelte:fragment slot="actions">
<Button disabled={arePrefsDisabled} submit>Update</Button>
</svelte:fragment>
</CardGrid>
</Form>
@@ -1,4 +1,4 @@
import type { Models } from '@aw-labs/appwrite-console';
import type { Models } from '@appwrite.io/console';
import { sdk } from '$lib/stores/sdk';
import type { PageLoad } from './$types';
import { error } from '@sveltejs/kit';
@@ -1,4 +1,4 @@
import { Query } from '@aw-labs/appwrite-console';
import { Query } from '@appwrite.io/console';
import { sdk } from '$lib/stores/sdk';
import { getLimit, getPage, pageToOffset } from '$lib/helpers/load';
import { PAGE_LIMIT } from '$lib/constants';
@@ -8,7 +8,7 @@
import { Button } from '$lib/elements/forms';
import { addNotification } from '$lib/stores/notifications';
import { sdk } from '$lib/stores/sdk';
import type { Models } from '@aw-labs/appwrite-console';
import type { Models } from '@appwrite.io/console';
export let showDelete = false;
export let selectedMembership: Models.Membership;
@@ -14,7 +14,7 @@
import { Button } from '$lib/elements/forms';
import { Container } from '$lib/layout';
import DeleteMembership from '../deleteMembership.svelte';
import type { Models } from '@aw-labs/appwrite-console';
import type { Models } from '@appwrite.io/console';
import type { PageData } from './$types';
import { trackEvent } from '$lib/actions/analytics';
import { toLocaleDateTime } from '$lib/helpers/date';
@@ -1,6 +1,6 @@
import { derived } from 'svelte/store';
import { page } from '$app/stores';
import type { Models } from '@aw-labs/appwrite-console';
import type { Models } from '@appwrite.io/console';
export const user = derived(
page,
@@ -8,7 +8,7 @@
import Create from './create.svelte';
import Grid from './grid.svelte';
import Table from './table.svelte';
import type { Models } from '@aw-labs/appwrite-console';
import type { Models } from '@appwrite.io/console';
import type { PageData } from './$types';
import { columns } from './store';
@@ -1,7 +1,7 @@
import { CARD_LIMIT } from '$lib/constants';
import { getLimit, getPage, getView, pageToOffset, View } from '$lib/helpers/load';
import { sdk } from '$lib/stores/sdk';
import { Query } from '@aw-labs/appwrite-console';
import { Query } from '@appwrite.io/console';
import type { PageLoad } from './$types';
export const load: PageLoad = async ({ url, route }) => {
@@ -5,7 +5,7 @@
import { Button, InputText, FormList } from '$lib/elements/forms';
import { addNotification } from '$lib/stores/notifications';
import { sdk } from '$lib/stores/sdk';
import { ID } from '@aw-labs/appwrite-console';
import { ID } from '@appwrite.io/console';
import { createEventDispatcher } from 'svelte';
export let showCreate = false;
@@ -1,6 +1,6 @@
<script lang="ts">
import { goto, invalidate } from '$app/navigation';
import type { Models } from '@aw-labs/appwrite-console';
import type { Models } from '@appwrite.io/console';
import CreateCollection from './createCollection.svelte';
import { showCreate } from './store';
import { base } from '$app/paths';
@@ -1,4 +1,4 @@
import { Query } from '@aw-labs/appwrite-console';
import { Query } from '@appwrite.io/console';
import { sdk } from '$lib/stores/sdk';
import { getLimit, getPage, getView, pageToOffset, View } from '$lib/helpers/load';
import { CARD_LIMIT } from '$lib/constants';
@@ -5,7 +5,7 @@ import Breadcrumbs from './breadcrumbs.svelte';
import Header from './header.svelte';
import { error } from '@sveltejs/kit';
import SubNavigation from './subNavigation.svelte';
import { Query } from '@aw-labs/appwrite-console';
import { Query } from '@appwrite.io/console';
export const load: LayoutLoad = async ({ params, depends }) => {
depends(Dependencies.COLLECTION);
@@ -1,7 +1,7 @@
import { Dependencies, PAGE_LIMIT } from '$lib/constants';
import { getLimit, getPage, getView, pageToOffset, View } from '$lib/helpers/load';
import { sdk } from '$lib/stores/sdk';
import { Query } from '@aw-labs/appwrite-console';
import { Query } from '@appwrite.io/console';
import type { PageLoad } from './$types';
export const load: PageLoad = async ({ params, depends, url, route }) => {
@@ -1,4 +1,4 @@
import { Query } from '@aw-labs/appwrite-console';
import { Query } from '@appwrite.io/console';
import { sdk } from '$lib/stores/sdk';
import { getLimit, getPage, pageToOffset } from '$lib/helpers/load';
import { PAGE_LIMIT } from '$lib/constants';
@@ -1,5 +1,5 @@
<script context="module" lang="ts">
import type { Models } from '@aw-labs/appwrite-console';
import type { Models } from '@appwrite.io/console';
import { sdk } from '$lib/stores/sdk';
export async function submitBoolean(
@@ -1,5 +1,5 @@
<script context="module" lang="ts">
import type { Models } from '@aw-labs/appwrite-console';
import type { Models } from '@appwrite.io/console';
import { sdk } from '$lib/stores/sdk';
export async function submitDatetime(
@@ -1,5 +1,5 @@
<script context="module" lang="ts">
import type { Models } from '@aw-labs/appwrite-console';
import type { Models } from '@appwrite.io/console';
import { sdk } from '$lib/stores/sdk';
@@ -1,5 +1,5 @@
<script context="module" lang="ts">
import type { Models } from '@aw-labs/appwrite-console';
import type { Models } from '@appwrite.io/console';
import { sdk } from '$lib/stores/sdk';
export async function submitEnum(
@@ -1,5 +1,5 @@
<script context="module" lang="ts">
import type { Models } from '@aw-labs/appwrite-console';
import type { Models } from '@appwrite.io/console';
import { sdk } from '$lib/stores/sdk';
export async function submitFloat(
@@ -1,6 +1,6 @@
<script context="module" lang="ts">
import { sdk } from '$lib/stores/sdk';
import type { Models } from '@aw-labs/appwrite-console';
import type { Models } from '@appwrite.io/console';
export async function submitInteger(
databaseId: string,
@@ -1,5 +1,5 @@
<script context="module" lang="ts">
import type { Models } from '@aw-labs/appwrite-console';
import type { Models } from '@appwrite.io/console';
import { sdk } from '$lib/stores/sdk';
export async function submitIp(
@@ -1,5 +1,5 @@
<script context="module" lang="ts">
import type { Models } from '@aw-labs/appwrite-console';
import type { Models } from '@appwrite.io/console';
import { sdk } from '$lib/stores/sdk';
export async function submitString(
@@ -1,5 +1,5 @@
<script context="module" lang="ts">
import type { Models } from '@aw-labs/appwrite-console';
import type { Models } from '@appwrite.io/console';
import { sdk } from '$lib/stores/sdk';
export async function submitUrl(
@@ -13,7 +13,7 @@
import type { WizardStepsType } from '$lib/layout/wizard.svelte';
import { Dependencies } from '$lib/constants';
import { Submit, trackEvent, trackError } from '$lib/actions/analytics';
import { ID } from '@aw-labs/appwrite-console';
import { ID } from '@appwrite.io/console';
const databaseId = $page.params.database;
const collectionId = $page.params.collection;
@@ -1,4 +1,4 @@
import { Query } from '@aw-labs/appwrite-console';
import { Query } from '@appwrite.io/console';
import { sdk } from '$lib/stores/sdk';
import { getLimit, getPage, pageToOffset } from '$lib/helpers/load';
import { PAGE_LIMIT } from '$lib/constants';
@@ -1,5 +1,5 @@
<script lang="ts">
import type { Models } from '@aw-labs/appwrite-console';
import type { Models } from '@appwrite.io/console';
import Boolean from './attributes/boolean.svelte';
import Datetime from './attributes/datetime.svelte';
import Enum from './attributes/enum.svelte';
@@ -1,6 +1,6 @@
<script lang="ts">
import { InputCheckbox, InputSelect } from '$lib/elements/forms';
import type { Models } from '@aw-labs/appwrite-console';
import type { Models } from '@appwrite.io/console';
export let id: string;
export let label: string;
@@ -1,6 +1,6 @@
<script lang="ts">
import { InputDateTime } from '$lib/elements/forms';
import type { Models } from '@aw-labs/appwrite-console';
import type { Models } from '@appwrite.io/console';
export let id: string;
export let label: string;
@@ -1,6 +1,6 @@
<script lang="ts">
import { InputSelect } from '$lib/elements/forms';
import type { Models } from '@aw-labs/appwrite-console';
import type { Models } from '@appwrite.io/console';
export let id: string;
export let label: string;
@@ -1,6 +1,6 @@
<script lang="ts">
import { InputNumber } from '$lib/elements/forms';
import type { Models } from '@aw-labs/appwrite-console';
import type { Models } from '@appwrite.io/console';
export let id: string;
export let label: string;
@@ -1,7 +1,7 @@
<script lang="ts">
import InputText from '$lib/elements/forms/inputText.svelte';
import InputTextarea from '$lib/elements/forms/inputTextarea.svelte';
import type { Models } from '@aw-labs/appwrite-console';
import type { Models } from '@appwrite.io/console';
export let id: string;
export let label: string;
@@ -1,6 +1,6 @@
<script lang="ts">
import InputURL from '$lib/elements/forms/inputURL.svelte';
import type { Models } from '@aw-labs/appwrite-console';
import type { Models } from '@appwrite.io/console';
export let id: string;
export let label: string;
@@ -8,7 +8,7 @@
import { sdk } from '$lib/stores/sdk';
import { addNotification } from '$lib/stores/notifications';
import { writable } from 'svelte/store';
import type { Models } from '@aw-labs/appwrite-console';
import type { Models } from '@appwrite.io/console';
import { Dependencies } from '$lib/constants';
import { invalidate } from '$app/navigation';
import { Submit, trackEvent, trackError } from '$lib/actions/analytics';
@@ -1,5 +1,5 @@
import { page } from '$app/stores';
import { derived } from 'svelte/store';
import type { Models } from '@aw-labs/appwrite-console';
import type { Models } from '@appwrite.io/console';
export const doc = derived(page, ($page) => $page.data.document as Models.Document);
@@ -16,7 +16,7 @@
import Create from './createIndex.svelte';
import Overview from './overviewIndex.svelte';
import CreateAttribute from '../createAttribute.svelte';
import type { Models } from '@aw-labs/appwrite-console';
import type { Models } from '@appwrite.io/console';
import { invalidate } from '$app/navigation';
import { Dependencies } from '$lib/constants';
import { Button } from '$lib/elements/forms';
@@ -4,7 +4,7 @@
import { addNotification } from '$lib/stores/notifications';
import { collection } from '../store';
import { sdk } from '$lib/stores/sdk';
import type { Models } from '@aw-labs/appwrite-console';
import type { Models } from '@appwrite.io/console';
import { createEventDispatcher } from 'svelte';
import { page } from '$app/stores';
import { Submit, trackEvent, trackError } from '$lib/actions/analytics';
@@ -1,7 +1,7 @@
<script lang="ts">
import { Modal } from '$lib/components';
import { Button, InputText, FormList } from '$lib/elements/forms';
import type { Models } from '@aw-labs/appwrite-console';
import type { Models } from '@appwrite.io/console';
export let showOverview = false;
export let selectedIndex: Models.Index = null;
@@ -1,6 +1,6 @@
import { page } from '$app/stores';
import type { Column } from '$lib/components/viewSelector.svelte';
import type { Models } from '@aw-labs/appwrite-console';
import type { Models } from '@appwrite.io/console';
import { derived, writable } from 'svelte/store';
export type Attributes =
@@ -1,4 +1,4 @@
import type { Models } from '@aw-labs/appwrite-console';
import type { Models } from '@appwrite.io/console';
import { sdk } from '$lib/stores/sdk';
import type { PageLoad } from './$types';
@@ -7,7 +7,7 @@
import { Button, InputText, FormList } from '$lib/elements/forms';
import { addNotification } from '$lib/stores/notifications';
import { sdk } from '$lib/stores/sdk';
import { ID } from '@aw-labs/appwrite-console';
import { ID } from '@appwrite.io/console';
import { createEventDispatcher } from 'svelte';
export let showCreate = false;
@@ -1,6 +1,6 @@
import { page } from '$app/stores';
import type { Column } from '$lib/components/viewSelector.svelte';
import type { Models } from '@aw-labs/appwrite-console';
import type { Models } from '@appwrite.io/console';
import { derived, writable } from 'svelte/store';
export const database = derived(page, ($page) => $page.data.database as Models.Database);
@@ -1,4 +1,4 @@
import type { Models } from '@aw-labs/appwrite-console';
import type { Models } from '@appwrite.io/console';
import { sdk } from '$lib/stores/sdk';
import type { PageLoad } from './$types';
@@ -1,4 +1,4 @@
import type { Models } from '@aw-labs/appwrite-console';
import type { Models } from '@appwrite.io/console';
import { sdk } from '$lib/stores/sdk';
import type { PageLoad } from './$types';
import { error } from '@sveltejs/kit';
@@ -1,4 +1,4 @@
import { Query } from '@aw-labs/appwrite-console';
import { Query } from '@appwrite.io/console';
import { sdk } from '$lib/stores/sdk';
import { getLimit, getPage, pageToOffset } from '$lib/helpers/load';
import { CARD_LIMIT, Dependencies } from '$lib/constants';
@@ -16,7 +16,7 @@
import { base } from '$app/paths';
import { page } from '$app/stores';
import { Submit, trackEvent, trackError } from '$lib/actions/analytics';
import { ID } from '@aw-labs/appwrite-console';
import { ID } from '@appwrite.io/console';
const projectId = $page.params.project;
@@ -28,8 +28,8 @@
const response = await sdk.forProject.functions.create(
$createFunction.id ?? ID.unique(),
$createFunction.name,
$createFunction.execute,
$createFunction.runtime,
$createFunction.execute,
$createFunction.events,
$createFunction.schedule,
$createFunction.timeout
@@ -3,7 +3,7 @@
import { Modal } from '$lib/components';
import { InputText, FormList } from '$lib/elements/forms';
import { createEventDispatcher } from 'svelte';
import type { Models } from '@aw-labs/appwrite-console';
import type { Models } from '@appwrite.io/console';
export let showCreate = false;
export let selectedVar: Partial<Models.Variable> = null;
@@ -30,7 +30,7 @@
import { log } from '$lib/stores/logs';
import { invalidate } from '$app/navigation';
import { Dependencies } from '$lib/constants';
import type { Models } from '@aw-labs/appwrite-console';
import type { Models } from '@appwrite.io/console';
import type { PageData } from './$types';
import Delete from './delete.svelte';
import Create from './create.svelte';
@@ -1,4 +1,4 @@
import { Query } from '@aw-labs/appwrite-console';
import { Query } from '@appwrite.io/console';
import { sdk } from '$lib/stores/sdk';
import { getLimit, getPage, pageToOffset } from '$lib/helpers/load';
import { Dependencies, PAGE_LIMIT } from '$lib/constants';
@@ -4,7 +4,7 @@
import { Button } from '$lib/elements/forms';
import { addNotification } from '$lib/stores/notifications';
import { sdk } from '$lib/stores/sdk';
import type { Models } from '@aw-labs/appwrite-console';
import type { Models } from '@appwrite.io/console';
import { createEventDispatcher } from 'svelte';
export let showActivate = false;
@@ -6,7 +6,7 @@
import { Button } from '$lib/elements/forms';
import { addNotification } from '$lib/stores/notifications';
import { sdk } from '$lib/stores/sdk';
import type { Models } from '@aw-labs/appwrite-console';
import type { Models } from '@appwrite.io/console';
export let showDelete = false;
export let selectedDeployment: Models.Deployment = null;

Some files were not shown because too many files have changed in this diff Show More