diff --git a/apps/api/src/routes/api/v1/handlers.ts b/apps/api/src/routes/api/v1/handlers.ts index c57766ed6..d16d3ed24 100644 --- a/apps/api/src/routes/api/v1/handlers.ts +++ b/apps/api/src/routes/api/v1/handlers.ts @@ -353,8 +353,10 @@ export async function getCurrentUser( // No new token -> not switching teams } } + const pendingInvitations = await prisma.teamInvitation.findMany({ where: { uid: request.user.userId } }) return { settings: await prisma.setting.findFirst(), + pendingInvitations, supportedServiceTypesAndVersions, token, ...request.user, diff --git a/apps/ui/src/lib/store.ts b/apps/ui/src/lib/store.ts index 4e8244e29..aa3493ca5 100644 --- a/apps/ui/src/lib/store.ts +++ b/apps/ui/src/lib/store.ts @@ -20,6 +20,7 @@ interface AppSession { gitlab: string | null, }, supportedServiceTypesAndVersions: Array + pendingInvitations: Array } interface AddToast { type?: "info" | "success" | "error", @@ -47,7 +48,8 @@ export const appSession: Writable = writable({ github: null, gitlab: null }, - supportedServiceTypesAndVersions: [] + supportedServiceTypesAndVersions: [], + pendingInvitations: [] }); export const disabledButton: Writable = writable(false); export const isDeploymentEnabled: Writable = writable(false); diff --git a/apps/ui/src/routes/__layout.svelte b/apps/ui/src/routes/__layout.svelte index be3a49550..ac7edee82 100644 --- a/apps/ui/src/routes/__layout.svelte +++ b/apps/ui/src/routes/__layout.svelte @@ -66,6 +66,8 @@ + + diff --git a/apps/ui/src/routes/iam/__layout.svelte b/apps/ui/src/routes/iam/__layout.svelte new file mode 100644 index 000000000..5b7d16bd3 --- /dev/null +++ b/apps/ui/src/routes/iam/__layout.svelte @@ -0,0 +1,28 @@ + + +
+ +
+
+ +
+ +
+
diff --git a/apps/ui/src/routes/iam/index.svelte b/apps/ui/src/routes/iam/index.svelte index 9b140b130..ba1d9b7e9 100644 --- a/apps/ui/src/routes/iam/index.svelte +++ b/apps/ui/src/routes/iam/index.svelte @@ -29,9 +29,11 @@ import { addToast, appSession } from '$lib/store'; import { goto } from '$app/navigation'; import Cookies from 'js-cookie'; - if (accounts.length === 0) { - accounts.push(account); - } + let search = ''; + let searchResults: any = []; + // if (accounts.length === 0) { + // accounts.push(account); + // } async function resetPassword(id: any) { const sure = window.confirm('Are you sure you want to reset the password?'); @@ -65,22 +67,6 @@ return errorNotification(error); } } - async function acceptInvitation(id: any, teamId: any) { - try { - await post(`/iam/team/${teamId}/invitation/accept`, { id }); - return window.location.reload(); - } catch (error) { - return errorNotification(error); - } - } - async function revokeInvitation(id: any, teamId: any) { - try { - await post(`/iam/team/${teamId}/invitation/revoke`, { id }); - return window.location.reload(); - } catch (error) { - return errorNotification(error); - } - } async function switchTeam(selectedTeamId: any) { try { @@ -104,9 +90,78 @@ const { id } = await post('/iam/new', {}); return await goto(`/iam/team/${id}`, { replaceState: true }); } + function searchAccount() { + searchResults = accounts.filter((account: { email: string | string[] }) => { + return account.email.includes(search); + }); + } -