diff --git a/packages/nc-gui/components/dashboard/Sidebar/TopSection.vue b/packages/nc-gui/components/dashboard/Sidebar/TopSection.vue index 794d6c5f01..bf8e565ebf 100644 --- a/packages/nc-gui/components/dashboard/Sidebar/TopSection.vue +++ b/packages/nc-gui/components/dashboard/Sidebar/TopSection.vue @@ -57,7 +57,7 @@ const navigateToIntegrations = () => { { return props.type === 'base' ? ProjectRoles : WorkspaceUserRoles }) +const userRoles = computed(() => { + return props.type === 'base' ? baseRoles?.value : workspaceRoles?.value +}) const inviteData = reactive({ email: '', @@ -47,6 +52,8 @@ const emailBadges = ref>([]) const allowedRoles = ref<[]>([]) +const disabledRoles = ref<[]>([]) + const isLoading = ref(false) const organizationStore = useOrganization() @@ -77,13 +84,15 @@ const focusOnDiv = () => { watch(dialogShow, async (newVal) => { if (newVal) { try { - // todo: enable after discussing with anbu - // const currentRoleIndex = Object.values(orderedRoles.value).findIndex( - // (role) => userRoles.value && Object.keys(userRoles.value).includes(role), - // ) - // if (currentRoleIndex !== -1) { - allowedRoles.value = Object.values(orderedRoles.value) // .slice(currentRoleIndex + 1) - // } + const rolesArr = Object.values(orderedRoles.value) + const currentRoleIndex = rolesArr.findIndex((role) => userRoles.value && Object.keys(userRoles.value).includes(role)) + if (currentRoleIndex !== -1) { + allowedRoles.value = rolesArr.slice(currentRoleIndex) + disabledRoles.value = rolesArr.slice(0, currentRoleIndex) + } else { + allowedRoles.value = rolesArr + disabledRoles.value = [] + } } catch (e: any) { message.error(await extractSdkResponseErrorMsg(e)) } @@ -350,6 +359,7 @@ const onRoleChange = (role: keyof typeof RoleLabels) => (inviteData.roles = role :description="false" :on-role-change="onRoleChange" :role="inviteData.roles" + :disabled-roles="disabledRoles" :roles="allowedRoles" class="!min-w-[152px] nc-invite-role-selector" size="lg" diff --git a/packages/nc-gui/components/general/Gift.vue b/packages/nc-gui/components/general/Gift.vue index c14687c15b..516afc6f9b 100644 --- a/packages/nc-gui/components/general/Gift.vue +++ b/packages/nc-gui/components/general/Gift.vue @@ -1,8 +1,8 @@