Skip to content

Commit

Permalink
UserManager: show proper org domain (#476)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jordigh committed Jul 31, 2024
1 parent 42f696d commit bda85cf
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions app/client/ui/UserManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
* It can be instantiated by calling showUserManagerModal with the UserAPI and IUserManagerOptions.
*/
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 {getGristConfig} from 'app/common/urlUtils';
import {FullUser} from 'app/common/LoginSessionAPI';
import * as roles from 'app/common/roles';
import {Organization, PermissionData, UserAPI} from 'app/common/UserAPI';
Expand Down Expand Up @@ -816,14 +817,19 @@ const cssMemberPublicAccess = styled(cssMemberSecondary, `
function renderTitle(resourceType: ResourceType, resource?: Resource, personal?: boolean) {
switch (resourceType) {
case 'organization': {
if (personal) { return t('Your role for this team site'); }
if (personal) {
return t('Your role for this team site');
}

const gristConfig = getGristConfig();
const gristHomeHost = gristConfig.homeUrl ? new URL(gristConfig.homeUrl).host : '';
const baseDomain = gristConfig.baseDomain || gristHomeHost;
const orgName = (resource as Organization).name;
const orgDisplay = isOrgInPathOnly() ? `${baseDomain}/o/${orgName}` : `${orgName}${baseDomain}`;

return [
t('Manage members of team site'),
!resource ? null : cssOrgName(
`${(resource as Organization).name} (`,
cssOrgDomain(`${(resource as Organization).domain}.getgrist.com`),
')',
)
resource ? cssOrgName(`${orgName} (`, cssOrgDomain(orgDisplay), ')') : null,
];
}
default: {
Expand Down

0 comments on commit bda85cf

Please sign in to comment.