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:
parent
f0fe2368e1
commit
e824d83f93
@ -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,10 +151,11 @@ export const StrategyItemContainer: FC<IStrategyItemContainerProps> = ({
|
|||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<StyledHeaderContainer>
|
<StyledHeaderContainer>
|
||||||
|
<StrategyHeaderLink>
|
||||||
<StringTruncator
|
<StringTruncator
|
||||||
maxWidth="400"
|
maxWidth="400"
|
||||||
maxLength={15}
|
maxLength={15}
|
||||||
text={formatStrategyName(strategy.name)}
|
text={formatStrategyName(String(strategy.name))}
|
||||||
/>
|
/>
|
||||||
<ConditionallyRender
|
<ConditionallyRender
|
||||||
condition={
|
condition={
|
||||||
@ -158,10 +165,13 @@ export const StrategyItemContainer: FC<IStrategyItemContainerProps> = ({
|
|||||||
}
|
}
|
||||||
show={
|
show={
|
||||||
<StyledCustomTitle>
|
<StyledCustomTitle>
|
||||||
{formatStrategyName(String(strategy.title))}
|
{formatStrategyName(
|
||||||
|
String(strategy.title)
|
||||||
|
)}
|
||||||
</StyledCustomTitle>
|
</StyledCustomTitle>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
|
</StrategyHeaderLink>
|
||||||
<ConditionallyRender
|
<ConditionallyRender
|
||||||
condition={Boolean(description)}
|
condition={Boolean(description)}
|
||||||
show={
|
show={
|
||||||
|
Loading…
Reference in New Issue
Block a user