Skip to content
This repository has been archived by the owner on Jun 10, 2021. It is now read-only.

Commit

Permalink
MV fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
kyle-ssg committed Apr 7, 2021
1 parent 21b1eba commit 993b28c
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 5 deletions.
6 changes: 4 additions & 2 deletions web/components/modals/CreateFlag.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ const CreateFlag = class extends Component {
projectFlag,
environmentFlag,
identityFlag: Object.assign({}, identityFlag || {}, {
multivariate_options: [],
feature_state_value: initial_value,
enabled: default_enabled,
}),
Expand Down Expand Up @@ -287,7 +288,7 @@ const CreateFlag = class extends Component {
const { isEdit, hasFeature, projectFlag, identity, identityName } = this.props;
const Provider = identity ? IdentityProvider : FeatureListProvider;
const controlValue = Utils.calculateControl(multivariate_options, environmentVariations);
const valueString = !!multivariate_options && multivariate_options.length ? `Control Value - ${controlValue}%` : `Value (optional)${' - these can be set per environment'}`;
const valueString = identity ? 'User override' : !!multivariate_options && multivariate_options.length ? `Control Value - ${controlValue}%` : `Value (optional)${' - these can be set per environment'}`;
const enabledString = isEdit ? 'Enabled' : 'Enabled by default';
const environmentVariations = this.props.environmentVariations;

Expand Down Expand Up @@ -393,10 +394,11 @@ const CreateFlag = class extends Component {
title={`${valueString}`}
/>
</FormGroup>
{this.props.hasFeature('mv') && (
{this.props.hasFeature('mv') && !identity&& (
<div>
<FormGroup className="ml-3 mb-4 mr-3">
<VariationOptions
disabled={!!identity}
controlValue={controlValue}
variationOverrides={environmentVariations}
updateVariation={this.updateVariation}
Expand Down
1 change: 1 addition & 0 deletions web/components/mv/VariationValue.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ const VariationValue = ({
default_percentage_allocation: Utils.safeParseEventValue(e) ? parseInt(Utils.safeParseEventValue(e)) : null,
});
}}
disabled={disabled}
value={value.default_percentage_allocation}
inputProps={{ style: { marginTop: 2 }, maxLength: 3 }}
title={weightTitle}
Expand Down
30 changes: 27 additions & 3 deletions web/components/pages/UserPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,11 @@ const UserPage = class extends Component {
const flagEnabledDifferent = type === 'FLAG' && (hasUserOverride ? false
: actualEnabled !== flagEnabled);
const flagValueDifferent = type !== 'FLAG' && (hasUserOverride ? false : actualValue !== flagValue);
const projectFlag = projectFlags && projectFlags.find(p => p.id === (environmentFlag && environmentFlag.feature));
const isMultiVariateOverride = flagValueDifferent && projectFlag && projectFlag.multivariate_options && projectFlag.multivariate_options.find((v) => {
const value = Utils.featureStateToValue(v);
return value === actualValue;
});
const flagDifferent = flagEnabledDifferent || flagValueDifferent;
return (
<Row
Expand Down Expand Up @@ -206,18 +211,37 @@ const UserPage = class extends Component {

) : (
flagEnabledDifferent ? (
<span data-test={`feature-override-${i}`} className="flex-row chip">
{isMultiVariateOverride ? (
<span>
This flag is being overridden by a variation defined on your feature, the control value is <strong>{flagEnabled ? 'on' : 'off'}</strong> for this user
</span>
) : (
<span>
This flag is being overridden by segments and would normally be <strong>{flagEnabled ? 'on' : 'off'}</strong> for this user
</span>
)}

<span
className="chip-icon icon ion-md-information"
/>
</span>
) : flagValueDifferent ? isMultiVariateOverride ? (
<span data-test={`feature-override-${i}`} className="flex-row chip">
<span>
This flag is being overriden by segments and would normally be <strong>{flagEnabled ? 'on' : 'off'}</strong> for this user
This feature is being overriden by a % variation for this user, the control value of this feature is <FeatureValue
data-test={`user-feature-original-value-${i}`}
value={`${flagValue}`}
/>
</span>
<span
className="chip-icon icon ion-md-information"
/>
</span>
) : flagValueDifferent ? (
) : (
<span data-test={`feature-override-${i}`} className="flex-row chip">
<span>
This flag is being overriden by segments and would normally be <FeatureValue
This feature is being overriden by segments and would normally be <FeatureValue
data-test={`user-feature-original-value-${i}`}
value={`${flagValue}`}
/> for this user
Expand Down
3 changes: 3 additions & 0 deletions web/styles/components/_input.scss
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ textarea {
-webkit-appearance: none;
background-image: none;

&:disabled {
opacity: 0.5;
}
&:read-only {
color: #777;
}
Expand Down

0 comments on commit 993b28c

Please sign in to comment.