From ff2ae0aeab29569d9fa9c969d98e725f48d94138 Mon Sep 17 00:00:00 2001 From: Steven Nguyen Date: Thu, 1 Jun 2023 17:59:50 -0700 Subject: [PATCH] Add user labels to user list and detail pages --- src/lib/actions/analytics.ts | 1 + .../project-[project]/auth/+page.svelte | 17 ++++ .../auth/user-[user]/+page.svelte | 2 + .../auth/user-[user]/updateLabels.svelte | 98 +++++++++++++++++++ 4 files changed, 118 insertions(+) create mode 100644 src/routes/console/project-[project]/auth/user-[user]/updateLabels.svelte diff --git a/src/lib/actions/analytics.ts b/src/lib/actions/analytics.ts index 84c178cc46..0fd6ea1fa9 100644 --- a/src/lib/actions/analytics.ts +++ b/src/lib/actions/analytics.ts @@ -118,6 +118,7 @@ export enum Submit { UserCreate = 'submit_user_create', UserDelete = 'submit_user_delete', UserUpdateEmail = 'submit_user_update_email', + UserUpdateLabels = 'submit_user_update_labels', UserUpdateName = 'submit_user_update_name', UserUpdatePassword = 'submit_user_update_password', UserUpdatePhone = 'submit_user_update_phone', diff --git a/src/routes/console/project-[project]/auth/+page.svelte b/src/routes/console/project-[project]/auth/+page.svelte index 0063f7ea1f..b5317a73a1 100644 --- a/src/routes/console/project-[project]/auth/+page.svelte +++ b/src/routes/console/project-[project]/auth/+page.svelte @@ -26,6 +26,7 @@ import Create from './createUser.svelte'; import type { Models } from '@appwrite.io/console'; import type { PageData } from './$types'; + import { tooltip } from '$lib/actions/tooltip'; export let data: PageData; @@ -49,6 +50,7 @@ Identifiers Status ID + Labels Joined @@ -102,6 +104,21 @@ + + {#each user.labels.slice(0, 2) as label, i} + {#if i == 0} + + {label} + + {:else} + +{user.labels.length - 1} + {/if} + {/each} + {toLocaleDateTime(user.registration)} diff --git a/src/routes/console/project-[project]/auth/user-[user]/+page.svelte b/src/routes/console/project-[project]/auth/user-[user]/+page.svelte index b48becb71b..04ef2f14a2 100644 --- a/src/routes/console/project-[project]/auth/user-[user]/+page.svelte +++ b/src/routes/console/project-[project]/auth/user-[user]/+page.svelte @@ -2,6 +2,7 @@ import { Container } from '$lib/layout'; import DangerZone from './dangerZone.svelte'; import UpdateEmail from './updateEmail.svelte'; + import UpdateLabels from './updateLabels.svelte'; import UpdateName from './updateName.svelte'; import UpdatePassword from './updatePassword.svelte'; import UpdatePhone from './updatePhone.svelte'; @@ -15,6 +16,7 @@ + diff --git a/src/routes/console/project-[project]/auth/user-[user]/updateLabels.svelte b/src/routes/console/project-[project]/auth/user-[user]/updateLabels.svelte new file mode 100644 index 0000000000..c152633cb6 --- /dev/null +++ b/src/routes/console/project-[project]/auth/user-[user]/updateLabels.svelte @@ -0,0 +1,98 @@ + + +
+ + User labels +

+ Categorize and manage your users based on specific criteria by assigning them + customizable labels. Roles will be assigned to users based on the assigned labels. +

+ +
    + +
  • + {#each suggestedLabels as suggestedLabel} + { + if (!labels.includes(suggestedLabel)) { + labels = [...labels, suggestedLabel]; + } else { + labels = labels.filter((e) => e !== suggestedLabel); + } + }}> + + {/each} +
  • + {#if error} +
  • + {error} +
  • + {/if} +
+
+ + + + +
+