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

Commit 241f20c

Browse files
committed
identity flag mv
1 parent 365fc46 commit 241f20c

File tree

3 files changed

+43
-21
lines changed

3 files changed

+43
-21
lines changed

common/stores/identity-store.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,13 @@ const controller = {
6767
? data.put(`${Project.api}environments/${environmentId}/identities/${identity}/featurestates/${identityFlag.id}/`, Object.assign({}, {
6868
id: identityFlag.id,
6969
enabled: identityFlag.enabled,
70+
multivariate_feature_state_values:identityFlag.multivariate_options,
7071
feature_state_value: identityFlag.feature_state_value,
7172
}))
7273
: data.post(`${Project.api}environments/${environmentId}/identities/${identity}/featurestates/`, {
7374
feature: projectFlag.id,
7475
enabled: environmentFlag.enabled,
76+
multivariate_feature_state_values:identityFlag.multivariate_options,
7577
feature_state_value: identityFlag.feature_state_value,
7678
});
7779

web/components/modals/CreateFlag.js

Lines changed: 39 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ const CreateFlag = class extends Component {
3636
initial_value: Utils.getTypedValue(feature_state_value),
3737
description,
3838
multivariate_options: _.cloneDeep(multivariate_options),
39+
identityVariations: this.props.identityFlag && this.props.identityFlag.multivariate_feature_state_values ? _.cloneDeep(this.props.identityFlag.multivariate_feature_state_values) : [],
3940
selectedIdentity: null,
4041
allowEditDescription,
4142
enabledIndentity: false,
@@ -115,7 +116,7 @@ const CreateFlag = class extends Component {
115116
projectFlag,
116117
environmentFlag,
117118
identityFlag: Object.assign({}, identityFlag || {}, {
118-
multivariate_options: [],
119+
multivariate_options: this.state.identityVariations,
119120
feature_state_value: initial_value,
120121
enabled: default_enabled,
121122
}),
@@ -370,6 +371,23 @@ const CreateFlag = class extends Component {
370371
</FormGroup>
371372
)}
372373

374+
{identity && description && (
375+
<FormGroup className="mb-4 mr-3 ml-3" >
376+
<InputGroup
377+
value={description}
378+
data-test="featureDesc"
379+
inputProps={{
380+
className: 'full-width',
381+
readOnly: !!identity,
382+
name: 'featureDesc',
383+
}}
384+
onChange={e => this.setState({ description: Utils.safeParseEventValue(e) })}
385+
isValid={name && name.length}
386+
type="text" title={identity ? 'Description' : 'Description (optional)'}
387+
placeholder="No description"
388+
/>
389+
</FormGroup>
390+
)}
373391
<FormGroup className="mb-4 mr-3 ml-3">
374392
<div>
375393
<label>{enabledString}</label>
@@ -384,7 +402,7 @@ const CreateFlag = class extends Component {
384402
</FormGroup>
385403

386404
{!(!!identity && (multivariate_options && !!multivariate_options.length)) && (
387-
<FormGroup className="ml-3 mb-4 mr-3">
405+
<FormGroup className="mx-3 mb-4 mr-3">
388406
<InputGroup
389407
component={(
390408
<ValueEditor
@@ -402,6 +420,25 @@ const CreateFlag = class extends Component {
402420
</FormGroup>
403421
) }
404422

423+
{!!identity && hasFeature('mv') && (
424+
<div>
425+
<FormGroup className="mb-4 mx-3">
426+
<VariationOptions
427+
disabled
428+
select
429+
controlValue={this.props.environmentFlag.feature_state_value}
430+
variationOverrides={this.state.identityVariations}
431+
setVariations={(identityVariations) => {
432+
this.setState({ identityVariations });
433+
}}
434+
updateVariation={() => {}}
435+
weightTitle="Override Weight %"
436+
multivariateOptions={projectFlag.multivariate_options}
437+
removeVariation={() => {}}
438+
/>
439+
</FormGroup>
440+
</div>
441+
)}
405442
{this.props.hasFeature('mv') && !identity && (
406443
<div>
407444
<FormGroup className="ml-3 mb-4 mr-3">
@@ -419,23 +456,6 @@ const CreateFlag = class extends Component {
419456
</div>
420457

421458
)}
422-
{identity && (
423-
<FormGroup className="mb-4 mr-3 ml-3" >
424-
<InputGroup
425-
value={description}
426-
data-test="featureDesc"
427-
inputProps={{
428-
className: 'full-width',
429-
readOnly: !!identity,
430-
name: 'featureDesc',
431-
}}
432-
onChange={e => this.setState({ description: Utils.safeParseEventValue(e) })}
433-
isValid={name && name.length}
434-
type="text" title={identity ? 'Description' : 'Description (optional)'}
435-
placeholder="e.g. 'This determines what size the header is' "
436-
/>
437-
</FormGroup>
438-
)}
439459
{!isEdit && !identity && Settings}
440460
</>
441461
);

web/components/pages/UserPage.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ const UserPage = class extends Component {
7272

7373
editFlag = (projectFlag, environmentFlag, identityFlag) => {
7474
API.trackEvent(Constants.events.VIEW_USER_FEATURE);
75-
openModal('Edit User Feature', <CreateFlagModal
75+
openModal('Edit User Feature: ' + projectFlag.name, <CreateFlagModal
7676
isEdit
7777
identity={this.props.match.params.id}
7878
identityName={this.props.match.params.identity}
@@ -81,7 +81,7 @@ const UserPage = class extends Component {
8181
projectFlag={projectFlag}
8282
identityFlag={identityFlag}
8383
environmentFlag={environmentFlag}
84-
/>);
84+
/>, null, { className: 'side-modal fade' });
8585
};
8686

8787
createTrait = () => {

0 commit comments

Comments
 (0)