diff --git a/frontend/src/component/Reporting/ReportCard/ReportCard.jsx b/frontend/src/component/Reporting/ReportCard/ReportCard.tsx similarity index 78% rename from frontend/src/component/Reporting/ReportCard/ReportCard.jsx rename to frontend/src/component/Reporting/ReportCard/ReportCard.tsx index 26c3370c17..88a446efb3 100644 --- a/frontend/src/component/Reporting/ReportCard/ReportCard.jsx +++ b/frontend/src/component/Reporting/ReportCard/ReportCard.tsx @@ -1,23 +1,19 @@ import classnames from 'classnames'; import { Paper } from '@material-ui/core'; -import PropTypes from 'prop-types'; - import CheckIcon from '@material-ui/icons/Check'; import ReportProblemOutlinedIcon from '@material-ui/icons/ReportProblemOutlined'; import ConditionallyRender from '../../common/ConditionallyRender/ConditionallyRender'; - import styles from './ReportCard.module.scss'; import ReactTimeAgo from 'react-timeago'; +import { IProjectHealthReport } from "../../../interfaces/project"; -const ReportCard = ({ - health, - activeCount, - staleCount, - potentiallyStaleCount, - lastUpdate, -}) => { - const healthLessThan50 = health < 50; - const healthLessThan75 = health < 75; +interface IReportCardProps { + healthReport: IProjectHealthReport +} + +export const ReportCard = ({ healthReport }: IReportCardProps) => { + const healthLessThan50 = healthReport.health < 50; + const healthLessThan75 = healthReport.health < 75; const healthClasses = classnames(styles.reportCardHealthRating, { [styles.healthWarning]: healthLessThan75, @@ -27,21 +23,21 @@ const ReportCard = ({ const renderActiveToggles = () => ( <> - {activeCount} active toggles + {healthReport.activeCount} active toggles ); const renderStaleToggles = () => ( <> - {staleCount} stale toggles + {healthReport.staleCount} stale toggles ); const renderPotentiallyStaleToggles = () => ( <> - {potentiallyStaleCount} potentially stale toggles + {healthReport.potentiallyStaleCount} potentially stale toggles ); @@ -52,14 +48,14 @@ const ReportCard = ({

Health rating

-1} + condition={healthReport.health > -1} show={
-

{health}%

+

{healthReport.health}%

Last updated:{' '}

@@ -73,12 +69,12 @@ const ReportCard = ({
  • Also includes potentially stale toggles. @@ -88,7 +84,7 @@ const ReportCard = ({
  • @@ -101,13 +97,13 @@ const ReportCard = ({
    Review your feature toggles and delete @@ -126,9 +122,3 @@ const ReportCard = ({ ); }; - -ReportCard.propTypes = { - features: PropTypes.array.isRequired, -}; - -export default ReportCard; diff --git a/frontend/src/component/Reporting/ReportCard/ReportCardContainer.jsx b/frontend/src/component/Reporting/ReportCard/ReportCardContainer.jsx deleted file mode 100644 index fb1a1ccda3..0000000000 --- a/frontend/src/component/Reporting/ReportCard/ReportCardContainer.jsx +++ /dev/null @@ -1,19 +0,0 @@ -import { connect } from 'react-redux'; - -import ReportCard from './ReportCard'; -import { filterByProject } from '../utils'; - -const mapStateToProps = (state, ownProps) => { - const features = state.features.toJS(); - - const sameProject = filterByProject(ownProps.selectedProject); - const featuresByProject = features.filter(sameProject); - - return { - features: featuresByProject, - }; -}; - -const ReportCardContainer = connect(mapStateToProps, null)(ReportCard); - -export default ReportCardContainer; diff --git a/frontend/src/component/Reporting/Reporting.jsx b/frontend/src/component/Reporting/Reporting.jsx deleted file mode 100644 index d7465092db..0000000000 --- a/frontend/src/component/Reporting/Reporting.jsx +++ /dev/null @@ -1,107 +0,0 @@ -import React, { useEffect, useState } from 'react'; - -import PropTypes from 'prop-types'; - -import Select from '../common/select'; -import ReportCardContainer from './ReportCard/ReportCardContainer'; -import ReportToggleList from './ReportToggleList/ReportToggleList'; - -import ConditionallyRender from '../common/ConditionallyRender/ConditionallyRender'; - -import { formatProjectOptions } from './utils'; -import { REPORTING_SELECT_ID } from '../../testIds'; - -import styles from './Reporting.module.scss'; -import useHealthReport from '../../hooks/api/getters/useHealthReport/useHealthReport'; -import ApiError from '../common/ApiError/ApiError'; -import useQueryParams from '../../hooks/useQueryParams'; - -const Reporting = ({ projects }) => { - const [projectOptions, setProjectOptions] = useState([ - { key: 'default', label: 'Default' }, - ]); - const [selectedProject, setSelectedProject] = useState('default'); - const { project, error, refetch } = useHealthReport(selectedProject); - - const params = useQueryParams(); - const projectId = params.get('project'); - - useEffect(() => { - if (projectId) { - return setSelectedProject(projectId); - } - setSelectedProject(projects[0].id); - - /* eslint-disable-next-line */ - }, []); - - useEffect(() => { - setProjectOptions(formatProjectOptions(projects)); - }, [projects]); - - const onChange = e => { - const { value } = e.target; - - const selectedProject = projectOptions.find( - option => option.key === value - ); - - setSelectedProject(selectedProject.key); - }; - - const renderSelect = () => ( -
    -

    Project

    -