@ -5,23 +5,26 @@ import type { SelectValue } from 'ant-design-vue/es/select'
const props = withDefaults (
const props = withDefaults (
defineProps < {
defineProps < {
border ? : boolean
role : keyof typeof RoleLabels
role : keyof typeof RoleLabels
roles : ( keyof typeof RoleLabels ) [ ]
roles : ( keyof typeof RoleLabels ) [ ]
onRoleChange : ( role : keyof typeof RoleLabels ) => void
border ? : boolean
description ? : boolean
description ? : boolean
inherit ? : string
inherit ? : string
onRoleChange : ( role : keyof typeof RoleLabels ) => void
size ? : 'sm' | 'md' | 'lg'
size ? : 'sm' | 'md' | 'lg'
showInherit ? : boolean
} > ( ) ,
} > ( ) ,
{
{
border : true ,
border : true ,
description : true ,
description : true ,
size : 'sm' ,
size : 'sm' ,
showInherit : false ,
} ,
} ,
)
)
const roleRef = toRef ( props , 'role' )
const roleRef = toRef ( props , 'role' )
const inheritRef = toRef ( props , 'inherit' )
const inheritRef = toRef ( props , 'inherit' )
const showInherit = toRef ( props , 'showInherit' )
const descriptionRef = toRef ( props , 'description' )
const descriptionRef = toRef ( props , 'description' )
const isDropdownOpen = ref ( false )
const isDropdownOpen = ref ( false )
const dropdownRef = ref ( null )
const dropdownRef = ref ( null )
@ -36,14 +39,38 @@ function onChangeRole(val: SelectValue) {
< / script >
< / script >
< template >
< template >
< div ref = "dropdownRef" size = "lg" class = "nc-roles-selector relative" @ click = "isDropdownOpen = !isDropdownOpen" >
< div
< RolesBadge :border ="false" : inherit = "inheritRef === role" :role ="roleRef" :size ="sizeRef" clickable data -testid = " roles " / >
ref = "dropdownRef"
size = "lg"
class = "nc-roles-selector relative flex items-center gap-3"
@ click = "isDropdownOpen = !isDropdownOpen"
>
< RolesBadge
: border = "false"
: inherit = "inheritRef === role"
: role = "roleRef"
: size = "sizeRef"
clickable
data - testid = "roles"
class = "flex-none"
/ >
< NcTooltip
v - if = "showInherit && isEeUI && inheritRef === role"
class = "uppercase text-[10px] leading-4 text-gray-500"
placement = "bottom"
>
< template # title >
{ { $t ( 'tooltip.roleInheritedFromWorkspace' ) } }
< / template >
{ { $t ( 'objects.workspace' ) } }
< / NcTooltip >
< a -select
< a -select
: value = "roleRef"
: value = "roleRef"
: open = "isDropdownOpen"
: open = "isDropdownOpen"
: dropdown - match - select - width = "false"
: dropdown - match - select - width = "false"
dropdown - class - name = "!rounded-lg !h-fit max-w-[350px] nc-role-selector-dropdown"
dropdown - class - name = "!rounded-lg !h-fit max-w-[350px] nc-role-selector-dropdown"
class = "py-1 !absolute top-0 left-0 w-full h-full z-10 text-xs opacity-0"
class = "py-1 !absolute top-0 left-0 w-20 h-full z-10 text-xs opacity-0"
@ change = "onChangeRole"
@ change = "onChangeRole"
>
>
< a -select -option v-for ="rl in props.roles" :key="rl" v-e="['c:workspace:settings:user-role-change']" :value ="rl" >
< a -select -option v-for ="rl in props.roles" :key="rl" v-e="['c:workspace:settings:user-role-change']" :value ="rl" >