Skip to content

Commit ef90078

Browse files
authored
Member role management fixes (#695)
* Ensure that member roles currently not supported by the dashboard don't get lost when updating a member Fixed autofocus for some dialogs * changes as discussed * revert * Fix secret access in slots * Revert "Fix secret access in slots" This reverts commit 90cc626. * Fixed secret page, had to move code to parent component due to regression in Vue 2.6 The new v-slot directive, does not provide access to the slotProps to use in an v-if to overwrite the slot conditionally and have the default (fallback) slot content rendered otherwise. See also these related issues: vuejs/vue#10784 vuejs/vue#9725 vuejs/vue#9658
1 parent 1f6fd08 commit ef90078

File tree

9 files changed

+58
-64
lines changed

9 files changed

+58
-64
lines changed

frontend/src/components/NewShoot/NewShootDetails.vue

+3-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ limitations under the License.
8080
import HintColorizer from '@/components/HintColorizer'
8181
import Purpose from '@/components/Purpose'
8282
import { mapGetters, mapState } from 'vuex'
83-
import { getValidationErrors, compileMarkdown } from '@/utils'
83+
import { getValidationErrors, compileMarkdown, setDelayedInputFocus } from '@/utils'
8484
import { required, maxLength } from 'vuelidate/lib/validators'
8585
import { resourceName, noStartEndHyphen, noConsecutiveHyphen } from '@/utils/validators'
8686
import head from 'lodash/head'
@@ -251,6 +251,8 @@ export default {
251251
this.userInterActionBus.on('updateK8sMaintenance', updateK8sMaintenance => {
252252
this.updateK8sMaintenance = updateK8sMaintenance
253253
})
254+
255+
setDelayedInputFocus(this, 'name')
254256
}
255257
}
256258
</script>

frontend/src/components/ProjectServiceAccountRow.vue

+5-3
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,11 @@ limitations under the License.
6060
</v-list-item-subtitle>
6161
</v-list-item-content>
6262
<v-list-item-action class="ml-1">
63-
<v-chip class="mr-3" v-for="roleName in roleDisplayNames" :key="roleName" small color="black" outlined>
64-
{{roleName}}
65-
</v-chip>
63+
<div d-flex flex-row>
64+
<v-chip class="mr-3" v-for="roleName in roleDisplayNames" :key="roleName" small color="black" outlined>
65+
{{roleName}}
66+
</v-chip>
67+
</div>
6668
</v-list-item-action>
6769
<v-list-item-action v-if="isServiceAccountFromCurrentNamespace && canGetSecrets" class="ml-1">
6870
<v-tooltip top>

frontend/src/components/ProjectUserRow.vue

+5-3
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,11 @@ limitations under the License.
3131
</v-list-item-subtitle>
3232
</v-list-item-content>
3333
<v-list-item-action class="ml-1">
34-
<v-chip class="mr-3" v-for="roleName in roleDisplayNames" :key="roleName" small color="grey darken-4" outlined>
35-
{{roleName}}
36-
</v-chip>
34+
<div d-flex flex-row>
35+
<v-chip class="mr-3" v-for="roleName in roleDisplayNames" :key="roleName" small color="grey darken-4" outlined>
36+
{{roleName}}
37+
</v-chip>
38+
</div>
3739
</v-list-item-action>
3840
<v-list-item-action v-if="canPatchProject" class="ml-1">
3941
<v-tooltip top>

frontend/src/components/Secret.vue

+22-6
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,28 @@ limitations under the License.
3838
<!-- List of the added secrets -->
3939
<v-list two-line v-else>
4040
<secret-row
41-
v-for="row in rows"
42-
:key="row.metadata.name"
43-
:secret="row"
41+
v-for="secret in rows"
42+
:key="secret.metadata.name"
43+
:secret="secret"
4444
:secretDescriptorKey="secretDescriptorKey"
4545
@update="onUpdate"
4646
@delete="onDelete"
4747
>
48-
<!-- forward slot -->
49-
<template v-slot:rowSubTitle>
50-
<slot name="rowSubTitle" :secret="row"></slot>
48+
<template v-if="infrastructureKey === 'openstack' && isOwnSecretBinding(secret)" v-slot:rowSubTitle>
49+
{{secret.data.domainName}} / {{secret.data.tenantName}}
50+
</template>
51+
<template v-else-if="infrastructureKey === 'vsphere' && isOwnSecretBinding(secret)" v-slot:rowSubTitle>
52+
<v-tooltip top>
53+
<template v-slot:activator="{ on }">
54+
<span v-on="on">{{secret.data.vsphereUsername}}</span>
55+
</template>
56+
<span>vSphere Username</span>
57+
</v-tooltip> / <v-tooltip top>
58+
<template v-slot:activator="{ on }">
59+
<span v-on="on">{{secret.data.nsxtUsername}}</span>
60+
</template>
61+
<span>NSX-T Username</span>
62+
</v-tooltip>
5163
</template>
5264
</secret-row>
5365
</v-list>
@@ -59,6 +71,7 @@ limitations under the License.
5971
import { mapGetters } from 'vuex'
6072
import SecretRow from '@/components/SecretRow'
6173
import InfraIcon from '@/components/VendorIcon'
74+
import { isOwnSecretBinding } from '@/utils'
6275

