From 28087b289b689d6df8902351fa8fdd9245b32ab6 Mon Sep 17 00:00:00 2001 From: Robin Munn Date: Fri, 17 Jan 2025 14:54:36 -0500 Subject: [PATCH 1/4] Project page now shows "Ask to join project" btn Org members who aren't yet project members can ask to join a project by clicking the button, which will send an email to project managers. --- frontend/src/lib/i18n/locales/en.json | 3 +++ .../project/[project_code]/+page.svelte | 26 +++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/frontend/src/lib/i18n/locales/en.json b/frontend/src/lib/i18n/locales/en.json index 552e726f2..b43459eb3 100644 --- a/frontend/src/lib/i18n/locales/en.json +++ b/frontend/src/lib/i18n/locales/en.json @@ -531,6 +531,9 @@ Lexbox is free and [open source](https://github.com/sillsdev/languageforge-lexbo "promote_project": { "label": "Promote to real project", }, + "join_project": { + "label": "Ask to join project", + }, "open_with_viewer": "Browse", "open_with_flex": { "button": "Open with FLEx", diff --git a/frontend/src/routes/(authenticated)/project/[project_code]/+page.svelte b/frontend/src/routes/(authenticated)/project/[project_code]/+page.svelte index f7e3ff574..aa881a54b 100644 --- a/frontend/src/routes/(authenticated)/project/[project_code]/+page.svelte +++ b/frontend/src/routes/(authenticated)/project/[project_code]/+page.svelte @@ -56,6 +56,8 @@ import { getSearchParamValues } from '$lib/util/query-params'; import FlexModelVersionText from '$lib/components/Projects/FlexModelVersionText.svelte'; import CrdtSyncButton from './CrdtSyncButton.svelte'; + import {_askToJoinProject} from '../create/+page'; // TODO: Should we duplicate this function in the project_code/+page.ts file, rather than importing it from elsewhere? + import {Duration} from '$lib/util/time'; export let data: PageData; $: user = data.user; @@ -143,6 +145,11 @@ || projectRole && !project.isConfidential // public by default for members (non-members shouldn't even be here) || orgRoles.some(role => role === OrgRole.Admin); + // Almost mirrors PermissionService.CanAskToJoinProject() in C#, but admins won't be shown the "ask to join" button + $: canAskToJoinProject = !user.isAdmin + && !projectRole + && orgRoles.some((_) => true); + let resetProjectModal: ResetProjectModal; async function resetProject(): Promise { await resetProjectModal.open(project.code, project.resetStatus); @@ -271,6 +278,16 @@ } } + let askLoading = false; + async function askToJoinProject(projectId: string, projectName: string): Promise { + askLoading = true; + const joinResult = await _askToJoinProject(projectId); + askLoading = false; + if (!joinResult.error) { + notifySuccess($t('project.create.join_request_sent', { projectName }), Duration.Persistent); + } + } + let projectConfidentialityModal: ProjectConfidentialityModal; let openInFlexModal: OpenInFlexModal; let leaveModal: ConfirmModal; @@ -316,6 +333,15 @@ + {:else if canAskToJoinProject} + {:else} {:else}