mirror of
https://github.com/gristlabs/grist-core.git
synced 2024-10-27 20:44:07 +00:00
2563fb745a
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
65 lines
1.9 KiB
TypeScript
65 lines
1.9 KiB
TypeScript
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 {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.
|
|
*
|
|
* Used by AppHeader and AccountWidget.
|
|
*/
|
|
export function buildSiteSwitcher(appModel: AppModel) {
|
|
const orgs = appModel.topAppModel.orgs;
|
|
|
|
return [
|
|
menuSubHeader('Switch Sites'),
|
|
dom.forEach(orgs, (org) =>
|
|
menuItemLink(urlState().setLinkUrl({ org: org.domain || undefined }),
|
|
cssOrgSelected.cls('', appModel.currentOrg ? org.id === appModel.currentOrg.id : false),
|
|
getOrgName(org),
|
|
cssOrgCheckmark('Tick', testId('org-tick')),
|
|
testId('org'),
|
|
)
|
|
),
|
|
menuItemLink(
|
|
{ href: commonUrls.createTeamSite },
|
|
menuIcon('Plus'),
|
|
'Create new team site',
|
|
testId('create-new-site'),
|
|
),
|
|
];
|
|
}
|
|
|
|
const cssOrgSelected = styled('div', `
|
|
background-color: ${colors.dark};
|
|
color: ${colors.light};
|
|
`);
|
|
|
|
const cssOrgCheckmark = styled(icon, `
|
|
flex: none;
|
|
margin-left: 16px;
|
|
--icon-color: ${colors.light};
|
|
display: none;
|
|
.${cssOrgSelected.className} > & {
|
|
display: block;
|
|
}
|
|
`);
|