/*! * Copyright (c) 2024 PLANKA Software GmbH * Licensed under the Fair Use License: https://github.com/plankanban/planka/blob/master/LICENSE.md */ import React, { useCallback, useMemo } from 'react'; import PropTypes from 'prop-types'; import classNames from 'classnames'; import { useDispatch, useSelector } from 'react-redux'; import { Link } from 'react-router'; import { Draggable } from 'react-beautiful-dnd'; import { useTranslation } from 'react-i18next'; import { Button, Icon } from 'semantic-ui-react'; import { Tooltip } from '../../../lib/custom-ui'; import selectors from '../../../selectors'; import entryActions from '../../../entry-actions'; import Paths from '../../../constants/Paths'; import styles from './Item.module.scss'; const Item = React.memo(({ id, index }) => { const selectBoardById = useMemo(() => selectors.makeSelectBoardById(), []); const selectNotificationsTotalByBoardId = useMemo( () => selectors.makeSelectNotificationsTotalByBoardId(), [], ); const board = useSelector((state) => selectBoardById(state, id)); const notificationsTotal = useSelector((state) => selectNotificationsTotalByBoardId(state, id)); const isActive = useSelector((state) => id === selectors.selectPath(state).boardId); const canEdit = useSelector((state) => { const isEditModeEnabled = selectors.selectIsEditModeEnabled(state); // TODO: move out? if (!isEditModeEnabled) { return isEditModeEnabled; } return selectors.selectIsCurrentUserManagerForCurrentProject(state); }); const dispatch = useDispatch(); const [t] = useTranslation(); const handleEditClick = useCallback(() => { dispatch(entryActions.openBoardSettingsModal(id)); }, [id, dispatch]); return ( {({ innerRef, draggableProps, dragHandleProps }) => ( // eslint-disable-next-line react/jsx-props-no-spreading
{board.isPersisted ? ( <> {notificationsTotal > 0 && ( {notificationsTotal} )} {board.name} {canEdit && ( )} ) : ( {board.name} )}
)}
); }); Item.propTypes = { id: PropTypes.string.isRequired, index: PropTypes.number.isRequired, }; export default Item;