1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-02-14 00:19:16 +01:00

feat: link to strategy edit screens from playground strategy results (#4063)

This PR adds links from the strategy evaluation results directly to the
strategy edit screen.

If the code doesn't find any links, nothing changes.

The link text will be the name of the strategy and the title (if it
exists).


![image](https://github.com/Unleash/unleash/assets/17786332/10ddbee2-2b19-46b8-a8be-994233f759ea)
This commit is contained in:
Thomas Heartman 2023-06-22 13:51:38 +02:00 committed by GitHub
parent f0fe2368e1
commit e824d83f93
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -11,6 +11,7 @@ import { ConditionallyRender } from 'component/common/ConditionallyRender/Condit
import { PlaygroundStrategySchema } from 'openapi'; import { PlaygroundStrategySchema } from 'openapi';
import useUiConfig from 'hooks/api/getters/useUiConfig/useUiConfig'; import useUiConfig from 'hooks/api/getters/useUiConfig/useUiConfig';
import { Badge } from '../Badge/Badge'; import { Badge } from '../Badge/Badge';
import { Link } from 'react-router-dom';
interface IStrategyItemContainerProps { interface IStrategyItemContainerProps {
strategy: IFeatureStrategy | PlaygroundStrategySchema; strategy: IFeatureStrategy | PlaygroundStrategySchema;
@ -106,6 +107,11 @@ export const StrategyItemContainer: FC<IStrategyItemContainerProps> = ({
const Icon = getFeatureStrategyIcon(strategy.name); const Icon = getFeatureStrategyIcon(strategy.name);
const { uiConfig } = useUiConfig(); const { uiConfig } = useUiConfig();
const StrategyHeaderLink: React.FC =
'links' in strategy
? ({ children }) => <Link to={strategy.links.edit}>{children}</Link>
: ({ children }) => <> {children} </>;
return ( return (
<Box sx={{ position: 'relative' }}> <Box sx={{ position: 'relative' }}>
<ConditionallyRender <ConditionallyRender
@ -145,23 +151,27 @@ export const StrategyItemContainer: FC<IStrategyItemContainerProps> = ({
}} }}
/> />
<StyledHeaderContainer> <StyledHeaderContainer>
<StringTruncator <StrategyHeaderLink>
maxWidth="400" <StringTruncator
maxLength={15} maxWidth="400"
text={formatStrategyName(strategy.name)} maxLength={15}
/> text={formatStrategyName(String(strategy.name))}
<ConditionallyRender />
condition={ <ConditionallyRender
Boolean( condition={
uiConfig?.flags?.strategyImprovements Boolean(
) && Boolean(strategy.title) uiConfig?.flags?.strategyImprovements
} ) && Boolean(strategy.title)
show={ }
<StyledCustomTitle> show={
{formatStrategyName(String(strategy.title))} <StyledCustomTitle>
</StyledCustomTitle> {formatStrategyName(
} String(strategy.title)
/> )}
</StyledCustomTitle>
}
/>
</StrategyHeaderLink>
<ConditionallyRender <ConditionallyRender
condition={Boolean(description)} condition={Boolean(description)}
show={ show={