You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

OnboardingPage.tsx 2.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /*
  2. * SonarQube
  3. * Copyright (C) 2009-2018 SonarSource SA
  4. * mailto:info AT sonarsource DOT com
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Lesser General Public
  8. * License as published by the Free Software Foundation; either
  9. * version 3 of the License, or (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public License
  17. * along with this program; if not, write to the Free Software Foundation,
  18. * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  19. */
  20. import * as React from 'react';
  21. import { connect } from 'react-redux';
  22. import { InjectedRouter } from 'react-router';
  23. import OnboardingModal from './OnboardingModal';
  24. import { skipOnboarding } from '../../../store/users';
  25. import TeamOnboardingModal from '../teamOnboarding/TeamOnboardingModal';
  26. import { OnboardingContext } from '../../../app/components/OnboardingContext';
  27. interface DispatchProps {
  28. skipOnboarding: () => void;
  29. }
  30. interface OwnProps {
  31. router: InjectedRouter;
  32. }
  33. enum ModalKey {
  34. onboarding,
  35. teamOnboarding
  36. }
  37. interface State {
  38. modal?: ModalKey;
  39. }
  40. export class OnboardingPage extends React.PureComponent<OwnProps & DispatchProps, State> {
  41. state: State = { modal: ModalKey.onboarding };
  42. closeOnboarding = () => {
  43. this.props.skipOnboarding();
  44. this.props.router.replace('/');
  45. };
  46. openTeamOnboarding = () => {
  47. this.setState({ modal: ModalKey.teamOnboarding });
  48. };
  49. render() {
  50. const { modal } = this.state;
  51. return (
  52. <>
  53. {modal === ModalKey.onboarding && (
  54. <OnboardingContext.Consumer>
  55. {openProjectOnboarding => (
  56. <OnboardingModal
  57. onClose={this.closeOnboarding}
  58. onOpenProjectOnboarding={openProjectOnboarding}
  59. onOpenTeamOnboarding={this.openTeamOnboarding}
  60. />
  61. )}
  62. </OnboardingContext.Consumer>
  63. )}
  64. {modal === ModalKey.teamOnboarding && (
  65. <TeamOnboardingModal onFinish={this.closeOnboarding} />
  66. )}
  67. </>
  68. );
  69. }
  70. }
  71. const mapDispatchToProps: DispatchProps = { skipOnboarding };
  72. export default connect(
  73. null,
  74. mapDispatchToProps
  75. )(OnboardingPage);