6376
export default {
6477
components: {
@@ -128,6 +141,9 @@ export default {
128141
},
129142
onDelete (row) {
130143
this.$emit('delete', row)
144+
},
145+
isOwnSecretBinding (secret) {
146+
return isOwnSecretBinding(secret)
131147
}
132148
}
133149
}

frontend/src/components/ShootDetails/ShootDetailsCard.vue

+2-1
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,9 @@ limitations under the License.
8282
</v-list-item-icon>
8383
<v-list-item-content>
8484
<v-list-item-subtitle>Worker Groups</v-list-item-subtitle>
85-
<v-list-item-title class="d-flex align-center pt-1">
85+
<v-list-item-title class="d-flex flex-wrap align-center pt-1">
8686
<worker-group
87+
class="mr-2 mb-2"
8788
v-for="workerGroup in shootWorkerGroups"
8889
:workerGroup="workerGroup"
8990
:cloudProfileName="shootCloudProfileName"

frontend/src/components/dialogs/MemberDialog.vue

+18-16
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ limitations under the License.
4242
<v-col cols="4">
4343
<v-select
4444
color="black"
45+
item-color="black"
4546
label="Roles"
4647
:items="roleItems"
4748
multiple
@@ -80,10 +81,12 @@ import { required } from 'vuelidate/lib/validators'
8081
import { resourceName, unique } from '@/utils/validators'
8182
import GAlert from '@/components/GAlert'
8283
import { errorDetailsFromError, isConflict } from '@/utils/error'
83-
import { serviceAccountToDisplayName, isServiceAccount, setInputFocus, getValidationErrors, MEMBER_ROLE_DESCRIPTORS } from '@/utils'
84+
import { serviceAccountToDisplayName, isServiceAccount, setDelayedInputFocus, getValidationErrors, MEMBER_ROLE_DESCRIPTORS } from '@/utils'
8485
import filter from 'lodash/filter'
8586
import map from 'lodash/map'
8687
import includes from 'lodash/includes'
88+
import forEach from 'lodash/forEach'
89+
import find from 'lodash/find'
8790

8891
const defaultUsername = ''
8992
const defaultServiceName = 'robot'
@@ -117,6 +120,7 @@ export default {
117120
return {
118121
internalName: undefined,
119122
internalRoles: undefined,
123+
unsupportedRoles: undefined,
120124
errorMessage: undefined,
121125
detailedErrorMessage: undefined
122126
}
@@ -200,11 +204,8 @@ export default {
200204
isUpdateDialog () {
201205
return this.type === 'updateuser' || this.type === 'updateservice'
202206
},
203-
textField () {
204-
return this.$refs.internalName
205-
},
206207
roleItems () {
207-
return filter(MEMBER_ROLE_DESCRIPTORS, role => role.hidden !== true)
208+
return MEMBER_ROLE_DESCRIPTORS
208209
},
209210
nameLabel () {
210211
return this.isUserDialog ? 'User' : 'Service Account'
@@ -287,7 +288,7 @@ export default {
287288
if (this.valid) {
288289
try {
289290
const name = this.memberName
290-
const roles = this.internalRoles
291+
const roles = [...this.internalRoles, ...this.unsupportedRoles]
291292
await this.updateMember({ name, roles })
292293
if (this.isCurrentUser && !this.isAdmin) {
293294
await this.refreshSubjectRules()
@@ -323,9 +324,18 @@ export default {
323324
}
324325

325326
if (this.roles) {
326-
this.internalRoles = [...this.roles]
327+
this.internalRoles = []
328+
this.unsupportedRoles = []
329+
forEach(this.roles, role => {
330+
if (find(this.roleItems, { name: role })) {
331+
this.internalRoles.push(role)
332+
} else {
333+
this.unsupportedRoles.push(role)
334+
}
335+
})
327336
} else {
328337
this.internalRoles = [defaultRole]
338+
this.unsupportedRoles = []
329339
}
330340

331341
this.errorMessage = undefined
@@ -334,9 +344,7 @@ export default {
334344
this.setFocusAndSelection()
335345
},
336346
setFocusAndSelection () {
337-
if (this.textField) {
338-
setInputFocus(this, 'name')
339-
}
347+
setDelayedInputFocus(this, 'internalName')
340348
},
341349
defaultServiceName () {
342350
let name = defaultServiceName
@@ -355,12 +363,6 @@ export default {
355363
this.reset()
356364
}
357365
}
358-
},
359-
mounted () {
360-
if (this.textField) {
361-
const input = this.textField.$refs.input
362-
input.style.textTransform = 'lowercase'
363-
}
364366
}
365367
}
366368
</script>

frontend/src/utils/index.js

-5
Original file line numberDiff line numberDiff line change
@@ -689,11 +689,6 @@ export const MEMBER_ROLE_DESCRIPTORS = [
689689
{
690690
name: 'viewer',
691691
displayName: 'Viewer'
692-
},
693-
{
694-
name: 'owner',
695-
displayName: 'Technical Contact',
696-
hidden: true // Do not show on UI as currently cannot be modified
697692
}
698693
]
699694

frontend/src/views/Members.vue

+1-5
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,6 @@ import forEach from 'lodash/forEach'
209209
import join from 'lodash/join'
210210
import map from 'lodash/map'
211211
import find from 'lodash/find'
212-
import upperFirst from 'lodash/upperFirst'
213212
import escape from 'lodash/escape'
214213
import MemberDialog from '@/components/dialogs/MemberDialog'
215214
import MemberHelpDialog from '@/components/dialogs/MemberHelpDialog'
@@ -455,10 +454,7 @@ export default {
455454
const displayNames = []
456455
forEach(roleNames, roleName => {
457456
const roleDescriptor = find(MEMBER_ROLE_DESCRIPTORS, { name: roleName })
458-
if (!roleDescriptor) {
459-
displayNames.push(upperFirst(roleName))
460-
}
461-
if (!roleDescriptor.hidden) {
457+
if (roleDescriptor) {
462458
displayNames.push(roleDescriptor.displayName)
463459
}
464460
})

frontend/src/views/Secrets.vue

+2-24
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,7 @@ limitations under the License.
7373
@toogleHelp="onToogleHelp"
7474
@update="onUpdate"
7575
@delete="onDelete"
76-
>
77-
<template v-if="isOwnSecretBinding(secret)" v-slot:rowSubTitle="{ secret }">
78-
{{secret.data.domainName}} / {{secret.data.tenantName}}
79-
</template>
80-
</secret>
76+
></secret>
8177

8278
<secret
8379
v-if="hasCloudProfileForCloudProviderKind('alicloud')"
@@ -122,21 +118,7 @@ limitations under the License.
122118
@toogleHelp="onToogleHelp"
123119
@update="onUpdate"
124120
@delete="onDelete"
125-
>
126-
<template v-if="isOwnSecretBinding(secret)" v-slot:rowSubTitle="{ secret }">
127-
<v-tooltip top>
128-
<template v-slot:activator="{ on }">
129-
<span v-on="on">{{secret.data.vsphereUsername}}</span>
130-
</template>
131-
<span>vSphere Username</span>
132-
</v-tooltip> / <v-tooltip top>
133-
<template v-slot:activator="{ on }">
134-
<span v-on="on">{{secret.data.nsxtUsername}}</span>
135-
</template>
136-
<span>NSX-T Username</span>
137-
</v-tooltip>
138-
</template>
139-
</secret>
121+
></secret>
140122

141123
<template v-if="showDisabledCloudProviders">
142124

@@ -206,7 +188,6 @@ limitations under the License.
206188
<script>
207189
import { mapGetters } from 'vuex'
208190
import get from 'lodash/get'
209-
import { isOwnSecretBinding } from '@/utils'
210191
import DeleteDialog from '@/components/dialogs/SecretDialogDelete'
211192
import SecretDialogWrapper from '@/components/dialogs/SecretDialogWrapper'
212193
import Secret from '@/components/Secret'
@@ -323,9 +304,6 @@ export default {
323304
},
324305
hideDialogs () {
325306
merge(this.dialogState, this.initialDialogState)
326-
},
327-
isOwnSecretBinding (secret) {
328-
return isOwnSecretBinding(secret)
329307
}
330308
},
331309
mounted () {

0 commit comments

Comments
 (0)