diff --git a/frontend/app/components/Header/NewProjectButton/NewProjectButton.tsx b/frontend/app/components/Header/NewProjectButton/NewProjectButton.tsx
index 695139fa3..9c438c50f 100644
--- a/frontend/app/components/Header/NewProjectButton/NewProjectButton.tsx
+++ b/frontend/app/components/Header/NewProjectButton/NewProjectButton.tsx
@@ -3,26 +3,35 @@ import { Icon } from 'UI';
import cn from 'classnames';
import { useStore } from 'App/mstore';
import { useObserver } from 'mobx-react-lite';
-
-function NewProjectButton({ onClick, isAdmin = false }: any) {
+import { useModal } from 'App/components/Modal';
+import NewSiteForm from 'App/components/Client/Sites/NewSiteForm';
+import { init } from 'Duck/site';
+import { connect } from 'react-redux';
+interface Props {
+ isAdmin?: boolean;
+ init?: (data: any) => void;
+}
+function NewProjectButton(props: Props) {
+ const { isAdmin = false } = props;
const { userStore } = useStore();
const limtis = useObserver(() => userStore.limits);
const canAddProject = useObserver(() => isAdmin && (limtis.projects === -1 || limtis.projects > 0));
+ const { showModal, hideModal } = useModal();
+
+ const onClick = () => {
+ props.init({});
+ showModal(, { right: true });
+ };
return (
-
+ >
+
Add New Project
);
}
-export default NewProjectButton;
\ No newline at end of file
+export default connect(null, { init })(NewProjectButton);
diff --git a/frontend/app/components/Header/SiteDropdown.js b/frontend/app/components/Header/SiteDropdown.js
index 228190111..87fe2a0c2 100644
--- a/frontend/app/components/Header/SiteDropdown.js
+++ b/frontend/app/components/Header/SiteDropdown.js
@@ -2,104 +2,100 @@ import React from 'react';
import { connect } from 'react-redux';
import { setSiteId } from 'Duck/site';
import { withRouter } from 'react-router-dom';
-import { hasSiteId, siteChangeAvaliable, isRoute } from 'App/routes';
+import { hasSiteId, siteChangeAvaliable } from 'App/routes';
import { STATUS_COLOR_MAP, GREEN } from 'Types/site';
-import { Icon, SlideModal } from 'UI';
-import { pushNewSite } from 'Duck/user'
+import { Icon } from 'UI';
+import { pushNewSite } from 'Duck/user';
import { init } from 'Duck/site';
import styles from './siteDropdown.module.css';
import cn from 'classnames';
-import NewSiteForm from '../Client/Sites/NewSiteForm';
import { clearSearch } from 'Duck/search';
import { clearSearch as clearSearchLive } from 'Duck/liveSearch';
import { fetchList as fetchIntegrationVariables } from 'Duck/customField';
-import { withStore } from 'App/mstore'
+import { withStore } from 'App/mstore';
import AnimatedSVG, { ICONS } from '../shared/AnimatedSVG/AnimatedSVG';
import NewProjectButton from './NewProjectButton';
@withStore
@withRouter
-@connect(state => ({
- sites: state.getIn([ 'site', 'list' ]),
- siteId: state.getIn([ 'site', 'siteId' ]),
- account: state.getIn([ 'user', 'account' ]),
-}), {
- setSiteId,
- pushNewSite,
- init,
- clearSearch,
- clearSearchLive,
- fetchIntegrationVariables,
-})
+@connect(
+ (state) => ({
+ sites: state.getIn(['site', 'list']),
+ siteId: state.getIn(['site', 'siteId']),
+ account: state.getIn(['user', 'account']),
+ }),
+ {
+ setSiteId,
+ pushNewSite,
+ init,
+ clearSearch,
+ clearSearchLive,
+ fetchIntegrationVariables,
+ }
+)
export default class SiteDropdown extends React.PureComponent {
- state = { showProductModal: false }
+ state = { showProductModal: false };
- closeModal = (e, newSite) => {
- this.setState({ showProductModal: false })
- };
+ closeModal = (e, newSite) => {
+ this.setState({ showProductModal: false });
+ };
- newSite = () => {
- this.props.init({})
- this.setState({showProductModal: true})
- }
+ newSite = () => {
+ this.props.init({});
+ this.setState({ showProductModal: true });
+ };
- switchSite = (siteId) => {
- const { mstore, location } = this.props
+ switchSite = (siteId) => {
+ const { mstore, location } = this.props;
- this.props.setSiteId(siteId);
- this.props.fetchIntegrationVariables();
- this.props.clearSearch(location.pathname.includes('/sessions'));
- this.props.clearSearchLive();
+ this.props.setSiteId(siteId);
+ this.props.fetchIntegrationVariables();
+ this.props.clearSearch(location.pathname.includes('/sessions'));
+ this.props.clearSearchLive();
- mstore.initClient();
- }
+ mstore.initClient();
+ };
- render() {
- const { sites, siteId, account, location: { pathname } } = this.props;
- const { showProductModal } = this.state;
- const isAdmin = account.admin || account.superAdmin;
- const activeSite = sites.find(s => s.id == siteId);
- const disabled = !siteChangeAvaliable(pathname);
- const showCurrent = hasSiteId(pathname) || siteChangeAvaliable(pathname);
- // const canAddSites = isAdmin && account.limits.projects && account.limits.projects.remaining !== 0;
+ render() {
+ const {
+ sites,
+ siteId,
+ account,
+ location: { pathname },
+ } = this.props;
+ const { showProductModal } = this.state;
+ const isAdmin = account.admin || account.superAdmin;
+ const activeSite = sites.find((s) => s.id == siteId);
+ const disabled = !siteChangeAvaliable(pathname);
+ const showCurrent = hasSiteId(pathname) || siteChangeAvaliable(pathname);
+ // const canAddSites = isAdmin && account.limits.projects && account.limits.projects.remaining !== 0;
- return (
-
- {
- showCurrent ?
- (activeSite && activeSite.status === GREEN) ?
:
:
-
- }
-
{ showCurrent && activeSite ? activeSite.host : 'All Projects' }
-
-
-
- { !showCurrent && - { 'Does not require domain selection.' }
}
- {
- sites.map(site => (
- - this.switchSite(site.id)}>
-
- { site.host }
-
- ))
- }
-
-
-
-
-
}
- onClose={ this.closeModal }
- />
-
- );
- }
+ return (
+
+ {showCurrent ? (
+ activeSite && activeSite.status === GREEN ? (
+
+ ) : (
+
+ )
+ ) : (
+
+ )}
+
{showCurrent && activeSite ? activeSite.host : 'All Projects'}
+
+
+
+ {!showCurrent && - {'Does not require domain selection.'}
}
+ {sites.map((site) => (
+ - this.switchSite(site.id)}>
+
+ {site.host}
+
+ ))}
+
+
+
+
+ );
+ }
}