mirror of
https://github.com/Unleash/unleash.git
synced 2025-02-09 00:18:00 +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:
parent
f0fe2368e1
commit
e824d83f93
@ -11,6 +11,7 @@ import { ConditionallyRender } from 'component/common/ConditionallyRender/Condit
|
||||
import { PlaygroundStrategySchema } from 'openapi';
|
||||
import useUiConfig from 'hooks/api/getters/useUiConfig/useUiConfig';
|
||||
import { Badge } from '../Badge/Badge';
|
||||
import { Link } from 'react-router-dom';
|
||||
|
||||
interface IStrategyItemContainerProps {
|
||||
strategy: IFeatureStrategy | PlaygroundStrategySchema;
|
||||
@ -106,6 +107,11 @@ export const StrategyItemContainer: FC<IStrategyItemContainerProps> = ({
|
||||
const Icon = getFeatureStrategyIcon(strategy.name);
|
||||
const { uiConfig } = useUiConfig();
|
||||
|
||||
const StrategyHeaderLink: React.FC =
|
||||
'links' in strategy
|
||||
? ({ children }) => <Link to={strategy.links.edit}>{children}</Link>
|
||||
: ({ children }) => <> {children} </>;
|
||||
|
||||
return (
|
||||
<Box sx={{ position: 'relative' }}>
|
||||
<ConditionallyRender
|
||||
@ -145,23 +151,27 @@ export const StrategyItemContainer: FC<IStrategyItemContainerProps> = ({
|
||||
}}
|
||||
/>
|
||||
<StyledHeaderContainer>
|
||||
<StringTruncator
|
||||
maxWidth="400"
|
||||
maxLength={15}
|
||||
text={formatStrategyName(strategy.name)}
|
||||
/>
|
||||
<ConditionallyRender
|
||||
condition={
|
||||
Boolean(
|
||||
uiConfig?.flags?.strategyImprovements
|
||||
) && Boolean(strategy.title)
|
||||
}
|
||||
show={
|
||||
<StyledCustomTitle>
|
||||
{formatStrategyName(String(strategy.title))}
|
||||
</StyledCustomTitle>
|
||||
}
|
||||
/>
|
||||
<StrategyHeaderLink>
|
||||
<StringTruncator
|
||||
maxWidth="400"
|
||||
maxLength={15}
|
||||
text={formatStrategyName(String(strategy.name))}
|
||||
/>
|
||||
<ConditionallyRender
|
||||
condition={
|
||||
Boolean(
|
||||
uiConfig?.flags?.strategyImprovements
|
||||
) && Boolean(strategy.title)
|
||||
}
|
||||
show={
|
||||
<StyledCustomTitle>
|
||||
{formatStrategyName(
|
||||
String(strategy.title)
|
||||
)}
|
||||
</StyledCustomTitle>
|
||||
}
|
||||
/>
|
||||
</StrategyHeaderLink>
|
||||
<ConditionallyRender
|
||||
condition={Boolean(description)}
|
||||
show={
|
||||
|
Loading…
Reference in New Issue
Block a user