Browse Source

refactor/gui-v2-user-management-invite-button-cleanup-and-ui-improvements

pull/2854/head
Muhammed Mustafa 2 years ago
parent
commit
20f9e0afcc
  1. 12
      packages/nc-gui-v2/components/dashboard/settings/userManagement/ShareBase.vue
  2. 11
      packages/nc-gui-v2/components/dashboard/settings/userManagement/UsersModal.vue

12
packages/nc-gui-v2/components/dashboard/settings/userManagement/ShareBase.vue

@ -16,11 +16,8 @@ interface ShareBase {
role?: string role?: string
} }
enum Role { enum ShareBaseRole {
Owner = 'owner',
Editor = 'editor', Editor = 'editor',
User = 'user',
Guest = 'guest',
Viewer = 'viewer', Viewer = 'viewer',
} }
@ -47,7 +44,7 @@ const loadBase = async () => {
} }
} }
const createShareBase = async (role = Role.Viewer) => { const createShareBase = async (role = ShareBaseRole.Viewer) => {
try { try {
if (!project.value.id) return if (!project.value.id) return
@ -198,8 +195,7 @@ onMounted(() => {
<a-menu> <a-menu>
<a-menu-item> <a-menu-item>
<div v-if="base?.uuid" @click="disableSharedBase">Disable shared base</div> <div v-if="base?.uuid" @click="disableSharedBase">Disable shared base</div>
<div v-else @click="createShareBase(ShareBaseRole.Viewer)">Anyone with the link</div>
<div v-else @click="createShareBase(Role.Viewer)">Anyone with the link</div>
</a-menu-item> </a-menu-item>
</a-menu> </a-menu>
</template> </template>
@ -207,7 +203,7 @@ onMounted(() => {
<a-select v-if="base?.uuid" v-model:value="base.role" class="flex"> <a-select v-if="base?.uuid" v-model:value="base.role" class="flex">
<a-select-option <a-select-option
v-for="(role, index) in [Role.Editor, Role.Viewer]" v-for="(role, index) in [ShareBaseRole.Editor, ShareBaseRole.Viewer]"
:key="index" :key="index"
:value="role" :value="role"
dropdown-class-name="capitalize" dropdown-class-name="capitalize"

11
packages/nc-gui-v2/components/dashboard/settings/userManagement/UsersModal.vue

@ -15,12 +15,13 @@ import { isEmail } from '~~/utils/validation'
const { show, selectedUser } = defineProps<Props>() const { show, selectedUser } = defineProps<Props>()
const emits = defineEmits(['closed']) const emits = defineEmits(['closed'])
const toast = useToast() const toast = useToast()
interface Props { interface Props {
show: boolean show: boolean
selectedUser?: User selectedUser?: User
} }
interface Users { interface Users {
emails: string emails?: string
role: ProjectRole role: ProjectRole
invitationToken?: string invitationToken?: string
} }
@ -28,8 +29,7 @@ interface Users {
const { project } = useProject() const { project } = useProject()
const { $api, $e } = useNuxtApp() const { $api, $e } = useNuxtApp()
const usersData = $ref<Users>({ emails: '', role: ProjectRole.Guest, invitationToken: undefined }) const usersData = $ref<Users>({ emails: undefined, role: ProjectRole.Guest, invitationToken: undefined })
let isFirstRender = $ref(true)
const inviteToken = $ref(null) const inviteToken = $ref(null)
const formRef = ref() const formRef = ref()
@ -58,11 +58,10 @@ const validators = computed(() => {
const { validateInfos } = useForm(usersData, validators) const { validateInfos } = useForm(usersData, validators)
onMounted(() => { onMounted(() => {
if (isFirstRender && selectedUser) { if (!usersData.emails && selectedUser?.email) {
usersData.emails = selectedUser.email usersData.emails = selectedUser.email
usersData.role = selectedUser.roles usersData.role = selectedUser.roles
} }
if (isFirstRender) isFirstRender = false
}) })
const saveUser = async () => { const saveUser = async () => {
@ -112,7 +111,7 @@ const clickInviteMore = () => {
$e('c:user:invite-more') $e('c:user:invite-more')
usersData.invitationToken = undefined usersData.invitationToken = undefined
usersData.role = ProjectRole.Guest usersData.role = ProjectRole.Guest
usersData.emails = '' usersData.emails = undefined
} }
</script> </script>

Loading…
Cancel
Save