(core) make Grist easier to run with a single server

Summary:
This makes many small changes so that Grist is less fussy to run as a single instance behind a reverse proxy. Some users had difficulty with the self-connections Grist would make, due to internal network setup, and since these are unnecessary in any case in this scenario, they are now optimized away. Likewise some users had difficulties related to doc worker urls, which are now also optimized away. With these changes, users should be able to get a lot further on first try, at least far enough to open and edit documents.

The `GRIST_SINGLE_ORG` setting was proving a bit confusing, since it appeared to only work when set to `docs`. This diff
adds a check for whether the specified org exists, and if not, it creates it. This still depends on having a user email to make as the owner of the team, so there could be remaining difficulties there.

Test Plan: tested manually with nginx

Reviewers: jarek

Reviewed By: jarek

Differential Revision: https://phab.getgrist.com/D3299
This commit is contained in:
Paul Fitzpatrick
2022-03-02 14:07:26 -05:00
parent 0da397ab90
commit 2563fb745a
13 changed files with 228 additions and 68 deletions

View File

@@ -14,7 +14,7 @@ import * as roles from 'app/common/roles';
import {Organization, SUPPORT_EMAIL} from 'app/common/UserAPI';
import {Disposable, dom, DomElementArg, styled} from 'grainjs';
import {cssMenuItem} from 'popweasel';
import {buildSiteSwitcher} from 'app/client/ui/SiteSwitcher';
import {maybeAddSiteSwitcherSection} from 'app/client/ui/SiteSwitcher';
/**
* Render the user-icon that opens the account menu. When no user is logged in, render a Sign-in
@@ -91,7 +91,6 @@ export class AccountWidget extends Disposable {
}
const users = this._appModel.topAppModel.users;
const orgs = this._appModel.topAppModel.orgs;
return [
cssUserInfo(
@@ -143,10 +142,7 @@ export class AccountWidget extends Disposable {
menuItemLink({href: getLogoutUrl()}, "Sign Out", testId('dm-log-out')),
dom.maybe((use) => use(orgs).length > 0, () => [
menuDivider(),
buildSiteSwitcher(this._appModel),
]),
maybeAddSiteSwitcherSection(this._appModel),
];
}

View File

@@ -4,14 +4,14 @@ import {cssLeftPane} from 'app/client/ui/PagePanels';
import {colors, testId, vars} from 'app/client/ui2018/cssVars';
import * as version from 'app/common/version';
import {BindableValue, Disposable, dom, styled} from "grainjs";
import {menu, menuDivider, menuItem, menuItemLink, menuSubHeader} from 'app/client/ui2018/menus';
import {menu, menuItem, menuItemLink, menuSubHeader} from 'app/client/ui2018/menus';
import {Organization, SUPPORT_EMAIL} from 'app/common/UserAPI';
import {AppModel} from 'app/client/models/AppModel';
import {icon} from 'app/client/ui2018/icons';
import {DocPageModel} from 'app/client/models/DocPageModel';
import * as roles from 'app/common/roles';
import {loadUserManager} from 'app/client/lib/imports';
import {buildSiteSwitcher} from 'app/client/ui/SiteSwitcher';
import {maybeAddSiteSwitcherSection} from 'app/client/ui/SiteSwitcher';
export class AppHeader extends Disposable {
@@ -24,7 +24,6 @@ export class AppHeader extends Disposable {
const theme = getTheme(this._appModel.topAppModel.productFlavor);
const user = this._appModel.currentValidUser;
const orgs = this._appModel.topAppModel.orgs;
const currentOrg = this._appModel.currentOrg;
const isTeamSite = Boolean(currentOrg && !currentOrg.owner);
const isBillingManager = Boolean(currentOrg && currentOrg.billingAccount &&
@@ -74,10 +73,7 @@ export class AppHeader extends Disposable {
) :
null,
dom.maybe((use) => use(orgs).length > 0, () => [
menuDivider(),
buildSiteSwitcher(this._appModel),
]),
maybeAddSiteSwitcherSection(this._appModel),
], { placement: 'bottom-start' }),
testId('dm-org'),
),

View File

@@ -1,14 +1,25 @@
import {commonUrls} from 'app/common/gristUrls';
import {commonUrls, getSingleOrg} from 'app/common/gristUrls';
import {getOrgName} from 'app/common/UserAPI';
import {dom, makeTestId, styled} from 'grainjs';
import {AppModel} from 'app/client/models/AppModel';
import {urlState} from 'app/client/models/gristUrlState';
import {menuIcon, menuItemLink, menuSubHeader} from 'app/client/ui2018/menus';
import {menuDivider, menuIcon, menuItemLink, menuSubHeader} from 'app/client/ui2018/menus';
import {icon} from 'app/client/ui2018/icons';
import {colors} from 'app/client/ui2018/cssVars';
const testId = makeTestId('test-site-switcher-');
/**
* Adds a menu divider and a site switcher, if there is need for one.
*/
export function maybeAddSiteSwitcherSection(appModel: AppModel) {
const orgs = appModel.topAppModel.orgs;
return dom.maybe((use) => use(orgs).length > 0 && !getSingleOrg(), () => [
menuDivider(),
buildSiteSwitcher(appModel),
]);
}
/**
* Builds a menu sub-section that displays a list of orgs/sites that the current
* valid user has access to, with buttons to navigate to them.