@@ -86,7 +86,7 @@ export default class AccessControlModal extends WebComponent {
8686 this . accessGrantRoles = this . accessGrants ?. map ( item => this . getAuthorizationRole ( item ) ) ?? [ ]
8787 this . authenticatedAccessRoleValue = this . getAuthenticatedAccessRole ( )
8888 this . publicAccessRoleValue = this . getPublicAccessRole ( )
89- void this . refreshAccessGrantLabels ( )
89+ this . refreshAccessGrantLabels ( )
9090 }
9191 }
9292
@@ -107,7 +107,7 @@ export default class AccessControlModal extends WebComponent {
107107 }
108108 }
109109
110- return this . getAuthorizationSubjectLabel ( authorization )
110+ return this . getAuthorizationSubjectLabel ( this . getSharedAuthorization ( authorization ) )
111111 } ) )
112112
113113 if ( this . accessGrants === grants ) {
@@ -118,6 +118,7 @@ export default class AccessControlModal extends WebComponent {
118118 private getAccessGrantEntries ( ) {
119119 return ( this . accessGrants ?? [ ] )
120120 . map ( ( authorization , index ) => {
121+ authorization = this . getSharedAuthorization ( authorization )
121122 const subjectLabel = this . getAccessGrantSubjectLabel ( authorization , index )
122123
123124 return {
@@ -139,10 +140,10 @@ export default class AccessControlModal extends WebComponent {
139140 }
140141
141142 private getSharedAccessGrantEntries ( ) {
142- return this . getAccessGrantEntries ( ) . filter ( ( { authorization } ) => ! this . isGeneralAccessAuthorization ( authorization ) )
143+ return this . getAccessGrantEntries ( ) . filter ( ( { authorization } ) => this . getAuthorizationSubjectIris ( authorization ) . length > 0 )
143144 }
144145
145- private renderAccessGrants ( ) {
146+ private renderAccessGrants ( ) {
146147 const query = this . searchValue . trim ( ) . toLowerCase ( )
147148 const accessGrants = this . getSharedAccessGrantEntries ( ) . filter ( ( { subjectLabel } ) => {
148149 if ( ! query ) {
@@ -239,8 +240,11 @@ export default class AccessControlModal extends WebComponent {
239240 return solidLogicSingleton . acl . roleFromModes ( authorization . mode )
240241 }
241242
242- private isGeneralAccessAuthorization ( authorization : Authorization ) : boolean {
243- return authorization . agentClass . includes ( Authenticated . iri ) || authorization . agentClass . includes ( Public . iri )
243+ private getSharedAuthorization ( authorization : Authorization ) : Authorization {
244+ return {
245+ ...authorization ,
246+ agentClass : authorization . agentClass . filter ( iri => iri !== Authenticated . iri && iri !== Public . iri )
247+ }
244248 }
245249
246250 private getAuthenticatedAccessRole ( ) : AccessRole {
@@ -493,39 +497,39 @@ export default class AccessControlModal extends WebComponent {
493497
494498 return `Share "${ subjectLabel } "`
495499 }
496-
500+
497501 protected render ( ) {
498502 const dialogTitle = this . getDialogTitle ( )
499-
503+
500504 return html `
501- < solid-ui-dialog title =${ dialogTitle } >
502- < form @submit =${ this . onSubmit } >
503- < solid-ui-dialog-content >
504- ${ this . renderAddAccessForm ( ) }
505- ${ this . renderAccessGrantsSection ( ) }
506- ${ this . renderGeneralAccessSection ( ) }
507- </ solid-ui-dialog-content >
508-
509- < solid-ui-dialog-footer >
510- < div class ="access-control-footer-actions ">
511- < solid-ui-button
512- variant ="secondary "
513- @click =${ this . onCancelClick }
514- >
515- Cancel
516- </ solid-ui-button >
517- < solid-ui-button
518- ?disabled =${ ! this . hasUnsavedChanges ( ) || this . submitting }
519- ?loading =${ this . submitting }
520- type="button"
521- @click=${ this . onSaveClick }
522- >
523- Save Changes
524- </ solid-ui-button >
525- </ div >
526- </ solid-ui-dialog-footer >
527- </ form >
528- </ solid-ui-dialog >
505+ < solid-ui-dialog title =${ dialogTitle } >
506+ < form @submit =${ this . onSubmit } >
507+ < solid-ui-dialog-content >
508+ ${ this . renderAddAccessForm ( ) }
509+ ${ this . renderAccessGrantsSection ( ) }
510+ ${ this . renderGeneralAccessSection ( ) }
511+ </ solid-ui-dialog-content >
512+
513+ < solid-ui-dialog-footer >
514+ < div class ="access-control-footer-actions ">
515+ < solid-ui-button
516+ variant ="secondary "
517+ @click =${ this . onCancelClick }
518+ >
519+ Cancel
520+ </ solid-ui-button >
521+ < solid-ui-button
522+ ?disabled =${ ! this . hasUnsavedChanges ( ) || this . submitting }
523+ ?loading =${ this . submitting }
524+ type="button"
525+ @click=${ this . onSaveClick }
526+ >
527+ Save Changes
528+ </ solid-ui-button >
529+ </ div >
530+ </ solid-ui-dialog-footer >
531+ </ form >
532+ </ solid-ui-dialog >
529533 `
530534 }
531535
@@ -545,7 +549,11 @@ export default class AccessControlModal extends WebComponent {
545549 }
546550
547551 if ( this . principalInputValue . trim ( ) ) {
548- await this . commitPrinciplesFromInputSafely ( )
552+ const committed = await this . commitPrinciplesFromInputSafely ( )
553+
554+ if ( ! committed ) {
555+ return
556+ }
549557 }
550558
551559 await this . saveAccessChanges ( )
@@ -620,7 +628,7 @@ export default class AccessControlModal extends WebComponent {
620628 return
621629 }
622630
623- void this . queuePendingPrinciples ( [ option . value ] , this . addAccessRoleValue , option . label )
631+ this . queuePendingPrinciples ( [ option . value ] , this . addAccessRoleValue , option . label )
624632 }
625633
626634 private onSearchInput ( event : Event ) {
@@ -727,7 +735,7 @@ export default class AccessControlModal extends WebComponent {
727735 return undefined
728736 }
729737
730- const subjects = this . getAuthorizationSubjectEntries ( authorization )
738+ const subjects = this . getAuthorizationSubjectEntries ( this . getSharedAuthorization ( authorization ) )
731739 if ( ! subjects . length ) {
732740 return undefined
733741 }
@@ -783,8 +791,7 @@ export default class AccessControlModal extends WebComponent {
783791 return false
784792 }
785793
786- await this . queuePendingPrinciples ( [ rawValue ] , this . addAccessRoleValue , undefined , rawValue )
787- return true
794+ return this . queuePendingPrinciples ( [ rawValue ] , this . addAccessRoleValue , undefined , rawValue )
788795 }
789796
790797 private async commitPrinciplesFromInputSafely ( ) : Promise < boolean > {
@@ -802,7 +809,7 @@ export default class AccessControlModal extends WebComponent {
802809 role : AccessRole = this . addAccessRoleValue ,
803810 preferredLabel ?: string ,
804811 inputSnapshot ?: string
805- ) {
812+ ) : Promise < boolean > {
806813 const snapshot = inputSnapshot ?? this . principalInputValue . trim ( )
807814 const pendingGrantResults = await Promise . all ( principles . map ( async principle => this . createPendingAccessGrant ( principle , role , preferredLabel ) ) )
808815 const newGrants = pendingGrantResults . flatMap ( result => ( 'grant' in result ? [ result . grant ] : [ ] ) )
@@ -811,17 +818,25 @@ export default class AccessControlModal extends WebComponent {
811818 . map ( result => `${ result . principle } (${ result . error } )` )
812819
813820 if ( ! newGrants . length ) {
821+ if ( failedGrants . length ) {
822+ this . failed = true
823+ }
814824 this . logPendingGrantFailures ( failedGrants , false )
815- return
825+ return false
816826 }
817827
818828 const merged = [ ...this . pendingAccessGrants , ...newGrants ]
819829 this . pendingAccessGrants = this . dedupePendingAccessGrants ( merged )
830+ if ( failedGrants . length ) {
831+ this . failed = true
832+ }
820833 this . logPendingGrantFailures ( failedGrants , true )
821834
822- if ( this . principalInputValue . trim ( ) === snapshot ) {
835+ if ( ! failedGrants . length && this . principalInputValue . trim ( ) === snapshot ) {
823836 this . principalInputValue = ''
824837 }
838+
839+ return failedGrants . length === 0
825840 }
826841
827842 private async createPendingAccessGrant (
0 commit comments