Commit 4ef4f0f1 authored by Paul Slaughter's avatar Paul Slaughter

Merge branch 'jivanvl-replace-undercore-lodash-feature-flags' into 'master'

Replace underscore/lodash in feature_flags

Closes #210264

See merge request gitlab-org/gitlab!27130
parents d2beeb7e e9168f21
<script> <script>
import _ from 'underscore'; import { isEmpty } from 'lodash';
import { GlLoadingIcon, GlButton } from '@gitlab/ui'; import { GlLoadingIcon, GlButton } from '@gitlab/ui';
import axios from '~/lib/utils/axios_utils'; import axios from '~/lib/utils/axios_utils';
import { __ } from '~/locale'; import { __ } from '~/locale';
...@@ -80,7 +80,7 @@ export default { ...@@ -80,7 +80,7 @@ export default {
* @returns Boolean * @returns Boolean
*/ */
shouldRenderCreateButton() { shouldRenderCreateButton() {
return !_.isEmpty(this.filter) && !this.isLoading && !this.results.length; return !isEmpty(this.filter) && !this.isLoading && !this.results.length;
}, },
}, },
watch: { watch: {
......
<script> <script>
import { createNamespacedHelpers } from 'vuex'; import { createNamespacedHelpers } from 'vuex';
import _ from 'underscore'; import { isEmpty } from 'lodash';
import { GlEmptyState, GlLoadingIcon, GlButton, GlModalDirective, GlLink } from '@gitlab/ui'; import { GlEmptyState, GlLoadingIcon, GlButton, GlModalDirective, GlLink } from '@gitlab/ui';
import FeatureFlagsTable from './feature_flags_table.vue'; import FeatureFlagsTable from './feature_flags_table.vue';
import store from '../store'; import store from '../store';
...@@ -148,7 +148,7 @@ export default { ...@@ -148,7 +148,7 @@ export default {
]; ];
}, },
hasNewPath() { hasNewPath() {
return !_.isEmpty(this.newFeatureFlagPath); return !isEmpty(this.newFeatureFlagPath);
}, },
emptyStateTitle() { emptyStateTitle() {
if (this.scope === this.$options.scopes.disabled) { if (this.scope === this.$options.scopes.disabled) {
......
<script> <script>
import _ from 'underscore'; import { escape as esc } from 'lodash';
import { GlButton, GlTooltipDirective, GlModal, GlToggle } from '@gitlab/ui'; import { GlButton, GlTooltipDirective, GlModal, GlToggle } from '@gitlab/ui';
import { sprintf, s__ } from '~/locale'; import { sprintf, s__ } from '~/locale';
import Icon from '~/vue_shared/components/icon.vue'; import Icon from '~/vue_shared/components/icon.vue';
...@@ -41,7 +41,7 @@ export default { ...@@ -41,7 +41,7 @@ export default {
return sprintf( return sprintf(
s__('FeatureFlags|Delete %{name}?'), s__('FeatureFlags|Delete %{name}?'),
{ {
name: _.escape(this.deleteFeatureFlagName), name: esc(this.deleteFeatureFlagName),
}, },
false, false,
); );
...@@ -50,7 +50,7 @@ export default { ...@@ -50,7 +50,7 @@ export default {
return sprintf( return sprintf(
s__('FeatureFlags|Feature flag %{name} will be removed. Are you sure?'), s__('FeatureFlags|Feature flag %{name} will be removed. Are you sure?'),
{ {
name: _.escape(this.deleteFeatureFlagName), name: esc(this.deleteFeatureFlagName),
}, },
false, false,
); );
......
<script> <script>
import Vue from 'vue'; import Vue from 'vue';
import _ from 'underscore'; import { memoize, isString } from 'lodash';
import { import {
GlButton, GlButton,
GlBadge, GlBadge,
...@@ -134,7 +134,7 @@ export default { ...@@ -134,7 +134,7 @@ export default {
* @param {Object} scope * @param {Object} scope
*/ */
removeScope(scope) { removeScope(scope) {
if (_.isString(scope.id) && scope.id.startsWith(INTERNAL_ID_PREFIX)) { if (isString(scope.id) && scope.id.startsWith(INTERNAL_ID_PREFIX)) {
this.formScopes = this.formScopes.filter(s => s !== scope); this.formScopes = this.formScopes.filter(s => s !== scope);
} else { } else {
Vue.set(scope, 'shouldBeDestroyed', true); Vue.set(scope, 'shouldBeDestroyed', true);
...@@ -169,7 +169,7 @@ export default { ...@@ -169,7 +169,7 @@ export default {
return !this.permissionsFlag || scope.canUpdate; return !this.permissionsFlag || scope.canUpdate;
}, },
isRolloutPercentageInvalid: _.memoize(function isRolloutPercentageInvalid(percentage) { isRolloutPercentageInvalid: memoize(function isRolloutPercentageInvalid(percentage) {
return !this.$options.rolloutPercentageRegex.test(percentage); return !this.$options.rolloutPercentageRegex.test(percentage);
}), }),
......
import _ from 'underscore'; import { property } from 'lodash';
export const ROLLOUT_STRATEGY_ALL_USERS = 'default'; export const ROLLOUT_STRATEGY_ALL_USERS = 'default';
export const ROLLOUT_STRATEGY_PERCENT_ROLLOUT = 'gradualRolloutUserId'; export const ROLLOUT_STRATEGY_PERCENT_ROLLOUT = 'gradualRolloutUserId';
...@@ -12,5 +12,5 @@ export const ALL_ENVIRONMENTS_NAME = '*'; ...@@ -12,5 +12,5 @@ export const ALL_ENVIRONMENTS_NAME = '*';
export const INTERNAL_ID_PREFIX = 'internal_'; export const INTERNAL_ID_PREFIX = 'internal_';
export const fetchPercentageParams = _.property(['parameters', 'percentage']); export const fetchPercentageParams = property(['parameters', 'percentage']);
export const fetchUserIdParams = _.property(['parameters', 'userIds']); export const fetchUserIdParams = property(['parameters', 'userIds']);
import _ from 'underscore'; import { isEmpty, uniqueId, isString } from 'lodash';
import { import {
ROLLOUT_STRATEGY_ALL_USERS, ROLLOUT_STRATEGY_ALL_USERS,
ROLLOUT_STRATEGY_PERCENT_ROLLOUT, ROLLOUT_STRATEGY_PERCENT_ROLLOUT,
...@@ -74,7 +74,7 @@ export const mapFromScopesViewModel = params => { ...@@ -74,7 +74,7 @@ export const mapFromScopesViewModel = params => {
} }
// Strip out any internal IDs // Strip out any internal IDs
const id = _.isString(s.id) && s.id.startsWith(INTERNAL_ID_PREFIX) ? undefined : s.id; const id = isString(s.id) && s.id.startsWith(INTERNAL_ID_PREFIX) ? undefined : s.id;
const strategies = [ const strategies = [
{ {
...@@ -83,7 +83,7 @@ export const mapFromScopesViewModel = params => { ...@@ -83,7 +83,7 @@ export const mapFromScopesViewModel = params => {
}, },
]; ];
if (!_.isEmpty(userIdParameters)) { if (!isEmpty(userIdParameters)) {
strategies.push({ name: ROLLOUT_STRATEGY_USER_ID, parameters: userIdParameters }); strategies.push({ name: ROLLOUT_STRATEGY_USER_ID, parameters: userIdParameters });
} }
...@@ -123,7 +123,7 @@ export const createNewEnvironmentScope = (overrides = {}, featureFlagPermissions ...@@ -123,7 +123,7 @@ export const createNewEnvironmentScope = (overrides = {}, featureFlagPermissions
const defaultScope = { const defaultScope = {
environmentScope: '', environmentScope: '',
active: false, active: false,
id: _.uniqueId(INTERNAL_ID_PREFIX), id: uniqueId(INTERNAL_ID_PREFIX),
rolloutStrategy: ROLLOUT_STRATEGY_ALL_USERS, rolloutStrategy: ROLLOUT_STRATEGY_ALL_USERS,
rolloutPercentage: DEFAULT_PERCENT_ROLLOUT, rolloutPercentage: DEFAULT_PERCENT_ROLLOUT,
rolloutUserIds: '', rolloutUserIds: '',
......
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