From 6bccffef9744f9a3e180a8b59883a22523b5f40b Mon Sep 17 00:00:00 2001 From: andreas-unleash Date: Thu, 8 Dec 2022 14:41:51 +0200 Subject: [PATCH] Fix/favorites UI improvements (#2636) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Favorite UI improvements ## About the changes Closes # ### Important files ## Discussion points Signed-off-by: andreas-unleash --- .../FavoriteIconButton/FavoriteIconButton.tsx | 54 ++++--- .../FavoriteIconHeader/FavoriteIconHeader.tsx | 9 +- .../FavoriteIconCell/FavoriteIconCell.tsx | 26 ++- .../feature/FeatureView/FeatureView.tsx | 16 +- .../project/Project/Project.styles.ts | 3 +- .../src/component/project/Project/Project.tsx | 152 ++++++++++-------- .../ProjectFeatureToggles.tsx | 5 +- .../project/ProjectCard/ProjectCard.tsx | 5 +- 8 files changed, 155 insertions(+), 115 deletions(-) diff --git a/frontend/src/component/common/FavoriteIconButton/FavoriteIconButton.tsx b/frontend/src/component/common/FavoriteIconButton/FavoriteIconButton.tsx index 5cf1cce351..7697789a35 100644 --- a/frontend/src/component/common/FavoriteIconButton/FavoriteIconButton.tsx +++ b/frontend/src/component/common/FavoriteIconButton/FavoriteIconButton.tsx @@ -1,50 +1,58 @@ import React, { VFC } from 'react'; -import { Dialogue } from 'component/common/Dialogue/Dialogue'; -import useFeatureApi from 'hooks/api/actions/useFeatureApi/useFeatureApi'; -import useToast from 'hooks/useToast'; -import { formatUnknownError } from 'utils/formatUnknownError'; -import { IconButton } from '@mui/material'; +import { IconButton, SxProps, Theme } from '@mui/material'; import { ConditionallyRender } from '../ConditionallyRender/ConditionallyRender'; import { Star as StarIcon, StarBorder as StarBorderIcon, } from '@mui/icons-material'; +import { TooltipResolver } from '../TooltipResolver/TooltipResolver'; interface IFavoriteIconButtonProps { onClick: (event?: any) => void; isFavorite: boolean; size?: 'medium' | 'large'; + sx?: SxProps; } export const FavoriteIconButton: VFC = ({ onClick, isFavorite, size = 'large', + sx, }) => { return ( - + - size === 'medium' - ? theme.spacing(2) - : theme.spacing(3), - }} - /> + + + size === 'medium' + ? theme.spacing(2) + : theme.spacing(3), + }} + /> + } elseShow={ - - size === 'medium' - ? theme.spacing(2) - : theme.spacing(3), - }} - /> + + + size === 'medium' + ? theme.spacing(2) + : theme.spacing(3), + }} + /> + } /> diff --git a/frontend/src/component/common/Table/FavoriteIconHeader/FavoriteIconHeader.tsx b/frontend/src/component/common/Table/FavoriteIconHeader/FavoriteIconHeader.tsx index c8dc95bcb4..f5c537fd0f 100644 --- a/frontend/src/component/common/Table/FavoriteIconHeader/FavoriteIconHeader.tsx +++ b/frontend/src/component/common/Table/FavoriteIconHeader/FavoriteIconHeader.tsx @@ -1,10 +1,11 @@ import { useState, VFC } from 'react'; -import { IconButton, Tooltip } from '@mui/material'; +import { IconButton } from '@mui/material'; import { Star as StarIcon, StarBorder as StarBorderIcon, } from '@mui/icons-material'; import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender'; +import { TooltipResolver } from '../../TooltipResolver/TooltipResolver'; interface IFavoriteIconHeaderProps { isActive: boolean; @@ -22,13 +23,12 @@ export const FavoriteIconHeader: VFC = ({ }; return ( - = ({ display: 'flex', alignItems: 'center', justifyContent: 'center', + padding: 1.25, }} onClick={onToggle} size="small" @@ -46,6 +47,6 @@ export const FavoriteIconHeader: VFC = ({ elseShow={} /> - + ); }; diff --git a/frontend/src/component/common/Table/cells/FavoriteIconCell/FavoriteIconCell.tsx b/frontend/src/component/common/Table/cells/FavoriteIconCell/FavoriteIconCell.tsx index ba46ba0a33..53653ad455 100644 --- a/frontend/src/component/common/Table/cells/FavoriteIconCell/FavoriteIconCell.tsx +++ b/frontend/src/component/common/Table/cells/FavoriteIconCell/FavoriteIconCell.tsx @@ -5,6 +5,7 @@ import { StarBorder as StarBorderIcon, } from '@mui/icons-material'; import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender'; +import { TooltipResolver } from '../../../TooltipResolver/TooltipResolver'; interface IFavoriteIconCellProps { value?: boolean; @@ -26,14 +27,27 @@ export const FavoriteIconCell: VFC = ({ - - + + + + + } elseShow={ - - - + + + + + } /> diff --git a/frontend/src/component/feature/FeatureView/FeatureView.tsx b/frontend/src/component/feature/FeatureView/FeatureView.tsx index 917aac0836..f4b56b799c 100644 --- a/frontend/src/component/feature/FeatureView/FeatureView.tsx +++ b/frontend/src/component/feature/FeatureView/FeatureView.tsx @@ -1,19 +1,12 @@ -import { IconButton, Tab, Tabs, useMediaQuery } from '@mui/material'; -import React, { useCallback, useState } from 'react'; -import { - Archive, - FileCopy, - Label, - WatchLater, - Star as StarIcon, - StarBorder as StarBorderIcon, -} from '@mui/icons-material'; +import { Tab, Tabs, useMediaQuery } from '@mui/material'; +import React, { useState } from 'react'; +import { Archive, FileCopy, Label, WatchLater } from '@mui/icons-material'; import { Link, Route, - useNavigate, Routes, useLocation, + useNavigate, } from 'react-router-dom'; import { useFeature } from 'hooks/api/getters/useFeature/useFeature'; import useProject from 'hooks/api/getters/useProject/useProject'; @@ -130,6 +123,7 @@ export const FeatureView = () => { )} /> diff --git a/frontend/src/component/project/Project/Project.styles.ts b/frontend/src/component/project/Project/Project.styles.ts index cd19609118..ab223f91b4 100644 --- a/frontend/src/component/project/Project/Project.styles.ts +++ b/frontend/src/component/project/Project/Project.styles.ts @@ -19,7 +19,8 @@ export const useStyles = makeStyles()(theme => ({ innerContainer: { padding: '1.25rem 2rem', display: 'flex', - alignItems: 'center', + flexDirection: 'column', + alignItems: 'start', }, separator: { width: '100%', diff --git a/frontend/src/component/project/Project/Project.tsx b/frontend/src/component/project/Project/Project.tsx index cb8e10b1b1..35606e475a 100644 --- a/frontend/src/component/project/Project/Project.tsx +++ b/frontend/src/component/project/Project/Project.tsx @@ -20,7 +20,7 @@ import { } from 'component/providers/AccessProvider/permissions'; import { useRequiredPathParam } from 'hooks/useRequiredPathParam'; import useUiConfig from 'hooks/api/getters/useUiConfig/useUiConfig'; -import { Routes, Route, useLocation } from 'react-router-dom'; +import { Route, Routes, useLocation } from 'react-router-dom'; import { DeleteProjectDialogue } from './DeleteProject/DeleteProjectDialogue'; import { ProjectLog } from './ProjectLog/ProjectLog'; import { ChangeRequestOverview } from 'component/changeRequest/ChangeRequestOverview/ChangeRequestOverview'; @@ -31,17 +31,28 @@ import { ProjectSettings } from './ProjectSettings/ProjectSettings'; import { useChangeRequestsEnabled } from 'hooks/useChangeRequestsEnabled'; import { FavoriteIconButton } from '../../common/FavoriteIconButton/FavoriteIconButton'; import { useFavoriteProjectsApi } from '../../../hooks/api/actions/useFavoriteProjectsApi/useFavoriteProjectsApi'; -import { CenteredNavLink } from '../../admin/menu/CenteredNavLink'; const StyledDiv = styled('div')(() => ({ display: 'flex', })); +const Row = styled('div')(({ theme }) => ({ + display: 'flex', + flexDirection: 'row', + justifyContent: 'center', + paddingBottom: theme.spacing(0.25), +})); + +const Column = styled('div')(() => ({ + display: 'flex', + flexDirection: 'column', +})); + const StyledName = styled('div')(({ theme }) => ({ overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap', - paddingBottom: theme.spacing(2), + paddingTop: theme.spacing(1), })); const StyledTitle = styled('span')(({ theme }) => ({ @@ -168,71 +179,82 @@ const Project = () => { >
- ( - - )} - /> -

