organizationRoot.tsx 875 B

123456789101112131415161718192021222324252627282930313233
  1. import {Component} from 'react';
  2. import {withRouter, WithRouterProps} from 'react-router';
  3. import {setLastRoute} from 'app/actionCreators/navigation';
  4. import {setActiveProject} from 'app/actionCreators/projects';
  5. type Props = WithRouterProps;
  6. /**
  7. * This is the parent container for organization-level views such
  8. * as the Dashboard, Stats, Activity, etc...
  9. *
  10. * Currently is just used to unset active project
  11. */
  12. class OrganizationRoot extends Component<Props> {
  13. componentDidMount() {
  14. setActiveProject(null);
  15. }
  16. componentWillUnmount() {
  17. const {location} = this.props;
  18. const {pathname, search} = location;
  19. // Save last route so that we can jump back to view from settings
  20. setLastRoute(`${pathname}${search || ''}`);
  21. }
  22. render() {
  23. return this.props.children;
  24. }
  25. }
  26. export {OrganizationRoot};
  27. export default withRouter(OrganizationRoot);