From 79fccbd8f3f88ba908ca12585ef77d7bfe22f7db Mon Sep 17 00:00:00 2001 From: Tymoteusz Czech <2625371+Tymek@users.noreply.github.com> Date: Fri, 30 Aug 2024 13:39:11 +0200 Subject: [PATCH] refactor: ts checking conditionallyrender props (#7840) Fix issues found by TS checking after removing ConditionallyRender --- .../groups/GroupsList/GroupCard/GroupCard.tsx | 22 ++++---- frontend/src/component/common/Badge/Badge.tsx | 16 +++--- frontend/src/component/layout/Error/Error.tsx | 1 + .../SegmentExecution/SegmentExecution.tsx | 1 + .../ReportTable/ReportCard/ReportCard.tsx | 51 +++++++++---------- 5 files changed, 48 insertions(+), 43 deletions(-) diff --git a/frontend/src/component/admin/groups/GroupsList/GroupCard/GroupCard.tsx b/frontend/src/component/admin/groups/GroupsList/GroupCard/GroupCard.tsx index 0c1fd4465655..d85ec189c7bd 100644 --- a/frontend/src/component/admin/groups/GroupsList/GroupCard/GroupCard.tsx +++ b/frontend/src/component/admin/groups/GroupsList/GroupCard/GroupCard.tsx @@ -171,16 +171,18 @@ export const GroupCard = ({ ))} elseShow={ - - Not used} - /> - + + Not used + + } + /> } /> diff --git a/frontend/src/component/common/Badge/Badge.tsx b/frontend/src/component/common/Badge/Badge.tsx index 81652c652caf..94e46e512ed4 100644 --- a/frontend/src/component/common/Badge/Badge.tsx +++ b/frontend/src/component/common/Badge/Badge.tsx @@ -70,15 +70,17 @@ const StyledBadgeIcon = styled('span')< : theme.palette[color].main, })); -const BadgeIcon = (color: Color, icon: ReactElement) => ( +const BadgeIcon = (color: Color, icon?: ReactElement) => ( - cloneElement(icon!, { - sx: { fontSize: '16px' }, - }) + elseShow={ + icon + ? cloneElement(icon, { + sx: { fontSize: '16px' }, + }) + : null } /> @@ -110,7 +112,7 @@ export const Badge: FC = forwardRef( > = forwardRef( /> ), diff --git a/frontend/src/component/layout/Error/Error.tsx b/frontend/src/component/layout/Error/Error.tsx index 853d530d62e5..595e448a5cce 100644 --- a/frontend/src/component/layout/Error/Error.tsx +++ b/frontend/src/component/layout/Error/Error.tsx @@ -55,6 +55,7 @@ export const Error: VFC = ({ error }) => { } + elseShow={undefined} /> } > diff --git a/frontend/src/component/playground/Playground/PlaygroundResultsTable/FeatureResultInfoPopoverCell/FeatureStrategyList/StrategyList/StrategyItem/StrategyExecution/SegmentExecution/SegmentExecution.tsx b/frontend/src/component/playground/Playground/PlaygroundResultsTable/FeatureResultInfoPopoverCell/FeatureStrategyList/StrategyList/StrategyItem/StrategyExecution/SegmentExecution/SegmentExecution.tsx index 91007c58d236..c8d4d2575f8f 100644 --- a/frontend/src/component/playground/Playground/PlaygroundResultsTable/FeatureResultInfoPopoverCell/FeatureStrategyList/StrategyList/StrategyItem/StrategyExecution/SegmentExecution/SegmentExecution.tsx +++ b/frontend/src/component/playground/Playground/PlaygroundResultsTable/FeatureResultInfoPopoverCell/FeatureStrategyList/StrategyList/StrategyItem/StrategyExecution/SegmentExecution/SegmentExecution.tsx @@ -54,6 +54,7 @@ export const SegmentExecution: VFC = ({ } + elseShow={undefined} /> } isExpanded diff --git a/frontend/src/component/project/Project/ProjectHealth/ReportTable/ReportCard/ReportCard.tsx b/frontend/src/component/project/Project/ProjectHealth/ReportTable/ReportCard/ReportCard.tsx index 8f6b87239419..e8e516012f0c 100644 --- a/frontend/src/component/project/Project/ProjectHealth/ReportTable/ReportCard/ReportCard.tsx +++ b/frontend/src/component/project/Project/ProjectHealth/ReportTable/ReportCard/ReportCard.tsx @@ -80,29 +80,6 @@ export const ReportCard = ({ healthReport }: IReportCardProps) => { ? 'warning.main' : 'success.main'; - const renderActiveToggles = () => ( - - - {healthReport.activeCount} active flags - - ); - - const renderStaleToggles = () => ( - - - {healthReport.staleCount} stale flags - - ); - - const renderPotentiallyStaleToggles = () => ( - - - - {healthReport.potentiallyStaleCount} potentially stale flags - - - ); - const StalenessInfoIcon = () => ( {
  • + + + {healthReport.activeCount} active flags + + + } />
  • {
  • + + + {healthReport.staleCount} stale flags + + + } />
  • @@ -190,7 +181,15 @@ export const ReportCard = ({ healthReport }: IReportCardProps) => { condition={Boolean( healthReport.potentiallyStaleCount, )} - show={renderPotentiallyStaleToggles} + show={ + + + + {healthReport.potentiallyStaleCount}{' '} + potentially stale flags + + + } />