(core) Revert part of the recent tweaks to AppHeader

Summary:
In non-SaaS Grist, the AppHeader will no longer link to templates
page. Also, the last visited site is now reset when switching accounts.

Test Plan: Existing tests.

Reviewers: jarek

Reviewed By: jarek

Differential Revision: https://phab.getgrist.com/D4048
pull/684/head
George Gevoian 8 months ago
parent 927e92e3e8
commit d1826987bb

@ -128,6 +128,7 @@ export interface AppModel {
isOwnerOrEditor(): boolean; // If user is an owner or editor of this org
/** Creates an computed observable to dismiss a popup or check if it was dismissed */
dismissedPopup(name: DismissedPopup): Observable<boolean>;
switchUser(user: FullUser, org?: string): Promise<void>;
}
export class TopAppModelImpl extends Disposable implements TopAppModel {
@ -402,6 +403,11 @@ export class AppModelImpl extends Disposable implements AppModel {
return computed;
}
public async switchUser(user: FullUser, org?: string) {
await this.api.setSessionActive(user.email, org);
this.lastVisitedOrgDomain.set(null);
}
private _updateLastVisitedOrgDomain({doc, org}: IGristUrlState, availableOrgs: Organization[]) {
if (
!org ||

@ -174,7 +174,7 @@ export class AccountWidget extends Disposable {
// Switch BrowserSession to use the given user for the currently loaded org.
private async _switchAccount(user: FullUser) {
await this._appModel.api.setSessionActive(user.email);
await this._appModel.switchUser(user);
if (urlState().state.get().doc) {
// Document access level may have changed.
// If it was not accessible but now is, we currently need to reload the page to get

@ -92,8 +92,10 @@ export class AppHeader extends Disposable {
}
private _buildOrgLinkOrMenu() {
const {currentValidUser, isPersonal, isTemplatesSite} = this._appModel;
if (!currentValidUser && (isPersonal || isTemplatesSite)) {
const {currentValidUser, isTemplatesSite} = this._appModel;
const {deploymentType} = getGristConfig();
if (deploymentType === 'saas' && !currentValidUser && isTemplatesSite) {
// When signed out and on the templates site (in SaaS Grist), link to the templates page.
return cssOrgLink(
cssOrgName(dom.text(this._appLogoOrgName), testId('dm-orgname')),
{href: commonUrls.templates},
@ -180,11 +182,11 @@ export class AppHeader extends Disposable {
}): AppLogoOrgNameAndLink {
const {
currentValidUser,
isPersonal,
isTemplatesSite,
} = this._appModel;
if (!currentValidUser && (isPersonal || isTemplatesSite)) {
// When signed out and not on a team site, link to the templates site.
const {deploymentType} = getGristConfig();
if (deploymentType === 'saas' && !currentValidUser && isTemplatesSite) {
// When signed out and on the templates site (in SaaS Grist), link to the templates page.
return {
name: t('Grist Templates'),
link: {

@ -63,7 +63,7 @@ async function switchToPersonalUrl(ev: MouseEvent, appModel: AppModel, org: stri
if (ev.shiftKey || ev.metaKey || ev.ctrlKey || ev.altKey) { return; }
ev.preventDefault();
// Set the active session for the given org, then load its home page.
await appModel.api.setSessionActive(user.email, org);
await appModel.switchUser(user, org);
window.location.assign(urlState().makeUrl({org}));
}

@ -93,7 +93,7 @@ describe("Fork", function() {
it(`can create an ${content} unsaved document when ${mode}`, async function() {
let visitedSites: string[];
if (mode === 'anonymous') {
visitedSites = ['Grist Templates'];
visitedSites = ['@Guest'];
await personal.anon.login();
} else {
visitedSites = ['Test Grist', `@${personal.name}`];

Loading…
Cancel
Save