Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 27 additions & 4 deletions ui/src/views/UserEditView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@
v-model holds an array of group **names** (strings),
matching the payload contract of rest/service/id/user. -->
<v-autocomplete
v-if="isEdit"
v-model="groups"
v-model:menu="groupMenu"
:items="groupResults"
:loading="groupLoading"
:search="groupSearchQuery"
Expand Down Expand Up @@ -191,6 +191,7 @@ let companyDebounce = null
const groupSearchQuery = ref('')
const groupResults = ref([])
const groupLoading = ref(false)
const groupMenu = ref(false)
let groupDebounce = null

const isEdit = computed(() => !!route.params.id)
Expand Down Expand Up @@ -286,6 +287,24 @@ function onGroupModelUpdate() {
groupResults.value = []
}

/** Preload the first page of groups so the dropdown can be opened
* with content already visible on mount (used on /new where the user
* has no pre-selected groups). The list endpoint returns 200 with an
* empty array when no IAM is configured, so this is safe to call. */
async function preloadGroups() {
groupLoading.value = true
try {
const url = 'rest/service/id/group?rows=20&page=1&sidx=name&sord=asc'
const resp = await api.get(url)
groupResults.value = Array.isArray(resp) ? resp : (Array.isArray(resp?.data) ? resp.data : [])
} catch (err) {
console.error('Group preload failed:', err)
groupResults.value = []
} finally {
groupLoading.value = false
}
}

async function searchGroups(query) {
if (!query || query.length < 1) {
groupResults.value = []
Expand Down Expand Up @@ -406,6 +425,11 @@ onMounted(async () => {
demoMode.value = true
errorStore.clear()
}
// Preload group list and open the dropdown so the available groups
// are visible on mount (per Fabrice's UX feedback). Only on /new
// since /edit already shows the user's existing groups as chips.
await preloadGroups()
groupMenu.value = true
}
initGuard()
})
Expand All @@ -427,9 +451,8 @@ async function save() {
company: form.value.company,
mail: form.value.mail,
// groups is an array of names (strings). Defensive `.map(g => g.name || g)`
// in case any legacy object slipped through. Only sent on edit since the
// groups field is hidden on New User for this PR.
...(isEdit.value ? { groups: groups.value.map(g => g.name || g) } : {}),
// in case any legacy object slipped through.
groups: groups.value.map(g => g.name || g),
}

if (isEdit.value) {
Expand Down
Loading