Skip to content

Commit

Permalink
Project page now shows "Ask to join project" btn
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
rmunn committed Jan 17, 2025
1 parent 30c8d5a commit 28087b2
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
3 changes: 3 additions & 0 deletions frontend/src/lib/i18n/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<void> {
await resetProjectModal.open(project.code, project.resetStatus);
Expand Down Expand Up @@ -271,6 +278,16 @@
}
}
let askLoading = false;
async function askToJoinProject(projectId: string, projectName: string): Promise<void> {
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;
Expand Down Expand Up @@ -316,6 +333,15 @@
<CrdtSyncButton projectId={project.id} />
<OpenInFlexModal bind:this={openInFlexModal} {project}/>
<OpenInFlexButton projectId={project.id} on:click={openInFlexModal.open}/>
{:else if canAskToJoinProject}
<Button
variant="btn-primary"
loading={askLoading}
on:click={() => askToJoinProject(project.id, project.name)}
>
<span class="i-mdi-email text-2xl"></span>
{$t('project_page.join_project.label')}
</Button>
{:else}
<Dropdown>
<button class="btn btn-primary">
Expand Down

0 comments on commit 28087b2

Please sign in to comment.