|
|
@ -1,6 +1,6 @@ |
|
|
|
<script lang="ts" setup> |
|
|
|
<script lang="ts" setup> |
|
|
|
import { OrgUserRoles } from 'nocodb-sdk' |
|
|
|
import { OrgUserRoles } from 'nocodb-sdk' |
|
|
|
import type { OrgUserReqType, RequestParams, Roles, UserType } from 'nocodb-sdk' |
|
|
|
import type { OrgUserReqType, RequestParams, UserType } from 'nocodb-sdk' |
|
|
|
import type { User } from '#imports' |
|
|
|
import type { User } from '#imports' |
|
|
|
import { extractSdkResponseErrorMsg, iconMap, useApi, useCopy, useDashboard, useDebounceFn, useNuxtApp } from '#imports' |
|
|
|
import { extractSdkResponseErrorMsg, iconMap, useApi, useCopy, useDashboard, useDebounceFn, useNuxtApp } from '#imports' |
|
|
|
|
|
|
|
|
|
|
@ -60,9 +60,11 @@ const loadUsers = useDebounceFn(async (page = currentPage.value, limit = current |
|
|
|
} |
|
|
|
} |
|
|
|
}, 500) |
|
|
|
}, 500) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
onMounted(() => { |
|
|
|
loadUsers() |
|
|
|
loadUsers() |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
const updateRole = async (userId: string, roles: Roles) => { |
|
|
|
const updateRole = async (userId: string, roles: string) => { |
|
|
|
try { |
|
|
|
try { |
|
|
|
await api.orgUsers.update(userId, { |
|
|
|
await api.orgUsers.update(userId, { |
|
|
|
roles, |
|
|
|
roles, |
|
|
@ -75,9 +77,11 @@ const updateRole = async (userId: string, roles: Roles) => { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const deleteUser = async (userId: string) => { |
|
|
|
const deleteModalInfo = ref<UserType | null>(null) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const deleteUser = async () => { |
|
|
|
try { |
|
|
|
try { |
|
|
|
await api.orgUsers.delete(userId) |
|
|
|
await api.orgUsers.delete(deleteModalInfo.value?.id as string) |
|
|
|
message.success(t('msg.success.userDeleted')) |
|
|
|
message.success(t('msg.success.userDeleted')) |
|
|
|
|
|
|
|
|
|
|
|
await loadUsers() |
|
|
|
await loadUsers() |
|
|
@ -89,12 +93,14 @@ const deleteUser = async (userId: string) => { |
|
|
|
$e('a:org-user:user-deleted') |
|
|
|
$e('a:org-user:user-deleted') |
|
|
|
} catch (e: any) { |
|
|
|
} catch (e: any) { |
|
|
|
message.error(await extractSdkResponseErrorMsg(e)) |
|
|
|
message.error(await extractSdkResponseErrorMsg(e)) |
|
|
|
} |
|
|
|
} finally { |
|
|
|
// closing the modal |
|
|
|
// closing the modal |
|
|
|
isOpen.value = false |
|
|
|
isOpen.value = false |
|
|
|
|
|
|
|
deleteModalInfo.value = null |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const resendInvite = async (user: User) => { |
|
|
|
const resendInvite = async (user: UserType) => { |
|
|
|
try { |
|
|
|
try { |
|
|
|
await api.orgUsers.resendInvite(user.id) |
|
|
|
await api.orgUsers.resendInvite(user.id) |
|
|
|
|
|
|
|
|
|
|
@ -121,7 +127,7 @@ const copyInviteUrl = async (user: User) => { |
|
|
|
$e('c:user:copy-url') |
|
|
|
$e('c:user:copy-url') |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const copyPasswordResetUrl = async (user: User) => { |
|
|
|
const copyPasswordResetUrl = async (user: UserType) => { |
|
|
|
try { |
|
|
|
try { |
|
|
|
const { reset_password_url } = await api.orgUsers.generatePasswordResetToken(user.id) |
|
|
|
const { reset_password_url } = await api.orgUsers.generatePasswordResetToken(user.id) |
|
|
|
|
|
|
|
|
|
|
@ -134,74 +140,72 @@ const copyPasswordResetUrl = async (user: User) => { |
|
|
|
message.error(await extractSdkResponseErrorMsg(e)) |
|
|
|
message.error(await extractSdkResponseErrorMsg(e)) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const openInviteModal = () => { |
|
|
|
|
|
|
|
showUserModal.value = true |
|
|
|
|
|
|
|
userMadalKey.value++ |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const openDeleteModal = (user: UserType) => { |
|
|
|
|
|
|
|
deleteModalInfo.value = user |
|
|
|
|
|
|
|
isOpen.value = true |
|
|
|
|
|
|
|
} |
|
|
|
</script> |
|
|
|
</script> |
|
|
|
|
|
|
|
|
|
|
|
<template> |
|
|
|
<template> |
|
|
|
<div data-testid="nc-super-user-list"> |
|
|
|
<div data-testid="nc-super-user-list"> |
|
|
|
<div class="max-w-[900px] mx-auto"> |
|
|
|
<div class="max-w-195 mx-auto"> |
|
|
|
<div class="text-xl my-4 text-left font-weight-bold">{{ $t('title.userManagement') }}</div> |
|
|
|
<div class="text-2xl my-4 text-left font-weight-bold">User Management</div> |
|
|
|
<div class="py-2 flex gap-4 items-center"> |
|
|
|
<div class="py-2 flex gap-4 items-center justify-between"> |
|
|
|
<a-input-search |
|
|
|
<a-input v-model:value="searchText" class="!max-w-90 !rounded-md" placeholder="Search members" @change="loadUsers()"> |
|
|
|
v-model:value="searchText" |
|
|
|
<template #prefix> |
|
|
|
size="middle" |
|
|
|
<PhMagnifyingGlassBold class="!h-3.5 text-gray-500" /> |
|
|
|
class="max-w-[300px]" |
|
|
|
</template> |
|
|
|
:placeholder="$t('labels.searchUsers')" |
|
|
|
</a-input> |
|
|
|
@blur="loadUsers" |
|
|
|
<div class="flex gap-3 items-center justify-center"> |
|
|
|
@keydown.enter="loadUsers" |
|
|
|
<component :is="iconMap.reload" class="cursor-pointer" @click="loadUsers(currentPage, currentLimit)" /> |
|
|
|
> |
|
|
|
<NcButton data-testid="nc-super-user-invite" size="small" type="primary" @click="openInviteModal"> |
|
|
|
</a-input-search> |
|
|
|
|
|
|
|
<div class="flex-grow"></div> |
|
|
|
|
|
|
|
<component :is="iconMap.reload" class="cursor-pointer" @click="loadUsers" /> |
|
|
|
|
|
|
|
<a-button |
|
|
|
|
|
|
|
data-testid="nc-super-user-invite" |
|
|
|
|
|
|
|
size="middle" |
|
|
|
|
|
|
|
class="!rounded-md" |
|
|
|
|
|
|
|
type="primary" |
|
|
|
|
|
|
|
@click=" |
|
|
|
|
|
|
|
() => { |
|
|
|
|
|
|
|
showUserModal = true |
|
|
|
|
|
|
|
userMadalKey++ |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
" |
|
|
|
|
|
|
|
> |
|
|
|
|
|
|
|
<div class="flex items-center gap-1"> |
|
|
|
<div class="flex items-center gap-1"> |
|
|
|
<component :is="iconMap.plus" /> |
|
|
|
<component :is="iconMap.plus" /> |
|
|
|
{{ $t('activity.inviteUser') }} |
|
|
|
{{ $t('activity.inviteUser') }} |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</a-button> |
|
|
|
</NcButton> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<a-table |
|
|
|
</div> |
|
|
|
:row-key="(record) => record.id" |
|
|
|
<div class="w-[780px] mt-5 border-1 rounded-md h-[613px]"> |
|
|
|
:data-source="users" |
|
|
|
<div class="flex w-full bg-gray-50 border-b-1"> |
|
|
|
:pagination="pagination" |
|
|
|
<span class="py-3.5 text-gray-500 font-medium text-3.5 w-1/3 text-start pl-10">{{ $t('labels.email') }}</span> |
|
|
|
:loading="isLoading" |
|
|
|
<span class="py-3.5 text-gray-500 font-medium text-3.5 w-1/3 text-start pl-20">{{ $t('objects.role') }}</span> |
|
|
|
size="small" |
|
|
|
<span class="py-3.5 text-gray-500 font-medium text-3.5 w-1/3 text-end pl-42">{{ $t('labels.action') }}</span> |
|
|
|
@change="loadUsers($event.current)" |
|
|
|
</div> |
|
|
|
> |
|
|
|
<div v-if="isLoading" class="flex items-center justify-center text-center h-[513px]"> |
|
|
|
<template #emptyText> |
|
|
|
<GeneralLoader size="xlarge" /> |
|
|
|
|
|
|
|
</div> |
|
|
|
|
|
|
|
<!-- if users are empty --> |
|
|
|
|
|
|
|
<div v-else-if="!users.length" class="flex items-center justify-center text-center h-128.25"> |
|
|
|
<a-empty :image="Empty.PRESENTED_IMAGE_SIMPLE" :description="$t('labels.noData')" /> |
|
|
|
<a-empty :image="Empty.PRESENTED_IMAGE_SIMPLE" :description="$t('labels.noData')" /> |
|
|
|
</template> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<!-- Email --> |
|
|
|
|
|
|
|
<a-table-column key="email" :title="$t('labels.email')" data-index="email"> |
|
|
|
|
|
|
|
<template #default="{ text }"> |
|
|
|
|
|
|
|
<div> |
|
|
|
|
|
|
|
{{ text }} |
|
|
|
|
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</template> |
|
|
|
<section v-else class="tbody"> |
|
|
|
</a-table-column> |
|
|
|
<div |
|
|
|
|
|
|
|
v-for="el of users" |
|
|
|
<!-- Role --> |
|
|
|
:key="el.id" |
|
|
|
<a-table-column key="roles" :title="$t('objects.role')" data-index="roles"> |
|
|
|
data-testid="nc-token-list" |
|
|
|
<template #default="{ record }"> |
|
|
|
class="flex py-3 justify-around px-5 border-b-1" |
|
|
|
<div> |
|
|
|
:class="{ |
|
|
|
<div v-if="record.roles.includes('super')" class="font-weight-bold">{{ $t('labels.superAdmin') }}</div> |
|
|
|
'py-4': el.roles?.includes('super'), |
|
|
|
|
|
|
|
}" |
|
|
|
|
|
|
|
> |
|
|
|
|
|
|
|
<span class="text-3.5 text-start w-1/3 pl-5"> |
|
|
|
|
|
|
|
{{ el.email }} |
|
|
|
|
|
|
|
</span> |
|
|
|
|
|
|
|
<span class="text-3.5 text-start w-1/3 pl-18"> |
|
|
|
|
|
|
|
<div v-if="el?.roles?.includes('super')" class="font-weight-bold">Super Admin</div> |
|
|
|
<a-select |
|
|
|
<a-select |
|
|
|
v-else |
|
|
|
v-else |
|
|
|
v-model:value="record.roles" |
|
|
|
v-model:value="el.roles" |
|
|
|
class="w-[220px] nc-user-roles" |
|
|
|
class="w-55 nc-user-roles" |
|
|
|
:dropdown-match-select-width="false" |
|
|
|
:dropdown-match-select-width="false" |
|
|
|
@change="updateRole(record.id, record.roles)" |
|
|
|
@change="updateRole(el.id, el.roles as string)" |
|
|
|
> |
|
|
|
> |
|
|
|
<a-select-option |
|
|
|
<a-select-option |
|
|
|
class="nc-users-list-role-option" |
|
|
|
class="nc-users-list-role-option" |
|
|
@ -225,86 +229,47 @@ const copyPasswordResetUrl = async (user: User) => { |
|
|
|
</span> |
|
|
|
</span> |
|
|
|
</a-select-option> |
|
|
|
</a-select-option> |
|
|
|
</a-select> |
|
|
|
</a-select> |
|
|
|
</div> |
|
|
|
</span> |
|
|
|
</template> |
|
|
|
<span class="w-1/3 pl-43"> |
|
|
|
</a-table-column> |
|
|
|
<div |
|
|
|
|
|
|
|
class="flex items-center gap-2" |
|
|
|
<!-- <!– Projects –> |
|
|
|
:class="{ |
|
|
|
<a-table-column key="projectsCount" :title="$t('objects.projects')" data-index="projectsCount"> |
|
|
|
'opacity-0': el.roles?.includes('super'), |
|
|
|
<template #default="{ text }"> |
|
|
|
}" |
|
|
|
<div> |
|
|
|
> |
|
|
|
{{ text }} |
|
|
|
<NcDropdown :trigger="['click']"> |
|
|
|
</div> |
|
|
|
<MdiDotsVertical |
|
|
|
</template> |
|
|
|
class="border-1 !text-gray-600 h-5.5 w-5.5 rounded outline-0 p-0.5 nc-workspace-menu transform transition-transform !text-gray-400 cursor-pointer hover:(!text-gray-500 bg-gray-100)" |
|
|
|
</a-table-column> --> |
|
|
|
/> |
|
|
|
|
|
|
|
|
|
|
|
<!-- Actions --> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<a-table-column key="id" :title="$t('labels.actions')" data-index="id"> |
|
|
|
|
|
|
|
<template #default="{ text, record }"> |
|
|
|
|
|
|
|
<div v-if="!record.roles.includes('super')" class="flex items-center gap-2"> |
|
|
|
|
|
|
|
<a-dropdown :trigger="['click']" class="flex" placement="bottomRight" overlay-class-name="nc-dropdown-user-mgmt"> |
|
|
|
|
|
|
|
<div class="flex flex-row items-center"> |
|
|
|
|
|
|
|
<a-button type="text" class="!px-0"> |
|
|
|
|
|
|
|
<div class="flex flex-row items-center h-[1.2rem]"> |
|
|
|
|
|
|
|
<component :is="iconMap.threeDotHorizontal" class="nc-user-row-action" /> |
|
|
|
|
|
|
|
</div> |
|
|
|
|
|
|
|
</a-button> |
|
|
|
|
|
|
|
</div> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<template #overlay> |
|
|
|
<template #overlay> |
|
|
|
<a-menu> |
|
|
|
<NcMenu> |
|
|
|
<template v-if="record.invite_token"> |
|
|
|
<template v-if="!el.roles?.includes('super')"> |
|
|
|
<a-menu-item> |
|
|
|
|
|
|
|
<!-- Resend invite Email --> |
|
|
|
<!-- Resend invite Email --> |
|
|
|
<div class="flex flex-row items-center py-3" @click="resendInvite(record)"> |
|
|
|
<NcMenuItem @click="resendInvite(el)"> |
|
|
|
<component :is="iconMap.email" class="flex h-[1rem] text-gray-500" /> |
|
|
|
<component :is="iconMap.email" class="flex text-gray-500" /> |
|
|
|
<div class="text-xs pl-2">{{ $t('activity.resendInvite') }}</div> |
|
|
|
<div>{{ $t('activity.resendInvite') }}</div> |
|
|
|
</div> |
|
|
|
</NcMenuItem> |
|
|
|
</a-menu-item> |
|
|
|
<NcMenuItem @click="copyInviteUrl(el)"> |
|
|
|
<a-menu-item> |
|
|
|
<component :is="iconMap.copy" class="flex text-gray-500" /> |
|
|
|
<div class="flex flex-row items-center py-3" @click="copyInviteUrl(record)"> |
|
|
|
<div>{{ $t('activity.copyInviteURL') }}</div> |
|
|
|
<component :is="iconMap.copy" class="flex h-[1rem] text-gray-500" /> |
|
|
|
</NcMenuItem> |
|
|
|
<div class="text-xs pl-2">{{ $t('activity.copyInviteURL') }}</div> |
|
|
|
<NcMenuItem @click="copyPasswordResetUrl(el)"> |
|
|
|
</div> |
|
|
|
<component :is="iconMap.copy" class="flex text-gray-500" /> |
|
|
|
</a-menu-item> |
|
|
|
<div>{{ $t('activity.copyPasswordResetURL') }}</div> |
|
|
|
|
|
|
|
</NcMenuItem> |
|
|
|
</template> |
|
|
|
</template> |
|
|
|
<a-menu-item> |
|
|
|
<NcDivider v-if="!el.roles?.includes('super')" /> |
|
|
|
<div class="flex flex-row items-center py-3" @click="copyPasswordResetUrl(record)"> |
|
|
|
<NcMenuItem class="!text-red-500 !hover:bg-red-50" @click="openDeleteModal(el)"> |
|
|
|
<component :is="iconMap.copy" class="flex h-[1rem] text-gray-500" /> |
|
|
|
<MaterialSymbolsDeleteOutlineRounded /> |
|
|
|
<div class="text-xs pl-2">{{ $t('activity.copyPasswordResetURL') }}</div> |
|
|
|
{{ $t('general.remove') }} {{ $t('objects.user') }} |
|
|
|
</div> |
|
|
|
</NcMenuItem> |
|
|
|
</a-menu-item> |
|
|
|
</NcMenu> |
|
|
|
<a-menu-item> |
|
|
|
|
|
|
|
<div class="flex flex-row items-center py-3" @click="isOpen = true"> |
|
|
|
|
|
|
|
<!-- Delete user modal --> |
|
|
|
|
|
|
|
<GeneralDeleteModal v-model:visible="isOpen" entity-name="User" :on-delete="() => deleteUser(text)"> |
|
|
|
|
|
|
|
<template #entity-preview> |
|
|
|
|
|
|
|
<span> |
|
|
|
|
|
|
|
<div class="flex flex-row items-center py-2.25 px-2.5 bg-gray-50 rounded-lg text-gray-700 mb-4"> |
|
|
|
|
|
|
|
<GeneralIcon icon="account" class="nc-view-icon"></GeneralIcon> |
|
|
|
|
|
|
|
<div |
|
|
|
|
|
|
|
class="capitalize text-ellipsis overflow-hidden select-none w-full pl-1.75" |
|
|
|
|
|
|
|
:style="{ wordBreak: 'keep-all', whiteSpace: 'nowrap', display: 'inline' }" |
|
|
|
|
|
|
|
> |
|
|
|
|
|
|
|
{{ record.email }} |
|
|
|
|
|
|
|
</div> |
|
|
|
|
|
|
|
</div> |
|
|
|
|
|
|
|
</span> |
|
|
|
|
|
|
|
</template> |
|
|
|
</template> |
|
|
|
</GeneralDeleteModal> |
|
|
|
</NcDropdown> |
|
|
|
<component :is="iconMap.delete" data-testid="nc-super-user-delete" class="flex h-[1rem] text-gray-500" /> |
|
|
|
|
|
|
|
<div class="text-xs pl-2">{{ $t('general.delete') }}</div> |
|
|
|
|
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</a-menu-item> |
|
|
|
</span> |
|
|
|
</a-menu> |
|
|
|
|
|
|
|
</template> |
|
|
|
|
|
|
|
</a-dropdown> |
|
|
|
|
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<span v-else></span> |
|
|
|
</section> |
|
|
|
</template> |
|
|
|
|
|
|
|
</a-table-column> |
|
|
|
|
|
|
|
</a-table> |
|
|
|
|
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<div v-if="pagination.total > 10" class="flex items-center justify-center mt-7"> |
|
|
|
<div v-if="pagination.total > 10" class="flex items-center justify-center mt-7"> |
|
|
|
<a-pagination |
|
|
|
<a-pagination |
|
|
|