mirror of
https://github.com/gristlabs/grist-core.git
synced 2024-10-27 20:44:07 +00:00
(core) Avoid flagging support user as collaborator
Summary: When initially added in the User Manager, the support user (e.g. support@getgrist.com) was misleadingly being annotated as a free collaborator. This fixes the annotation to be "Grist support" instead. Test Plan: Browser test. Reviewers: jarek Reviewed By: jarek Differential Revision: https://phab.getgrist.com/D3730
This commit is contained in:
parent
629fcccd5a
commit
c558800de5
@ -6,6 +6,7 @@ import {ShareAnnotations, ShareAnnotator} from 'app/common/ShareAnnotator';
|
||||
import {normalizeEmail} from 'app/common/emails';
|
||||
import {GristLoadConfig} from 'app/common/gristUrls';
|
||||
import * as roles from 'app/common/roles';
|
||||
import {getGristConfig} from 'app/common/urlUtils';
|
||||
import {ANONYMOUS_USER_EMAIL, Document, EVERYONE_EMAIL, FullUser, getRealAccess, Organization,
|
||||
PermissionData, PermissionDelta, UserAPI, Workspace} from 'app/common/UserAPI';
|
||||
import {computed, Computed, Disposable, obsArray, ObsArray, observable, Observable} from 'grainjs';
|
||||
@ -179,7 +180,8 @@ export class UserManagerModelImpl extends Disposable implements UserManagerModel
|
||||
super();
|
||||
if (this._options.appModel) {
|
||||
const product = this._options.appModel.currentProduct;
|
||||
this._shareAnnotator = new ShareAnnotator(product, initData);
|
||||
const {supportEmail} = getGristConfig();
|
||||
this._shareAnnotator = new ShareAnnotator(product, initData, {supportEmail});
|
||||
}
|
||||
this.annotate();
|
||||
}
|
||||
|
@ -28,14 +28,23 @@ export interface ShareAnnotations {
|
||||
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
|
||||
* current shares in place.
|
||||
*/
|
||||
export class ShareAnnotator {
|
||||
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) {
|
||||
@ -84,7 +93,10 @@ export class ShareAnnotator {
|
||||
.map(([k, ]) => normalizeEmail(k)));
|
||||
for (const email of tweaks) {
|
||||
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);
|
||||
}
|
||||
|
@ -578,6 +578,9 @@ export interface GristLoadConfig {
|
||||
|
||||
// TODO: remove when comments will be released.
|
||||
featureComments?: boolean;
|
||||
|
||||
// Email address of the support user.
|
||||
supportEmail?: string;
|
||||
}
|
||||
|
||||
export const HideableUiElements = StringUnion("helpCenter", "billing", "templates", "multiSite", "multiAccounts");
|
||||
|
@ -1,6 +1,7 @@
|
||||
import {getPageTitleSuffix, GristLoadConfig, HideableUiElements, IHideableUiElement} from 'app/common/gristUrls';
|
||||
import {getTagManagerSnippet} from 'app/common/tagManager';
|
||||
import {Document} from 'app/common/UserAPI';
|
||||
import {SUPPORT_EMAIL} from 'app/gen-server/lib/HomeDBManager';
|
||||
import {isAnonymousUser, RequestWithLogin} from 'app/server/lib/Authorizer';
|
||||
import {RequestWithOrg} from 'app/server/lib/extractOrg';
|
||||
import {GristServer} from 'app/server/lib/GristServer';
|
||||
@ -63,6 +64,7 @@ export function makeGristConfig(homeUrl: string|null, extra: Partial<GristLoadCo
|
||||
supportedLngs: readLoadedLngs(req?.i18n),
|
||||
namespaces: readLoadedNamespaces(req?.i18n),
|
||||
featureComments: process.env.COMMENTS === "true",
|
||||
supportEmail: SUPPORT_EMAIL,
|
||||
...extra,
|
||||
};
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user