UserManager: show proper org domain (#476)

We had `getgrist.com` hardcoded here, which only works for SaaS. The
base domain as well as the way that orgs are encoded in the URL can be
different in other circumstances.

If we are encoding orgs in the domain name, that's easy. We just do
`orgname.base.domain.name`. If we are not, then we first try a base
domain, and if that isn't set, we'll use the domain of the home
server.
pull/1157/head
Jordi Gutiérrez Hermoso 2 months ago committed by jordigh
parent 95189158c0
commit 952544432e

@ -6,8 +6,9 @@
* It can be instantiated by calling showUserManagerModal with the UserAPI and IUserManagerOptions. * It can be instantiated by calling showUserManagerModal with the UserAPI and IUserManagerOptions.
*/ */
import { makeT } from 'app/client/lib/localization'; import { makeT } from 'app/client/lib/localization';
import {commonUrls} from 'app/common/gristUrls'; import {commonUrls, isOrgInPathOnly} from 'app/common/gristUrls';
import {capitalizeFirstWord, isLongerThan} from 'app/common/gutil'; import {capitalizeFirstWord, isLongerThan} from 'app/common/gutil';
import {getGristConfig} from 'app/common/urlUtils';
import {FullUser} from 'app/common/LoginSessionAPI'; import {FullUser} from 'app/common/LoginSessionAPI';
import * as roles from 'app/common/roles'; import * as roles from 'app/common/roles';
import {Organization, PermissionData, UserAPI} from 'app/common/UserAPI'; import {Organization, PermissionData, UserAPI} from 'app/common/UserAPI';
@ -816,15 +817,25 @@ const cssMemberPublicAccess = styled(cssMemberSecondary, `
function renderTitle(resourceType: ResourceType, resource?: Resource, personal?: boolean) { function renderTitle(resourceType: ResourceType, resource?: Resource, personal?: boolean) {
switch (resourceType) { switch (resourceType) {
case 'organization': { case 'organization': {
if (personal) { return t('Your role for this team site'); } if (personal) {
return [ return t('Your role for this team site');
t('Manage members of team site'), }
!resource ? null : cssOrgName(
`${(resource as Organization).name} (`, function getOrgDisplay() {
cssOrgDomain(`${(resource as Organization).domain}.getgrist.com`), if (!resource) {
')', return null;
) }
];
const org = resource as Organization;
const gristConfig = getGristConfig();
const gristHomeHost = gristConfig.homeUrl ? new URL(gristConfig.homeUrl).host : '';
const baseDomain = gristConfig.baseDomain || gristHomeHost;
const orgDisplay = isOrgInPathOnly() ? `${baseDomain}/o/${org.domain}` : `${org.domain}${baseDomain}`;
return cssOrgName(`${org.name} (`, cssOrgDomain(orgDisplay), ')');
}
return [t('Manage members of team site'), getOrgDisplay()];
} }
default: { default: {
return personal ? return personal ?

Loading…
Cancel
Save