mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
MM-52419 - move preparing workspace onboarding behind usecaseonboarding ff for self-hosted (#23090)
* MM-52419 - move preparing workspace onboarding behind usecaseonboarding ff for self-hosted * fetch active teams instead of just my teams * use the onboarding flow enabled config value * remove unnecessary conditions --------- Co-authored-by: Mattermost Build <build@mattermost.com>
This commit is contained in:
parent
8e359790a7
commit
9e3f6e1840
@ -12,8 +12,8 @@ import {
|
|||||||
import {logout, loadMe, loadMeREST} from 'mattermost-redux/actions/users';
|
import {logout, loadMe, loadMeREST} from 'mattermost-redux/actions/users';
|
||||||
import {Preferences} from 'mattermost-redux/constants';
|
import {Preferences} from 'mattermost-redux/constants';
|
||||||
import {getConfig, isPerformanceDebuggingEnabled} from 'mattermost-redux/selectors/entities/general';
|
import {getConfig, isPerformanceDebuggingEnabled} from 'mattermost-redux/selectors/entities/general';
|
||||||
import {getCurrentTeamId, getMyTeams, getTeam, getMyTeamMember, getTeamMemberships} from 'mattermost-redux/selectors/entities/teams';
|
import {getCurrentTeamId, getMyTeams, getTeam, getMyTeamMember, getTeamMemberships, getActiveTeamsList} from 'mattermost-redux/selectors/entities/teams';
|
||||||
import {getBool, isCollapsedThreadsEnabled, isGraphQLEnabled} from 'mattermost-redux/selectors/entities/preferences';
|
import {getBool, getIsOnboardingFlowEnabled, isCollapsedThreadsEnabled, isGraphQLEnabled} from 'mattermost-redux/selectors/entities/preferences';
|
||||||
import {getCurrentUser, getCurrentUserId, isFirstAdmin} from 'mattermost-redux/selectors/entities/users';
|
import {getCurrentUser, getCurrentUserId, isFirstAdmin} from 'mattermost-redux/selectors/entities/users';
|
||||||
import {getCurrentChannelStats, getCurrentChannelId, getMyChannelMember, getRedirectChannelNameForTeam, getChannelsNameMapInTeam, getAllDirectChannels, getChannelMessageCount} from 'mattermost-redux/selectors/entities/channels';
|
import {getCurrentChannelStats, getCurrentChannelId, getMyChannelMember, getRedirectChannelNameForTeam, getChannelsNameMapInTeam, getAllDirectChannels, getChannelMessageCount} from 'mattermost-redux/selectors/entities/channels';
|
||||||
import {appsEnabled} from 'mattermost-redux/selectors/entities/apps';
|
import {appsEnabled} from 'mattermost-redux/selectors/entities/apps';
|
||||||
@ -352,7 +352,7 @@ export async function redirectUserToDefaultTeam() {
|
|||||||
// Assume we need to load the user if they don't have any team memberships loaded or the user loaded
|
// Assume we need to load the user if they don't have any team memberships loaded or the user loaded
|
||||||
let user = getCurrentUser(state);
|
let user = getCurrentUser(state);
|
||||||
const shouldLoadUser = Utils.isEmptyObject(getTeamMemberships(state)) || !user;
|
const shouldLoadUser = Utils.isEmptyObject(getTeamMemberships(state)) || !user;
|
||||||
|
const onboardingFlowEnabled = getIsOnboardingFlowEnabled(state);
|
||||||
if (shouldLoadUser) {
|
if (shouldLoadUser) {
|
||||||
if (isGraphQLEnabled(state)) {
|
if (isGraphQLEnabled(state)) {
|
||||||
await dispatch(loadMe());
|
await dispatch(loadMe());
|
||||||
@ -374,8 +374,9 @@ export async function redirectUserToDefaultTeam() {
|
|||||||
const teamId = LocalStorageStore.getPreviousTeamId(user.id);
|
const teamId = LocalStorageStore.getPreviousTeamId(user.id);
|
||||||
|
|
||||||
let myTeams = getMyTeams(state);
|
let myTeams = getMyTeams(state);
|
||||||
if (myTeams.length === 0) {
|
const teams = getActiveTeamsList(state);
|
||||||
if (isUserFirstAdmin) {
|
if (teams.length === 0) {
|
||||||
|
if (isUserFirstAdmin && onboardingFlowEnabled) {
|
||||||
getHistory().push('/preparing-workspace');
|
getHistory().push('/preparing-workspace');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@ import {useIntl} from 'react-intl';
|
|||||||
import {useSelector, useDispatch} from 'react-redux';
|
import {useSelector, useDispatch} from 'react-redux';
|
||||||
import {useLocation, useHistory} from 'react-router-dom';
|
import {useLocation, useHistory} from 'react-router-dom';
|
||||||
|
|
||||||
|
import {redirectUserToDefaultTeam} from 'actions/global_actions';
|
||||||
import {trackEvent} from 'actions/telemetry_actions.jsx';
|
import {trackEvent} from 'actions/telemetry_actions.jsx';
|
||||||
|
|
||||||
import LaptopAlertSVG from 'components/common/svg_images_components/laptop_alert_svg';
|
import LaptopAlertSVG from 'components/common/svg_images_components/laptop_alert_svg';
|
||||||
@ -14,6 +15,7 @@ import LoadingScreen from 'components/loading_screen';
|
|||||||
|
|
||||||
import {clearErrors, logError} from 'mattermost-redux/actions/errors';
|
import {clearErrors, logError} from 'mattermost-redux/actions/errors';
|
||||||
import {verifyUserEmail, getMe} from 'mattermost-redux/actions/users';
|
import {verifyUserEmail, getMe} from 'mattermost-redux/actions/users';
|
||||||
|
import {getIsOnboardingFlowEnabled} from 'mattermost-redux/selectors/entities/preferences';
|
||||||
import {getCurrentUserId} from 'mattermost-redux/selectors/entities/users';
|
import {getCurrentUserId} from 'mattermost-redux/selectors/entities/users';
|
||||||
import {DispatchFunc} from 'mattermost-redux/types/actions';
|
import {DispatchFunc} from 'mattermost-redux/types/actions';
|
||||||
|
|
||||||
@ -38,6 +40,7 @@ const DoVerifyEmail = () => {
|
|||||||
const token = params.get('token') ?? '';
|
const token = params.get('token') ?? '';
|
||||||
|
|
||||||
const loggedIn = Boolean(useSelector(getCurrentUserId));
|
const loggedIn = Boolean(useSelector(getCurrentUserId));
|
||||||
|
const onboardingFlowEnabled = useSelector(getIsOnboardingFlowEnabled);
|
||||||
|
|
||||||
const [verifyStatus, setVerifyStatus] = useState(VerifyStatus.PENDING);
|
const [verifyStatus, setVerifyStatus] = useState(VerifyStatus.PENDING);
|
||||||
const [serverError, setServerError] = useState('');
|
const [serverError, setServerError] = useState('');
|
||||||
@ -49,11 +52,15 @@ const DoVerifyEmail = () => {
|
|||||||
|
|
||||||
const handleRedirect = () => {
|
const handleRedirect = () => {
|
||||||
if (loggedIn) {
|
if (loggedIn) {
|
||||||
// need info about whether admin or not,
|
if (onboardingFlowEnabled) {
|
||||||
// and whether admin has already completed
|
// need info about whether admin or not,
|
||||||
// first time onboarding. Instead of fetching and orchestrating that here,
|
// and whether admin has already completed
|
||||||
// let the default root component handle it.
|
// first time onboarding. Instead of fetching and orchestrating that here,
|
||||||
history.push('/');
|
// let the default root component handle it.
|
||||||
|
history.push('/');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
redirectUserToDefaultTeam();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,6 +8,7 @@ import {withRouter} from 'react-router-dom';
|
|||||||
import {getConfig} from 'mattermost-redux/selectors/entities/general';
|
import {getConfig} from 'mattermost-redux/selectors/entities/general';
|
||||||
import {GenericAction} from 'mattermost-redux/types/actions';
|
import {GenericAction} from 'mattermost-redux/types/actions';
|
||||||
import {getCurrentRelativeTeamUrl} from 'mattermost-redux/selectors/entities/teams';
|
import {getCurrentRelativeTeamUrl} from 'mattermost-redux/selectors/entities/teams';
|
||||||
|
import {getIsOnboardingFlowEnabled} from 'mattermost-redux/selectors/entities/preferences';
|
||||||
import {isFirstAdmin} from 'mattermost-redux/selectors/entities/users';
|
import {isFirstAdmin} from 'mattermost-redux/selectors/entities/users';
|
||||||
|
|
||||||
import {getUserGuideDropdownPluginMenuItems} from 'selectors/plugins';
|
import {getUserGuideDropdownPluginMenuItems} from 'selectors/plugins';
|
||||||
@ -31,6 +32,7 @@ function mapStateToProps(state: GlobalState) {
|
|||||||
teamUrl: getCurrentRelativeTeamUrl(state),
|
teamUrl: getCurrentRelativeTeamUrl(state),
|
||||||
pluginMenuItems: getUserGuideDropdownPluginMenuItems(state),
|
pluginMenuItems: getUserGuideDropdownPluginMenuItems(state),
|
||||||
isFirstAdmin: isFirstAdmin(state),
|
isFirstAdmin: isFirstAdmin(state),
|
||||||
|
onboardingFlowEnabled: getIsOnboardingFlowEnabled(state),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,6 +34,7 @@ describe('components/channel_header/components/UserGuideDropdown', () => {
|
|||||||
},
|
},
|
||||||
pluginMenuItems: [],
|
pluginMenuItems: [],
|
||||||
isFirstAdmin: false,
|
isFirstAdmin: false,
|
||||||
|
onboardingFlowEnabled: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
test('should match snapshot', () => {
|
test('should match snapshot', () => {
|
||||||
|
@ -13,7 +13,7 @@ import {UserProfile} from '@mattermost/types/users';
|
|||||||
|
|
||||||
import {Client4} from 'mattermost-redux/client';
|
import {Client4} from 'mattermost-redux/client';
|
||||||
import {getConfig, getLicense} from 'mattermost-redux/selectors/entities/general';
|
import {getConfig, getLicense} from 'mattermost-redux/selectors/entities/general';
|
||||||
import {isGraphQLEnabled} from 'mattermost-redux/selectors/entities/preferences';
|
import {getIsOnboardingFlowEnabled, isGraphQLEnabled} from 'mattermost-redux/selectors/entities/preferences';
|
||||||
import {getTeamByName, getMyTeamMember} from 'mattermost-redux/selectors/entities/teams';
|
import {getTeamByName, getMyTeamMember} from 'mattermost-redux/selectors/entities/teams';
|
||||||
import {getCurrentUser} from 'mattermost-redux/selectors/entities/users';
|
import {getCurrentUser} from 'mattermost-redux/selectors/entities/users';
|
||||||
import {isSystemAdmin} from 'mattermost-redux/utils/user_utils';
|
import {isSystemAdmin} from 'mattermost-redux/utils/user_utils';
|
||||||
@ -104,6 +104,7 @@ const Login = ({onCustomizeHeader}: LoginProps) => {
|
|||||||
const currentUser = useSelector(getCurrentUser);
|
const currentUser = useSelector(getCurrentUser);
|
||||||
const experimentalPrimaryTeam = useSelector((state: GlobalState) => (ExperimentalPrimaryTeam ? getTeamByName(state, ExperimentalPrimaryTeam) : undefined));
|
const experimentalPrimaryTeam = useSelector((state: GlobalState) => (ExperimentalPrimaryTeam ? getTeamByName(state, ExperimentalPrimaryTeam) : undefined));
|
||||||
const experimentalPrimaryTeamMember = useSelector((state: GlobalState) => getMyTeamMember(state, experimentalPrimaryTeam?.id ?? ''));
|
const experimentalPrimaryTeamMember = useSelector((state: GlobalState) => getMyTeamMember(state, experimentalPrimaryTeam?.id ?? ''));
|
||||||
|
const onboardingFlowEnabled = useSelector(getIsOnboardingFlowEnabled);
|
||||||
const isCloud = useSelector(isCurrentLicenseCloud);
|
const isCloud = useSelector(isCurrentLicenseCloud);
|
||||||
const graphQLEnabled = useSelector(isGraphQLEnabled);
|
const graphQLEnabled = useSelector(isGraphQLEnabled);
|
||||||
|
|
||||||
@ -634,12 +635,14 @@ const Login = ({onCustomizeHeader}: LoginProps) => {
|
|||||||
} else if (experimentalPrimaryTeamMember.team_id) {
|
} else if (experimentalPrimaryTeamMember.team_id) {
|
||||||
// Only set experimental team if user is on that team
|
// Only set experimental team if user is on that team
|
||||||
history.push(`/${ExperimentalPrimaryTeam}`);
|
history.push(`/${ExperimentalPrimaryTeam}`);
|
||||||
} else {
|
} else if (onboardingFlowEnabled) {
|
||||||
// need info about whether admin or not,
|
// need info about whether admin or not,
|
||||||
// and whether admin has already completed
|
// and whether admin has already completed
|
||||||
// first time onboarding. Instead of fetching and orchestrating that here,
|
// first time onboarding. Instead of fetching and orchestrating that here,
|
||||||
// let the default root component handle it.
|
// let the default root component handle it.
|
||||||
history.push('/');
|
history.push('/');
|
||||||
|
} else {
|
||||||
|
redirectUserToDefaultTeam();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -12,6 +12,7 @@ import {sendEmailInvitesToTeamGracefully} from 'mattermost-redux/actions/teams';
|
|||||||
import {getFirstAdminSetupComplete as getFirstAdminSetupCompleteAction} from 'mattermost-redux/actions/general';
|
import {getFirstAdminSetupComplete as getFirstAdminSetupCompleteAction} from 'mattermost-redux/actions/general';
|
||||||
import {ActionResult} from 'mattermost-redux/types/actions';
|
import {ActionResult} from 'mattermost-redux/types/actions';
|
||||||
import {Team} from '@mattermost/types/teams';
|
import {Team} from '@mattermost/types/teams';
|
||||||
|
import {getIsOnboardingFlowEnabled} from 'mattermost-redux/selectors/entities/preferences';
|
||||||
import {isFirstAdmin} from 'mattermost-redux/selectors/entities/users';
|
import {isFirstAdmin} from 'mattermost-redux/selectors/entities/users';
|
||||||
import {getCurrentTeam, getMyTeams} from 'mattermost-redux/selectors/entities/teams';
|
import {getCurrentTeam, getMyTeams} from 'mattermost-redux/selectors/entities/teams';
|
||||||
import {getFirstAdminSetupComplete, getConfig, getLicense} from 'mattermost-redux/selectors/entities/general';
|
import {getFirstAdminSetupComplete, getConfig, getLicense} from 'mattermost-redux/selectors/entities/general';
|
||||||
@ -109,6 +110,7 @@ const PreparingWorkspace = (props: Props) => {
|
|||||||
defaultMessage: 'Something went wrong. Please try again.',
|
defaultMessage: 'Something went wrong. Please try again.',
|
||||||
});
|
});
|
||||||
const isUserFirstAdmin = useSelector(isFirstAdmin);
|
const isUserFirstAdmin = useSelector(isFirstAdmin);
|
||||||
|
const onboardingFlowEnabled = useSelector(getIsOnboardingFlowEnabled);
|
||||||
|
|
||||||
const currentTeam = useSelector(getCurrentTeam);
|
const currentTeam = useSelector(getCurrentTeam);
|
||||||
const myTeams = useSelector(getMyTeams);
|
const myTeams = useSelector(getMyTeams);
|
||||||
@ -289,7 +291,7 @@ const PreparingWorkspace = (props: Props) => {
|
|||||||
}, [submissionState]);
|
}, [submissionState]);
|
||||||
|
|
||||||
const adminRevisitedPage = firstAdminSetupComplete && submissionState === SubmissionStates.Presubmit;
|
const adminRevisitedPage = firstAdminSetupComplete && submissionState === SubmissionStates.Presubmit;
|
||||||
const shouldRedirect = !isUserFirstAdmin || adminRevisitedPage;
|
const shouldRedirect = !isUserFirstAdmin || adminRevisitedPage || !onboardingFlowEnabled;
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (shouldRedirect) {
|
if (shouldRedirect) {
|
||||||
|
@ -10,9 +10,10 @@ import classNames from 'classnames';
|
|||||||
import {Client4} from 'mattermost-redux/client';
|
import {Client4} from 'mattermost-redux/client';
|
||||||
import {rudderAnalytics, RudderTelemetryHandler} from 'mattermost-redux/client/rudder';
|
import {rudderAnalytics, RudderTelemetryHandler} from 'mattermost-redux/client/rudder';
|
||||||
import {General} from 'mattermost-redux/constants';
|
import {General} from 'mattermost-redux/constants';
|
||||||
import {Theme} from 'mattermost-redux/selectors/entities/preferences';
|
import {Theme, getIsOnboardingFlowEnabled} from 'mattermost-redux/selectors/entities/preferences';
|
||||||
import {getConfig} from 'mattermost-redux/selectors/entities/general';
|
import {getConfig} from 'mattermost-redux/selectors/entities/general';
|
||||||
import {getCurrentUser, isCurrentUserSystemAdmin, checkIsFirstAdmin} from 'mattermost-redux/selectors/entities/users';
|
import {getCurrentUser, isCurrentUserSystemAdmin, checkIsFirstAdmin} from 'mattermost-redux/selectors/entities/users';
|
||||||
|
import {getActiveTeamsList} from 'mattermost-redux/selectors/entities/teams';
|
||||||
import {setUrl} from 'mattermost-redux/actions/general';
|
import {setUrl} from 'mattermost-redux/actions/general';
|
||||||
import {setSystemEmojis} from 'mattermost-redux/actions/emojis';
|
import {setSystemEmojis} from 'mattermost-redux/actions/emojis';
|
||||||
|
|
||||||
@ -89,8 +90,6 @@ import {ActionResult} from 'mattermost-redux/types/actions';
|
|||||||
|
|
||||||
import WelcomePostRenderer from 'components/welcome_post_renderer';
|
import WelcomePostRenderer from 'components/welcome_post_renderer';
|
||||||
|
|
||||||
import {getMyTeams} from 'mattermost-redux/selectors/entities/teams';
|
|
||||||
|
|
||||||
import {applyLuxonDefaults} from './effects';
|
import {applyLuxonDefaults} from './effects';
|
||||||
|
|
||||||
import RootProvider from './root_provider';
|
import RootProvider from './root_provider';
|
||||||
@ -360,8 +359,11 @@ export default class Root extends React.PureComponent<Props, State> {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const myTeams = getMyTeams(storeState);
|
const teams = getActiveTeamsList(storeState);
|
||||||
if (myTeams.length > 0) {
|
|
||||||
|
const onboardingFlowEnabled = getIsOnboardingFlowEnabled(storeState);
|
||||||
|
|
||||||
|
if (teams.length > 0 || !onboardingFlowEnabled) {
|
||||||
GlobalActions.redirectUserToDefaultTeam();
|
GlobalActions.redirectUserToDefaultTeam();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@ import {connect} from 'react-redux';
|
|||||||
|
|
||||||
import {getFirstAdminSetupComplete} from 'mattermost-redux/actions/general';
|
import {getFirstAdminSetupComplete} from 'mattermost-redux/actions/general';
|
||||||
import {getCurrentUserId, isCurrentUserSystemAdmin, isFirstAdmin} from 'mattermost-redux/selectors/entities/users';
|
import {getCurrentUserId, isCurrentUserSystemAdmin, isFirstAdmin} from 'mattermost-redux/selectors/entities/users';
|
||||||
|
import {getIsOnboardingFlowEnabled} from 'mattermost-redux/selectors/entities/preferences';
|
||||||
import {GenericAction} from 'mattermost-redux/types/actions';
|
import {GenericAction} from 'mattermost-redux/types/actions';
|
||||||
|
|
||||||
import {GlobalState} from 'types/store';
|
import {GlobalState} from 'types/store';
|
||||||
@ -13,7 +14,11 @@ import {GlobalState} from 'types/store';
|
|||||||
import RootRedirect, {Props} from './root_redirect';
|
import RootRedirect, {Props} from './root_redirect';
|
||||||
|
|
||||||
function mapStateToProps(state: GlobalState) {
|
function mapStateToProps(state: GlobalState) {
|
||||||
const isElegibleForFirstAdmingOnboarding = isCurrentUserSystemAdmin(state);
|
const onboardingFlowEnabled = getIsOnboardingFlowEnabled(state);
|
||||||
|
let isElegibleForFirstAdmingOnboarding = onboardingFlowEnabled;
|
||||||
|
if (isElegibleForFirstAdmingOnboarding) {
|
||||||
|
isElegibleForFirstAdmingOnboarding = isCurrentUserSystemAdmin(state);
|
||||||
|
}
|
||||||
return {
|
return {
|
||||||
currentUserId: getCurrentUserId(state),
|
currentUserId: getCurrentUserId(state),
|
||||||
isElegibleForFirstAdmingOnboarding,
|
isElegibleForFirstAdmingOnboarding,
|
||||||
|
@ -17,7 +17,7 @@ import {getTeamInviteInfo} from 'mattermost-redux/actions/teams';
|
|||||||
import {createUser, loadMe, loadMeREST} from 'mattermost-redux/actions/users';
|
import {createUser, loadMe, loadMeREST} from 'mattermost-redux/actions/users';
|
||||||
import {DispatchFunc} from 'mattermost-redux/types/actions';
|
import {DispatchFunc} from 'mattermost-redux/types/actions';
|
||||||
import {getConfig, getLicense} from 'mattermost-redux/selectors/entities/general';
|
import {getConfig, getLicense} from 'mattermost-redux/selectors/entities/general';
|
||||||
import {isGraphQLEnabled} from 'mattermost-redux/selectors/entities/preferences';
|
import {getIsOnboardingFlowEnabled, isGraphQLEnabled} from 'mattermost-redux/selectors/entities/preferences';
|
||||||
import {getCurrentUserId} from 'mattermost-redux/selectors/entities/users';
|
import {getCurrentUserId} from 'mattermost-redux/selectors/entities/users';
|
||||||
import {isEmail} from 'mattermost-redux/utils/helpers';
|
import {isEmail} from 'mattermost-redux/utils/helpers';
|
||||||
|
|
||||||
@ -25,6 +25,7 @@ import {GlobalState} from 'types/store';
|
|||||||
|
|
||||||
import {getGlobalItem} from 'selectors/storage';
|
import {getGlobalItem} from 'selectors/storage';
|
||||||
|
|
||||||
|
import {redirectUserToDefaultTeam} from 'actions/global_actions';
|
||||||
import {removeGlobalItem, setGlobalItem} from 'actions/storage';
|
import {removeGlobalItem, setGlobalItem} from 'actions/storage';
|
||||||
import {addUserToTeamFromInvite} from 'actions/team_actions';
|
import {addUserToTeamFromInvite} from 'actions/team_actions';
|
||||||
import {trackEvent} from 'actions/telemetry_actions.jsx';
|
import {trackEvent} from 'actions/telemetry_actions.jsx';
|
||||||
@ -103,6 +104,7 @@ const Signup = ({onCustomizeHeader}: SignupProps) => {
|
|||||||
} = config;
|
} = config;
|
||||||
const {IsLicensed} = useSelector(getLicense);
|
const {IsLicensed} = useSelector(getLicense);
|
||||||
const loggedIn = Boolean(useSelector(getCurrentUserId));
|
const loggedIn = Boolean(useSelector(getCurrentUserId));
|
||||||
|
const onboardingFlowEnabled = useSelector(getIsOnboardingFlowEnabled);
|
||||||
const usedBefore = useSelector((state: GlobalState) => (!inviteId && !loggedIn && token ? getGlobalItem(state, token, null) : undefined));
|
const usedBefore = useSelector((state: GlobalState) => (!inviteId && !loggedIn && token ? getGlobalItem(state, token, null) : undefined));
|
||||||
const graphQLEnabled = useSelector(isGraphQLEnabled);
|
const graphQLEnabled = useSelector(isGraphQLEnabled);
|
||||||
|
|
||||||
@ -307,7 +309,15 @@ const Signup = ({onCustomizeHeader}: SignupProps) => {
|
|||||||
} else if (inviteId) {
|
} else if (inviteId) {
|
||||||
getInviteInfo(inviteId);
|
getInviteInfo(inviteId);
|
||||||
} else if (loggedIn) {
|
} else if (loggedIn) {
|
||||||
history.push('/');
|
if (onboardingFlowEnabled) {
|
||||||
|
// need info about whether admin or not,
|
||||||
|
// and whether admin has already completed
|
||||||
|
// first tiem onboarding. Instead of fetching and orchestrating that here,
|
||||||
|
// let the default root component handle it.
|
||||||
|
history.push('/');
|
||||||
|
} else {
|
||||||
|
redirectUserToDefaultTeam();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -450,12 +460,14 @@ const Signup = ({onCustomizeHeader}: SignupProps) => {
|
|||||||
|
|
||||||
if (redirectTo) {
|
if (redirectTo) {
|
||||||
history.push(redirectTo);
|
history.push(redirectTo);
|
||||||
} else {
|
} else if (onboardingFlowEnabled) {
|
||||||
// need info about whether admin or not,
|
// need info about whether admin or not,
|
||||||
// and whether admin has already completed
|
// and whether admin has already completed
|
||||||
// first tiem onboarding. Instead of fetching and orchestrating that here,
|
// first tiem onboarding. Instead of fetching and orchestrating that here,
|
||||||
// let the default root component handle it.
|
// let the default root component handle it.
|
||||||
history.push('/');
|
history.push('/');
|
||||||
|
} else {
|
||||||
|
redirectUserToDefaultTeam();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@ import {bindActionCreators, Dispatch, ActionCreatorsMapObject} from 'redux';
|
|||||||
|
|
||||||
import {getTermsOfService, updateMyTermsOfServiceStatus} from 'mattermost-redux/actions/users';
|
import {getTermsOfService, updateMyTermsOfServiceStatus} from 'mattermost-redux/actions/users';
|
||||||
import {getConfig} from 'mattermost-redux/selectors/entities/general';
|
import {getConfig} from 'mattermost-redux/selectors/entities/general';
|
||||||
|
import {getIsOnboardingFlowEnabled} from 'mattermost-redux/selectors/entities/preferences';
|
||||||
|
|
||||||
import {GlobalState} from '@mattermost/types/store';
|
import {GlobalState} from '@mattermost/types/store';
|
||||||
import {ActionFunc, GenericAction} from 'mattermost-redux/types/actions';
|
import {ActionFunc, GenericAction} from 'mattermost-redux/types/actions';
|
||||||
@ -25,7 +26,9 @@ type Actions = {
|
|||||||
|
|
||||||
function mapStateToProps(state: GlobalState) {
|
function mapStateToProps(state: GlobalState) {
|
||||||
const config = getConfig(state);
|
const config = getConfig(state);
|
||||||
|
const onboardingFlowEnabled = getIsOnboardingFlowEnabled(state);
|
||||||
return {
|
return {
|
||||||
|
onboardingFlowEnabled,
|
||||||
termsEnabled: config.EnableCustomTermsOfService === 'true',
|
termsEnabled: config.EnableCustomTermsOfService === 'true',
|
||||||
emojiMap: getEmojiMap(state),
|
emojiMap: getEmojiMap(state),
|
||||||
};
|
};
|
||||||
|
@ -27,6 +27,7 @@ describe('components/terms_of_service/TermsOfService', () => {
|
|||||||
location: {search: ''},
|
location: {search: ''},
|
||||||
termsEnabled: true,
|
termsEnabled: true,
|
||||||
emojiMap: {} as EmojiMap,
|
emojiMap: {} as EmojiMap,
|
||||||
|
onboardingFlowEnabled: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
test('should match snapshot', () => {
|
test('should match snapshot', () => {
|
||||||
|
@ -38,6 +38,7 @@ export interface TermsOfServiceProps {
|
|||||||
) => {data: UpdateMyTermsOfServiceStatusResponse};
|
) => {data: UpdateMyTermsOfServiceStatusResponse};
|
||||||
};
|
};
|
||||||
emojiMap: EmojiMap;
|
emojiMap: EmojiMap;
|
||||||
|
onboardingFlowEnabled: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface TermsOfServiceState {
|
interface TermsOfServiceState {
|
||||||
@ -110,12 +111,14 @@ export default class TermsOfService extends React.PureComponent<TermsOfServicePr
|
|||||||
const redirectTo = query.get('redirect_to');
|
const redirectTo = query.get('redirect_to');
|
||||||
if (redirectTo && redirectTo.match(/^\/([^/]|$)/)) {
|
if (redirectTo && redirectTo.match(/^\/([^/]|$)/)) {
|
||||||
getHistory().push(redirectTo);
|
getHistory().push(redirectTo);
|
||||||
} else {
|
} else if (this.props.onboardingFlowEnabled) {
|
||||||
// need info about whether admin or not,
|
// need info about whether admin or not,
|
||||||
// and whether admin has already completed
|
// and whether admin has already completed
|
||||||
// first time onboarding. Instead of fetching and orchestrating that here,
|
// first time onboarding. Instead of fetching and orchestrating that here,
|
||||||
// let the default root component handle it.
|
// let the default root component handle it.
|
||||||
getHistory().push('/');
|
getHistory().push('/');
|
||||||
|
} else {
|
||||||
|
GlobalActions.redirectUserToDefaultTeam();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
@ -245,6 +245,10 @@ export function isCustomGroupsEnabled(state: GlobalState): boolean {
|
|||||||
return getConfig(state).EnableCustomGroups === 'true';
|
return getConfig(state).EnableCustomGroups === 'true';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getIsOnboardingFlowEnabled(state: GlobalState): boolean {
|
||||||
|
return getConfig(state).EnableOnboardingFlow === 'true';
|
||||||
|
}
|
||||||
|
|
||||||
export function insightsAreEnabled(state: GlobalState): boolean {
|
export function insightsAreEnabled(state: GlobalState): boolean {
|
||||||
const isConfiguredForFeature = getConfig(state).InsightsEnabled === 'true';
|
const isConfiguredForFeature = getConfig(state).InsightsEnabled === 'true';
|
||||||
const featureIsEnabled = getFeatureFlagValue(state, 'InsightsEnabled') === 'true';
|
const featureIsEnabled = getFeatureFlagValue(state, 'InsightsEnabled') === 'true';
|
||||||
|
Loading…
Reference in New Issue
Block a user