mirror of
https://github.com/gristlabs/grist-core.git
synced 2026-03-02 04:09:24 +00:00
(core) Tweak navbar, breadcrumbs, and sign-in buttons
Summary: The changes are intended to smooth over some sharp edges when a signed-out user is using Grist (particularly while on the templates site). Test Plan: Browser tests. Reviewers: paulfitz Reviewed By: paulfitz Differential Revision: https://phab.getgrist.com/D3957
This commit is contained in:
@@ -79,7 +79,6 @@ import {Document as APIDocument, DocReplacementOptions, DocState, DocStateCompar
|
||||
import {convertFromColumn} from 'app/common/ValueConverter';
|
||||
import {guessColInfo} from 'app/common/ValueGuesser';
|
||||
import {parseUserAction} from 'app/common/ValueParser';
|
||||
import {TEMPLATES_ORG_DOMAIN} from 'app/gen-server/ApiServer';
|
||||
import {Document} from 'app/gen-server/entity/Document';
|
||||
import {ParseFileResult, ParseOptions} from 'app/plugin/FileParserAPI';
|
||||
import {AccessTokenOptions, AccessTokenResult, GristDocAPI} from 'app/plugin/GristAPI';
|
||||
@@ -98,6 +97,7 @@ import log from 'app/server/lib/log';
|
||||
import {LogMethods} from "app/server/lib/LogMethods";
|
||||
import {NullSandbox, UnavailableSandboxMethodError} from 'app/server/lib/NullSandbox';
|
||||
import {DocRequests} from 'app/server/lib/Requests';
|
||||
import {getTemplateOrg} from 'app/server/lib/sendAppPage';
|
||||
import {shortDesc} from 'app/server/lib/shortDesc';
|
||||
import {TableMetadataLoader} from 'app/server/lib/TableMetadataLoader';
|
||||
import {DocTriggers} from "app/server/lib/Triggers";
|
||||
@@ -1402,8 +1402,9 @@ export class ActiveDoc extends EventEmitter {
|
||||
|
||||
await dbManager.forkDoc(userId, doc, forkIds.forkId);
|
||||
|
||||
// TODO: Need a more precise way to identify a template. (This org now also has tutorials.)
|
||||
const isTemplate = TEMPLATES_ORG_DOMAIN === doc.workspace.org.domain && doc.type !== 'tutorial';
|
||||
// TODO: Remove the right side once all template docs have their type set to "template".
|
||||
const isTemplate = doc.type === 'template' ||
|
||||
(doc.workspace.org.domain === getTemplateOrg() && doc.type !== 'tutorial');
|
||||
this.logTelemetryEvent(docSession, 'documentForked', {
|
||||
limited: {
|
||||
forkIdDigest: forkIds.forkId,
|
||||
|
||||
@@ -12,7 +12,6 @@ import {removeTrailingSlash} from 'app/common/gutil';
|
||||
import {LocalPlugin} from "app/common/plugin";
|
||||
import {TELEMETRY_TEMPLATE_SIGNUP_COOKIE_NAME} from 'app/common/Telemetry';
|
||||
import {Document as APIDocument} from 'app/common/UserAPI';
|
||||
import {TEMPLATES_ORG_DOMAIN} from 'app/gen-server/ApiServer';
|
||||
import {Document} from "app/gen-server/entity/Document";
|
||||
import {HomeDBManager} from 'app/gen-server/lib/HomeDBManager';
|
||||
import {assertAccess, getTransitiveHeaders, getUserId, isAnonymousUser,
|
||||
@@ -24,7 +23,7 @@ import {getCookieDomain} from 'app/server/lib/gristSessions';
|
||||
import {getAssignmentId} from 'app/server/lib/idUtils';
|
||||
import log from 'app/server/lib/log';
|
||||
import {adaptServerUrl, addOrgToPathIfNeeded, pruneAPIResult, trustOrigin} from 'app/server/lib/requestUtils';
|
||||
import {ISendAppPageOptions} from 'app/server/lib/sendAppPage';
|
||||
import {getTemplateOrg, ISendAppPageOptions} from 'app/server/lib/sendAppPage';
|
||||
|
||||
export interface AttachOptions {
|
||||
app: express.Application; // Express app to which to add endpoints
|
||||
@@ -304,8 +303,9 @@ export function attachAppEndpoint(options: AttachOptions): void {
|
||||
|
||||
const isPublic = ((doc as unknown) as APIDocument).public ?? false;
|
||||
const isSnapshot = Boolean(parseUrlId(urlId).snapshotId);
|
||||
// TODO: Need a more precise way to identify a template. (This org now also has tutorials.)
|
||||
const isTemplate = TEMPLATES_ORG_DOMAIN === doc.workspace.org.domain && doc.type !== 'tutorial';
|
||||
// TODO: Remove the right side once all template docs have their type set to "template".
|
||||
const isTemplate = doc.type === 'template' ||
|
||||
(doc.workspace.org.domain === getTemplateOrg() && doc.type !== 'tutorial');
|
||||
if (isPublic || isTemplate) {
|
||||
gristServer.getTelemetry().logEvent('documentOpened', {
|
||||
limited: {
|
||||
|
||||
@@ -3,6 +3,7 @@ import {isAffirmative} from 'app/common/gutil';
|
||||
import {getTagManagerSnippet} from 'app/common/tagManager';
|
||||
import {Document} from 'app/common/UserAPI';
|
||||
import {SUPPORT_EMAIL} from 'app/gen-server/lib/HomeDBManager';
|
||||
import {appSettings} from 'app/server/lib/AppSettings';
|
||||
import {isAnonymousUser, isSingleUserMode, RequestWithLogin} from 'app/server/lib/Authorizer';
|
||||
import {RequestWithOrg} from 'app/server/lib/extractOrg';
|
||||
import {GristServer} from 'app/server/lib/GristServer';
|
||||
@@ -78,6 +79,7 @@ export function makeGristConfig(options: MakeGristConfigOptons): GristLoadConfig
|
||||
userLocale: (req as RequestWithLogin | undefined)?.user?.options?.locale,
|
||||
telemetry: server?.getTelemetry().getTelemetryConfig(),
|
||||
deploymentType: server?.getDeploymentType(),
|
||||
templateOrg: getTemplateOrg(),
|
||||
...extra,
|
||||
};
|
||||
}
|
||||
@@ -152,6 +154,18 @@ export function makeSendAppPage(opts: {
|
||||
};
|
||||
}
|
||||
|
||||
export function getTemplateOrg() {
|
||||
let org = appSettings.section('templates').flag('org').readString({
|
||||
envVar: 'GRIST_TEMPLATE_ORG',
|
||||
});
|
||||
if (!org) { return null; }
|
||||
|
||||
if (process.env.GRIST_ID_PREFIX) {
|
||||
org += `-${process.env.GRIST_ID_PREFIX}`;
|
||||
}
|
||||
return org;
|
||||
}
|
||||
|
||||
function shouldSupportAnon() {
|
||||
// Enable UI for anonymous access if a flag is explicitly set in the environment
|
||||
return process.env.GRIST_SUPPORT_ANON === "true";
|
||||
|
||||
Reference in New Issue
Block a user