/*! * Copyright (c) 2024 PLANKA Software GmbH * Licensed under the Fair Use License: https://github.com/plankanban/planka/blob/master/LICENSE.md */ import React, { useCallback } from 'react'; import { useDispatch, useSelector } from 'react-redux'; import { useTranslation } from 'react-i18next'; import { Button, Divider, Header, Tab } from 'semantic-ui-react'; import selectors from '../../../selectors'; import entryActions from '../../../entry-actions'; import { usePopupInClosableContext } from '../../../hooks'; import ConfirmationStep from '../../common/ConfirmationStep'; import ProjectManagers from '../../project-managers/ProjectManagers'; import styles from './ManagersPane.module.scss'; const ManagersPane = React.memo(() => { const projectManagers = useSelector(selectors.selectManagersForCurrentProject); // TODO: rename? const isShared = useSelector( (state) => !selectors.selectCurrentProject(state).ownerProjectManagerId, ); const dispatch = useDispatch(); const [t] = useTranslation(); const firstProjectManager = projectManagers[0]; const handleToggleSharedConfirm = useCallback(() => { dispatch( entryActions.updateCurrentProject({ ownerProjectManagerId: isShared ? firstProjectManager.id : null, }), ); }, [firstProjectManager, isShared, dispatch]); const ConfirmationPopup = usePopupInClosableContext(ConfirmationStep); let toggleSharedButtonContent; if (isShared) { toggleSharedButtonContent = projectManagers.length === 1 ? t('action.makeProjectPrivate', { context: 'title', }) : t('common.onlyOneManagerShouldRemainToMakeThisProjectPrivate'); } else { toggleSharedButtonContent = t('action.makeProjectShared', { context: 'title', }); } return (
{t('common.dangerZone', { context: 'title', })}
); }); export default ManagersPane;