@ -28,14 +28,23 @@ export interface ShareAnnotations {
users : Map < string , ShareAnnotation > ; // Annotations keyed by normalized user email.
users : Map < string , ShareAnnotation > ; // Annotations keyed by normalized user email.
}
}
export interface ShareAnnotatorOptions {
supportEmail? : string ; // Known email address of the support user (e.g. support@getgrist.com).
}
/ * *
/ * *
* Helper for annotating users mentioned in a proposed change of shares , given the
* Helper for annotating users mentioned in a proposed change of shares , given the
* current shares in place .
* current shares in place .
* /
* /
export class ShareAnnotator {
export class ShareAnnotator {
private _features = this . _product ? . features ? ? { } ;
private _features = this . _product ? . features ? ? { } ;
private _supportEmail = this . _options . supportEmail ;
constructor ( private _product : Product | null , private _state : PermissionData ) {
constructor (
private _product : Product | null ,
private _state : PermissionData ,
private _options : ShareAnnotatorOptions = { }
) {
}
}
public updateState ( state : PermissionData ) {
public updateState ( state : PermissionData ) {
@ -84,7 +93,10 @@ export class ShareAnnotator {
. map ( ( [ k , ] ) = > normalizeEmail ( k ) ) ) ;
. map ( ( [ k , ] ) = > normalizeEmail ( k ) ) ) ;
for ( const email of tweaks ) {
for ( const email of tweaks ) {
const annotation = annotations . users . get ( email ) || makeAnnotation ( {
const annotation = annotations . users . get ( email ) || makeAnnotation ( {
email , isMember : false , access : '<set>' ,
email ,
isMember : false ,
isSupport : Boolean ( email . trim ( ) !== '' && email === this . _supportEmail ) ,
access : '<set>' ,
} ) ;
} ) ;
annotations . users . set ( email , annotation ) ;
annotations . users . set ( email , annotation ) ;
}
}