From e1c633af999220c965206fe5ed65a23d244154bb Mon Sep 17 00:00:00 2001 From: Shekar Siri Date: Thu, 23 Jun 2022 16:16:24 +0200 Subject: [PATCH] change(ui) - project limit check --- .../Sites/AddProjectButton/AddUserButton.tsx | 29 +++++++++++++++++ .../Client/Sites/AddProjectButton/index.ts | 1 + frontend/app/components/Client/Sites/Sites.js | 31 +++++++------------ 3 files changed, 41 insertions(+), 20 deletions(-) create mode 100644 frontend/app/components/Client/Sites/AddProjectButton/AddUserButton.tsx create mode 100644 frontend/app/components/Client/Sites/AddProjectButton/index.ts diff --git a/frontend/app/components/Client/Sites/AddProjectButton/AddUserButton.tsx b/frontend/app/components/Client/Sites/AddProjectButton/AddUserButton.tsx new file mode 100644 index 000000000..078122bb2 --- /dev/null +++ b/frontend/app/components/Client/Sites/AddProjectButton/AddUserButton.tsx @@ -0,0 +1,29 @@ +import React from 'react'; +import { Popup, IconButton } from 'UI'; +import { useStore } from 'App/mstore'; +import { useObserver } from 'mobx-react-lite'; + +const PERMISSION_WARNING = 'You don’t have the permissions to perform this action.'; +const LIMIT_WARNING = 'You have reached site limit.'; + +function AddProjectButton({ isAdmin = false, onClick }: any ) { + const { userStore } = useStore(); + const limtis = useObserver(() => userStore.limits); + const canAddProject = useObserver(() => isAdmin && (limtis.projects === -1 || limtis.projects > 0)); + return ( + + + + ); +} + +export default AddProjectButton; \ No newline at end of file diff --git a/frontend/app/components/Client/Sites/AddProjectButton/index.ts b/frontend/app/components/Client/Sites/AddProjectButton/index.ts new file mode 100644 index 000000000..66beb9cf8 --- /dev/null +++ b/frontend/app/components/Client/Sites/AddProjectButton/index.ts @@ -0,0 +1 @@ +export { default } from './AddUserButton'; \ No newline at end of file diff --git a/frontend/app/components/Client/Sites/Sites.js b/frontend/app/components/Client/Sites/Sites.js index 0dd140add..5a6791191 100644 --- a/frontend/app/components/Client/Sites/Sites.js +++ b/frontend/app/components/Client/Sites/Sites.js @@ -2,7 +2,7 @@ import React from 'react'; import { connect } from 'react-redux'; import cn from 'classnames'; import withPageTitle from 'HOCs/withPageTitle'; -import { Loader, SlideModal, IconButton, Icon, Button, Popup, TextLink } from 'UI'; +import { Loader, SlideModal, Icon, Button, Popup, TextLink } from 'UI'; import { init, remove, fetchGDPR } from 'Duck/site'; import { RED, YELLOW, GREEN, STATUS_COLOR_MAP } from 'Types/site'; import stl from './sites.module.css'; @@ -10,8 +10,9 @@ import NewSiteForm from './NewSiteForm'; import GDPRForm from './GDPRForm'; import TrackingCodeModal from 'Shared/TrackingCodeModal'; import BlockedIps from './BlockedIps'; -import { confirm } from 'UI'; +import { confirm, PageTitle } from 'UI'; import SiteSearch from './SiteSearch'; +import AddProjectButton from './AddProjectButton'; const STATUS_MESSAGE_MAP = { [ RED ]: ' There seems to be an issue (please verify your installation)', @@ -19,9 +20,6 @@ const STATUS_MESSAGE_MAP = { [ GREEN ]: 'All good!', }; -const PERMISSION_WARNING = 'You don’t have the permissions to perform this action.'; -const LIMIT_WARNING = 'You have reached site limit.'; - const BLOCKED_IPS = 'BLOCKED_IPS'; const NONE = 'NONE'; @@ -143,21 +141,14 @@ class Sites extends React.PureComponent { />
-

{ 'Projects' }

- -
- -
-
+ {/*

{ 'Projects' }

*/} + Projects
} + actionButton={( + + )} + /> +