-
-
Notifications
You must be signed in to change notification settings - Fork 739
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: health score components in personal dashboard #8348
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
import { Box, styled, useTheme } from '@mui/material'; | ||
import { Link } from 'react-router-dom'; | ||
import type { FC } from 'react'; | ||
|
||
const Dot = styled('span', { | ||
shouldForwardProp: (prop) => prop !== 'color', | ||
})<{ color?: string }>(({ theme, color }) => ({ | ||
height: '15px', | ||
width: '15px', | ||
borderRadius: '50%', | ||
display: 'inline-block', | ||
backgroundColor: color, | ||
})); | ||
|
||
const FlagCountsWrapper = styled(Box)(({ theme }) => ({ | ||
display: 'flex', | ||
flexDirection: 'column', | ||
gap: theme.spacing(2), | ||
})); | ||
|
||
const FlagsCount = styled('p')(({ theme }) => ({ | ||
color: theme.palette.text.secondary, | ||
marginLeft: theme.spacing(3), | ||
})); | ||
|
||
const StatusWithDot = styled(Box)(({ theme }) => ({ | ||
display: 'flex', | ||
alignItems: 'center', | ||
gap: theme.spacing(1), | ||
})); | ||
|
||
export const FlagCounts: FC<{ | ||
projectId: string; | ||
activeCount: number; | ||
potentiallyStaleCount: number; | ||
staleCount: number; | ||
hideLinks?: boolean; | ||
}> = ({ | ||
projectId, | ||
activeCount, | ||
potentiallyStaleCount, | ||
staleCount, | ||
hideLinks = false, | ||
}) => { | ||
const theme = useTheme(); | ||
|
||
return ( | ||
<FlagCountsWrapper> | ||
<Box> | ||
<StatusWithDot> | ||
<Dot color={theme.palette.success.border} /> | ||
<Box sx={{ fontWeight: 'bold' }}>Active</Box> | ||
</StatusWithDot> | ||
<FlagsCount>{activeCount} feature flags</FlagsCount> | ||
</Box> | ||
<Box> | ||
<StatusWithDot> | ||
<Dot color={theme.palette.warning.border} /> | ||
<Box sx={{ fontWeight: 'bold' }}>Potentially stale</Box> | ||
{hideLinks ? null : ( | ||
<Link to='/feature-toggle-type'>(configure)</Link> | ||
)} | ||
</StatusWithDot> | ||
<FlagsCount>{potentiallyStaleCount} feature flags</FlagsCount> | ||
</Box> | ||
<Box> | ||
<StatusWithDot> | ||
<Dot color={theme.palette.error.border} /> | ||
<Box sx={{ fontWeight: 'bold' }}>Stale</Box> | ||
{hideLinks ? null : ( | ||
<Link to={`/projects/${projectId}?state=IS%3Astale`}> | ||
(view flags) | ||
</Link> | ||
)} | ||
</StatusWithDot> | ||
<FlagsCount>{staleCount} feature flags</FlagsCount> | ||
</Box> | ||
</FlagCountsWrapper> | ||
); | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -165,6 +165,16 @@ export class PersonalDashboardService { | |
); | ||
} | ||
|
||
const [projectInsights] = | ||
await this.projectReadModel.getProjectsForInsights({ | ||
id: projectId, | ||
}); | ||
const totalFlags = projectInsights?.featureCount || 0; | ||
const potentiallyStaleFlags = | ||
projectInsights?.potentiallyStaleFeatureCount || 0; | ||
const staleFlags = projectInsights?.staleFeatureCount || 0; | ||
const currentHealth = projectInsights?.health || 0; | ||
|
||
return { | ||
latestEvents, | ||
onboardingStatus, | ||
|
@@ -173,6 +183,11 @@ export class PersonalDashboardService { | |
insights: { | ||
avgHealthCurrentWindow, | ||
avgHealthPastWindow, | ||
totalFlags, | ||
potentiallyStaleFlags, | ||
staleFlags, | ||
activeFlags: totalFlags - staleFlags - potentiallyStaleFlags, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't we also get the total flags in the payload? Any reason we calculate again? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We do get it in the personal dashboard global overview. This is the project details endpoint. Theoretically we could reuse the value from the global overview but this was just convenient. If we ever decide to re-use the project endpoint we get all the data in one go. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So in other words this change allows to move the project details around without thinking about the data source since it's self sufficient. |
||
health: currentHealth, | ||
}, | ||
}; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this code is extracted from the project insights health widget so that we can compose is inside personal dashboard