From 31d88da08bfa49cbe7538853da989f7e7fcf4e29 Mon Sep 17 00:00:00 2001 From: Youssef Khedher Date: Tue, 7 Dec 2021 13:17:32 +0100 Subject: [PATCH] feat: update health report (#541) * fix: align styling with other pages * feat: add last updat to heath report * add feature status to last seen in health overview * fix: add mobile style * fix:add background color on table hover Co-authored-by: Fredrik Strand Oseberg --- .../Reporting/ReportCard/ReportCard.jsx | 59 +++++++++++++++---- .../ReportCard/ReportCard.module.scss | 31 ++++++++++ .../ReportToggleList.module.scss | 26 ++++++++ .../ReportToggleListHeader.jsx | 57 +++++++++++++++--- .../ReportToggleListItem.jsx | 26 ++++---- .../FeatureToggleListItem.jsx | 5 +- .../FeatureToggleListNewItem.tsx | 5 +- .../FeatureStatus/FeatureStatus.tsx | 17 ++++-- .../Project/ProjectHealth/ProjectHealth.tsx | 21 +++---- frontend/src/interfaces/project.ts | 1 + 10 files changed, 196 insertions(+), 52 deletions(-) diff --git a/frontend/src/component/Reporting/ReportCard/ReportCard.jsx b/frontend/src/component/Reporting/ReportCard/ReportCard.jsx index 368f6071d1..26c3370c17 100644 --- a/frontend/src/component/Reporting/ReportCard/ReportCard.jsx +++ b/frontend/src/component/Reporting/ReportCard/ReportCard.jsx @@ -1,4 +1,3 @@ -import React from 'react'; import classnames from 'classnames'; import { Paper } from '@material-ui/core'; import PropTypes from 'prop-types'; @@ -8,12 +7,14 @@ import ReportProblemOutlinedIcon from '@material-ui/icons/ReportProblemOutlined' import ConditionallyRender from '../../common/ConditionallyRender/ConditionallyRender'; import styles from './ReportCard.module.scss'; +import ReactTimeAgo from 'react-timeago'; const ReportCard = ({ health, activeCount, staleCount, potentiallyStaleCount, + lastUpdate, }) => { const healthLessThan50 = health < 50; const healthLessThan75 = health < 75; @@ -52,11 +53,22 @@ const ReportCard = ({
-1} - show={

{health}%

} + show={ +
+

{health}%

+

+ Last updated:{' '} + +

+
+ } />
-
+

Toggle report

  • @@ -65,28 +77,49 @@ const ReportCard = ({ show={renderActiveToggles} />
  • + + Also includes potentially stale toggles. +

    + } + /> +
  • -
  • - -

Potential actions

-

- Review your feature toggles and delete unused - toggles. -

+
    +
  • + +
  • +
+ + Review your feature toggles and delete + unused toggles. +

+ } + elseShow={ +

+ No action is required +

+ } + />
diff --git a/frontend/src/component/Reporting/ReportCard/ReportCard.module.scss b/frontend/src/component/Reporting/ReportCard/ReportCard.module.scss index c22181a065..b6ad146ea2 100644 --- a/frontend/src/component/Reporting/ReportCard/ReportCard.module.scss +++ b/frontend/src/component/Reporting/ReportCard/ReportCard.module.scss @@ -2,6 +2,8 @@ width: 100%; padding: var(--card-padding); margin: var(--card-margin-y) 0; + border-radius: 10px; + box-shadow: none; } .header { @@ -14,9 +16,19 @@ display: flex; justify-content: space-between; } +.reportCardHealth { + padding: 10px; +} +.reportCardAction { + padding: 10px; +} +.reportCardToggle { + padding: 10px; +} .reportCardHealthInnerContainer { display: flex; + flex-direction: column; align-items: center; justify-content: center; align-items: center; @@ -70,6 +82,12 @@ .reportCardActionText { max-width: 300px; font-size: var(--p-size); + margin-left: 35px; +} +.reportCardNoActionText { + max-width: 300px; + font-size: var(--p-size); + margin-left: 15px; } .reportCardBtn { @@ -83,3 +101,16 @@ .healthWarning { color: var(--warning); } +.lastUpdate { + color: #585858; +} + +@media (max-width: 600px) { + .reportCardContainer { + flex-wrap: wrap; + } + .reportCardToggle { + margin: 10px 5px; + flex-basis: 100%; + } +} diff --git a/frontend/src/component/Reporting/ReportToggleList/ReportToggleList.module.scss b/frontend/src/component/Reporting/ReportToggleList/ReportToggleList.module.scss index 5a6f4b5275..1400b00ae9 100644 --- a/frontend/src/component/Reporting/ReportToggleList/ReportToggleList.module.scss +++ b/frontend/src/component/Reporting/ReportToggleList/ReportToggleList.module.scss @@ -1,6 +1,8 @@ .reportToggleList { width: 100%; margin: var(--card-margin-y) 0; + border-radius: 10px; + box-shadow: none; } .bulkAction { @@ -65,7 +67,31 @@ cursor: pointer; } +.tableRow:hover { + background-color: #eeeeee; +} + .checkbox { margin: 0; padding: 0; } + +@media only screen and (max-width: 800px) { + .hideColumn { + display: none; + } + th { + min-width: 120px; + } +} +@media only screen and (max-width: 550px) { + .hideColumnStatus { + display: none; + } +} + +@media only screen and (max-width: 425px) { + .hideColumnLastSeen { + display: none; + } +} diff --git a/frontend/src/component/Reporting/ReportToggleList/ReportToggleListHeader/ReportToggleListHeader.jsx b/frontend/src/component/Reporting/ReportToggleList/ReportToggleListHeader/ReportToggleListHeader.jsx index 9ba5e8fbbf..016bd26642 100644 --- a/frontend/src/component/Reporting/ReportToggleList/ReportToggleListHeader/ReportToggleListHeader.jsx +++ b/frontend/src/component/Reporting/ReportToggleList/ReportToggleListHeader/ReportToggleListHeader.jsx @@ -5,11 +5,23 @@ import PropTypes from 'prop-types'; import ConditionallyRender from '../../../common/ConditionallyRender/ConditionallyRender'; -import { NAME, LAST_SEEN, CREATED, EXPIRED, STATUS, REPORT } from '../../constants'; +import { + NAME, + LAST_SEEN, + CREATED, + EXPIRED, + STATUS, + REPORT, +} from '../../constants'; import styles from '../ReportToggleList.module.scss'; -const ReportToggleListHeader = ({ handleCheckAll, checkAll, setSortData, bulkActionsOn }) => { +const ReportToggleListHeader = ({ + handleCheckAll, + checkAll, + setSortData, + bulkActionsOn, +}) => { const handleSort = type => { setSortData(prev => ({ sortKey: type, @@ -34,27 +46,56 @@ const ReportToggleListHeader = ({ handleCheckAll, checkAll, setSortData, bulkAct } /> - handleSort(NAME)}> + handleSort(NAME)} + > Name - handleSort(LAST_SEEN)}> + handleSort(LAST_SEEN)} + > Last seen - handleSort(CREATED)}> + handleSort(CREATED)} + > Created - handleSort(EXPIRED)}> + handleSort(EXPIRED)} + > Expired - handleSort(STATUS)}> + handleSort(STATUS)} + > Status - handleSort(REPORT)}> + handleSort(REPORT)} + > Report diff --git a/frontend/src/component/Reporting/ReportToggleList/ReportToggleListItem/ReportToggleListItem.jsx b/frontend/src/component/Reporting/ReportToggleList/ReportToggleListItem/ReportToggleListItem.jsx index d6948e63c0..afaf89a606 100644 --- a/frontend/src/component/Reporting/ReportToggleList/ReportToggleListItem/ReportToggleListItem.jsx +++ b/frontend/src/component/Reporting/ReportToggleList/ReportToggleListItem/ReportToggleListItem.jsx @@ -7,6 +7,7 @@ import { Checkbox } from '@material-ui/core'; import CheckIcon from '@material-ui/icons/Check'; import ReportProblemOutlinedIcon from '@material-ui/icons/ReportProblemOutlined'; import ConditionallyRender from '../../../common/ConditionallyRender/ConditionallyRender'; +import FeatureStatus from '../../../feature/FeatureView2/FeatureStatus/FeatureStatus'; import { pluralize, @@ -75,20 +76,13 @@ const ReportToggleListItem = ({ return pluralize(result, 'day'); } + return 'N/A'; }; const formatLastSeenAt = () => { - if (!lastSeenAt) return 'Never'; - - const [date, now] = getDates(lastSeenAt); - const diff = getDiffInDays(date, now); - if (diff === 0) return '1 day'; - - if (diff) { - return pluralize(diff, 'day'); - } - - return '1 day'; + return ( + + ); }; const renderStatus = (icon, text) => ( @@ -126,7 +120,7 @@ const ReportToggleListItem = ({ history.push(getTogglePath(project, name)); }; - const statusClasses = classnames(styles.active, { + const statusClasses = classnames(styles.active, styles.hideColumnStatus, { [styles.stale]: stale, }); @@ -151,9 +145,11 @@ const ReportToggleListItem = ({ } /> {name} - {formatLastSeenAt()} - {formatCreatedAt()} - {formatExpiredAt()} + {formatLastSeenAt()} + {formatCreatedAt()} + + {formatExpiredAt()} + {stale ? 'Stale' : 'Active'} {formatReportStatus()} diff --git a/frontend/src/component/feature/FeatureToggleList/FeatureToggleListItem/FeatureToggleListItem.jsx b/frontend/src/component/feature/FeatureToggleList/FeatureToggleListItem/FeatureToggleListItem.jsx index 6bf0591d72..d7c9d627b8 100644 --- a/frontend/src/component/feature/FeatureToggleList/FeatureToggleListItem/FeatureToggleListItem.jsx +++ b/frontend/src/component/feature/FeatureToggleList/FeatureToggleListItem/FeatureToggleListItem.jsx @@ -58,7 +58,10 @@ const FeatureToggleListItem = ({ className={classnames(styles.listItem, rest.className)} > - + - + { +const FeatureStatus = ({ + lastSeenAt, + tooltipPlacement, +}: FeatureStatusProps) => { const styles = useStyles(); const Wrapper = ( props: React.PropsWithChildren<{ color: string; toolTip: string }> ) => { return ( - +
{ ) => { return ( {value} @@ -94,7 +100,10 @@ const FeatureStatus = ({ lastSeenAt }: FeatureStatusProps) => { /> } elseShow={ - + } diff --git a/frontend/src/component/project/Project/ProjectHealth/ProjectHealth.tsx b/frontend/src/component/project/Project/ProjectHealth/ProjectHealth.tsx index 367aaa9fd2..0424d2fdbb 100644 --- a/frontend/src/component/project/Project/ProjectHealth/ProjectHealth.tsx +++ b/frontend/src/component/project/Project/ProjectHealth/ProjectHealth.tsx @@ -1,8 +1,8 @@ import useHealthReport from '../../../../hooks/api/getters/useHealthReport/useHealthReport'; import ApiError from '../../../common/ApiError/ApiError'; import ConditionallyRender from '../../../common/ConditionallyRender'; -import ReportCardContainer from '../../../Reporting/ReportCard/ReportCardContainer' -import ReportToggleList from '../../../Reporting/ReportToggleList/ReportToggleList' +import ReportCardContainer from '../../../Reporting/ReportCard/ReportCardContainer'; +import ReportToggleList from '../../../Reporting/ReportToggleList/ReportToggleList'; interface ProjectHealthProps { projectId: string; @@ -25,18 +25,19 @@ const ProjectHealth = ({ projectId }: ProjectHealthProps) => { } />
- ) -} + ); +}; -export default ProjectHealth; \ No newline at end of file +export default ProjectHealth; diff --git a/frontend/src/interfaces/project.ts b/frontend/src/interfaces/project.ts index 7ea03ed0ee..f905258ec4 100644 --- a/frontend/src/interfaces/project.ts +++ b/frontend/src/interfaces/project.ts @@ -24,4 +24,5 @@ export interface IProjectHealthReport extends IProject { staleCount: number; potentiallyStaleCount: number; activeCount: number; + updatedAt: Date; }