From 5217c5c13fd645a0f24c245be8e51354838a9703 Mon Sep 17 00:00:00 2001 From: SeongHo Park Date: Fri, 19 Jul 2024 10:50:42 +0700 Subject: [PATCH 01/20] add removeProjectFromOrg in backend --- .../project/[project_code]/+page.ts | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/frontend/src/routes/(authenticated)/project/[project_code]/+page.ts b/frontend/src/routes/(authenticated)/project/[project_code]/+page.ts index 71cb0c1dd..86201c06e 100644 --- a/frontend/src/routes/(authenticated)/project/[project_code]/+page.ts +++ b/frontend/src/routes/(authenticated)/project/[project_code]/+page.ts @@ -16,6 +16,7 @@ import type { LeaveProjectMutation, Organization, ProjectPageQuery, + RemoveProjectFromOrgMutation, SetProjectConfidentialityInput, SetProjectConfidentialityMutation, } from '$lib/gql/types'; @@ -327,6 +328,30 @@ export async function _changeProjectDescription(input: ChangeProjectDescriptionI return result; } +export async function _removeProjectFromOrg(projectId: string, orgId: string): $OpResult { + //language=GraphQL + const result = await getClient() + .mutation( + graphql(` + mutation RemoveProjectFromOrg($input: RemoveProjectFromOrgInput!) { + removeProjectFromOrg(input: $input) { + organization { + id + } + errors { + __typename + ... on Error { + message + } + } + } + } + `), + { input: { projectId: projectId, orgId: orgId } } + ); + return result; +} + export async function _setProjectConfidentiality(input: SetProjectConfidentialityInput): $OpResult { //language=GraphQL const result = await getClient() From 0d0f6568b80864513d7e367a7530b6b5f8d7c93d Mon Sep 17 00:00:00 2001 From: SeongHo Park Date: Fri, 19 Jul 2024 10:51:05 +0700 Subject: [PATCH 02/20] frontend for remove modal --- .../project/[project_code]/+page.svelte | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/frontend/src/routes/(authenticated)/project/[project_code]/+page.svelte b/frontend/src/routes/(authenticated)/project/[project_code]/+page.svelte index 13474298d..1d5dd02c1 100644 --- a/frontend/src/routes/(authenticated)/project/[project_code]/+page.svelte +++ b/frontend/src/routes/(authenticated)/project/[project_code]/+page.svelte @@ -13,6 +13,7 @@ _changeProjectName, _deleteProjectUser, _leaveProject, + _removeProjectFromOrg, type ProjectUser, } from './+page'; import AddProjectMember from './AddProjectMember.svelte'; @@ -95,6 +96,19 @@ } } + let removeProjectFromOrgModal: DeleteModal; + // let orgToRemove: string | undefined; + async function removeProjectFromOrg(orgId: string): Promise { + // orgToRemove = orgId; + const removed = await removeUserModal.prompt(async () => { + const { error } = await _removeProjectFromOrg(project.id, orgId); + return error?.message; + }); + if (removed) { + notifyWarning('Your project has successfully been removed from the organization.'); + } + } + async function updateProjectName(newName: string): Promise { const result = await _changeProjectName({ projectId: project.id, name: newName }); if (result.error) { @@ -347,12 +361,20 @@
removeProjectFromOrg(event.detail)} > {#if canManage} {/if} + + {'Would you like to remove your project from the organization, {orgId}'} + Date: Fri, 19 Jul 2024 11:34:33 +0700 Subject: [PATCH 03/20] add dropdown to org badge --- .../project/[project_code]/OrgList.svelte | 33 ++++++++++++++++--- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/frontend/src/routes/(authenticated)/project/[project_code]/OrgList.svelte b/frontend/src/routes/(authenticated)/project/[project_code]/OrgList.svelte index bfddbf1b8..057aec1e7 100644 --- a/frontend/src/routes/(authenticated)/project/[project_code]/OrgList.svelte +++ b/frontend/src/routes/(authenticated)/project/[project_code]/OrgList.svelte @@ -1,11 +1,19 @@ @@ -23,9 +31,26 @@
{/if} {#each organizations as org (org.id)} - - {org.name} - + + + + {org.name} + + + + {/each} From 6e4e18a46876b877e6abaf21339016913d08f9db Mon Sep 17 00:00:00 2001 From: SeongHo Park Date: Fri, 19 Jul 2024 12:00:27 +0700 Subject: [PATCH 04/20] readability --- frontend/src/lib/components/modals/DeleteModal.svelte | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/frontend/src/lib/components/modals/DeleteModal.svelte b/frontend/src/lib/components/modals/DeleteModal.svelte index 31be78352..60ca5bffc 100644 --- a/frontend/src/lib/components/modals/DeleteModal.svelte +++ b/frontend/src/lib/components/modals/DeleteModal.svelte @@ -12,10 +12,10 @@ } + cancelText={isRemoveDialog ? $t('delete_modal.dont_remove') : $t('delete_modal.dont_delete')}> From 339eeae57e9b66c389f663f4a489dcd4f0911b9d Mon Sep 17 00:00:00 2001 From: SeongHo Park Date: Fri, 19 Jul 2024 12:17:14 +0700 Subject: [PATCH 05/20] fix small bug --- .../(authenticated)/project/[project_code]/+page.svelte | 2 +- .../(authenticated)/project/[project_code]/OrgList.svelte | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/frontend/src/routes/(authenticated)/project/[project_code]/+page.svelte b/frontend/src/routes/(authenticated)/project/[project_code]/+page.svelte index 1d5dd02c1..d1fe1f033 100644 --- a/frontend/src/routes/(authenticated)/project/[project_code]/+page.svelte +++ b/frontend/src/routes/(authenticated)/project/[project_code]/+page.svelte @@ -100,7 +100,7 @@ // let orgToRemove: string | undefined; async function removeProjectFromOrg(orgId: string): Promise { // orgToRemove = orgId; - const removed = await removeUserModal.prompt(async () => { + const removed = await removeProjectFromOrgModal.prompt(async () => { const { error } = await _removeProjectFromOrg(project.id, orgId); return error?.message; }); diff --git a/frontend/src/routes/(authenticated)/project/[project_code]/OrgList.svelte b/frontend/src/routes/(authenticated)/project/[project_code]/OrgList.svelte index 057aec1e7..b0b36c3fa 100644 --- a/frontend/src/routes/(authenticated)/project/[project_code]/OrgList.svelte +++ b/frontend/src/routes/(authenticated)/project/[project_code]/OrgList.svelte @@ -11,7 +11,7 @@ export let organizations: Org[] = []; const dispatch = createEventDispatcher<{ - removeFromOrg: string; + removeProjectFromOrg: string; }>(); const TRUNCATED_MEMBER_COUNT = 5; @@ -44,9 +44,9 @@
  • -
  • From 24a64586d2b681e7f61f6694a7f321ddca3834b7 Mon Sep 17 00:00:00 2001 From: SeongHo Park Date: Fri, 19 Jul 2024 13:30:04 +0700 Subject: [PATCH 06/20] add slot for delete modal --- .../(authenticated)/project/[project_code]/MembersList.svelte | 1 + .../(authenticated)/project/[project_code]/OrgList.svelte | 2 ++ 2 files changed, 3 insertions(+) diff --git a/frontend/src/routes/(authenticated)/project/[project_code]/MembersList.svelte b/frontend/src/routes/(authenticated)/project/[project_code]/MembersList.svelte index 3cf3e8232..1cdb0e1a3 100644 --- a/frontend/src/routes/(authenticated)/project/[project_code]/MembersList.svelte +++ b/frontend/src/routes/(authenticated)/project/[project_code]/MembersList.svelte @@ -138,6 +138,7 @@ {/if} + diff --git a/frontend/src/routes/(authenticated)/project/[project_code]/OrgList.svelte b/frontend/src/routes/(authenticated)/project/[project_code]/OrgList.svelte index b0b36c3fa..c659735c6 100644 --- a/frontend/src/routes/(authenticated)/project/[project_code]/OrgList.svelte +++ b/frontend/src/routes/(authenticated)/project/[project_code]/OrgList.svelte @@ -53,4 +53,6 @@ {/each} + + From 6536c4587b037012c16ed0426b9c61b51326233a Mon Sep 17 00:00:00 2001 From: SeongHo Park Date: Fri, 19 Jul 2024 13:30:22 +0700 Subject: [PATCH 07/20] cache invalidation for removeProjectFromOrg --- frontend/src/lib/gql/gql-client.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/frontend/src/lib/gql/gql-client.ts b/frontend/src/lib/gql/gql-client.ts index d4f79fcd0..45bdbbc57 100644 --- a/frontend/src/lib/gql/gql-client.ts +++ b/frontend/src/lib/gql/gql-client.ts @@ -28,6 +28,7 @@ import { type BulkAddProjectMembersMutationVariables, type DeleteDraftProjectMutationVariables, type MutationAddProjectToOrgArgs, + type MutationRemoveProjectFromOrgArgs, } from './types'; import type {Readable, Unsubscriber} from 'svelte/store'; import {derived} from 'svelte/store'; @@ -75,6 +76,9 @@ function createGqlClient(_gqlEndpoint?: string): Client { }, addProjectToOrg: (result, args: MutationAddProjectToOrgArgs, cache, _info) => { cache.invalidate({__typename: 'Project', id: args.input.projectId}); + }, + removeProjectFromOrg: (result, args: MutationRemoveProjectFromOrgArgs, cache, _info) => { + cache.invalidate({__typename: 'Project', id: args.input.projectId}); } } } From cb41f447450da9dd2f7fc31783e0720468c66ce3 Mon Sep 17 00:00:00 2001 From: SeongHo Park Date: Fri, 19 Jul 2024 14:39:38 +0700 Subject: [PATCH 08/20] only show management dropdown for admin, org manager, and project manager --- .../project/[project_code]/+page.svelte | 3 +- .../project/[project_code]/OrgList.svelte | 49 +++++++++++-------- 2 files changed, 30 insertions(+), 22 deletions(-) diff --git a/frontend/src/routes/(authenticated)/project/[project_code]/+page.svelte b/frontend/src/routes/(authenticated)/project/[project_code]/+page.svelte index d1fe1f033..a3969b90b 100644 --- a/frontend/src/routes/(authenticated)/project/[project_code]/+page.svelte +++ b/frontend/src/routes/(authenticated)/project/[project_code]/+page.svelte @@ -360,6 +360,7 @@
    removeProjectFromOrg(event.detail)} > @@ -397,7 +398,7 @@ isRemoveDialog > {$t('project_page.confirm_remove', { - userName: userToDelete?.user.name ?? '', + userName: userToDelete?.user.name ?? '' })} diff --git a/frontend/src/routes/(authenticated)/project/[project_code]/OrgList.svelte b/frontend/src/routes/(authenticated)/project/[project_code]/OrgList.svelte index c659735c6..5abcce353 100644 --- a/frontend/src/routes/(authenticated)/project/[project_code]/OrgList.svelte +++ b/frontend/src/routes/(authenticated)/project/[project_code]/OrgList.svelte @@ -1,6 +1,6 @@
    @@ -118,6 +124,21 @@ {/if} + + + + + + {#if $$slots.actions} {/if} From 48016c0b0d2c1d6893a1a938b156db7a777a7f65 Mon Sep 17 00:00:00 2001 From: SeongHo Park Date: Fri, 19 Jul 2024 15:28:46 +0700 Subject: [PATCH 11/20] implement backend & create remove modal --- .../components/Projects/ProjectTable.svelte | 1 + .../(authenticated)/org/[org_id]/+page.svelte | 28 +++++++++++++++++-- .../(authenticated)/org/[org_id]/+page.ts | 25 +++++++++++++++++ 3 files changed, 51 insertions(+), 3 deletions(-) diff --git a/frontend/src/lib/components/Projects/ProjectTable.svelte b/frontend/src/lib/components/Projects/ProjectTable.svelte index cbe9436fd..598e7534a 100644 --- a/frontend/src/lib/components/Projects/ProjectTable.svelte +++ b/frontend/src/lib/components/Projects/ProjectTable.svelte @@ -142,6 +142,7 @@ {#if $$slots.actions} {/if} + {/each} diff --git a/frontend/src/routes/(authenticated)/org/[org_id]/+page.svelte b/frontend/src/routes/(authenticated)/org/[org_id]/+page.svelte index 3de1d91f7..0b2231a4a 100644 --- a/frontend/src/routes/(authenticated)/org/[org_id]/+page.svelte +++ b/frontend/src/routes/(authenticated)/org/[org_id]/+page.svelte @@ -1,6 +1,5 @@
    @@ -127,23 +120,6 @@ {/if} - {#if canManage} - - - - - - - {/if} {#if $$slots.actions} {/if} diff --git a/frontend/src/routes/(authenticated)/org/[org_id]/+page.svelte b/frontend/src/routes/(authenticated)/org/[org_id]/+page.svelte index 3a6c9af14..d78529439 100644 --- a/frontend/src/routes/(authenticated)/org/[org_id]/+page.svelte +++ b/frontend/src/routes/(authenticated)/org/[org_id]/+page.svelte @@ -22,6 +22,7 @@ import ProjectTable from '$lib/components/Projects/ProjectTable.svelte'; import type { UUID } from 'crypto'; import BulkAddOrgMembers from './BulkAddOrgMembers.svelte'; + import Dropdown from '$lib/components/Dropdown.svelte'; export let data: PageData; $: user = data.user; @@ -135,28 +136,43 @@
    {#if $queryParamValues.tab === 'projects'} - removeProjectFromOrg(event.detail.projectId, event.detail.projectName)} - > + + + {#if canManage} + + + + + {/if} + + + > {$t('org_page.confirm_remove_project_from_org', {projectName: projectToRemove, orgName: org.name})} - {:else if $queryParamValues.tab === 'members'} - openUserModal(event.detail)} - on:removeMember={(event) => _deleteOrgUser(org.id, event.detail.id)} - on:changeMemberRole={(event) => openChangeMemberRoleModal(event.detail)} - /> + openUserModal(event.detail)} + on:removeMember={(event) => _deleteOrgUser(org.id, event.detail.id)} + on:changeMemberRole={(event) => openChangeMemberRoleModal(event.detail)} + /> {:else if $queryParamValues.tab === 'history'}
    From 71305b8371223265b6237f77336a5cbcca196093 Mon Sep 17 00:00:00 2001 From: SeongHo Park Date: Wed, 24 Jul 2024 10:37:05 +0700 Subject: [PATCH 19/20] small fix --- frontend/src/lib/i18n/locales/en.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/lib/i18n/locales/en.json b/frontend/src/lib/i18n/locales/en.json index 2732b81b1..269d015ec 100644 --- a/frontend/src/lib/i18n/locales/en.json +++ b/frontend/src/lib/i18n/locales/en.json @@ -401,8 +401,8 @@ the [Linguistics Institute at Payap University](https://li.payap.ac.th/) in Chia "remove_project_from_org": "Your project has been removed from {orgName}" }, "project_name_empty_error": "Project name cannot be empty", - "confirm_remove_project": "Would you like to remove {userName} from this project?", "confirm_remove_org": "Would you like to remove your project from {orgName}?", + "confirm_remove": "Would you like to remove {userName} from this project?", "history": "History", "project_code": "Project Code", "summary": "Summary", From 13b694a3c6b608b37daccbd5f207f9bf45671b22 Mon Sep 17 00:00:00 2001 From: SeongHo Park Date: Wed, 24 Jul 2024 14:34:05 +0700 Subject: [PATCH 20/20] small fix addressing review comment --- frontend/src/lib/components/Projects/ProjectTable.svelte | 3 --- .../(authenticated)/project/[project_code]/OrgList.svelte | 4 ++-- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/frontend/src/lib/components/Projects/ProjectTable.svelte b/frontend/src/lib/components/Projects/ProjectTable.svelte index 76a5d7d19..a9e3209ac 100644 --- a/frontend/src/lib/components/Projects/ProjectTable.svelte +++ b/frontend/src/lib/components/Projects/ProjectTable.svelte @@ -43,8 +43,6 @@ {#if isColumnVisible('type')} {$t('project.table.type')} {/if} - - {#if $$slots.actions} {/if} @@ -123,7 +121,6 @@ {#if $$slots.actions} {/if} - {/each} diff --git a/frontend/src/routes/(authenticated)/project/[project_code]/OrgList.svelte b/frontend/src/routes/(authenticated)/project/[project_code]/OrgList.svelte index 0a177612f..0fc6d9928 100644 --- a/frontend/src/routes/(authenticated)/project/[project_code]/OrgList.svelte +++ b/frontend/src/routes/(authenticated)/project/[project_code]/OrgList.svelte @@ -45,10 +45,10 @@