Commit 6c533ed6 authored by Jose Vargas's avatar Jose Vargas

Replace undercore with lodash on the pages folder

This replaces all underscore methods with native
and or lodash ones inside the pages folder
parent be65c3c1
import $ from 'jquery'; import $ from 'jquery';
import _ from 'underscore'; import { debounce } from 'lodash';
import axios from '~/lib/utils/axios_utils'; import axios from '~/lib/utils/axios_utils';
import flash from '~/flash'; import flash from '~/flash';
import { __ } from '~/locale'; import { __ } from '~/locale';
...@@ -34,7 +34,7 @@ export default () => { ...@@ -34,7 +34,7 @@ export default () => {
$broadcastMessage.on( $broadcastMessage.on(
'input', 'input',
_.debounce(function onMessageInput() { debounce(function onMessageInput() {
const message = $(this).val(); const message = $(this).val();
if (message === '') { if (message === '') {
$jsBroadcastMessagePreview.text(__('Your message here')); $jsBroadcastMessagePreview.text(__('Your message here'));
......
<script> <script>
import _ from 'underscore'; import { escape as esc } from 'lodash';
import DeprecatedModal from '~/vue_shared/components/deprecated_modal.vue'; import DeprecatedModal from '~/vue_shared/components/deprecated_modal.vue';
import { s__, sprintf } from '~/locale'; import { s__, sprintf } from '~/locale';
...@@ -34,7 +34,7 @@ export default { ...@@ -34,7 +34,7 @@ export default {
return sprintf( return sprintf(
s__('AdminProjects|Delete Project %{projectName}?'), s__('AdminProjects|Delete Project %{projectName}?'),
{ {
projectName: `'${_.escape(this.projectName)}'`, projectName: `'${esc(this.projectName)}'`,
}, },
false, false,
); );
...@@ -46,7 +46,7 @@ export default { ...@@ -46,7 +46,7 @@ export default {
and all related resources including issues, merge requests, etc.. Once you confirm and press and all related resources including issues, merge requests, etc.. Once you confirm and press
%{strong_start}Delete project%{strong_end}, it cannot be undone or recovered.`), %{strong_start}Delete project%{strong_end}, it cannot be undone or recovered.`),
{ {
projectName: `<strong>${_.escape(this.projectName)}</strong>`, projectName: `<strong>${esc(this.projectName)}</strong>`,
strong_start: '<strong>', strong_start: '<strong>',
strong_end: '</strong>', strong_end: '</strong>',
}, },
...@@ -57,7 +57,7 @@ export default { ...@@ -57,7 +57,7 @@ export default {
return sprintf( return sprintf(
s__('AdminUsers|To confirm, type %{projectName}'), s__('AdminUsers|To confirm, type %{projectName}'),
{ {
projectName: `<code>${_.escape(this.projectName)}</code>`, projectName: `<code>${esc(this.projectName)}</code>`,
}, },
false, false,
); );
......
<script> <script>
import _ from 'underscore'; import { escape as esc } from 'lodash';
import { GlModal, GlButton, GlFormInput } from '@gitlab/ui'; import { GlModal, GlButton, GlFormInput } from '@gitlab/ui';
import { s__, sprintf } from '~/locale'; import { s__, sprintf } from '~/locale';
...@@ -56,7 +56,7 @@ export default { ...@@ -56,7 +56,7 @@ export default {
return sprintf( return sprintf(
this.content, this.content,
{ {
username: `<strong>${_.escape(this.username)}</strong>`, username: `<strong>${esc(this.username)}</strong>`,
strong_start: '<strong>', strong_start: '<strong>',
strong_end: '</strong>', strong_end: '</strong>',
}, },
...@@ -67,7 +67,7 @@ export default { ...@@ -67,7 +67,7 @@ export default {
return sprintf( return sprintf(
s__('AdminUsers|To confirm, type %{username}'), s__('AdminUsers|To confirm, type %{username}'),
{ {
username: `<code>${_.escape(this.username)}</code>`, username: `<code>${esc(this.username)}</code>`,
}, },
false, false,
); );
......
import _ from 'underscore'; import { debounce } from 'lodash';
import InputValidator from '~/validators/input_validator'; import InputValidator from '~/validators/input_validator';
import fetchGroupPathAvailability from './fetch_group_path_availability'; import fetchGroupPathAvailability from './fetch_group_path_availability';
...@@ -20,7 +20,7 @@ export default class GroupPathValidator extends InputValidator { ...@@ -20,7 +20,7 @@ export default class GroupPathValidator extends InputValidator {
const container = opts.container || ''; const container = opts.container || '';
const validateElements = document.querySelectorAll(`${container} .js-validate-group-path`); const validateElements = document.querySelectorAll(`${container} .js-validate-group-path`);
this.debounceValidateInput = _.debounce(inputDomElement => { this.debounceValidateInput = debounce(inputDomElement => {
GroupPathValidator.validateGroupPathInput(inputDomElement); GroupPathValidator.validateGroupPathInput(inputDomElement);
}, debounceTimeoutDuration); }, debounceTimeoutDuration);
......
<script> <script>
import _ from 'underscore'; import { escape as esc } from 'lodash';
import axios from '~/lib/utils/axios_utils'; import axios from '~/lib/utils/axios_utils';
import createFlash from '~/flash'; import createFlash from '~/flash';
import DeprecatedModal2 from '~/vue_shared/components/deprecated_modal_2.vue'; import DeprecatedModal2 from '~/vue_shared/components/deprecated_modal_2.vue';
...@@ -48,7 +48,7 @@ export default { ...@@ -48,7 +48,7 @@ export default {
const label = `<span const label = `<span
class="label color-label" class="label color-label"
style="background-color: ${this.labelColor}; color: ${this.labelTextColor};" style="background-color: ${this.labelColor}; color: ${this.labelTextColor};"
>${_.escape(this.labelTitle)}</span>`; >${esc(this.labelTitle)}</span>`;
return sprintf( return sprintf(
s__('Labels|<span>Promote label</span> %{labelTitle} <span>to Group Label?</span>'), s__('Labels|<span>Promote label</span> %{labelTitle} <span>to Group Label?</span>'),
......
<script> <script>
import _ from 'underscore';
export default { export default {
props: { props: {
initialCronInterval: { initialCronInterval: {
...@@ -24,7 +22,7 @@ export default { ...@@ -24,7 +22,7 @@ export default {
}, },
computed: { computed: {
intervalIsPreset() { intervalIsPreset() {
return _.contains(this.cronIntervalPresets, this.cronInterval); return Object.values(this.cronIntervalPresets).includes(this.cronInterval);
}, },
// The text input is editable when there's a custom interval, or when it's // The text input is editable when there's a custom interval, or when it's
// a preset interval and the user clicks the 'custom' radio button // a preset interval and the user clicks the 'custom' radio button
......
<script> <script>
import _ from 'underscore'; import { escape as esc } from 'lodash';
import { GlModal, GlModalDirective } from '@gitlab/ui'; import { GlModal, GlModalDirective } from '@gitlab/ui';
import { s__, sprintf } from '~/locale'; import { s__, sprintf } from '~/locale';
...@@ -38,7 +38,7 @@ export default { ...@@ -38,7 +38,7 @@ export default {
return sprintf( return sprintf(
s__('WikiPageConfirmDelete|Delete page %{pageTitle}?'), s__('WikiPageConfirmDelete|Delete page %{pageTitle}?'),
{ {
pageTitle: _.escape(this.pageTitle), pageTitle: esc(this.pageTitle),
}, },
false, false,
); );
......
import _ from 'underscore'; import { debounce } from 'lodash';
import InputValidator from '~/validators/input_validator'; import InputValidator from '~/validators/input_validator';
import axios from '~/lib/utils/axios_utils'; import axios from '~/lib/utils/axios_utils';
...@@ -20,7 +20,7 @@ export default class UsernameValidator extends InputValidator { ...@@ -20,7 +20,7 @@ export default class UsernameValidator extends InputValidator {
const container = opts.container || ''; const container = opts.container || '';
const validateLengthElements = document.querySelectorAll(`${container} .js-validate-username`); const validateLengthElements = document.querySelectorAll(`${container} .js-validate-username`);
this.debounceValidateInput = _.debounce(inputDomElement => { this.debounceValidateInput = debounce(inputDomElement => {
UsernameValidator.validateUsernameInput(inputDomElement); UsernameValidator.validateUsernameInput(inputDomElement);
}, debounceTimeoutDuration); }, debounceTimeoutDuration);
......
import $ from 'jquery'; import $ from 'jquery';
import _ from 'underscore'; import { last } from 'lodash';
import { scaleLinear, scaleThreshold } from 'd3-scale'; import { scaleLinear, scaleThreshold } from 'd3-scale';
import { select } from 'd3-selection'; import { select } from 'd3-selection';
import dateFormat from 'dateformat'; import dateFormat from 'dateformat';
...@@ -164,11 +164,11 @@ export default class ActivityCalendar { ...@@ -164,11 +164,11 @@ export default class ActivityCalendar {
.enter() .enter()
.append('g') .append('g')
.attr('transform', (group, i) => { .attr('transform', (group, i) => {
_.each(group, (stamp, a) => { group.forEach((stamp, a) => {
if (a === 0 && stamp.day === this.firstDayOfWeek) { if (a === 0 && stamp.day === this.firstDayOfWeek) {
const month = stamp.date.getMonth(); const month = stamp.date.getMonth();
const x = this.daySizeWithSpace * i + 1 + this.daySizeWithSpace; const x = this.daySizeWithSpace * i + 1 + this.daySizeWithSpace;
const lastMonth = _.last(this.months); const lastMonth = last(this.months);
if ( if (
lastMonth == null || lastMonth == null ||
(month !== lastMonth.month && x - this.daySizeWithSpace !== lastMonth.x) (month !== lastMonth.month && x - this.daySizeWithSpace !== lastMonth.x)
......
import { debounce } from 'underscore'; import { debounce } from 'lodash';
import axios from '~/lib/utils/axios_utils'; import axios from '~/lib/utils/axios_utils';
import { __ } from '~/locale'; import { __ } from '~/locale';
import Flash from '~/flash'; import Flash from '~/flash';
......
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