Commit a81a2301 authored by Natalia Tepluhina's avatar Natalia Tepluhina

Merge branch '196673-replace-underscore-in-javacript-environments-folder' into 'master'

Replace underscore with lodash in env folder

Closes #196673

See merge request gitlab-org/gitlab!27160
parents 70fce78e 71e66603
......@@ -3,7 +3,7 @@
* Render modal to confirm rollback/redeploy.
*/
import _ from 'underscore';
import { escape as esc } from 'lodash';
import { GlModal } from '@gitlab/ui';
import { s__, sprintf } from '~/locale';
......@@ -30,7 +30,7 @@ export default {
: s__('Environments|Rollback environment %{name}?');
return sprintf(title, {
name: _.escape(this.environment.name),
name: esc(this.environment.name),
});
},
......@@ -50,10 +50,10 @@ export default {
},
modalText() {
const linkStart = `<a class="commit-sha mr-0" href="${_.escape(this.commitUrl)}">`;
const commitId = _.escape(this.commitShortSha);
const linkStart = `<a class="commit-sha mr-0" href="${esc(this.commitUrl)}">`;
const commitId = esc(this.commitShortSha);
const linkEnd = '</a>';
const name = _.escape(this.name);
const name = esc(this.name);
const body = this.environment.isLastDeployment
? s__(
'Environments|This action will relaunch the job for commit %{linkStart}%{commitId}%{linkEnd}, putting the environment in a previous version. Are you sure you want to continue?',
......
<script>
/* eslint-disable @gitlab/vue-require-i18n-strings */
import _ from 'underscore';
import { isEmpty } from 'lodash';
import { GlTooltipDirective } from '@gitlab/ui';
import { __, sprintf } from '~/locale';
import { convertObjectPropsToCamelCase } from '~/lib/utils/common_utils';
......@@ -79,7 +79,7 @@ export default {
* @returns {Boolean}
*/
hasLastDeploymentKey() {
if (this.model && this.model.last_deployment && !_.isEmpty(this.model.last_deployment)) {
if (this.model && this.model.last_deployment && !isEmpty(this.model.last_deployment)) {
return true;
}
return false;
......@@ -390,8 +390,8 @@ export default {
deploymentHasUser() {
return (
this.model &&
!_.isEmpty(this.model.last_deployment) &&
!_.isEmpty(this.model.last_deployment.user)
!isEmpty(this.model.last_deployment) &&
!isEmpty(this.model.last_deployment.user)
);
},
......@@ -404,8 +404,8 @@ export default {
deploymentUser() {
if (
this.model &&
!_.isEmpty(this.model.last_deployment) &&
!_.isEmpty(this.model.last_deployment.user)
!isEmpty(this.model.last_deployment) &&
!isEmpty(this.model.last_deployment.user)
) {
return this.model.last_deployment.user;
}
......@@ -431,8 +431,8 @@ export default {
shouldRenderBuildName() {
return (
!this.isFolder &&
!_.isEmpty(this.model.last_deployment) &&
!_.isEmpty(this.model.last_deployment.deployable)
!isEmpty(this.model.last_deployment) &&
!isEmpty(this.model.last_deployment.deployable)
);
},
......@@ -473,7 +473,7 @@ export default {
shouldRenderDeploymentID() {
return (
!this.isFolder &&
!_.isEmpty(this.model.last_deployment) &&
!isEmpty(this.model.last_deployment) &&
this.model.last_deployment.iid !== undefined
);
},
......
......@@ -3,7 +3,7 @@
* Render environments table.
*/
import { GlLoadingIcon } from '@gitlab/ui';
import _ from 'underscore';
import { flow, reverse, sortBy } from 'lodash/fp';
import environmentTableMixin from 'ee_else_ce/environments/mixins/environments_table_mixin';
import { s__ } from '~/locale';
import glFeatureFlagsMixin from '~/vue_shared/mixins/gl_feature_flags_mixin';
......@@ -102,13 +102,13 @@ export default {
* 4. Reverse (last deployment descending, name ascending),
* 5. Put folders first.
*/
return _.chain(environments)
.sortBy(env => (env.isFolder ? env.folderName : env.name))
.reverse()
.sortBy(env => (env.last_deployment ? env.last_deployment.created_at : '0000'))
.reverse()
.sortBy(env => (env.isFolder ? -1 : 1))
.value();
return flow(
sortBy(env => (env.isFolder ? env.folderName : env.name)),
reverse,
sortBy(env => (env.last_deployment ? env.last_deployment.created_at : '0000')),
reverse,
sortBy(env => (env.isFolder ? -1 : 1)),
)(environments);
},
},
};
......
/**
* Common code between environmets app and folder view
*/
import _ from 'underscore';
import { isEqual, isFunction, omitBy } from 'lodash';
import Visibility from 'visibilityjs';
import EnvironmentsStore from 'ee_else_ce/environments/stores/environments_store';
import Poll from '../../lib/utils/poll';
......@@ -54,7 +54,7 @@ export default {
const response = this.filterNilValues(resp.config.params);
const request = this.filterNilValues(this.requestData);
if (_.isEqual(response, request)) {
if (isEqual(response, request)) {
this.store.storeAvailableCount(resp.data.available_count);
this.store.storeStoppedCount(resp.data.stopped_count);
this.store.storeEnvironments(resp.data.environments);
......@@ -64,7 +64,7 @@ export default {
},
filterNilValues(obj) {
return _.omit(obj, value => _.isUndefined(value) || _.isNull(value));
return omitBy(obj, value => value === undefined || value === null);
},
/**
......@@ -109,7 +109,7 @@ export default {
.then(() => this.fetchEnvironments())
.catch(err => {
this.isLoading = false;
Flash(_.isFunction(errorMessage) ? errorMessage(err.response.data) : errorMessage);
Flash(isFunction(errorMessage) ? errorMessage(err.response.data) : errorMessage);
});
}
},
......
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