Commit 473d9e3d authored by Phil Hughes's avatar Phil Hughes

Merge branch '194130-unable-to-create-feature-flags-with-userids' into 'master'

Resolve "Unable to create feature flags with userIds"

Closes #194130

See merge request gitlab-org/gitlab!22528
parents 14c9856b 3ebc9ef1
...@@ -59,18 +59,18 @@ export const mapToScopesViewModel = scopesFromRails => ...@@ -59,18 +59,18 @@ export const mapToScopesViewModel = scopesFromRails =>
*/ */
export const mapFromScopesViewModel = params => { export const mapFromScopesViewModel = params => {
const scopes = (params.scopes || []).map(s => { const scopes = (params.scopes || []).map(s => {
const percentParameters = {}; const parameters = {};
if (s.rolloutStrategy === ROLLOUT_STRATEGY_PERCENT_ROLLOUT) { if (s.rolloutStrategy === ROLLOUT_STRATEGY_PERCENT_ROLLOUT) {
percentParameters.groupId = PERCENT_ROLLOUT_GROUP_ID; parameters.groupId = PERCENT_ROLLOUT_GROUP_ID;
percentParameters.percentage = s.rolloutPercentage; parameters.percentage = s.rolloutPercentage;
} else if (s.rolloutStrategy === ROLLOUT_STRATEGY_USER_ID) {
parameters.userIds = (s.rolloutUserIds || '').replace(/, /g, ',');
} }
const userIdParameters = {}; const userIdParameters = {};
if (s.shouldIncludeUserIds || s.rolloutStrategy === ROLLOUT_STRATEGY_USER_ID) { if (s.shouldIncludeUserIds && s.rolloutStrategy !== ROLLOUT_STRATEGY_USER_ID) {
userIdParameters.userIds = (s.rolloutUserIds || '').replace(/, /g, ','); userIdParameters.userIds = (s.rolloutUserIds || '').replace(/, /g, ',');
} else if (Array.isArray(s.rolloutUserIds) && s.rolloutUserIds.length > 0) {
userIdParameters.userIds = s.rolloutUserIds.join(',');
} }
// Strip out any internal IDs // Strip out any internal IDs
...@@ -79,7 +79,7 @@ export const mapFromScopesViewModel = params => { ...@@ -79,7 +79,7 @@ export const mapFromScopesViewModel = params => {
const strategies = [ const strategies = [
{ {
name: s.rolloutStrategy, name: s.rolloutStrategy,
parameters: percentParameters, parameters,
}, },
]; ];
......
---
title: Ensure When userWithId Is Picked User IDs are Sent
merge_request: 22528
author:
type: fixed
...@@ -161,9 +161,10 @@ describe('feature flags helpers spec', () => { ...@@ -161,9 +161,10 @@ describe('feature flags helpers spec', () => {
canUpdate: true, canUpdate: true,
protected: true, protected: true,
shouldBeDestroyed: true, shouldBeDestroyed: true,
shouldIncludeUserIds: true,
rolloutStrategy: ROLLOUT_STRATEGY_PERCENT_ROLLOUT, rolloutStrategy: ROLLOUT_STRATEGY_PERCENT_ROLLOUT,
rolloutPercentage: '48', rolloutPercentage: '48',
rolloutUserIds: ['123', '234'], rolloutUserIds: '123, 234',
}, },
], ],
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment