|
3 | 3 | import { useState } from 'react' |
4 | 4 | import { |
5 | 5 | Chip, |
6 | | - ChipDropdown, |
7 | 6 | ChipModal, |
8 | 7 | ChipModalBody, |
9 | 8 | ChipModalError, |
@@ -80,6 +79,17 @@ export function CredentialGroupAccess({ workspaceId, groupId }: CredentialGroupA |
80 | 79 | : subjectType === 'access_control_group' |
81 | 80 | ? applicablePermissionGroups.map((group) => ({ value: group.id, label: group.name })) |
82 | 81 | : [...WORKSPACE_ROLE_OPTIONS] |
| 82 | + const targetOptionsPending = |
| 83 | + subjectType === 'workflow' |
| 84 | + ? workflows.isPending |
| 85 | + : subjectType === 'access_control_group' |
| 86 | + ? permissionConfig.isPending || permissionGroups.isPending |
| 87 | + : false |
| 88 | + const targetPlaceholder = targetOptionsPending |
| 89 | + ? `Loading ${subjectType === 'workflow' ? 'workflows' : 'access control groups'}...` |
| 90 | + : targetOptions.length === 0 |
| 91 | + ? `No ${subjectType === 'workflow' ? 'workflows' : 'access control groups'} available` |
| 92 | + : 'Select one' |
83 | 93 |
|
84 | 94 | const labelForSubject = (subject: ResourcePolicySubject): string => { |
85 | 95 | switch (subject.type) { |
@@ -229,31 +239,29 @@ export function CredentialGroupAccess({ workspaceId, groupId }: CredentialGroupA |
229 | 239 | > |
230 | 240 | <ChipModalHeader onClose={() => setShowAdd(false)}>Add access</ChipModalHeader> |
231 | 241 | <ChipModalBody> |
232 | | - <ChipModalField type='custom' title='Subject type'> |
233 | | - <ChipDropdown |
234 | | - value={subjectType} |
235 | | - onChange={(value) => { |
236 | | - setSubjectType(value as ManagedSubjectType) |
237 | | - setTargetId('') |
238 | | - setModalError(null) |
239 | | - }} |
240 | | - options={[...SUBJECT_TYPE_OPTIONS]} |
241 | | - /> |
242 | | - </ChipModalField> |
243 | 242 | <ChipModalField |
244 | | - type='custom' |
| 243 | + type='dropdown' |
| 244 | + title='Subject type' |
| 245 | + value={subjectType} |
| 246 | + onChange={(value) => { |
| 247 | + setSubjectType(value as ManagedSubjectType) |
| 248 | + setTargetId('') |
| 249 | + setModalError(null) |
| 250 | + }} |
| 251 | + options={SUBJECT_TYPE_OPTIONS} |
| 252 | + /> |
| 253 | + <ChipModalField |
| 254 | + type='dropdown' |
245 | 255 | title={subjectType === 'workspace_role' ? 'Minimum role' : 'Subject'} |
246 | | - > |
247 | | - <ChipDropdown |
248 | | - value={targetId} |
249 | | - onChange={(value) => { |
250 | | - setTargetId(value) |
251 | | - setModalError(null) |
252 | | - }} |
253 | | - options={targetOptions} |
254 | | - placeholder='Select one' |
255 | | - /> |
256 | | - </ChipModalField> |
| 256 | + value={targetId} |
| 257 | + onChange={(value) => { |
| 258 | + setTargetId(value) |
| 259 | + setModalError(null) |
| 260 | + }} |
| 261 | + options={targetOptions} |
| 262 | + placeholder={targetPlaceholder} |
| 263 | + disabled={targetOptionsPending || targetOptions.length === 0} |
| 264 | + /> |
257 | 265 | <ChipModalError>{modalError}</ChipModalError> |
258 | 266 | </ChipModalBody> |
259 | 267 | <ChipModalFooter |
|
0 commit comments