mirror of
https://github.com/Unleash/unleash.git
synced 2025-01-25 00:07:47 +01:00
refactor: ts checking conditionallyrender props (#7840)
Fix issues found by TS checking after removing ConditionallyRender
This commit is contained in:
parent
a918590d1e
commit
79fccbd8f3
@ -171,16 +171,18 @@ export const GroupCard = ({
|
|||||||
</Tooltip>
|
</Tooltip>
|
||||||
))}
|
))}
|
||||||
elseShow={
|
elseShow={
|
||||||
<Tooltip
|
<ConditionallyRender
|
||||||
title='This group is not used in any project'
|
condition={!group.rootRole}
|
||||||
arrow
|
show={
|
||||||
describeChild
|
<Tooltip
|
||||||
>
|
title='This group is not used in any project'
|
||||||
<ConditionallyRender
|
arrow
|
||||||
condition={!group.rootRole}
|
describeChild
|
||||||
show={<Badge>Not used</Badge>}
|
>
|
||||||
/>
|
<Badge>Not used</Badge>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
|
}
|
||||||
|
/>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
</ProjectBadgeContainer>
|
</ProjectBadgeContainer>
|
||||||
|
@ -70,15 +70,17 @@ const StyledBadgeIcon = styled('span')<
|
|||||||
: theme.palette[color].main,
|
: theme.palette[color].main,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
const BadgeIcon = (color: Color, icon: ReactElement) => (
|
const BadgeIcon = (color: Color, icon?: ReactElement) => (
|
||||||
<StyledBadgeIcon color={color}>
|
<StyledBadgeIcon color={color}>
|
||||||
<ConditionallyRender
|
<ConditionallyRender
|
||||||
condition={Boolean(icon?.props.sx)}
|
condition={Boolean(icon?.props.sx)}
|
||||||
show={icon}
|
show={icon}
|
||||||
elseShow={() =>
|
elseShow={
|
||||||
cloneElement(icon!, {
|
icon
|
||||||
sx: { fontSize: '16px' },
|
? cloneElement(icon, {
|
||||||
})
|
sx: { fontSize: '16px' },
|
||||||
|
})
|
||||||
|
: null
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
</StyledBadgeIcon>
|
</StyledBadgeIcon>
|
||||||
@ -110,7 +112,7 @@ export const Badge: FC<IBadgeProps> = forwardRef(
|
|||||||
>
|
>
|
||||||
<ConditionallyRender
|
<ConditionallyRender
|
||||||
condition={Boolean(icon) && !iconRight}
|
condition={Boolean(icon) && !iconRight}
|
||||||
show={BadgeIcon(color, icon!)}
|
show={BadgeIcon(color, icon)}
|
||||||
/>
|
/>
|
||||||
<ConditionallyRender
|
<ConditionallyRender
|
||||||
condition={
|
condition={
|
||||||
@ -122,7 +124,7 @@ export const Badge: FC<IBadgeProps> = forwardRef(
|
|||||||
/>
|
/>
|
||||||
<ConditionallyRender
|
<ConditionallyRender
|
||||||
condition={Boolean(icon) && Boolean(iconRight)}
|
condition={Boolean(icon) && Boolean(iconRight)}
|
||||||
show={BadgeIcon(color, icon!)}
|
show={BadgeIcon(color, icon)}
|
||||||
/>
|
/>
|
||||||
</StyledBadge>
|
</StyledBadge>
|
||||||
),
|
),
|
||||||
|
@ -55,6 +55,7 @@ export const Error: VFC<IErrorProps> = ({ error }) => {
|
|||||||
<ConditionallyRender
|
<ConditionallyRender
|
||||||
condition={showZendeskButton}
|
condition={showZendeskButton}
|
||||||
show={<ZendeskButton />}
|
show={<ZendeskButton />}
|
||||||
|
elseShow={undefined}
|
||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
|
@ -54,6 +54,7 @@ export const SegmentExecution: VFC<ISegmentExecutionProps> = ({
|
|||||||
</span>
|
</span>
|
||||||
</SegmentResultTextWrapper>
|
</SegmentResultTextWrapper>
|
||||||
}
|
}
|
||||||
|
elseShow={undefined}
|
||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
isExpanded
|
isExpanded
|
||||||
|
@ -80,29 +80,6 @@ export const ReportCard = ({ healthReport }: IReportCardProps) => {
|
|||||||
? 'warning.main'
|
? 'warning.main'
|
||||||
: 'success.main';
|
: 'success.main';
|
||||||
|
|
||||||
const renderActiveToggles = () => (
|
|
||||||
<StyledBoxActive>
|
|
||||||
<CheckIcon />
|
|
||||||
<span>{healthReport.activeCount} active flags</span>
|
|
||||||
</StyledBoxActive>
|
|
||||||
);
|
|
||||||
|
|
||||||
const renderStaleToggles = () => (
|
|
||||||
<StyledBoxStale>
|
|
||||||
<ReportProblemOutlinedIcon />
|
|
||||||
<span>{healthReport.staleCount} stale flags</span>
|
|
||||||
</StyledBoxStale>
|
|
||||||
);
|
|
||||||
|
|
||||||
const renderPotentiallyStaleToggles = () => (
|
|
||||||
<StyledBoxStale>
|
|
||||||
<ReportProblemOutlinedIcon />
|
|
||||||
<span>
|
|
||||||
{healthReport.potentiallyStaleCount} potentially stale flags
|
|
||||||
</span>
|
|
||||||
</StyledBoxStale>
|
|
||||||
);
|
|
||||||
|
|
||||||
const StalenessInfoIcon = () => (
|
const StalenessInfoIcon = () => (
|
||||||
<HtmlTooltip
|
<HtmlTooltip
|
||||||
title={
|
title={
|
||||||
@ -157,7 +134,14 @@ export const ReportCard = ({ healthReport }: IReportCardProps) => {
|
|||||||
<li>
|
<li>
|
||||||
<ConditionallyRender
|
<ConditionallyRender
|
||||||
condition={Boolean(healthReport.activeCount)}
|
condition={Boolean(healthReport.activeCount)}
|
||||||
show={renderActiveToggles}
|
show={
|
||||||
|
<StyledBoxActive>
|
||||||
|
<CheckIcon />
|
||||||
|
<span>
|
||||||
|
{healthReport.activeCount} active flags
|
||||||
|
</span>
|
||||||
|
</StyledBoxActive>
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
</li>
|
</li>
|
||||||
<ConditionallyRender
|
<ConditionallyRender
|
||||||
@ -172,7 +156,14 @@ export const ReportCard = ({ healthReport }: IReportCardProps) => {
|
|||||||
<li>
|
<li>
|
||||||
<ConditionallyRender
|
<ConditionallyRender
|
||||||
condition={Boolean(healthReport.staleCount)}
|
condition={Boolean(healthReport.staleCount)}
|
||||||
show={renderStaleToggles}
|
show={
|
||||||
|
<StyledBoxStale>
|
||||||
|
<ReportProblemOutlinedIcon />
|
||||||
|
<span>
|
||||||
|
{healthReport.staleCount} stale flags
|
||||||
|
</span>
|
||||||
|
</StyledBoxStale>
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
</li>
|
</li>
|
||||||
</StyledList>
|
</StyledList>
|
||||||
@ -190,7 +181,15 @@ export const ReportCard = ({ healthReport }: IReportCardProps) => {
|
|||||||
condition={Boolean(
|
condition={Boolean(
|
||||||
healthReport.potentiallyStaleCount,
|
healthReport.potentiallyStaleCount,
|
||||||
)}
|
)}
|
||||||
show={renderPotentiallyStaleToggles}
|
show={
|
||||||
|
<StyledBoxStale>
|
||||||
|
<ReportProblemOutlinedIcon />
|
||||||
|
<span>
|
||||||
|
{healthReport.potentiallyStaleCount}{' '}
|
||||||
|
potentially stale flags
|
||||||
|
</span>
|
||||||
|
</StyledBoxStale>
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
</li>
|
</li>
|
||||||
</StyledList>
|
</StyledList>
|
||||||
|
Loading…
Reference in New Issue
Block a user