Skip to content

🔥 🔥 🔥 A Free & Self-hostable Airtable Alternative

fix(nc-gui): add confirmation modal while removing user

Ramesh Mane435e22c5851b
diff --git a/packages/nc-gui/components/nc/ModalConfirm.vue b/packages/nc-gui/components/nc/ModalConfirm.vue
index e33136562d..2daf527fb1 100644
--- a/packages/nc-gui/components/nc/ModalConfirm.vue
+++ b/packages/nc-gui/components/nc/ModalConfirm.vue
@@ -245,6 +245,7 @@ useSelectedCellKeydownListener(
ref="cancelBtnRef"
:type="cancelProps?.type ?? 'secondary'"
size="small"
+ class="nc-modal-confirm-cancel-btn"
:class="cancelClass"
v-bind="cancelProps"
:hide-focus="initialFocus"
@@ -257,6 +258,7 @@ useSelectedCellKeydownListener(
ref="okBtnRef"
:type="okProps?.type ?? 'primary'"
size="small"
+ class="nc-modal-confirm-ok-btn"
:class="okClass"
v-bind="okProps"
:hide-focus="initialFocus"
diff --git a/packages/nc-gui/components/workspace/CollaboratorsList.vue b/packages/nc-gui/components/workspace/CollaboratorsList.vue
index 42402c8b6f..255ec37cbf 100644
--- a/packages/nc-gui/components/workspace/CollaboratorsList.vue
+++ b/packages/nc-gui/components/workspace/CollaboratorsList.vue
@@ -17,9 +17,11 @@ const { workspaceRoles } = useRoles()
const { user } = useGlobal()
+const { showInfoModal } = useNcConfirmModal()
+
const workspaceStore = useWorkspace()
-const { removeCollaborator, updateCollaborator: _updateCollaborator } = workspaceStore
+const { removeCollaborator: _removeCollaborator, updateCollaborator: _updateCollaborator } = workspaceStore
const { collaborators, activeWorkspace, workspacesList, isCollaboratorsLoading, removingCollaboratorMap } =
storeToRefs(workspaceStore)
@@ -71,7 +73,10 @@ const filterCollaborators = computed(() => {
if (!collaborators.value) return []
- return collaborators.value.filter((collab) => searchCompare([collab.display_name, collab.email], userSearchText.value))
+ return collaborators.value.filter(
+ (collab) =>
+ searchCompare([collab.display_name, collab.email], userSearchText.value) && !removingCollaboratorMap.value[collab.id],
+ )
})
const selected = reactive<{
@@ -236,6 +241,23 @@ const handleScroll = (e) => {
topScroll.value = e.target?.scrollTop
}
+
+const removeCollaborator = (userId: string, workspaceId: string) => {
+ showInfoModal({
+ title: userId === user.value?.id ? t('title.confirmLeaveWorkspaceTitle') : t('title.confirmRemoveMemberFromWorkspaceTitle'),
+ content:
+ userId === user.value?.id ? t('title.confirmLeaveWorkspaceSubtile') : t('title.confirmRemoveMemberFromWorkspaceSubtitle'),
+ showCancelBtn: true,
+ showIcon: false,
+ okProps: {
+ type: 'danger',
+ },
+ okText: userId === user.value?.id ? t('activity.leaveWorkspace') : t('general.remove'),
+ okCallback: async () => {
+ _removeCollaborator(userId, workspaceId)
+ },
+ })
+}
</script>
<template>
diff --git a/packages/nc-gui/composables/useNcConfirmModal.ts b/packages/nc-gui/composables/useNcConfirmModal.ts
index 95b8f4ba17..d926dd8a26 100644
--- a/packages/nc-gui/composables/useNcConfirmModal.ts
+++ b/packages/nc-gui/composables/useNcConfirmModal.ts
@@ -104,6 +104,7 @@ const useNcConfirmModal = () => {
closeDialog()
},
'okClass': okClass,
+ 'okProps': okProps,
'update:visible': () => closeDialog(key),
'showIcon': showIcon,
'maskClosable': maskClosable,
diff --git a/packages/nc-gui/lang/en.json b/packages/nc-gui/lang/en.json
index 732d6ba1a3..5468e86b5a 100644
--- a/packages/nc-gui/lang/en.json
+++ b/packages/nc-gui/lang/en.json
@@ -908,7 +908,11 @@
"thisPrivateBaseHasBeenLockedSubtext": "To unlock, please upgrade to the {plan} plan or convert this Base to a Shared Base.",
"mOfNFieldsHaveCustomPermissions": "{m}/{n} fields have custom permissions",
"cancelSubscriptionBeforeDeletingWorkspace": "Cancel subscription before deleting workspace",
- "cancelSubscriptionBeforeDeletingWorkspaceSubtext": "This workspace has an active subscription. Please review and cancel it before proceeding with deletion."
+ "cancelSubscriptionBeforeDeletingWorkspaceSubtext": "This workspace has an active subscription. Please review and cancel it before proceeding with deletion.",
+ "confirmLeaveWorkspaceTitle": "Are you sure you want to leave this workspace?",
+ "confirmLeaveWorkspaceSubtile": "If you leave this workspace, you will lose access to all the bases and data within this workspace. You’ll need an invitation to rejoin.",
+ "confirmRemoveMemberFromWorkspaceTitle": "Are you sure you want to remove member from workspace?",
+ "confirmRemoveMemberFromWorkspaceSubtitle": "If you remove, they will lose access to all bases and data within this workspace. They’ll need an invitation to rejoin."
},
"labels": {
"configurationError": "Incomplete configuration",