mirror of
https://github.com/gristlabs/grist-core.git
synced 2024-10-27 20:44:07 +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 {AppModel} from 'app/client/models/AppModel';
|
||||||
import {DocPageModel} from 'app/client/models/DocPageModel';
|
import {DocPageModel} from 'app/client/models/DocPageModel';
|
||||||
import {reportWarning} from 'app/client/models/errors';
|
import {reportWarning} from 'app/client/models/errors';
|
||||||
@ -25,6 +26,8 @@ export interface UserManagerModel {
|
|||||||
isOrg: boolean; // Indicates if the UserManager is for an org
|
isOrg: boolean; // Indicates if the UserManager is for an org
|
||||||
annotations: Observable<ShareAnnotations>; // More information about shares, keyed by email.
|
annotations: Observable<ShareAnnotations>; // More information about shares, keyed by email.
|
||||||
|
|
||||||
|
gristDoc: GristDoc|null; // Populated if there is an open document.
|
||||||
|
|
||||||
// Resets all unsaved changes
|
// Resets all unsaved changes
|
||||||
reset(): void;
|
reset(): void;
|
||||||
// Recreate annotations, factoring in any changes on the back-end.
|
// 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 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
|
// 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.
|
// 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) => {
|
public readonly isAnythingChanged: Computed<boolean> = this.autoDispose(computed<boolean>((use) => {
|
||||||
@ -142,6 +147,7 @@ export class UserManagerModelImpl extends Disposable implements UserManagerModel
|
|||||||
}
|
}
|
||||||
) {
|
) {
|
||||||
super();
|
super();
|
||||||
|
this.gristDoc = this._options.docPageModel?.gristDoc.get() ?? null;
|
||||||
if (this._options.appModel) {
|
if (this._options.appModel) {
|
||||||
const features = this._options.appModel.currentFeatures;
|
const features = this._options.appModel.currentFeatures;
|
||||||
this._shareAnnotator = new ShareAnnotator(features, initData);
|
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.
|
// Loop through the members and update the delta.
|
||||||
for (const m of members) {
|
for (const m of members) {
|
||||||
let access = m.access.get();
|
let access = m.access.get();
|
||||||
if (m === this.publicMember && access === roles.EDITOR &&
|
if (m === this.publicMember && access === roles.EDITOR && this.gristDoc?.hasGranularAccessRules()) {
|
||||||
this._options.docPageModel?.gristDoc.get()?.hasGranularAccessRules()) {
|
|
||||||
access = roles.VIEWER;
|
access = roles.VIEWER;
|
||||||
if (!options?.silent) {
|
if (!options?.silent) {
|
||||||
reportWarning('Public "Editor" access is incompatible with Access Rules. Reduced to "Viewer".');
|
reportWarning('Public "Editor" access is incompatible with Access Rules. Reduced to "Viewer".');
|
||||||
|
@ -121,6 +121,7 @@ export function showUserManagerModal(userApi: UserAPI, options: IUserManagerOpti
|
|||||||
dom.on('click', () => ctl.close()),
|
dom.on('click', () => ctl.close()),
|
||||||
testId('um-cancel')
|
testId('um-cancel')
|
||||||
),
|
),
|
||||||
|
dom.maybe(use => use(modelObs)?.resourceType === 'document' && use(modelObs)?.gristDoc, () =>
|
||||||
cssAccessLink({href: urlState().makeUrl({docPage: 'acl'})},
|
cssAccessLink({href: urlState().makeUrl({docPage: 'acl'})},
|
||||||
dom.text(use => (use(modelObs) && use(use(modelObs)!.isAnythingChanged)) ? 'Save & ' : ''),
|
dom.text(use => (use(modelObs) && use(use(modelObs)!.isAnythingChanged)) ? 'Save & ' : ''),
|
||||||
'Open Access Rules',
|
'Open Access Rules',
|
||||||
@ -128,6 +129,8 @@ export function showUserManagerModal(userApi: UserAPI, options: IUserManagerOpti
|
|||||||
ev.preventDefault();
|
ev.preventDefault();
|
||||||
return onConfirm(ctl).then(() => urlState().pushUrl({docPage: 'acl'}));
|
return onConfirm(ctl).then(() => urlState().pushUrl({docPage: 'acl'}));
|
||||||
}),
|
}),
|
||||||
|
testId('um-open-access-rules')
|
||||||
|
)
|
||||||
),
|
),
|
||||||
testId('um-buttons'),
|
testId('um-buttons'),
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user