]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-9788 Onboarding tutorial is shown many times
authorStas Vilchik <stas.vilchik@sonarsource.com>
Thu, 12 Oct 2017 09:04:36 +0000 (11:04 +0200)
committerStas Vilchik <stas.vilchik@sonarsource.com>
Mon, 16 Oct 2017 09:08:02 +0000 (11:08 +0200)
server/sonar-web/src/main/js/app/components/nav/global/GlobalNav.js
server/sonar-web/src/main/js/apps/tutorials/onboarding/Onboarding.js
server/sonar-web/src/main/js/store/users/actions.js
server/sonar-web/src/main/js/store/users/reducer.js

index 4611d30d5c80dac6450bd6698c0ceaeb9a7ec7ac..0284617f18a8a2902ed3721023a22b4c1cf57e03 100644 (file)
@@ -30,13 +30,15 @@ import Tooltip from '../../../../components/controls/Tooltip';
 import HelpIcon from '../../../../components/icons-components/HelpIcon';
 import OnboardingModal from '../../../../apps/tutorials/onboarding/OnboardingModal';
 import { getCurrentUser, getAppState, getGlobalSettingValue } from '../../../../store/rootReducer';
+import { skipOnboarding } from '../../../../store/users/actions';
 import { translate } from '../../../../helpers/l10n';
 import './GlobalNav.css';
 
 /*::
 type Props = {
   appState: { organizationsEnabled: boolean },
-  currentUser: { isLoggedIn: boolean, showOnboardingTutorial: true },
+  currentUser: { isLoggedIn: boolean, showOnboardingTutorial: boolean },
+  skipOnboarding: () => void,
   sonarCloud: boolean
 };
 */
@@ -95,6 +97,7 @@ class GlobalNav extends React.PureComponent {
 
   closeOnboardingTutorial = () => {
     this.setState({ onboardingTutorialOpen: false, onboardingTutorialTooltip: true });
+    this.props.skipOnboarding();
     this.interval = setInterval(() => {
       this.setState({ onboardingTutorialTooltip: false });
     }, 3000);
@@ -153,4 +156,6 @@ const mapStateToProps = state => {
   };
 };
 
-export default connect(mapStateToProps)(GlobalNav);
+const mapDispatchToProps = { skipOnboarding };
+
+export default connect(mapStateToProps, mapDispatchToProps)(GlobalNav);
index d0e4b41b23405ae23707ba711327c7da57984c2e..c5ec51485110994a72c7838a9fc64dc8d8d8dc15 100644 (file)
@@ -139,7 +139,7 @@ export default class Onboarding extends React.PureComponent {
 
   handleFinish = (projectKey /*: string | void */) => this.setState({ finished: true, projectKey });
 
-  handleReset = () => this.setState({ finished: false });
+  handleReset = () => this.setState({ finished: false, projectKey: undefined });
 
   render() {
     if (!this.props.currentUser.isLoggedIn) {
index 0183deee9b03ae16f3dc14b1f5a117e0d82df88f..aaee44981383c2e0e7ed1d29eacec04fbd29dcef 100644 (file)
@@ -21,6 +21,7 @@ import { getCurrentUser } from '../../api/users';
 
 export const RECEIVE_CURRENT_USER = 'RECEIVE_CURRENT_USER';
 export const RECEIVE_USER = 'RECEIVE_USER';
+export const SKIP_ONBOARDING = 'SKIP_ONBOARDING';
 
 export const receiveCurrentUser = user => ({
   type: RECEIVE_CURRENT_USER,
@@ -32,5 +33,7 @@ export const receiveUser = user => ({
   user
 });
 
+export const skipOnboarding = () => ({ type: SKIP_ONBOARDING });
+
 export const fetchCurrentUser = () => dispatch =>
   getCurrentUser().then(user => dispatch(receiveCurrentUser(user)));
index 836f74a9697e200794fc6efbae24ca6573ff2eac..79472f1f8d3acc6617d305ed3b959da2f5626a5a 100644 (file)
@@ -19,7 +19,7 @@
  */
 import { combineReducers } from 'redux';
 import { uniq, keyBy } from 'lodash';
-import { RECEIVE_CURRENT_USER, RECEIVE_USER } from './actions';
+import { RECEIVE_CURRENT_USER, RECEIVE_USER, SKIP_ONBOARDING } from './actions';
 import { actions as membersActions } from '../organizationsMembers/actions';
 
 const usersByLogin = (state = {}, action = {}) => {
@@ -57,6 +57,9 @@ const currentUser = (state = null, action = {}) => {
   if (action.type === RECEIVE_CURRENT_USER) {
     return action.user;
   }
+  if (action.type === SKIP_ONBOARDING) {
+    return state ? { ...state, showOnboardingTutorial: false } : null;
+  }
   return state;
 };