diff --git a/packages/site/src/lib/components/shell/User.svelte b/packages/site/src/lib/components/shell/User.svelte index 23641ff25..2f3bd7107 100644 --- a/packages/site/src/lib/components/shell/User.svelte +++ b/packages/site/src/lib/components/shell/User.svelte @@ -6,6 +6,7 @@ import { mode } from '$lib/supabase' import { api_update_dev_admin_role } from '$api/db/update-dev-admin-role/_call' import { invalidateAll } from '$app/navigation' + import { dev } from '$app/environment' $: ({ user, admin } = $page.data) let show_menu = false @@ -72,7 +73,7 @@ {/if} {$page.data.t('account.account_settings')} {$page.data.t('account.log_out')} - {#if mode === 'development'} + {#if dev || mode === 'development'} diff --git a/packages/site/src/routes/admin/dictionaries/+page.svelte b/packages/site/src/routes/admin/dictionaries/+page.svelte index 823263277..0a17619be 100644 --- a/packages/site/src/routes/admin/dictionaries/+page.svelte +++ b/packages/site/src/routes/admin/dictionaries/+page.svelte @@ -62,7 +62,7 @@ + placeholder="Search dictionaries and users"> dictionary_roles.some(({ role }) => role === 'manager')) - $: contributors = dictionary.editors.filter(({ dictionary_roles }) => dictionary_roles.some(({ role }) => role === 'contributor')) + $: managers = dictionary.editors.filter(({ dictionary_roles }) => dictionary_roles.some(({ role, dictionary_id }) => role === 'manager' && dictionary_id === dictionary.id)) + $: contributors = dictionary.editors.filter(({ dictionary_roles }) => dictionary_roles.some(({ role, dictionary_id }) => role === 'contributor' && dictionary_id === dictionary.id)) diff --git a/packages/site/src/routes/admin/dictionaries/RolesManagment.svelte b/packages/site/src/routes/admin/dictionaries/RolesManagment.svelte index 44cbfd9e7..e34c0c130 100644 --- a/packages/site/src/routes/admin/dictionaries/RolesManagment.svelte +++ b/packages/site/src/routes/admin/dictionaries/RolesManagment.svelte @@ -19,8 +19,9 @@ on:additem={toggle} /> {#if show} + {@const users_without_editors = users.filter(({ id: user_id }) => !editors.some(({ id: editor_id }) => editor_id === user_id))} {#await import('./SelectUserModal.svelte') then { default: SelectUserModal }} - + {/await} {/if} diff --git a/packages/site/src/routes/api/db/update-dev-admin-role/+server.ts b/packages/site/src/routes/api/db/update-dev-admin-role/+server.ts index f38778825..40ca1897c 100644 --- a/packages/site/src/routes/api/db/update-dev-admin-role/+server.ts +++ b/packages/site/src/routes/api/db/update-dev-admin-role/+server.ts @@ -3,6 +3,7 @@ import type { RequestHandler } from './$types' import { ResponseCodes } from '$lib/constants' import { mode } from '$lib/supabase' import { getAdminSupabaseClient } from '$lib/supabase/admin' +import { dev } from '$app/environment' export interface UpdateDevAdminRoleRequestBody { role_level: number @@ -11,8 +12,10 @@ export interface UpdateDevAdminRoleRequestBody { export const POST: RequestHandler = async ({ request, locals: { getSession } }) => { const { role_level } = await request.json() as UpdateDevAdminRoleRequestBody - if (mode !== 'development') - error(ResponseCodes.BAD_REQUEST, `Only works on dev`) + if (!dev) { + if (mode !== 'development') + error(ResponseCodes.BAD_REQUEST, `Only works on dev`) + } if (typeof role_level !== 'number') error(ResponseCodes.BAD_REQUEST, `Role must be a number`) diff --git a/supabase/seed.sql b/supabase/seed.sql index a64ce5d12..2dcdb481c 100644 --- a/supabase/seed.sql +++ b/supabase/seed.sql @@ -1,6 +1,6 @@ -INSERT INTO auth.users ("aud", "email", "id", "instance_id", "role") VALUES -('authenticated', 'jacob@livingtongues.org', 'de2d3715-6337-45a3-a81a-d82c3210b2a7', '00000000-0000-0000-0000-000000000000', 'authenticated'), -('authenticated', 'diego@livingtongues.org', 'be43b1dd-6c64-494d-b5da-10d70c384433', '00000000-0000-0000-0000-000000000000', 'authenticated'); +-- INSERT INTO auth.users ("aud", "email", "id", "instance_id", "role", "confirmation_token", "recovery_token", "email_change_token_new", "email_change") VALUES +-- ('authenticated', 'jacob@livingtongues.org', 'de2d3715-6337-45a3-a81a-d82c3210b2a7', '00000000-0000-0000-0000-000000000000', 'authenticated', '', '', '', ''), +-- ('authenticated', 'diego@livingtongues.org', 'be43b1dd-6c64-494d-b5da-10d70c384433', '00000000-0000-0000-0000-000000000000', 'authenticated', '', '', '', ''); -INSERT INTO "public"."dictionaries" ("id", "name", "gloss_languages", "created_at", "created_by", "updated_at", "updated_by") VALUES -('test', 'Test Dictionary', '{"en"}', '2024-03-18 14:16:22.367188+00', 'de2d3715-6337-45a3-a81a-d82c3210b2a7', '2024-03-18 14:16:22.367188+00', 'de2d3715-6337-45a3-a81a-d82c3210b2a7'); \ No newline at end of file +-- INSERT INTO "public"."dictionaries" ("id", "name", "gloss_languages", "created_at", "created_by", "updated_at", "updated_by") VALUES +-- ('test', 'Test Dictionary', '{"en"}', '2024-03-18 14:16:22.367188+00', 'de2d3715-6337-45a3-a81a-d82c3210b2a7', '2024-03-18 14:16:22.367188+00', 'de2d3715-6337-45a3-a81a-d82c3210b2a7'); \ No newline at end of file