Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implements ToggleTypeWidget Refactored HealthWidget to it's own component Signed-off-by: andreas-unleash <andreas@getunleash.ai> <!-- Thanks for creating a PR! To make it easier for reviewers and everyone else to understand what your changes relate to, please add some relevant content to the headings below. Feel free to ignore or delete sections that you don't think are relevant. Thank you! ❤️ --> ## About the changes <!-- Describe the changes introduced. What are they and why are they being introduced? Feel free to also add screenshots or steps to view the changes if they're visual. --> <!-- Does it close an issue? Multiple? --> Closes # <!-- (For internal contributors): Does it relate to an issue on public roadmap? --> <!-- Relates to [roadmap](https://github.com/orgs/Unleash/projects/10) item: # --> ### Important files <!-- PRs can contain a lot of changes, but not all changes are equally important. Where should a reviewer start looking to get an overview of the changes? Are any files particularly important? --> ![Screenshot 2023-01-25 at 11 38 07](https://user-images.githubusercontent.com/104830839/214531944-c7007192-e93f-48fc-8ee1-f44930f873d2.png) ## Discussion points <!-- Anything about the PR you'd like to discuss before it gets merged? Got any questions or doubts? --> Signed-off-by: andreas-unleash <andreas@getunleash.ai>
- Loading branch information
1 parent
decb7f3
commit 1e76362
Showing
5 changed files
with
149 additions
and
27 deletions.
There are no files selected for viewing
34 changes: 34 additions & 0 deletions
34
frontend/src/component/project/Project/ProjectInfo/HealthWidget.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { | ||
StyledArrowIcon, | ||
StyledDivInfoContainer, | ||
StyledDivPercentageContainer, | ||
StyledLink, | ||
StyledParagraphEmphasizedText, | ||
StyledParagraphSubtitle, | ||
StyledSpanLinkText, | ||
} from './ProjectInfo.styles'; | ||
import PercentageCircle from 'component/common/PercentageCircle/PercentageCircle'; | ||
|
||
interface IHealthWidgetProps { | ||
projectId: string; | ||
health: number; | ||
} | ||
export const HealthWidget = ({ projectId, health }: IHealthWidgetProps) => { | ||
return ( | ||
<StyledDivInfoContainer> | ||
<StyledDivPercentageContainer> | ||
<PercentageCircle percentage={health} /> | ||
</StyledDivPercentageContainer> | ||
<StyledParagraphSubtitle data-loading> | ||
Overall health rating | ||
</StyledParagraphSubtitle> | ||
<StyledParagraphEmphasizedText data-loading> | ||
{health}% | ||
</StyledParagraphEmphasizedText> | ||
<StyledLink data-loading to={`/projects/${projectId}/health`}> | ||
<StyledSpanLinkText data-loading>view more </StyledSpanLinkText> | ||
<StyledArrowIcon data-loading /> | ||
</StyledLink> | ||
</StyledDivInfoContainer> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 81 additions & 0 deletions
81
frontend/src/component/project/Project/ProjectInfo/ToggleTypesWidget.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
import { IFeatureToggleListItem } from '../../../../interfaces/featureToggle'; | ||
import { useMemo } from 'react'; | ||
import { | ||
StyledCount, | ||
StyledDivInfoContainer, | ||
StyledParagraphGridRow, | ||
StyledParagraphSubtitle, | ||
} from './ProjectInfo.styles'; | ||
import { getFeatureTypeIcons } from 'utils/getFeatureTypeIcons'; | ||
|
||
export interface IToggleTypesWidgetProps { | ||
features: IFeatureToggleListItem[]; | ||
} | ||
|
||
export const ToggleTypesWidget = ({ features }: IToggleTypesWidgetProps) => { | ||
const { release, experiment, operational, kill, permission } = | ||
useMemo(() => { | ||
const release = | ||
features?.filter(feature => feature.type === 'release') | ||
.length || 0; | ||
const experiment = | ||
features?.filter(feature => feature.type === 'experiment') | ||
.length || 0; | ||
const operational = | ||
features?.filter(feature => feature.type === 'operational') | ||
.length || 0; | ||
const kill = | ||
features?.filter(feature => feature.type === 'kill-switch') | ||
.length || 0; | ||
const permission = | ||
features?.filter(feature => feature.type === 'permission') | ||
.length || 0; | ||
|
||
return { | ||
release, | ||
experiment, | ||
operational, | ||
kill, | ||
permission, | ||
}; | ||
}, [features]); | ||
|
||
const ReleaseToggleIcon = getFeatureTypeIcons('release'); | ||
const ExperimentToggleIcon = getFeatureTypeIcons('experiment'); | ||
const OperationalToggleIcon = getFeatureTypeIcons('operational'); | ||
const KillToggleIcon = getFeatureTypeIcons('kill-switch'); | ||
const PermissionToggleIcon = getFeatureTypeIcons('permission'); | ||
|
||
return ( | ||
<StyledDivInfoContainer> | ||
<StyledParagraphSubtitle data-loading> | ||
Toggle types used | ||
</StyledParagraphSubtitle> | ||
<StyledParagraphGridRow data-loading> | ||
<ReleaseToggleIcon fontSize="inherit" data-loading /> | ||
<div>Release</div> | ||
<StyledCount>{release}</StyledCount> | ||
</StyledParagraphGridRow> | ||
<StyledParagraphGridRow data-loading> | ||
<ExperimentToggleIcon fontSize="inherit" data-loading /> | ||
<div>Experiment</div> | ||
<StyledCount>{experiment}</StyledCount> | ||
</StyledParagraphGridRow> | ||
<StyledParagraphGridRow data-loading> | ||
<OperationalToggleIcon fontSize="inherit" data-loading /> | ||
<div>Operational</div> | ||
<StyledCount>{operational}</StyledCount> | ||
</StyledParagraphGridRow> | ||
<StyledParagraphGridRow data-loading> | ||
<KillToggleIcon fontSize="inherit" data-loading /> | ||
<div>Kill switch</div> | ||
<StyledCount>{kill}</StyledCount> | ||
</StyledParagraphGridRow> | ||
<StyledParagraphGridRow data-loading> | ||
<PermissionToggleIcon fontSize="inherit" data-loading /> | ||
<div>Permission</div> | ||
<StyledCount>{permission}</StyledCount> | ||
</StyledParagraphGridRow> | ||
</StyledDivInfoContainer> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters