Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Project page now shows "Ask to join project" button for org members #1390

Merged
merged 4 commits into from
Jan 24, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading