// Copyright (C) 2020-2021 Intel Corporation // // SPDX-License-Identifier: MIT import React from 'react'; import moment from 'moment'; import { useSelector } from 'react-redux'; import { useHistory } from 'react-router'; import Text from 'antd/lib/typography/Text'; import Empty from 'antd/lib/empty'; import Card from 'antd/lib/card'; import Meta from 'antd/lib/card/Meta'; import Dropdown from 'antd/lib/dropdown'; import Button from 'antd/lib/button'; import { MoreOutlined } from '@ant-design/icons'; import { CombinedState, Project } from 'reducers/interfaces'; import { useCardHeightHOC } from 'utils/hooks'; import ProjectActionsMenuComponent from './actions-menu'; interface Props { projectInstance: Project; } const useCardHeight = useCardHeightHOC({ containerClassName: 'cvat-projects-page', siblingClassNames: ['cvat-projects-pagination', 'cvat-projects-page-top-bar'], paddings: 40, numberOfRows: 3, }); export default function ProjectItemComponent(props: Props): JSX.Element { const { projectInstance: { instance, preview }, } = props; const history = useHistory(); const height = useCardHeight(); const ownerName = instance.owner ? instance.owner.username : null; const updated = moment(instance.updatedDate).fromNow(); const deletes = useSelector((state: CombinedState) => state.projects.activities.deletes); const deleted = instance.id in deletes ? deletes[instance.id] : false; const onOpenProject = (): void => { history.push(`/projects/${instance.id}`); }; const style: React.CSSProperties = { height }; if (deleted) { style.pointerEvents = 'none'; style.opacity = 0.5; } return ( ) : (
) } size='small' style={style} className='cvat-projects-project-item-card' > {instance.name} )} description={(
{ownerName && ( <> {`Created ${ownerName ? `by ${ownerName}` : ''}`}
)} {`Last updated ${updated}`}
}>
)} />
); }