From bba20ff1b9271a381b0ce649111a1d11042ae4ea Mon Sep 17 00:00:00 2001 From: Hoang Nguyen Date: Mon, 28 Sep 2020 17:50:03 +0700 Subject: [PATCH] account: Choose `User` is the default selection when the user role is Domain Admin (#754) * account: choose `User` is the default selection when the user role is Domain Admin * renamed to userRole * Fix the incorrect variable Signed-off-by: Rohit Yadav --- ui/src/views/iam/AddAccount.vue | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/ui/src/views/iam/AddAccount.vue b/ui/src/views/iam/AddAccount.vue index fdfa44ddc35..eca86a75fe8 100644 --- a/ui/src/views/iam/AddAccount.vue +++ b/ui/src/views/iam/AddAccount.vue @@ -167,7 +167,8 @@ + :loading="timeZoneLoading" + :placeholder="apiParams.timezone.description"> {{ opt.name || opt.description }} @@ -270,6 +271,9 @@ export default { isAdminOrDomainAdmin () { return ['Admin', 'DomainAdmin'].includes(this.$store.getters.userInfo.roletype) }, + isDomainAdmin () { + return this.$store.getters.userInfo.roletype === 'DomainAdmin' + }, isValidValueForKey (obj, key) { return key in obj && obj[key] != null }, @@ -311,6 +315,12 @@ export default { api('listRoles').then(response => { this.roles = response.listrolesresponse.role || [] this.selectedRole = this.roles[0].id + if (this.isDomainAdmin()) { + const userRole = this.roles.filter(role => role.type === 'User') + if (userRole.length > 0) { + this.selectedRole = userRole[0].id + } + } }).finally(() => { this.roleLoading = false })