mirror of
				https://github.com/gristlabs/grist-core.git
				synced 2025-06-13 20:53:59 +00:00 
			
		
		
		
	(core) Show ACL link in UserManager conditionally
Summary: The 'Open Access Rules' link is now hidden unless the UserManager is opened inside a document, and the resource that users are being managed for is a document. Test Plan: Browser tests. Reviewers: dsagal Reviewed By: dsagal Differential Revision: https://phab.getgrist.com/D3142
This commit is contained in:
		
							parent
							
								
									c7331e2453
								
							
						
					
					
						commit
						05eb7afcb6
					
				@ -1,3 +1,4 @@
 | 
			
		||||
import {GristDoc} from 'app/client/components/GristDoc';
 | 
			
		||||
import {AppModel} from 'app/client/models/AppModel';
 | 
			
		||||
import {DocPageModel} from 'app/client/models/DocPageModel';
 | 
			
		||||
import {reportWarning} from 'app/client/models/errors';
 | 
			
		||||
@ -25,6 +26,8 @@ export interface UserManagerModel {
 | 
			
		||||
  isOrg: boolean;                              // Indicates if the UserManager is for an org
 | 
			
		||||
  annotations: Observable<ShareAnnotations>;   // More information about shares, keyed by email.
 | 
			
		||||
 | 
			
		||||
  gristDoc: GristDoc|null;                     // Populated if there is an open document.
 | 
			
		||||
 | 
			
		||||
  // Resets all unsaved changes
 | 
			
		||||
  reset(): void;
 | 
			
		||||
  // Recreate annotations, factoring in any changes on the back-end.
 | 
			
		||||
@ -119,6 +122,8 @@ export class UserManagerModelImpl extends Disposable implements UserManagerModel
 | 
			
		||||
 | 
			
		||||
  public isOrg: boolean = this.resourceType === 'organization';
 | 
			
		||||
 | 
			
		||||
  public gristDoc: GristDoc|null;
 | 
			
		||||
 | 
			
		||||
  // Checks if any members were added/removed/changed, if the max inherited role changed or if the
 | 
			
		||||
  // anonymous access setting changed to enable the confirm button to write changes to the server.
 | 
			
		||||
  public readonly isAnythingChanged: Computed<boolean> = this.autoDispose(computed<boolean>((use) => {
 | 
			
		||||
@ -142,6 +147,7 @@ export class UserManagerModelImpl extends Disposable implements UserManagerModel
 | 
			
		||||
    }
 | 
			
		||||
  ) {
 | 
			
		||||
    super();
 | 
			
		||||
    this.gristDoc = this._options.docPageModel?.gristDoc.get() ?? null;
 | 
			
		||||
    if (this._options.appModel) {
 | 
			
		||||
      const features = this._options.appModel.currentFeatures;
 | 
			
		||||
      this._shareAnnotator = new ShareAnnotator(features, initData);
 | 
			
		||||
@ -250,8 +256,7 @@ export class UserManagerModelImpl extends Disposable implements UserManagerModel
 | 
			
		||||
    // Loop through the members and update the delta.
 | 
			
		||||
    for (const m of members) {
 | 
			
		||||
      let access = m.access.get();
 | 
			
		||||
      if (m === this.publicMember && access === roles.EDITOR &&
 | 
			
		||||
          this._options.docPageModel?.gristDoc.get()?.hasGranularAccessRules()) {
 | 
			
		||||
      if (m === this.publicMember && access === roles.EDITOR && this.gristDoc?.hasGranularAccessRules()) {
 | 
			
		||||
        access = roles.VIEWER;
 | 
			
		||||
        if (!options?.silent) {
 | 
			
		||||
          reportWarning('Public "Editor" access is incompatible with Access Rules. Reduced to "Viewer".');
 | 
			
		||||
 | 
			
		||||
@ -121,13 +121,16 @@ export function showUserManagerModal(userApi: UserAPI, options: IUserManagerOpti
 | 
			
		||||
        dom.on('click', () => ctl.close()),
 | 
			
		||||
        testId('um-cancel')
 | 
			
		||||
      ),
 | 
			
		||||
      cssAccessLink({href: urlState().makeUrl({docPage: 'acl'})},
 | 
			
		||||
        dom.text(use => (use(modelObs) && use(use(modelObs)!.isAnythingChanged)) ? 'Save & ' : ''),
 | 
			
		||||
        'Open Access Rules',
 | 
			
		||||
        dom.on('click', (ev) => {
 | 
			
		||||
          ev.preventDefault();
 | 
			
		||||
          return onConfirm(ctl).then(() => urlState().pushUrl({docPage: 'acl'}));
 | 
			
		||||
        }),
 | 
			
		||||
      dom.maybe(use => use(modelObs)?.resourceType === 'document' && use(modelObs)?.gristDoc, () =>
 | 
			
		||||
        cssAccessLink({href: urlState().makeUrl({docPage: 'acl'})},
 | 
			
		||||
          dom.text(use => (use(modelObs) && use(use(modelObs)!.isAnythingChanged)) ? 'Save & ' : ''),
 | 
			
		||||
          'Open Access Rules',
 | 
			
		||||
          dom.on('click', (ev) => {
 | 
			
		||||
            ev.preventDefault();
 | 
			
		||||
            return onConfirm(ctl).then(() => urlState().pushUrl({docPage: 'acl'}));
 | 
			
		||||
          }),
 | 
			
		||||
          testId('um-open-access-rules')
 | 
			
		||||
        )
 | 
			
		||||
      ),
 | 
			
		||||
      testId('um-buttons'),
 | 
			
		||||
    )
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user