mirror of
https://github.com/gristlabs/grist-core.git
synced 2024-10-27 20:44:07 +00:00
(core) Use document access for showing form buttons
Summary: Site access was being used to show or hide form widget buttons. This meant that users granted owner access to a document couldn't see buttons to publish/unpublish or share a form. Now, document access is used instead. Test Plan: Manual. Reviewers: paulfitz Reviewed By: paulfitz Subscribers: paulfitz Differential Revision: https://phab.getgrist.com/D4207
This commit is contained in:
parent
a5099fc598
commit
14125b9b97
@ -24,6 +24,7 @@ import {cssButton} from 'app/client/ui2018/buttons';
|
||||
import {icon} from 'app/client/ui2018/icons';
|
||||
import {confirmModal} from 'app/client/ui2018/modals';
|
||||
import {INITIAL_FIELDS_COUNT} from 'app/common/Forms';
|
||||
import {isOwner} from 'app/common/roles';
|
||||
import {Events as BackboneEvents} from 'backbone';
|
||||
import {Computed, dom, Holder, IDomArgs, MultiHolder, Observable} from 'grainjs';
|
||||
import defaults from 'lodash/defaults';
|
||||
@ -58,6 +59,7 @@ export class FormView extends Disposable {
|
||||
private _remoteShare: AsyncComputed<{key: string}|null>;
|
||||
private _published: Computed<boolean>;
|
||||
private _showPublishedMessage: Observable<boolean>;
|
||||
private _isOwner: boolean;
|
||||
|
||||
public create(gristDoc: GristDoc, viewSectionModel: ViewSectionRec) {
|
||||
BaseView.call(this as any, gristDoc, viewSectionModel, {'addNewRow': false});
|
||||
@ -380,6 +382,8 @@ export class FormView extends Disposable {
|
||||
true
|
||||
));
|
||||
|
||||
this._isOwner = isOwner(this.gristDoc.docPageModel.currentDoc.get());
|
||||
|
||||
// Last line, build the dom.
|
||||
this.viewPane = this.autoDispose(this.buildDom());
|
||||
}
|
||||
@ -640,7 +644,7 @@ export class FormView extends Disposable {
|
||||
testId('link'),
|
||||
dom('div', 'Copy Link'),
|
||||
dom.prop('disabled', this._copyingLink),
|
||||
dom.show(use => this.gristDoc.appModel.isOwner() && use(this._published)),
|
||||
dom.show(use => this._isOwner && use(this._published)),
|
||||
dom.on('click', async (_event, element) => {
|
||||
try {
|
||||
this._copyingLink.set(true);
|
||||
@ -662,14 +666,14 @@ export class FormView extends Disposable {
|
||||
return published
|
||||
? style.cssIconButton(
|
||||
dom('div', 'Unpublish'),
|
||||
dom.show(this.gristDoc.appModel.isOwner()),
|
||||
dom.show(this._isOwner),
|
||||
style.cssIconButton.cls('-warning'),
|
||||
dom.on('click', () => this._handleClickUnpublish()),
|
||||
testId('unpublish'),
|
||||
)
|
||||
: style.cssIconButton(
|
||||
dom('div', 'Publish'),
|
||||
dom.show(this.gristDoc.appModel.isOwner()),
|
||||
dom.show(this._isOwner),
|
||||
cssButton.cls('-primary'),
|
||||
dom.on('click', () => this._handleClickPublish()),
|
||||
testId('publish'),
|
||||
@ -714,7 +718,7 @@ export class FormView extends Disposable {
|
||||
this._showPublishedMessage.set(false);
|
||||
}),
|
||||
),
|
||||
dom.show(this.gristDoc.appModel.isOwner()),
|
||||
dom.show(this._isOwner),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user