Skip to content

Commit

Permalink
opens feature health tab when clicking warning description
Browse files Browse the repository at this point in the history
  • Loading branch information
tiagoapolo committed Feb 24, 2025
1 parent 7ef0b63 commit e3b026f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 8 deletions.
26 changes: 19 additions & 7 deletions frontend/web/components/FeatureRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,14 @@ const FeatureRow: FC<FeatureRowProps> = ({
)
}

const openFeatureHealthTab = (id: number) => {
editFeature(
projectFlag,
environmentFlags?.[id],
Constants.featurePanelTabs.FEATURE_HEALTH,
)
}

const isReadOnly = readOnly || Utils.getFlagsmithHasFeature('read_only_mode')
const isFeatureHealthEnabled = Utils.getFlagsmithHasFeature('feature_health')

Expand Down Expand Up @@ -244,13 +252,9 @@ const FeatureRow: FC<FeatureRowProps> = ({
key={id}
space
data-test={`feature-item-${index}`}
onClick={() => {
const tab =
isFeatureHealthEnabled && featureUnhealthyEvents?.length
? Constants.featurePanelTabs.FEATURE_HEALTH
: undefined
!isReadOnly && editFeature(projectFlag, environmentFlags?.[id], tab)
}}
onClick={() =>
!isReadOnly && editFeature(projectFlag, environmentFlags?.[id])
}
>
<Flex className='table-column'>
<Row>
Expand Down Expand Up @@ -329,13 +333,21 @@ const FeatureRow: FC<FeatureRowProps> = ({
{isFeatureHealthEnabled && !!isCompact && (
<UnhealthyFlagWarning
featureUnhealthyEvents={featureUnhealthyEvents}
onClick={(e) => {
e?.stopPropagation()
openFeatureHealthTab(id)
}}
/>
)}
</Row>
{!isCompact && <StaleFlagWarning projectFlag={projectFlag} />}
{isFeatureHealthEnabled && !isCompact && (
<UnhealthyFlagWarning
featureUnhealthyEvents={featureUnhealthyEvents}
onClick={(e) => {
e?.stopPropagation()
openFeatureHealthTab(id)
}}
/>
)}
{description && !isCompact && (
Expand Down
4 changes: 3 additions & 1 deletion frontend/web/components/UnhealthyFlagWarning.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ import { warning } from 'ionicons/icons'

type UnhealthyFlagWarningType = {
featureUnhealthyEvents?: HealthEvent[]
onClick?: (e?: React.MouseEvent) => void
}

const UnhealthyFlagWarning: FC<UnhealthyFlagWarningType> = ({
featureUnhealthyEvents,
onClick,
}) => {
if (!featureUnhealthyEvents?.length) return null

Expand All @@ -18,7 +20,7 @@ const UnhealthyFlagWarning: FC<UnhealthyFlagWarningType> = ({
return (
<Tooltip
title={
<div className='fs-caption' style={{ color }}>
<div className='fs-caption' style={{ color }} onClick={onClick}>
<div>
This feature has {featureUnhealthyEvents?.length} active alert
{featureUnhealthyEvents?.length > 1 ? 's' : ''}. Check them in the
Expand Down

0 comments on commit e3b026f

Please sign in to comment.