mirror of
https://github.com/Unleash/unleash.git
synced 2025-01-25 00:07:47 +01:00
Fix/overall bugs (#271)
* fix: reporting * fix: center icon * fix: paths in featureview * fix: revert path in passwordauth * fix: remove console log
This commit is contained in:
parent
524936912d
commit
3bf9bd73ae
@ -21,30 +21,45 @@ const ReportCard = ({ features }) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const getPotentiallyStaleToggles = activeToggles => {
|
const getPotentiallyStaleToggles = activeToggles => {
|
||||||
const result = activeToggles.filter(feature => isFeatureExpired(feature) && !feature.stale);
|
const result = activeToggles.filter(
|
||||||
|
feature => isFeatureExpired(feature) && !feature.stale
|
||||||
|
);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
|
|
||||||
const getHealthRating = (total, staleTogglesCount, potentiallyStaleTogglesCount) => {
|
const getHealthRating = (
|
||||||
|
total,
|
||||||
|
staleTogglesCount,
|
||||||
|
potentiallyStaleTogglesCount
|
||||||
|
) => {
|
||||||
const startPercentage = 100;
|
const startPercentage = 100;
|
||||||
|
|
||||||
const stalePercentage = (staleTogglesCount / total) * 100;
|
const stalePercentage = (staleTogglesCount / total) * 100;
|
||||||
|
|
||||||
const potentiallyStalePercentage = (potentiallyStaleTogglesCount / total) * 100;
|
const potentiallyStalePercentage =
|
||||||
|
(potentiallyStaleTogglesCount / total) * 100;
|
||||||
|
|
||||||
return Math.round(startPercentage - stalePercentage - potentiallyStalePercentage);
|
return Math.round(
|
||||||
|
startPercentage - stalePercentage - potentiallyStalePercentage
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const total = features.length;
|
const total = features.length;
|
||||||
const activeTogglesArray = getActiveToggles();
|
const activeTogglesArray = getActiveToggles();
|
||||||
const potentiallyStaleToggles = getPotentiallyStaleToggles(activeTogglesArray);
|
const potentiallyStaleToggles = getPotentiallyStaleToggles(
|
||||||
|
activeTogglesArray
|
||||||
|
);
|
||||||
|
|
||||||
const activeTogglesCount = activeTogglesArray.length;
|
const activeTogglesCount = activeTogglesArray.length;
|
||||||
const staleTogglesCount = features.length - activeTogglesCount;
|
const staleTogglesCount = features.length - activeTogglesCount;
|
||||||
const potentiallyStaleTogglesCount = potentiallyStaleToggles.length;
|
const potentiallyStaleTogglesCount = potentiallyStaleToggles.length;
|
||||||
|
|
||||||
const healthRating = getHealthRating(total, staleTogglesCount, potentiallyStaleTogglesCount);
|
const healthRating = getHealthRating(
|
||||||
|
total,
|
||||||
|
staleTogglesCount,
|
||||||
|
potentiallyStaleTogglesCount
|
||||||
|
);
|
||||||
|
|
||||||
const healthLessThan50 = healthRating < 50;
|
const healthLessThan50 = healthRating < 50;
|
||||||
const healthLessThan75 = healthRating < 75;
|
const healthLessThan75 = healthRating < 75;
|
||||||
@ -71,7 +86,9 @@ const ReportCard = ({ features }) => {
|
|||||||
const renderPotentiallyStaleToggles = () => (
|
const renderPotentiallyStaleToggles = () => (
|
||||||
<>
|
<>
|
||||||
<ReportProblemOutlinedIcon className={styles.danger} />
|
<ReportProblemOutlinedIcon className={styles.danger} />
|
||||||
<span>{potentiallyStaleTogglesCount} potentially stale toggles</span>
|
<span>
|
||||||
|
{potentiallyStaleTogglesCount} potentially stale toggles
|
||||||
|
</span>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -82,10 +99,16 @@ const ReportCard = ({ features }) => {
|
|||||||
<h2 className={styles.header}>Toggle report</h2>
|
<h2 className={styles.header}>Toggle report</h2>
|
||||||
<ul className={styles.reportCardList}>
|
<ul className={styles.reportCardList}>
|
||||||
<li>
|
<li>
|
||||||
<ConditionallyRender condition={activeTogglesCount} show={renderActiveToggles} />
|
<ConditionallyRender
|
||||||
|
condition={activeTogglesCount}
|
||||||
|
show={renderActiveToggles}
|
||||||
|
/>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<ConditionallyRender condition={staleTogglesCount} show={renderStaleToggles} />
|
<ConditionallyRender
|
||||||
|
condition={staleTogglesCount}
|
||||||
|
show={renderStaleToggles}
|
||||||
|
/>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<ConditionallyRender
|
<ConditionallyRender
|
||||||
@ -99,8 +122,10 @@ const ReportCard = ({ features }) => {
|
|||||||
<h2 className={styles.header}>Health rating</h2>
|
<h2 className={styles.header}>Health rating</h2>
|
||||||
<div className={styles.reportCardHealthInnerContainer}>
|
<div className={styles.reportCardHealthInnerContainer}>
|
||||||
<ConditionallyRender
|
<ConditionallyRender
|
||||||
condition={healthRating}
|
condition={healthRating > -1}
|
||||||
show={<p className={healthClasses}>{healthRating}%</p>}
|
show={
|
||||||
|
<p className={healthClasses}>{healthRating}%</p>
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -108,7 +133,8 @@ const ReportCard = ({ features }) => {
|
|||||||
<h2 className={styles.header}>Potential actions</h2>
|
<h2 className={styles.header}>Potential actions</h2>
|
||||||
<div className={styles.reportCardActionContainer}>
|
<div className={styles.reportCardActionContainer}>
|
||||||
<p className={styles.reportCardActionText}>
|
<p className={styles.reportCardActionText}>
|
||||||
Review your feature toggles and delete unused toggles.
|
Review your feature toggles and delete unused
|
||||||
|
toggles.
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -14,13 +14,16 @@ import { REPORTING_SELECT_ID } from '../../testIds';
|
|||||||
import styles from './Reporting.module.scss';
|
import styles from './Reporting.module.scss';
|
||||||
|
|
||||||
const Reporting = ({ fetchFeatureToggles, projects }) => {
|
const Reporting = ({ fetchFeatureToggles, projects }) => {
|
||||||
const [projectOptions, setProjectOptions] = useState([{ key: 'default', label: 'Default' }]);
|
const [projectOptions, setProjectOptions] = useState([
|
||||||
|
{ key: 'default', label: 'Default' },
|
||||||
|
]);
|
||||||
const [selectedProject, setSelectedProject] = useState('default');
|
const [selectedProject, setSelectedProject] = useState('default');
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
fetchFeatureToggles();
|
fetchFeatureToggles();
|
||||||
setSelectedProject(projects[0].id);
|
setSelectedProject(projects[0].id);
|
||||||
}, [fetchFeatureToggles, projects]);
|
/* eslint-disable-next-line */
|
||||||
|
}, []);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setProjectOptions(formatProjectOptions(projects));
|
setProjectOptions(formatProjectOptions(projects));
|
||||||
@ -29,7 +32,9 @@ const Reporting = ({ fetchFeatureToggles, projects }) => {
|
|||||||
const onChange = e => {
|
const onChange = e => {
|
||||||
const { value } = e.target;
|
const { value } = e.target;
|
||||||
|
|
||||||
const selectedProject = projectOptions.find(option => option.key === value);
|
const selectedProject = projectOptions.find(
|
||||||
|
option => option.key === value
|
||||||
|
);
|
||||||
|
|
||||||
setSelectedProject(selectedProject.key);
|
setSelectedProject(selectedProject.key);
|
||||||
};
|
};
|
||||||
@ -52,7 +57,10 @@ const Reporting = ({ fetchFeatureToggles, projects }) => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<React.Fragment>
|
<React.Fragment>
|
||||||
<ConditionallyRender condition={multipleProjects} show={renderSelect} />
|
<ConditionallyRender
|
||||||
|
condition={multipleProjects}
|
||||||
|
show={renderSelect}
|
||||||
|
/>
|
||||||
|
|
||||||
<ReportCardContainer selectedProject={selectedProject} />
|
<ReportCardContainer selectedProject={selectedProject} />
|
||||||
<ReportToggleListContainer selectedProject={selectedProject} />
|
<ReportToggleListContainer selectedProject={selectedProject} />
|
||||||
|
@ -119,6 +119,7 @@
|
|||||||
|
|
||||||
.sortIcon {
|
.sortIcon {
|
||||||
margin-left: 8px;
|
margin-left: 8px;
|
||||||
|
transform: translateY(6px);
|
||||||
}
|
}
|
||||||
|
|
||||||
.reportToggleListHeader {
|
.reportToggleListHeader {
|
||||||
|
@ -11,6 +11,9 @@ const mapDispatchToProps = {
|
|||||||
fetchFeatureToggles,
|
fetchFeatureToggles,
|
||||||
};
|
};
|
||||||
|
|
||||||
const ReportingContainer = connect(mapStateToProps, mapDispatchToProps)(Reporting);
|
const ReportingContainer = connect(
|
||||||
|
mapStateToProps,
|
||||||
|
mapDispatchToProps
|
||||||
|
)(Reporting);
|
||||||
|
|
||||||
export default ReportingContainer;
|
export default ReportingContainer;
|
||||||
|
@ -113,32 +113,36 @@ const FeatureView = ({
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
const getTabData = () => [
|
|
||||||
{
|
const getTabData = () => {
|
||||||
label: 'Activation',
|
const path = !!isFeatureView ? 'features' : 'archive';
|
||||||
component: getTabComponent('activation'),
|
return [
|
||||||
name: 'strategies',
|
{
|
||||||
path: `/features/strategies/${featureToggleName}`,
|
label: 'Activation',
|
||||||
},
|
component: getTabComponent('activation'),
|
||||||
{
|
name: 'strategies',
|
||||||
label: 'Metrics',
|
path: `/${path}/strategies/${featureToggleName}`,
|
||||||
component: getTabComponent('metrics'),
|
},
|
||||||
name: 'metrics',
|
{
|
||||||
path: `/features/metrics/${featureToggleName}`,
|
label: 'Metrics',
|
||||||
},
|
component: getTabComponent('metrics'),
|
||||||
{
|
name: 'metrics',
|
||||||
label: 'Variants',
|
path: `/${path}/metrics/${featureToggleName}`,
|
||||||
component: getTabComponent('variants'),
|
},
|
||||||
name: 'variants',
|
{
|
||||||
path: `/features/variants/${featureToggleName}`,
|
label: 'Variants',
|
||||||
},
|
component: getTabComponent('variants'),
|
||||||
{
|
name: 'variants',
|
||||||
label: 'Log',
|
path: `/${path}/variants/${featureToggleName}`,
|
||||||
component: getTabComponent('log'),
|
},
|
||||||
name: 'logs',
|
{
|
||||||
path: `/features/logs/${featureToggleName}`,
|
label: 'Log',
|
||||||
},
|
component: getTabComponent('log'),
|
||||||
];
|
name: 'logs',
|
||||||
|
path: `/${path}/logs/${featureToggleName}`,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
if (!featureToggle) {
|
if (!featureToggle) {
|
||||||
if (features.length === 0) {
|
if (features.length === 0) {
|
||||||
|
Loading…
Reference in New Issue
Block a user