@@ -2,12 +2,13 @@ import { customElement, WebComponent } from '@/lib/components'
22import { html , nothing } from 'lit'
33import { property } from 'lit/decorators.js'
44import { ACCESS_ROLES , type AccessRole , type DirectoryEntry } from 'solid-logic'
5- import type { AsyncComboboxOptionsProvider , ComboboxChangeEvent } from '@/components/combobox'
5+ import type { AsyncComboboxOptionsProvider , ComboboxChangeEvent , ComboboxOptionData } from '@/components/combobox'
66
77import '~icons/lucide/book-user'
88import '~icons/lucide/user-round'
99import '~icons/lucide/users'
1010import '~icons/lucide/circle-x'
11+ import '~icons/lucide/globe'
1112import '@/components/button'
1213import '@/components/combobox'
1314import '@/components/combobox-option'
@@ -56,6 +57,9 @@ export default class AccessControlAddAccess extends WebComponent {
5657 @property ( { attribute : false } )
5758 accessor inputError = ''
5859
60+ @property ( { type : Boolean } )
61+ accessor disabled = false
62+
5963 @property ( { attribute : false } )
6064 accessor asyncOptionsProvider : AsyncComboboxOptionsProvider | null = null
6165
@@ -69,15 +73,16 @@ export default class AccessControlAddAccess extends WebComponent {
6973 }
7074
7175 private onPrincipalSelect ( event : ComboboxChangeEvent ) {
72- const option = event . detail . option
76+ const option = event . detail . option as ComboboxOptionData & { targetKind ?: 'origin' | 'trustedApp' }
7377 if ( typeof option . value !== 'string' ) {
7478 return
7579 }
7680
7781 this . dispatchEvent ( new CustomEvent < TargetSelectedDetail > ( 'target-selected' , {
7882 detail : {
7983 value : option . value ,
80- label : option . label
84+ label : option . label ,
85+ targetKind : option . targetKind
8186 } ,
8287 bubbles : true ,
8388 composed : true
@@ -86,12 +91,15 @@ export default class AccessControlAddAccess extends WebComponent {
8691
8792 private onRoleChange ( event : ComboboxChangeEvent ) {
8893 const role = event . detail . option . value
89- if ( typeof role !== 'string' || ! ACCESS_ROLES . includes ( role as AccessRole ) ) {
94+ const accessRole = typeof role === 'string'
95+ ? ACCESS_ROLES . find ( candidate => candidate === role )
96+ : undefined
97+ if ( ! accessRole ) {
9098 return
9199 }
92100
93101 this . dispatchEvent ( new CustomEvent < RoleChangedDetail > ( 'role-changed' , {
94- detail : { role : role as AccessRole } ,
102+ detail : { role : accessRole } ,
95103 bubbles : true ,
96104 composed : true
97105 } ) )
@@ -118,6 +126,7 @@ export default class AccessControlAddAccess extends WebComponent {
118126 < div class ="access-grants-input ">
119127 < solid-ui-combobox
120128 class ="access-principal-combobox "
129+ .disabled =${ this . disabled }
121130 label ="Add person, group or software agent URL."
122131 .srOnlyLabel=${ true }
123132 .value=${ this . principalInputValue }
@@ -133,6 +142,7 @@ export default class AccessControlAddAccess extends WebComponent {
133142 </ div >
134143 < solid-ui-combobox
135144 class ="access-role-select access-role-select--top "
145+ .disabled =${ this . disabled }
136146 .value =${ this . addAccessRoleValue }
137147 @change=${ this . onRoleChange }
138148 >
@@ -156,11 +166,17 @@ export default class AccessControlAddAccess extends WebComponent {
156166 < div class ="access-grants-pending ">
157167 ${ this . pendingAccessGrants . map ( ( grant , index ) => html `
158168 < div class ="access-grants-pending-item ">
159- < span class ="access-grants-pending-item-label "> ${ grant . label } </ span >
169+ < span class ="access-grants-pending-item-label ">
170+ ${ grant . targetKind === 'trustedApp'
171+ ? html `< icon-lucide-globe style ="width: 13px; height: 13px; vertical-align: -2px; "> </ icon-lucide-globe > `
172+ : nothing }
173+ ${ grant . label }
174+ </ span >
160175 < solid-ui-button
161176 type ="button "
162177 variant ="ghost "
163178 class ="access-grants-pending-item-remove "
179+ ?disabled =${ this . disabled }
164180 @click =${ ( ) => this . onPendingGrantRemove ( index ) }
165181 >
166182 < span class ="sr-only "> Remove ${ grant . label } </ span >
0 commit comments