-
+ + ( + + )} + /> +

{projectName} - - - Description:  - - - {project.description} - - - } - /> +

+
+ +

+
+ + + Description:  + + + {project.description} + + + } + /> + + + projectId:  + + + {projectId} + + +
- - projectId:  - - - {projectId} - + + navigate(`/projects/${projectId}/edit`) + } + tooltipProps={{ title: 'Edit project' }} + data-loading + > + + + { + setShowDelDialog(true); + }} + tooltipProps={{ title: 'Delete project' }} + data-loading + > + + -

- - - navigate(`/projects/${projectId}/edit`) - } - tooltipProps={{ title: 'Edit project' }} - data-loading - > - - - { - setShowDelDialog(true); - }} - tooltipProps={{ title: 'Delete project' }} - data-loading - > - - - -

+ +
diff --git a/frontend/src/component/project/Project/ProjectFeatureToggles/ProjectFeatureToggles.tsx b/frontend/src/component/project/Project/ProjectFeatureToggles/ProjectFeatureToggles.tsx index 704342fe1e..1f7094a1e3 100644 --- a/frontend/src/component/project/Project/ProjectFeatureToggles/ProjectFeatureToggles.tsx +++ b/frontend/src/component/project/Project/ProjectFeatureToggles/ProjectFeatureToggles.tsx @@ -2,7 +2,7 @@ import { useCallback, useEffect, useMemo, useState } from 'react'; import { useMediaQuery, useTheme } from '@mui/material'; import { Add } from '@mui/icons-material'; import { useNavigate, useSearchParams } from 'react-router-dom'; -import { useFlexLayout, useSortBy, useTable, SortingRule } from 'react-table'; +import { SortingRule, useFlexLayout, useSortBy, useTable } from 'react-table'; import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender'; import { PageHeader } from 'component/common/PageHeader/PageHeader'; import { PageContent } from 'component/common/PageContent/PageContent'; @@ -33,7 +33,6 @@ import { ChangeRequestDialogue } from 'component/changeRequest/ChangeRequestConf import { UpdateEnabledMessage } from 'component/changeRequest/ChangeRequestConfirmDialog/ChangeRequestMessages/UpdateEnabledMessage'; import { useChangeRequestsEnabled } from 'hooks/useChangeRequestsEnabled'; import { IFeatureToggleListItem } from 'interfaces/featureToggle'; -import { FeatureTagCell } from 'component/common/Table/cells/FeatureTagCell/FeatureTagCell'; import { FavoriteIconHeader } from 'component/common/Table/FavoriteIconHeader/FavoriteIconHeader'; import { FavoriteIconCell } from 'component/common/Table/cells/FavoriteIconCell/FavoriteIconCell'; import { useEnvironmentsRef } from './hooks/useEnvironmentsRef'; @@ -63,7 +62,7 @@ type ListItemType = Pick< }; }; -const staticColumns = ['Actions', 'name']; +const staticColumns = ['Actions', 'name', 'favorite']; const defaultSort: SortingRule & { columns?: string[]; diff --git a/frontend/src/component/project/ProjectCard/ProjectCard.tsx b/frontend/src/component/project/ProjectCard/ProjectCard.tsx index 157ef1fb9c..9aa5ec690d 100644 --- a/frontend/src/component/project/ProjectCard/ProjectCard.tsx +++ b/frontend/src/component/project/ProjectCard/ProjectCard.tsx @@ -2,14 +2,14 @@ import { Card, Menu, MenuItem } from '@mui/material'; import { useStyles } from './ProjectCard.styles'; import MoreVertIcon from '@mui/icons-material/MoreVert'; import { ReactComponent as ProjectIcon } from 'assets/icons/projectIcon.svg'; -import React, { useState, SyntheticEvent, useContext } from 'react'; +import React, { SyntheticEvent, useContext, useState } from 'react'; import { useNavigate } from 'react-router-dom'; import { Delete, Edit } from '@mui/icons-material'; import { getProjectEditPath } from 'utils/routePathHelpers'; import PermissionIconButton from 'component/common/PermissionIconButton/PermissionIconButton'; import { - UPDATE_PROJECT, DELETE_PROJECT, + UPDATE_PROJECT, } from 'component/providers/AccessProvider/permissions'; import AccessContext from 'contexts/AccessContext'; import { DEFAULT_PROJECT_ID } from 'hooks/api/getters/useDefaultProject/useDefaultProjectId'; @@ -76,6 +76,7 @@ export const ProjectCard = ({ onClick={onFavorite} isFavorite={isFavorite} size="medium" + sx={{ ml: -1 }} /> )} />