openreplay/frontend/app/components/Client/Sites/AddProjectButton/AddUserButton.tsx
Shekar Siri 0c0dd30a73
Preferences - UI and API improvements (#654)
* fix(tracker): fix assist typings

* fix(tracker): fix assist typings

* change(ui) - preferences - removed old

* change(ui) - preferences - wip

* change(ui) - preferences - list

* change(ui) - right box mardings

* change(ui) - preferences - integration item paddings

* change(ui) - preferences - integration icons

* change(ui) - preferences - integration icons

* change(ui) - preferences - integration - check status

* change(ui) - preferences - integration - check status

* change(ui) - preferences - metadata - move the delete button inside the modal

* change(ui) - preferences - webhooks - modal and delete btn changes

* change(ui) - preferences - modalContext updates

* change(ui) - input field forward refs

* change(ui) - metadata - modal

* change(ui) - metadata - set deleting item to null

* change(ui) - integrations

* change(ui) - hoc withcopy

* change(ui) - projects

* change(ui) - users list modal

* change(ui) - projects remove border for the last

* change(ui) - integrations new api changes

* change(ui) - github and jira changes

* change(ui) - github and jira changes

Co-authored-by: sylenien <nikita@openreplay.com>
2022-08-04 12:21:25 +02:00

30 lines
1.3 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import React from 'react';
import { Popup, Button, IconButton } from 'UI';
import { useStore } from 'App/mstore';
import { useObserver } from 'mobx-react-lite';
import { init, remove, fetchGDPR } from 'Duck/site';
import { connect } from 'react-redux';
import { useModal } from 'App/components/Modal';
import NewSiteForm from '../NewSiteForm';
const PERMISSION_WARNING = 'You dont have the permissions to perform this action.';
const LIMIT_WARNING = 'You have reached site limit.';
function AddProjectButton({ isAdmin = false, init = () => {} }: any) {
const { userStore } = useStore();
const { showModal, hideModal } = useModal();
const limtis = useObserver(() => userStore.limits);
const canAddProject = useObserver(() => isAdmin && (limtis.projects === -1 || limtis.projects > 0));
const onClick = () => {
init();
showModal(<NewSiteForm onClose={hideModal} />, { right: true });
};
return (
<Popup content={`${!isAdmin ? PERMISSION_WARNING : !canAddProject ? LIMIT_WARNING : 'Add a Project'}`}>
<Button rounded={true} variant="outline" icon="plus" onClick={onClick} disabled={!canAddProject || !isAdmin}></Button>
</Popup>
);
}
export default connect(null, { init, remove, fetchGDPR })(AddProjectButton);