mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
[MM-56654] Turn off landing page for Desktop App token flow, cleanup check for landing page (#26126)
This commit is contained in:
parent
41081b9eee
commit
c723bf345a
@ -45,6 +45,9 @@ function mapStateToProps(state: GlobalState) {
|
|||||||
telemetryEnabled: config.DiagnosticsEnabled === 'true',
|
telemetryEnabled: config.DiagnosticsEnabled === 'true',
|
||||||
noAccounts: config.NoAccounts === 'true',
|
noAccounts: config.NoAccounts === 'true',
|
||||||
telemetryId: config.DiagnosticId,
|
telemetryId: config.DiagnosticId,
|
||||||
|
iosDownloadLink: config.IosAppDownloadLink,
|
||||||
|
androidDownloadLink: config.AndroidAppDownloadLink,
|
||||||
|
appDownloadLink: config.AppDownloadLink,
|
||||||
permalinkRedirectTeamName: permalinkRedirectTeam ? permalinkRedirectTeam.name : '',
|
permalinkRedirectTeamName: permalinkRedirectTeam ? permalinkRedirectTeam.name : '',
|
||||||
showTermsOfService,
|
showTermsOfService,
|
||||||
plugins,
|
plugins,
|
||||||
|
@ -294,4 +294,44 @@ describe('components/Root', () => {
|
|||||||
wrapper.unmount();
|
wrapper.unmount();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('showLandingPageIfNecessary', () => {
|
||||||
|
const landingProps = {
|
||||||
|
...baseProps,
|
||||||
|
iosDownloadLink: 'http://iosapp.com',
|
||||||
|
androidDownloadLink: 'http://androidapp.com',
|
||||||
|
appDownloadLink: 'http://desktopapp.com',
|
||||||
|
...{
|
||||||
|
location: {
|
||||||
|
pathname: '/',
|
||||||
|
search: '',
|
||||||
|
},
|
||||||
|
} as RouteComponentProps,
|
||||||
|
history: {
|
||||||
|
push: jest.fn(),
|
||||||
|
} as unknown as RouteComponentProps['history'],
|
||||||
|
};
|
||||||
|
|
||||||
|
test('should show for normal cases', () => {
|
||||||
|
const wrapper = shallow(<Root {...landingProps}/>);
|
||||||
|
(wrapper.instance() as any).onConfigLoaded();
|
||||||
|
expect(landingProps.history.push).toHaveBeenCalledWith('/landing#/');
|
||||||
|
wrapper.unmount();
|
||||||
|
});
|
||||||
|
|
||||||
|
test('should not show for Desktop App login flow', () => {
|
||||||
|
const props = {
|
||||||
|
...landingProps,
|
||||||
|
...{
|
||||||
|
location: {
|
||||||
|
pathname: '/login/desktop',
|
||||||
|
},
|
||||||
|
} as RouteComponentProps,
|
||||||
|
};
|
||||||
|
const wrapper = shallow(<Root {...props}/>);
|
||||||
|
(wrapper.instance() as any).onConfigLoaded();
|
||||||
|
expect(props.history.push).not.toHaveBeenCalled();
|
||||||
|
wrapper.unmount();
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@ -146,6 +146,9 @@ type Props = {
|
|||||||
theme: Theme;
|
theme: Theme;
|
||||||
telemetryEnabled: boolean;
|
telemetryEnabled: boolean;
|
||||||
telemetryId?: string;
|
telemetryId?: string;
|
||||||
|
iosDownloadLink?: string;
|
||||||
|
androidDownloadLink?: string;
|
||||||
|
appDownloadLink?: string;
|
||||||
noAccounts: boolean;
|
noAccounts: boolean;
|
||||||
showTermsOfService: boolean;
|
showTermsOfService: boolean;
|
||||||
permalinkRedirectTeamName: string;
|
permalinkRedirectTeamName: string;
|
||||||
@ -292,30 +295,67 @@ export default class Root extends React.PureComponent<Props, State> {
|
|||||||
this.props.actions.migrateRecentEmojis();
|
this.props.actions.migrateRecentEmojis();
|
||||||
store.dispatch(loadRecentlyUsedCustomEmojis());
|
store.dispatch(loadRecentlyUsedCustomEmojis());
|
||||||
|
|
||||||
const iosDownloadLink = getConfig(store.getState()).IosAppDownloadLink;
|
this.showLandingPageIfNecessary();
|
||||||
const androidDownloadLink = getConfig(store.getState()).AndroidAppDownloadLink;
|
|
||||||
const desktopAppDownloadLink = getConfig(store.getState()).AppDownloadLink;
|
|
||||||
|
|
||||||
const toResetPasswordScreen = this.props.location.pathname === '/reset_password_complete';
|
|
||||||
|
|
||||||
// redirect to the mobile landing page if the user hasn't seen it before
|
|
||||||
let landing;
|
|
||||||
if (UserAgent.isAndroidWeb()) {
|
|
||||||
landing = androidDownloadLink;
|
|
||||||
} else if (UserAgent.isIosWeb()) {
|
|
||||||
landing = iosDownloadLink;
|
|
||||||
} else {
|
|
||||||
landing = desktopAppDownloadLink;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (landing && !this.props.isCloud && !BrowserStore.hasSeenLandingPage() && !toResetPasswordScreen && !this.props.location.pathname.includes('/landing') && !window.location.hostname?.endsWith('.test.mattermost.com') && !UserAgent.isDesktopApp() && !UserAgent.isChromebook()) {
|
|
||||||
this.props.history.push('/landing#' + this.props.location.pathname + this.props.location.search);
|
|
||||||
BrowserStore.setLandingPageSeen(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
Utils.applyTheme(this.props.theme);
|
Utils.applyTheme(this.props.theme);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
private showLandingPageIfNecessary = () => {
|
||||||
|
// We have nothing to redirect to if we're already on Desktop App
|
||||||
|
// Chromebook has no Desktop App to switch to
|
||||||
|
if (UserAgent.isDesktopApp() || UserAgent.isChromebook()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Nothing to link to if we've removed the Android App download link
|
||||||
|
if (UserAgent.isAndroidWeb() && !this.props.androidDownloadLink) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Nothing to link to if we've removed the iOS App download link
|
||||||
|
if (UserAgent.isIosWeb() && !this.props.iosDownloadLink) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Nothing to link to if we've removed the Desktop App download link
|
||||||
|
if (!this.props.appDownloadLink) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Only show the landing page once
|
||||||
|
if (BrowserStore.hasSeenLandingPage()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// We don't want to show when resetting the password
|
||||||
|
if (this.props.location.pathname === '/reset_password_complete') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// We don't want to show when we're doing Desktop App external login
|
||||||
|
if (this.props.location.pathname === '/login/desktop') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Stop this infinitely redirecting
|
||||||
|
if (this.props.location.pathname.includes('/landing')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Disabled to avoid breaking the CWS flow
|
||||||
|
if (this.props.isCloud) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Disable for Rainforest tests
|
||||||
|
if (window.location.hostname?.endsWith('.test.mattermost.com')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.props.history.push('/landing#' + this.props.location.pathname + this.props.location.search);
|
||||||
|
BrowserStore.setLandingPageSeen(true);
|
||||||
|
};
|
||||||
|
|
||||||
componentDidUpdate(prevProps: Props) {
|
componentDidUpdate(prevProps: Props) {
|
||||||
if (!deepEqual(prevProps.theme, this.props.theme)) {
|
if (!deepEqual(prevProps.theme, this.props.theme)) {
|
||||||
Utils.applyTheme(this.props.theme);
|
Utils.applyTheme(this.props.theme);
|
||||||
|
Loading…
Reference in New Issue
Block a user