From e3ee050e80efbb06941be97ca8559f3352be9a17 Mon Sep 17 00:00:00 2001 From: Jaanus Sellin Date: Wed, 20 Sep 2023 08:55:30 +0300 Subject: [PATCH] chore: remove project select (#4768) --- .../common/ProjectSelect/ProjectSelect.tsx | 74 ------------------- 1 file changed, 74 deletions(-) delete mode 100644 frontend/src/component/common/ProjectSelect/ProjectSelect.tsx diff --git a/frontend/src/component/common/ProjectSelect/ProjectSelect.tsx b/frontend/src/component/common/ProjectSelect/ProjectSelect.tsx deleted file mode 100644 index 9f8daeab7a..0000000000 --- a/frontend/src/component/common/ProjectSelect/ProjectSelect.tsx +++ /dev/null @@ -1,74 +0,0 @@ -import React, { MouseEventHandler, useMemo, VFC } from 'react'; -import { MenuItem, Typography } from '@mui/material'; -import DropdownMenu, { IDropdownMenuProps } from '../DropdownMenu/DropdownMenu'; -import useProjects from 'hooks/api/getters/useProjects/useProjects'; -import { IProjectCard } from 'interfaces/project'; - -const ALL_PROJECTS = { id: '*', name: '> All projects' }; - -interface IProjectSelectProps { - currentProjectId: string; - updateCurrentProject: (id: string) => void; -} - -const ProjectSelect: VFC> = ({ - currentProjectId, - updateCurrentProject, - ...rest -}) => { - const { projects } = useProjects(); - - const setProject = (value?: string | null) => { - const id = value && typeof value === 'string' ? value.trim() : '*'; - updateCurrentProject(id); - }; - - const currentProject = useMemo(() => { - const project = projects.find(i => i.id === currentProjectId); - return project || ALL_PROJECTS; - }, [currentProjectId, projects]); - - const handleChangeProject: MouseEventHandler = event => { - const target = (event.target as Element).getAttribute('data-target'); - setProject(target); - }; - - const renderProjectItem = (selectedId: string, item: IProjectCard) => ( - - {item.name} - - ); - - const renderProjectOptions = () => [ - - {ALL_PROJECTS.name} - , - ...projects.map(project => - renderProjectItem(currentProjectId, project) - ), - ]; - - return ( - - - - ); -}; - -export default ProjectSelect;