1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-01-25 00:07:47 +01:00

fix: viewers should be allowed to see strategy config (#645)

fixes #644
This commit is contained in:
Ivar Conradi Østhus 2022-01-29 15:18:11 +01:00 committed by GitHub
parent 8dddb285b6
commit 9c3e300448
3 changed files with 25 additions and 22 deletions

View File

@ -148,6 +148,17 @@ const FeatureStrategyAccordionBody: React.FC<
const { parameters } = strategy;
const ON = uiConfig.flags[C];
const editable = hasAccess(
UPDATE_FEATURE_STRATEGY,
projectId,
activeEnvironment.name
) ||
hasAccess(
CREATE_FEATURE_STRATEGY,
projectId,
activeEnvironment.name
);
return (
<div className={styles.accordionContainer}>
<ConditionallyRender
@ -193,28 +204,12 @@ const FeatureStrategyAccordionBody: React.FC<
/>
</Dialogue>
<ConditionallyRender
condition={
hasAccess(
UPDATE_FEATURE_STRATEGY,
projectId,
activeEnvironment.name
) ||
hasAccess(
CREATE_FEATURE_STRATEGY,
projectId,
activeEnvironment.name
)
}
show={
<Type
parameters={parameters}
updateParameter={updateParameters}
strategyDefinition={definition}
context={context}
editable
/>
}
<Type
parameters={parameters}
updateParameter={updateParameters}
strategyDefinition={definition}
context={context}
editable={editable}
/>
{children}

View File

@ -22,12 +22,14 @@ interface IFlexibleStrategyProps {
parameters: IParameter;
updateParameter: (field: string, value: any) => void;
context: any;
editable: boolean;
}
const FlexibleStrategy = ({
updateParameter,
parameters,
context,
editable=true
}: IFlexibleStrategyProps) => {
const onUpdate =
(field: string) =>
@ -66,6 +68,7 @@ const FlexibleStrategy = ({
<RolloutSlider
name="Rollout"
value={1 * rollout}
disabled={!editable}
onChange={updateRollout}
/>
@ -96,6 +99,7 @@ const FlexibleStrategy = ({
label="Stickiness"
options={stickinessOptions}
value={stickiness}
disabled={!editable}
data-test={FLEXIBLE_STRATEGY_STICKINESS_ID}
onChange={e =>
onUpdate('stickiness')(e, e.target.value as number)
@ -126,6 +130,7 @@ const FlexibleStrategy = ({
<Input
label="groupId"
value={groupId || ''}
disabled={!editable}
onChange={e => onUpdate('groupId')(e, e.target.value)}
data-test={FLEXIBLE_STRATEGY_GROUP_ID}
/>

View File

@ -66,6 +66,7 @@ const GeneralStrategy = ({
<RolloutSlider
name={name}
onChange={onChangePercentage.bind(this, name)}
disabled={!editable}
value={1 * value}
minLabel="off"
maxLabel="on"
@ -107,6 +108,7 @@ const GeneralStrategy = ({
size="small"
required={required}
style={{ width: '100%' }}
disabled={!editable}
name={name}
label={name}
onChange={onChangeTextField.bind(this, name)}
@ -148,6 +150,7 @@ const GeneralStrategy = ({
size="small"
style={{ width: '100%' }}
required={required}
disabled={!editable}
name={name}
label={name}
onChange={onChangeTextField.bind(this, name)}