Commit af616eea authored by Mike Greiling's avatar Mike Greiling

Merge branch 'leipert-prettier-arrow-parens-5' into 'master'

Format files with prettier arrowParens [5/15]

See merge request gitlab-org/gitlab!50531
parents 43b4f5b4 c04bd247
......@@ -365,171 +365,6 @@ app/assets/javascripts/lib/utils/text_markdown.js
app/assets/javascripts/lib/utils/text_utility.js
app/assets/javascripts/lib/utils/type_utility.js
## zen-robinson
app/assets/javascripts/lib/utils/unit_format/formatter_factory.js
app/assets/javascripts/lib/utils/url_utility.js
app/assets/javascripts/line_highlighter.js
app/assets/javascripts/locale/ensure_single_line.js
app/assets/javascripts/locale/index.js
app/assets/javascripts/locale/sprintf.js
app/assets/javascripts/logs/components/log_advanced_filters.vue
app/assets/javascripts/logs/logs_tracking_helper.js
app/assets/javascripts/logs/stores/actions.js
app/assets/javascripts/logs/stores/getters.js
app/assets/javascripts/logs/utils.js
app/assets/javascripts/main.js
app/assets/javascripts/manual_ordering.js
app/assets/javascripts/member_expiration_date.js
app/assets/javascripts/members.js
app/assets/javascripts/members/components/avatars/user_avatar.vue
app/assets/javascripts/members/components/filter_sort/members_filtered_search_bar.vue
app/assets/javascripts/members/components/filter_sort/sort_dropdown.vue
app/assets/javascripts/members/store/index.js
app/assets/javascripts/members/utils.js
app/assets/javascripts/merge_conflicts/components/diff_file_editor.js
app/assets/javascripts/merge_conflicts/components/inline_conflict_lines.js
app/assets/javascripts/merge_conflicts/components/parallel_conflict_lines.js
app/assets/javascripts/merge_conflicts/merge_conflict_store.js
app/assets/javascripts/merge_request.js
app/assets/javascripts/merge_request_tabs.js
app/assets/javascripts/milestone.js
app/assets/javascripts/milestone_select.js
app/assets/javascripts/milestones/components/milestone_combobox.vue
app/assets/javascripts/milestones/stores/actions.js
app/assets/javascripts/milestones/stores/mutations.js
## inspiring-lovelace
app/assets/javascripts/mini_pipeline_graph_dropdown.js
app/assets/javascripts/mirrors/mirror_repos.js
app/assets/javascripts/mirrors/ssh_mirror.js
app/assets/javascripts/monitoring/components/alert_widget.vue
app/assets/javascripts/monitoring/components/alert_widget_form.vue
app/assets/javascripts/monitoring/components/charts/annotations.js
app/assets/javascripts/monitoring/components/charts/anomaly.vue
app/assets/javascripts/monitoring/components/charts/bar.vue
app/assets/javascripts/monitoring/components/charts/column.vue
app/assets/javascripts/monitoring/components/charts/heatmap.vue
app/assets/javascripts/monitoring/components/charts/options.js
app/assets/javascripts/monitoring/components/charts/stacked_column.vue
app/assets/javascripts/monitoring/components/charts/time_series.vue
app/assets/javascripts/monitoring/components/dashboard_panel.vue
app/assets/javascripts/monitoring/components/duplicate_dashboard_form.vue
app/assets/javascripts/monitoring/components/duplicate_dashboard_modal.vue
app/assets/javascripts/monitoring/components/embeds/embed_group.vue
app/assets/javascripts/monitoring/components/embeds/metric_embed.vue
app/assets/javascripts/monitoring/components/empty_state.vue
app/assets/javascripts/monitoring/components/variables/dropdown_field.vue
app/assets/javascripts/monitoring/csv_export.js
app/assets/javascripts/monitoring/requests/index.js
app/assets/javascripts/monitoring/services/alerts_service.js
app/assets/javascripts/monitoring/stores/embed_group/getters.js
app/assets/javascripts/monitoring/stores/mutations.js
app/assets/javascripts/monitoring/stores/utils.js
app/assets/javascripts/monitoring/stores/variable_mapping.js
app/assets/javascripts/monitoring/utils.js
app/assets/javascripts/monitoring/validators.js
app/assets/javascripts/mr_notes/init_notes.js
app/assets/javascripts/mr_notes/stores/getters.js
## cool-dirac
app/assets/javascripts/mr_popover/components/mr_popover.vue
app/assets/javascripts/mr_popover/index.js
app/assets/javascripts/namespace_select.js
app/assets/javascripts/network/branch_graph.js
app/assets/javascripts/new_branch_form.js
app/assets/javascripts/notebook/cells/markdown.vue
app/assets/javascripts/notes.js
app/assets/javascripts/notes/components/diff_with_note.vue
app/assets/javascripts/notes/components/discussion_actions.vue
app/assets/javascripts/notes/components/discussion_counter.vue
app/assets/javascripts/notes/components/discussion_filter.vue
app/assets/javascripts/notes/components/multiline_comment_utils.js
app/assets/javascripts/notes/components/note_actions.vue
app/assets/javascripts/notes/components/note_body.vue
app/assets/javascripts/notes/components/note_form.vue
app/assets/javascripts/notes/components/noteable_discussion.vue
app/assets/javascripts/notes/components/noteable_note.vue
app/assets/javascripts/notes/components/notes_app.vue
app/assets/javascripts/notes/components/toggle_replies_widget.vue
app/assets/javascripts/notes/discussion_filters.js
app/assets/javascripts/notes/mixins/diff_line_note_form.js
app/assets/javascripts/notes/mixins/discussion_navigation.js
app/assets/javascripts/notes/mixins/resolvable.js
app/assets/javascripts/notes/sort_discussions.js
app/assets/javascripts/notes/stores/actions.js
app/assets/javascripts/notes/stores/collapse_utils.js
app/assets/javascripts/notes/stores/getters.js
app/assets/javascripts/notes/stores/mutations.js
app/assets/javascripts/notes/stores/utils.js
app/assets/javascripts/notes/utils.js
app/assets/javascripts/notifications_dropdown.js
## practical-cohen
app/assets/javascripts/onboarding_issues/index.js
app/assets/javascripts/operation_settings/store/actions.js
app/assets/javascripts/operation_settings/store/index.js
app/assets/javascripts/packages/details/components/package_files.vue
app/assets/javascripts/packages/list/components/packages_list.vue
app/assets/javascripts/packages/list/components/packages_list_app.vue
app/assets/javascripts/packages/list/components/packages_sort.vue
app/assets/javascripts/packages/list/stores/getters.js
app/assets/javascripts/packages/shared/components/package_tags.vue
app/assets/javascripts/packages/shared/utils.js
app/assets/javascripts/pages/admin/admin.js
app/assets/javascripts/pages/admin/application_settings/payload_previewer.js
app/assets/javascripts/pages/admin/broadcast_messages/broadcast_message.js
app/assets/javascripts/pages/admin/jobs/index/components/stop_jobs_modal.vue
app/assets/javascripts/pages/admin/projects/index.js
app/assets/javascripts/pages/admin/projects/index/index.js
app/assets/javascripts/pages/admin/users/index.js
app/assets/javascripts/pages/admin/users/new/index.js
app/assets/javascripts/pages/dashboard/projects/index/components/customize_homepage_banner.vue
app/assets/javascripts/pages/dashboard/projects/index/init_customize_homepage_banner.js
app/assets/javascripts/pages/groups/new/group_path_validator.js
app/assets/javascripts/pages/groups/shared/group_tabs.js
app/assets/javascripts/pages/milestones/shared/components/delete_milestone_modal.vue
app/assets/javascripts/pages/milestones/shared/components/promote_milestone_modal.vue
app/assets/javascripts/pages/milestones/shared/delete_milestone_modal_init.js
app/assets/javascripts/pages/milestones/shared/promote_milestone_modal_init.js
app/assets/javascripts/pages/profiles/show/index.js
app/assets/javascripts/pages/projects/blob/show/index.js
app/assets/javascripts/pages/projects/graphs/charts/index.js
app/assets/javascripts/pages/projects/graphs/components/code_coverage.vue
app/assets/javascripts/pages/projects/issues/service_desk/filtered_search.js
## vigorous-wiles
app/assets/javascripts/pages/projects/issues/show.js
app/assets/javascripts/pages/projects/jobs/index/index.js
app/assets/javascripts/pages/projects/labels/components/promote_label_modal.vue
app/assets/javascripts/pages/projects/labels/index/index.js
app/assets/javascripts/pages/projects/merge_requests/creations/new/compare.js
app/assets/javascripts/pages/projects/new/index.js
app/assets/javascripts/pages/projects/pages_domains/form.js
app/assets/javascripts/pages/projects/pipeline_schedules/shared/components/target_branch_dropdown.js
app/assets/javascripts/pages/projects/pipeline_schedules/shared/components/timezone_dropdown.js
app/assets/javascripts/pages/projects/pipelines/init_pipelines.js
app/assets/javascripts/pages/projects/project.js
app/assets/javascripts/pages/projects/settings/ci_cd/show/index.js
app/assets/javascripts/pages/projects/shared/permissions/external.js
app/assets/javascripts/pages/projects/shared/permissions/index.js
app/assets/javascripts/pages/projects/tags/index/index.js
app/assets/javascripts/pages/search/show/refresh_counts.js
app/assets/javascripts/pages/sessions/new/length_validator.js
app/assets/javascripts/pages/sessions/new/preserve_url_fragment.js
app/assets/javascripts/pages/sessions/new/signin_tabs_memoizer.js
app/assets/javascripts/pages/sessions/new/username_validator.js
app/assets/javascripts/pages/shared/mount_badge_settings.js
app/assets/javascripts/pages/shared/wikis/wikis.js
app/assets/javascripts/pages/users/activity_calendar.js
app/assets/javascripts/pages/users/index.js
app/assets/javascripts/pdf/index.vue
app/assets/javascripts/pdf/page/index.vue
app/assets/javascripts/performance/utils.js
app/assets/javascripts/performance_bar/components/detailed_metric.vue
app/assets/javascripts/performance_bar/components/request_selector.vue
app/assets/javascripts/performance_bar/index.js
app/assets/javascripts/performance_bar/performance_bar_log.js
## musing-khayyam
app/assets/javascripts/performance_bar/services/performance_bar_service.js
app/assets/javascripts/performance_bar/stores/performance_bar_store.js
......
......@@ -106,7 +106,7 @@ export const scaledSIFormatter = (unit = '', prefixOffset = 0) => {
const multiplicative = ['k', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y'];
const symbols = [...fractional, '', ...multiplicative];
const units = symbols.slice(fractional.length + prefixOffset).map(prefix => {
const units = symbols.slice(fractional.length + prefixOffset).map((prefix) => {
return `${prefix}${unit}`;
});
......@@ -126,7 +126,7 @@ export const scaledBinaryFormatter = (unit = '', prefixOffset = 0) => {
const multiplicative = ['Ki', 'Mi', 'Gi', 'Ti', 'Pi', 'Ei', 'Zi', 'Yi'];
const symbols = ['', ...multiplicative];
const units = symbols.slice(prefixOffset).map(prefix => {
const units = symbols.slice(prefixOffset).map((prefix) => {
return `${prefix}${unit}`;
});
......
......@@ -112,13 +112,13 @@ export function mergeUrlParams(params, url, options = {}) {
const mergedKeys = sort ? Object.keys(merged).sort() : Object.keys(merged);
const newQuery = mergedKeys
.filter(key => merged[key] !== null)
.map(key => {
.filter((key) => merged[key] !== null)
.map((key) => {
let value = merged[key];
const encodedKey = encodeURIComponent(key);
if (spreadArrays && Array.isArray(value)) {
value = merged[key]
.map(arrayValue => encodeURIComponent(arrayValue))
.map((arrayValue) => encodeURIComponent(arrayValue))
.join(`&${encodedKey}[]=`);
return `${encodedKey}[]=${value}`;
}
......@@ -150,11 +150,11 @@ export function removeParams(params, url = window.location.href, skipEncoding =
return url;
}
const removableParams = skipEncoding ? params : params.map(param => encodeURIComponent(param));
const removableParams = skipEncoding ? params : params.map((param) => encodeURIComponent(param));
const updatedQuery = query
.split('&')
.filter(paramPair => {
.filter((paramPair) => {
const [foundParam] = paramPair.split('=');
return removableParams.indexOf(foundParam) < 0;
})
......@@ -237,7 +237,7 @@ export function redirectTo(url) {
return window.location.assign(url);
}
export const escapeFileUrl = fileUrl => encodeURIComponent(fileUrl).replace(/%2F/g, '/');
export const escapeFileUrl = (fileUrl) => encodeURIComponent(fileUrl).replace(/%2F/g, '/');
export function webIDEUrl(route = undefined) {
let returnUrl = `${gon.relative_url_root || ''}/-/ide/`;
......@@ -396,7 +396,7 @@ export function queryToObject(query, options = {}) {
*/
export function objectToQuery(obj) {
return Object.keys(obj)
.map(k => `${encodeURIComponent(k)}=${encodeURIComponent(obj[k])}`)
.map((k) => `${encodeURIComponent(k)}=${encodeURIComponent(obj[k])}`)
.join('&');
}
......@@ -420,7 +420,7 @@ export const setUrlParams = (
const queryString = urlObj.search;
const searchParams = clearParams ? new URLSearchParams('') : new URLSearchParams(queryString);
Object.keys(params).forEach(key => {
Object.keys(params).forEach((key) => {
if (params[key] === null || params[key] === undefined) {
searchParams.delete(key);
} else if (Array.isArray(params[key])) {
......
......@@ -55,7 +55,7 @@ LineHighlighter.prototype.bindEvents = function () {
$fileHolder.on('click', 'a[data-line-number]', this.clickHandler);
$fileHolder.on('highlight:line', this.highlightHash);
window.addEventListener('hashchange', e => this.highlightHash(e.target.location.hash));
window.addEventListener('hashchange', (e) => this.highlightHash(e.target.location.hash));
};
LineHighlighter.prototype.highlightHash = function (newHash) {
......
......@@ -18,7 +18,7 @@ module.exports = function ensureSingleLine(str) {
if (str.includes('\n') || str.includes('\r')) {
return str
.split(SPLIT_REGEX)
.filter(s => s !== '')
.filter((s) => s !== '')
.join(' ');
}
return str;
......
......@@ -11,7 +11,7 @@ delete window.translations;
@param text The text to be translated
@returns {String} The translated text
*/
const gettext = text => locale.gettext(ensureSingleLine(text));
const gettext = (text) => locale.gettext(ensureSingleLine(text));
/**
Translate the text with a number
......@@ -56,7 +56,7 @@ const pgettext = (keyOrContext, key) => {
@param formatOptions for available options, please see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat
@returns {Intl.DateTimeFormat}
*/
const createDateTimeFormat = formatOptions => Intl.DateTimeFormat(languageCode(), formatOptions);
const createDateTimeFormat = (formatOptions) => Intl.DateTimeFormat(languageCode(), formatOptions);
export { languageCode };
export { gettext as __ };
......
......@@ -15,7 +15,7 @@ export default (input, parameters, escapeParameters = true) => {
let output = input;
if (parameters) {
Object.keys(parameters).forEach(parameterName => {
Object.keys(parameters).forEach((parameterName) => {
const parameterValue = parameters[parameterName];
const escapedParameterValue = escapeParameters ? escape(parameterValue) : parameterValue;
output = output.replace(new RegExp(`%{${parameterName}}`, 'g'), escapedParameterValue);
......
......@@ -42,7 +42,7 @@ export default {
*/
podOptions() {
if (this.pods.options.length) {
return this.pods.options.map(podName => ({ value: podName, title: podName }));
return this.pods.options.map((podName) => ({ value: podName, title: podName }));
}
return null;
},
......
......@@ -8,7 +8,7 @@ import Tracking from '~/tracking';
* 3. Change the time range
* 4. Use the search bar
*/
const trackLogs = label =>
const trackLogs = (label) =>
Tracking.event(document.body.dataset.page, 'logs_view', {
label,
property: 'count',
......
......@@ -11,14 +11,14 @@ const requestUntilData = (url, params) =>
backOff((next, stop) => {
axios
.get(url, { params })
.then(res => {
.then((res) => {
if (res.status === httpStatusCodes.ACCEPTED) {
next();
return;
}
stop(res);
})
.catch(err => {
.catch((err) => {
stop(err);
});
});
......@@ -66,12 +66,12 @@ const requestLogsUntilData = ({ commit, state }) => {
const filtersToParams = (filters = []) => {
// Strings become part of the `search`
const search = filters
.filter(f => typeof f === 'string')
.filter((f) => typeof f === 'string')
.join(' ')
.trim();
// null podName to show all pods
const podName = filters.find(f => f?.type === TOKEN_TYPE_POD_NAME)?.value?.data ?? null;
const podName = filters.find((f) => f?.type === TOKEN_TYPE_POD_NAME)?.value?.data ?? null;
return { search, podName };
};
......
......@@ -3,9 +3,9 @@ import { formatDate } from '../utils';
const mapTrace = ({ timestamp = null, pod = '', message = '' }) =>
[timestamp ? formatDate(timestamp) : '', pod, message].join(' | ');
export const trace = state => state.logs.lines.map(mapTrace).join('\n');
export const trace = (state) => state.logs.lines.map(mapTrace).join('\n');
export const showAdvancedFilters = state => {
export const showAdvancedFilters = (state) => {
if (state.environments.current) {
const environment = state.environments.options.find(
({ name }) => name === state.environments.current,
......
......@@ -22,4 +22,4 @@ export const getTimeRange = (seconds = 0) => {
};
};
export const formatDate = timestamp => dateFormat(timestamp, dateFormatMask);
export const formatDate = (timestamp) => dateFormat(timestamp, dateFormatMask);
......@@ -298,7 +298,7 @@ document.addEventListener('DOMContentLoaded', () => {
if (flashContainer && flashContainer.children.length) {
flashContainer
.querySelectorAll('.flash-alert, .flash-notice, .flash-success')
.forEach(flashEl => {
.forEach((flashEl) => {
removeFlashClickListener(flashEl);
});
}
......
......@@ -39,7 +39,7 @@ const initManualOrdering = (draggableSelector = 'li.issue') => {
onStart: () => {
sortableStart();
},
onUpdate: event => {
onUpdate: (event) => {
const el = event.item;
const url = el.getAttribute('url') || el.dataset.url;
......
......@@ -24,8 +24,8 @@ export default function memberExpirationDate(selector = '.js-access-expiration-d
format: 'yyyy-mm-dd',
minDate: new Date(),
container: $input.parent().get(0),
parse: dateString => parsePikadayDate(dateString),
toString: date => pikadayToString(date),
parse: (dateString) => parsePikadayDate(dateString),
toString: (date) => pikadayToString(date),
onSelect(dateText) {
$input.val(calendar.toString(dateText));
......
......@@ -46,7 +46,7 @@ export default class Members {
return $el.data('id');
},
toggleLabel: (selected, $el) => this.dropdownToggleLabel(selected, $el, $btn),
clicked: options => this.dropdownClicked(options),
clicked: (options) => this.dropdownClicked(options),
});
});
}
......
......@@ -38,7 +38,7 @@ export default {
return this.member.user;
},
badges() {
return generateBadges(this.member, this.isCurrentUser).filter(badge => badge.show);
return generateBadges(this.member, this.isCurrentUser).filter((badge) => badge.show);
},
statusEmoji() {
return this.user?.status?.emoji;
......
......@@ -45,7 +45,7 @@ export default {
computed: {
...mapState(['sourceId', 'filteredSearchBar', 'canManageMembers']),
tokens() {
return this.$options.availableTokens.filter(token => {
return this.$options.availableTokens.filter((token) => {
if (
Object.prototype.hasOwnProperty.call(token, 'requiredPermissions') &&
!this[token.requiredPermissions]
......@@ -61,8 +61,8 @@ export default {
const query = queryToObject(window.location.search);
const tokens = this.tokens
.filter(token => query[token.type])
.map(token => ({
.filter((token) => query[token.type])
.map((token) => ({
type: token.type,
value: {
data: query[token.type],
......
......@@ -14,7 +14,7 @@ export default {
return parseSortParam(this.tableSortableFields);
},
activeOption() {
return FIELDS.find(field => field.key === this.sort.sortByKey);
return FIELDS.find((field) => field.key === this.sort.sortByKey);
},
activeOptionLabel() {
return this.activeOption?.label;
......@@ -23,18 +23,18 @@ export default {
return !this.sort.sortDesc;
},
filteredOptions() {
return FIELDS.filter(field => this.tableSortableFields.includes(field.key) && field.sort).map(
field => ({
key: field.key,
label: field.label,
href: buildSortHref({
sortBy: field.key,
sortDesc: false,
filteredSearchBarTokens: this.filteredSearchBar.tokens,
filteredSearchBarSearchParam: this.filteredSearchBar.searchParam,
}),
return FIELDS.filter(
(field) => this.tableSortableFields.includes(field.key) && field.sort,
).map((field) => ({
key: field.key,
label: field.label,
href: buildSortHref({
sortBy: field.key,
sortDesc: false,
filteredSearchBarTokens: this.filteredSearchBar.tokens,
filteredSearchBarSearchParam: this.filteredSearchBar.searchParam,
}),
);
}));
},
},
methods: {
......
......@@ -2,7 +2,7 @@ import createState from 'ee_else_ce/members/store/state';
import mutations from 'ee_else_ce/members/store/mutations';
import * as actions from 'ee_else_ce/members/store/actions';
export default initialState => ({
export default (initialState) => ({
state: createState(initialState),
actions,
mutations,
......
......@@ -21,7 +21,7 @@ export const generateBadges = (member, isCurrentUser) => [
},
];
export const isGroup = member => {
export const isGroup = (member) => {
return Boolean(member.sharedWithGroup);
};
......@@ -37,7 +37,7 @@ export const canRemove = (member, sourceId) => {
return isDirectMember(member, sourceId) && member.canRemove;
};
export const canResend = member => {
export const canResend = (member) => {
return Boolean(member.invite?.canResend);
};
......@@ -47,11 +47,11 @@ export const canUpdate = (member, currentUserId, sourceId) => {
);
};
export const parseSortParam = sortableFields => {
export const parseSortParam = (sortableFields) => {
const sortParam = getParameterByName('sort');
const sortedField = FIELDS.filter(field => sortableFields.includes(field.key)).find(
field => field.sort?.asc === sortParam || field.sort?.desc === sortParam,
const sortedField = FIELDS.filter((field) => sortableFields.includes(field.key)).find(
(field) => field.sort?.asc === sortParam || field.sort?.desc === sortParam,
);
if (!sortedField) {
......@@ -70,7 +70,7 @@ export const buildSortHref = ({
filteredSearchBarTokens,
filteredSearchBarSearchParam,
}) => {
const sortDefinition = FIELDS.find(field => field.key === sortBy)?.sort;
const sortDefinition = FIELDS.find((field) => field.key === sortBy)?.sort;
if (!sortDefinition) {
return '';
......
......@@ -6,7 +6,7 @@ import axios from '~/lib/utils/axios_utils';
import { deprecatedCreateFlash as flash } from '~/flash';
import { __ } from '~/locale';
(global => {
((global) => {
global.mergeConflicts = global.mergeConflicts || {};
global.mergeConflicts.diffFileEditor = Vue.extend({
......
......@@ -4,7 +4,7 @@ import Vue from 'vue';
import actionsMixin from '../mixins/line_conflict_actions';
import utilsMixin from '../mixins/line_conflict_utils';
(global => {
((global) => {
global.mergeConflicts = global.mergeConflicts || {};
global.mergeConflicts.inlineConflictLines = Vue.extend({
......
......@@ -4,7 +4,7 @@ import Vue from 'vue';
import actionsMixin from '../mixins/line_conflict_actions';
import utilsMixin from '../mixins/line_conflict_utils';
(global => {
((global) => {
global.mergeConflicts = global.mergeConflicts || {};
global.mergeConflicts.parallelConflictLines = Vue.extend({
......
......@@ -5,7 +5,7 @@ import Vue from 'vue';
import Cookies from 'js-cookie';
import { s__ } from '~/locale';
(global => {
((global) => {
global.mergeConflicts = global.mergeConflicts || {};
const diffViewType = Cookies.get('diff_view');
......@@ -48,7 +48,7 @@ import { s__ } from '~/locale';
},
decorateFiles(files) {
files.forEach(file => {
files.forEach((file) => {
file.content = '';
file.resolutionData = {};
file.promptDiscardConfirmation = false;
......@@ -72,7 +72,7 @@ import { s__ } from '~/locale';
setInlineLine(file) {
file.inlineLines = [];
file.sections.forEach(section => {
file.sections.forEach((section) => {
let currentLineType = 'new';
const { conflict, lines, id } = section;
......@@ -80,7 +80,7 @@ import { s__ } from '~/locale';
file.inlineLines.push(this.getHeadHeaderLine(id));
}
lines.forEach(line => {
lines.forEach((line) => {
const { type } = line;
if ((type === 'new' || type === 'old') && currentLineType !== type) {
......@@ -102,7 +102,7 @@ import { s__ } from '~/locale';
file.parallelLines = [];
const linesObj = { left: [], right: [] };
file.sections.forEach(section => {
file.sections.forEach((section) => {
const { conflict, lines, id } = section;
if (conflict) {
......@@ -110,7 +110,7 @@ import { s__ } from '~/locale';
linesObj.right.push(this.getHeadHeaderLine(id));
}
lines.forEach(line => {
lines.forEach((line) => {
const { type } = line;
if (conflict) {
......@@ -156,9 +156,9 @@ import { s__ } from '~/locale';
const { files } = this.state.conflictsData;
let count = 0;
files.forEach(file => {
files.forEach((file) => {
if (file.type === CONFLICT_TYPES.TEXT) {
file.sections.forEach(section => {
file.sections.forEach((section) => {
if (section.conflict) {
count += 1;
}
......@@ -287,14 +287,14 @@ import { s__ } from '~/locale';
},
restoreFileLinesState(file) {
file.inlineLines.forEach(line => {
file.inlineLines.forEach((line) => {
if (line.hasConflict || line.isHeader) {
line.isSelected = false;
line.isUnselected = false;
}
});
file.parallelLines.forEach(lines => {
file.parallelLines.forEach((lines) => {
const left = lines[0];
const right = lines[1];
const isLeftMatch = left.hasConflict || left.isHeader;
......@@ -362,7 +362,7 @@ import { s__ } from '~/locale';
files: [],
};
this.state.conflictsData.files.forEach(file => {
this.state.conflictsData.files.forEach((file) => {
const addFile = {
old_path: file.old_path,
new_path: file.new_path,
......@@ -388,13 +388,13 @@ import { s__ } from '~/locale';
handleSelected(file, sectionId, selection) {
Vue.set(file.resolutionData, sectionId, selection);
file.inlineLines.forEach(line => {
file.inlineLines.forEach((line) => {
if (line.id === sectionId && (line.hasConflict || line.isHeader)) {
this.markLine(line, selection);
}
});
file.parallelLines.forEach(lines => {
file.parallelLines.forEach((lines) => {
const left = lines[0];
const right = lines[1];
const hasSameId = right.id === sectionId || left.id === sectionId;
......@@ -426,7 +426,7 @@ import { s__ } from '~/locale';
},
fileTextTypePresent() {
return this.state.conflictsData.files.some(f => f.type === CONFLICT_TYPES.TEXT);
return this.state.conflictsData.files.some((f) => f.type === CONFLICT_TYPES.TEXT);
},
};
})(window.gl || (window.gl = {}));
......@@ -31,7 +31,7 @@ function MergeRequest(opts) {
fieldName: 'description',
selector: '.detail-page-description',
lockVersion: this.$el.data('lockVersion'),
onSuccess: result => {
onSuccess: (result) => {
document.querySelector('#task_status').innerText = result.task_status;
document.querySelector('#task_status_short').innerText = result.task_status_short;
},
......@@ -69,8 +69,8 @@ MergeRequest.prototype.initMRBtnListeners = function () {
const draftToggles = document.querySelectorAll('.js-draft-toggle-button');
if (draftToggles.length) {
draftToggles.forEach(draftToggle => {
draftToggle.addEventListener('click', e => {
draftToggles.forEach((draftToggle) => {
draftToggle.addEventListener('click', (e) => {
e.preventDefault();
e.stopImmediatePropagation();
......@@ -127,7 +127,7 @@ MergeRequest.prototype.submitNoteForm = function (form, $button) {
};
MergeRequest.prototype.initCommitMessageListeners = function () {
$(document).on('click', 'a.js-with-description-link', e => {
$(document).on('click', 'a.js-with-description-link', (e) => {
const textarea = $('textarea.js-commit-message');
e.preventDefault();
......@@ -136,7 +136,7 @@ MergeRequest.prototype.initCommitMessageListeners = function () {
$('.js-without-description-hint').show();
});
$(document).on('click', 'a.js-without-description-link', e => {
$(document).on('click', 'a.js-without-description-link', (e) => {
const textarea = $('textarea.js-commit-message');
e.preventDefault();
......@@ -180,7 +180,7 @@ MergeRequest.toggleDraftStatus = function (title, isReady) {
const draftToggles = document.querySelectorAll('.js-draft-toggle-button');
if (draftToggles.length) {
draftToggles.forEach(el => {
draftToggles.forEach((el) => {
const draftToggle = el;
const url = setUrlParams(
{ 'merge_request[wip_event]': isReady ? 'wip' : 'unwip' },
......
......@@ -128,7 +128,7 @@ export default class MergeRequestTabs {
bindEvents() {
$('.merge-request-tabs a[data-toggle="tabvue"]').on('click', this.clickTab);
window.addEventListener('popstate', event => {
window.addEventListener('popstate', (event) => {
if (event.state && event.state.action) {
this.tabShown(event.state.action, event.target.location);
this.currentAction = event.state.action;
......@@ -177,14 +177,14 @@ export default class MergeRequestTabs {
this.currentTab = action;
if (this.mergeRequestTabPanesAll) {
this.mergeRequestTabPanesAll.forEach(el => {
this.mergeRequestTabPanesAll.forEach((el) => {
const tabPane = el;
tabPane.style.display = 'none';
});
}
if (this.mergeRequestTabsAll) {
this.mergeRequestTabsAll.forEach(el => {
this.mergeRequestTabsAll.forEach((el) => {
el.classList.remove('active');
});
}
......
......@@ -11,7 +11,7 @@ export default class Milestone {
}
bindTabsSwitching() {
return $('a[data-toggle="tab"]').on('show.bs.tab', e => {
return $('a[data-toggle="tab"]').on('show.bs.tab', (e) => {
const $target = $(e.target);
window.location.hash = $target.attr('href');
......
......@@ -89,7 +89,7 @@ export default class MilestoneSelect {
return getMilestones(contextId, reqParams)
.then(({ data }) =>
data
.map(m => ({
.map((m) => ({
...m,
// Public API includes `title` instead of `name`.
name: m.title,
......@@ -105,7 +105,7 @@ export default class MilestoneSelect {
return 0;
}),
)
.then(data => {
.then((data) => {
const extraOptions = [];
if (showAny) {
extraOptions.push({
......@@ -146,7 +146,7 @@ export default class MilestoneSelect {
$(`[data-milestone-id="${selectedMilestone}"] > a`).addClass('is-active');
});
},
renderRow: milestone => {
renderRow: (milestone) => {
const milestoneName = milestone.title || milestone.name;
let milestoneDisplayName = escape(milestoneName);
......@@ -178,8 +178,8 @@ export default class MilestoneSelect {
},
defaultLabel,
fieldName: $dropdown.data('fieldName'),
text: milestone => escape(milestone.title),
id: milestone => {
text: (milestone) => escape(milestone.title),
id: (milestone) => {
if (milestone !== undefined) {
if (!useId && !$dropdown.is('.js-issuable-form-dropdown')) {
return milestone.name;
......@@ -193,7 +193,7 @@ export default class MilestoneSelect {
// display:block overrides the hide-collapse rule
return $value.css('display', '');
},
opened: e => {
opened: (e) => {
const $el = $(e.currentTarget);
if ($dropdown.hasClass('js-issue-board-sidebar') || options.handleClick) {
selectedMilestone = $dropdown[0].dataset.selected || selectedMilestoneDefault;
......@@ -202,7 +202,7 @@ export default class MilestoneSelect {
$(`[data-milestone-id="${selectedMilestone}"] > a`, $el).addClass('is-active');
},
vue: $dropdown.hasClass('js-issue-board-sidebar'),
clicked: clickEvent => {
clicked: (clickEvent) => {
const { e } = clickEvent;
let selected = clickEvent.selectedObj;
......
......@@ -112,7 +112,7 @@ export default {
value: {
immediate: true,
handler() {
const milestoneTitles = this.value.map(milestone =>
const milestoneTitles = this.value.map((milestone) =>
milestone.title ? milestone.title : milestone,
);
if (!isEqual(milestoneTitles, this.selectedMilestones)) {
......
......@@ -41,10 +41,10 @@ export const fetchProjectMilestones = ({ commit, state }) => {
commit(types.REQUEST_START);
Api.projectMilestones(state.projectId)
.then(response => {
.then((response) => {
commit(types.RECEIVE_PROJECT_MILESTONES_SUCCESS, response);
})
.catch(error => {
.catch((error) => {
commit(types.RECEIVE_PROJECT_MILESTONES_ERROR, error);
})
.finally(() => {
......@@ -56,10 +56,10 @@ export const fetchGroupMilestones = ({ commit, state }) => {
commit(types.REQUEST_START);
Api.groupMilestones(state.groupId)
.then(response => {
.then((response) => {
commit(types.RECEIVE_GROUP_MILESTONES_SUCCESS, response);
})
.catch(error => {
.catch((error) => {
commit(types.RECEIVE_GROUP_MILESTONES_ERROR, error);
})
.finally(() => {
......@@ -76,10 +76,10 @@ export const searchProjectMilestones = ({ commit, state }) => {
commit(types.REQUEST_START);
Api.projectSearch(state.projectId, options)
.then(response => {
.then((response) => {
commit(types.RECEIVE_PROJECT_MILESTONES_SUCCESS, response);
})
.catch(error => {
.catch((error) => {
commit(types.RECEIVE_PROJECT_MILESTONES_ERROR, error);
})
.finally(() => {
......@@ -95,10 +95,10 @@ export const searchGroupMilestones = ({ commit, state }) => {
commit(types.REQUEST_START);
Api.groupMilestones(state.groupId, options)
.then(response => {
.then((response) => {
commit(types.RECEIVE_GROUP_MILESTONES_SUCCESS, response);
})
.catch(error => {
.catch((error) => {
commit(types.RECEIVE_GROUP_MILESTONES_ERROR, error);
})
.finally(() => {
......
......@@ -22,7 +22,7 @@ export default {
},
[types.REMOVE_SELECTED_MILESTONE](state, selectedMilestone) {
const filteredMilestones = state.selectedMilestones.filter(
milestone => milestone !== selectedMilestone,
(milestone) => milestone !== selectedMilestone,
);
Vue.set(state, 'selectedMilestones', filteredMilestones);
},
......
......@@ -47,7 +47,7 @@ export default class MiniPipelineGraph {
$(document).on(
'click',
`${this.container} .js-builds-dropdown-list a.mini-pipeline-graph-dropdown-item`,
e => {
(e) => {
e.stopPropagation();
},
);
......
......@@ -80,7 +80,7 @@ export default class MirrorRepos {
this.debouncedUpdateUrl = debounce(() => this.updateUrl(), 200);
this.$urlInput.on('input', () => this.debouncedUpdateUrl());
this.$protectedBranchesInput.on('change', () => this.updateProtectedBranches());
this.$table.on('click', '.js-delete-mirror', event => this.deleteMirror(event));
this.$table.on('click', '.js-delete-mirror', (event) => this.deleteMirror(event));
}
togglePassword() {
......
......@@ -29,10 +29,10 @@ export default class SSHMirror {
this.handleRepositoryUrlInput(true);
this.$repositoryUrl.on('keyup', () => this.handleRepositoryUrlInput());
this.$knownHosts.on('keyup', e => this.handleSSHKnownHostsInput(e));
this.$dropdownAuthType.on('change', e => this.handleAuthTypeChange(e));
this.$btnDetectHostKeys.on('click', e => this.handleDetectHostKeys(e));
this.$btnSSHHostsShowAdvanced.on('click', e => this.handleSSHHostsAdvanced(e));
this.$knownHosts.on('keyup', (e) => this.handleSSHKnownHostsInput(e));
this.$dropdownAuthType.on('change', (e) => this.handleAuthTypeChange(e));
this.$btnDetectHostKeys.on('click', (e) => this.handleDetectHostKeys(e));
this.$btnSSHHostsShowAdvanced.on('click', (e) => this.handleSSHHostsAdvanced(e));
}
/**
......@@ -100,7 +100,7 @@ export default class SSHMirror {
})
.catch(stop);
})
.then(res => {
.then((res) => {
$btnLoadSpinner.addClass('d-none');
// Once data is received, we show verification info along with Host keys and fingerprints
this.$hostKeysInformation
......@@ -160,7 +160,7 @@ export default class SSHMirror {
showSSHInformation(sshHostKeys) {
const $fingerprintsList = this.$hostKeysInformation.find('.js-fingerprints-list');
let fingerprints = '';
sshHostKeys.fingerprints.forEach(fingerprint => {
sshHostKeys.fingerprints.forEach((fingerprint) => {
const escFingerprints = escape(fingerprint.fingerprint);
fingerprints += `<code>${escFingerprints}</code>`;
});
......
......@@ -97,12 +97,12 @@ export default {
return Boolean(this.firingAlerts.length);
},
firingAlerts() {
return values(this.alertsToManage).filter(alert =>
return values(this.alertsToManage).filter((alert) =>
this.passedAlertThreshold(this.getQueryData(alert), alert),
);
},
formattedFiringAlerts() {
return this.firingAlerts.map(alert => this.formatAlertSummary(alert.alert_path));
return this.firingAlerts.map((alert) => this.formatAlertSummary(alert.alert_path));
},
configuredAlert() {
return this.hasAlerts ? values(this.alertsToManage)[0].metricId : '';
......@@ -116,13 +116,13 @@ export default {
fetchAlertData() {
this.isLoading = true;
const queriesWithAlerts = this.relevantQueries.filter(query => query.alert_path);
const queriesWithAlerts = this.relevantQueries.filter((query) => query.alert_path);
return Promise.all(
queriesWithAlerts.map(query =>
queriesWithAlerts.map((query) =>
this.service
.readAlert(query.alert_path)
.then(alertAttributes => this.setAlert(alertAttributes, query.metricId)),
.then((alertAttributes) => this.setAlert(alertAttributes, query.metricId)),
),
)
.then(() => {
......@@ -141,7 +141,7 @@ export default {
},
formatAlertSummary(alertPath) {
const alert = this.alertsToManage[alertPath];
const alertQuery = this.relevantQueries.find(query => query.metricId === alert.metricId);
const alertQuery = this.relevantQueries.find((query) => query.metricId === alert.metricId);
return `${alertQuery.label} ${alert.operator} ${alert.threshold}`;
},
......@@ -150,19 +150,19 @@ export default {
switch (operator) {
case OPERATORS.greaterThan:
return data.some(value => value > threshold);
return data.some((value) => value > threshold);
case OPERATORS.lessThan:
return data.some(value => value < threshold);
return data.some((value) => value < threshold);
case OPERATORS.equalTo:
return data.some(value => value === threshold);
return data.some((value) => value === threshold);
default:
return false;
}
},
getQueryData(alert) {
const alertQuery = this.relevantQueries.find(query => query.metricId === alert.metricId);
const alertQuery = this.relevantQueries.find((query) => query.metricId === alert.metricId);
return get(alertQuery, 'result[0].values', []).map(value => get(value, '[1]', null));
return get(alertQuery, 'result[0].values', []).map((value) => get(value, '[1]', null));
},
showModal() {
this.$root.$emit('bv::show::modal', this.modalId);
......@@ -179,7 +179,7 @@ export default {
this.isLoading = true;
this.service
.createAlert(newAlert)
.then(alertAttributes => {
.then((alertAttributes) => {
this.setAlert(alertAttributes, prometheus_metric_id);
this.isLoading = false;
this.hideModal();
......@@ -194,7 +194,7 @@ export default {
this.isLoading = true;
this.service
.updateAlert(alert, updatedAlert)
.then(alertAttributes => {
.then((alertAttributes) => {
this.setAlert(alertAttributes, this.alertsToManage[alert].metricId);
this.isLoading = false;
this.hideModal();
......
......@@ -99,7 +99,7 @@ export default {
return this.alertQuery.length ? true : null;
},
currentQuery() {
return this.relevantQueries.find(query => query.metricId === this.prometheusMetricId) || {};
return this.relevantQueries.find((query) => query.metricId === this.prometheusMetricId) || {};
},
formDisabled() {
// We need a prometheusMetricId to determine whether we're
......@@ -151,7 +151,7 @@ export default {
},
methods: {
selectQuery(queryId) {
const existingAlertPath = findKey(this.alertsToManage, alert => alert.metricId === queryId);
const existingAlertPath = findKey(this.alertsToManage, (alert) => alert.metricId === queryId);
const existingAlert = this.alertsToManage[existingAlertPath];
if (existingAlert) {
......
......@@ -52,7 +52,7 @@ export const annotationsYAxis = {
* @param {Object} annotation object
* @returns {Object} markLine object
*/
export const parseAnnotations = annotations =>
export const parseAnnotations = (annotations) =>
annotations.reduce(
(acc, annotation) => {
acc.lines.push({
......@@ -87,7 +87,7 @@ export const parseAnnotations = annotations =>
*/
export const generateAnnotationsSeries = ({ deployments = [], annotations = [] } = {}) => {
// deployment data points
const data = deployments.map(deployment => {
const data = deployments.map((deployment) => {
return {
name: 'deployments',
value: [deployment.createdAt, annotationsYAxisCoords.pos],
......
......@@ -62,7 +62,7 @@ export default {
},
computed: {
series() {
return this.graphData.metrics.map(metric => {
return this.graphData.metrics.map((metric) => {
const values = metric.result && metric.result[0] ? metric.result[0].values : [];
return {
label: metric.label,
......@@ -78,14 +78,14 @@ export default {
* This offset is the lowest value.
*/
yOffset() {
const values = flattenDeep(this.series.map(ser => ser.data.map(([, y]) => y)));
const values = flattenDeep(this.series.map((ser) => ser.data.map(([, y]) => y)));
const min = values.length ? Math.floor(Math.min(...values)) : 0;
return min < 0 ? -min : 0;
},
metricData() {
const originalMetricQuery = this.graphData.metrics[0];
const metricQuery = produce(originalMetricQuery, draftQuery => {
const metricQuery = produce(originalMetricQuery, (draftQuery) => {
// eslint-disable-next-line no-param-reassign
draftQuery.result[0].values = draftQuery.result[0].values.map(([x, y]) => [
x,
......@@ -112,7 +112,7 @@ export default {
},
showSymbol: true,
itemStyle: {
color: params => {
color: (params) => {
if (this.isDatapointAnomaly(params.dataIndex)) {
return colorValues.anomalySymbol;
}
......@@ -131,7 +131,7 @@ export default {
const yAxisWithOffset = {
axisLabel: {
formatter: num => roundOffFloat(num - this.yOffset, 3).toString(),
formatter: (num) => roundOffFloat(num - this.yOffset, 3).toString(),
},
};
......@@ -156,7 +156,7 @@ export default {
boundarySeries.push(
this.makeBoundarySeries({
name: this.formatLegendLabel(upperSeries),
data: calcOffsetY(upperSeries.data, i => -this.yValue(LOWER, i)),
data: calcOffsetY(upperSeries.data, (i) => -this.yValue(LOWER, i)),
areaStyle: {
color: AREA_COLOR,
opacity: AREA_OPACITY,
......
......@@ -67,12 +67,12 @@ export default {
},
setSvg(name) {
getSvgIconPathContent(name)
.then(path => {
.then((path) => {
if (path) {
this.$set(this.svgs, name, `path://${path}`);
}
})
.catch(e => {
.catch((e) => {
// eslint-disable-next-line no-console, @gitlab/require-i18n-strings
console.error('SVG could not be rendered correctly: ', e);
});
......
......@@ -90,7 +90,7 @@ export default {
},
setSvg(name) {
getSvgIconPathContent(name)
.then(path => {
.then((path) => {
if (path) {
this.$set(this.svgs, name, `path://${path}`);
}
......
......@@ -42,10 +42,10 @@ export default {
return this.graphData.y_label || '';
},
xAxisLabels() {
return this.metrics.result.map(res => Object.values(res.metric)[0]);
return this.metrics.result.map((res) => Object.values(res.metric)[0]);
},
yAxisLabels() {
return this.result.values.map(val => {
return this.result.values.map((val) => {
const [yLabel] = val;
return formatDate(new Date(yLabel), {
......
......@@ -51,7 +51,7 @@ const getDataAxisOptions = ({ format, precision, name }) => {
nameLocation: 'center', // same as gitlab-ui's default
scale: true,
axisLabel: {
formatter: val => formatter(val, precision, maxDataAxisTickLength),
formatter: (val) => formatter(val, precision, maxDataAxisTickLength),
},
};
};
......@@ -85,7 +85,7 @@ export const getTimeAxisOptions = ({
name: __('Time'),
type: axisTypes.time,
axisLabel: {
formatter: date => formatDate(date, { format, timezone }),
formatter: (date) => formatDate(date, { format, timezone }),
},
axisPointer: {
snap: false,
......@@ -109,7 +109,7 @@ export const getTooltipFormatter = ({
precision = defaultTooltipPrecision,
} = {}) => {
const formatter = getFormatter(format);
return num => formatter(num, precision);
return (num) => formatter(num, precision);
};
// Thresholds
......@@ -138,9 +138,9 @@ export const getValidThresholds = ({ mode, range = {}, values = [] } = {}) => {
const uniqueThresholds = uniq(values);
const numberThresholds = uniqueThresholds.filter(threshold => isFinite(threshold));
const numberThresholds = uniqueThresholds.filter((threshold) => isFinite(threshold));
const validThresholds = numberThresholds.filter(threshold => {
const validThresholds = numberThresholds.filter((threshold) => {
let isValid;
if (mode === thresholdModeTypes.PERCENTAGE) {
......@@ -152,7 +152,7 @@ export const getValidThresholds = ({ mode, range = {}, values = [] } = {}) => {
return isValid;
});
const transformedThresholds = validThresholds.map(threshold => {
const transformedThresholds = validThresholds.map((threshold) => {
let transformedThreshold;
if (mode === 'percentage') {
......
......@@ -68,7 +68,7 @@ export default {
if (!result || result.length === 0) {
return [];
}
return { name, data: result[0].values.map(val => val[1]) };
return { name, data: result[0].values.map((val) => val[1]) };
})
.slice(0, 1);
},
......@@ -89,7 +89,7 @@ export default {
if (!result || result.length === 0) {
return [];
}
return result[0].values.map(val => val[0]);
return result[0].values.map((val) => val[0]);
},
dataZoomConfig() {
const handleIcon = this.svgs['scroll-handle'];
......@@ -106,7 +106,7 @@ export default {
};
},
seriesNames() {
return this.graphData.metrics.map(metric => metric.label);
return this.graphData.metrics.map((metric) => metric.label);
},
},
created() {
......@@ -115,12 +115,12 @@ export default {
methods: {
setSvg(name) {
getSvgIconPathContent(name)
.then(path => {
.then((path) => {
if (path) {
this.$set(this.svgs, name, `path://${path}`);
}
})
.catch(e => {
.catch((e) => {
// eslint-disable-next-line no-console, @gitlab/require-i18n-strings
console.error('SVG could not be rendered correctly: ', e);
});
......
......@@ -11,7 +11,7 @@ import { makeDataSeries } from '~/helpers/monitor_helper';
import { graphDataValidatorForValues } from '../../utils';
import { formatDate, timezones } from '../../format_date';
export const timestampToISODate = timestamp => new Date(timestamp).toISOString();
export const timestampToISODate = (timestamp) => new Date(timestamp).toISOString();
const THROTTLED_DATAZOOM_WAIT = 1000; // milliseconds
......@@ -304,7 +304,7 @@ export default {
this.tooltip.content = [];
params.seriesData.forEach(dataPoint => {
params.seriesData.forEach((dataPoint) => {
if (dataPoint.value) {
const [, yVal] = dataPoint.value;
this.tooltip.type = dataPoint.name;
......@@ -327,12 +327,12 @@ export default {
},
setSvg(name) {
getSvgIconPathContent(name)
.then(path => {
.then((path) => {
if (path) {
this.$set(this.svgs, name, `path://${path}`);
}
})
.catch(e => {
.catch((e) => {
// eslint-disable-next-line no-console, @gitlab/require-i18n-strings
console.error('SVG could not be rendered correctly: ', e);
});
......
......@@ -271,8 +271,8 @@ export default {
methods: {
getGraphAlerts(queries) {
if (!this.allAlerts) return {};
const metricIdsForChart = queries.map(q => q.metricId);
return pickBy(this.allAlerts, alert => metricIdsForChart.includes(alert.metricId));
const metricIdsForChart = queries.map((q) => q.metricId);
return pickBy(this.allAlerts, (alert) => metricIdsForChart.includes(alert.metricId));
},
getGraphAlertValues(queries) {
return Object.values(this.getGraphAlerts(queries));
......@@ -346,10 +346,10 @@ export default {
}
},
getAlertRunbooks(queries) {
const hasRunbook = alert => Boolean(alert.runbookUrl);
const hasRunbook = (alert) => Boolean(alert.runbookUrl);
const graphAlertsWithRunbooks = pickBy(this.getGraphAlerts(queries), hasRunbook);
const alertToRunbookTransform = alert => {
const alertQuery = queries.find(query => query.metricId === alert.metricId);
const alertToRunbookTransform = (alert) => {
const alertQuery = queries.find((query) => query.metricId === alert.metricId);
return {
key: alert.metricId,
href: alert.runbookUrl,
......
......@@ -3,7 +3,7 @@ import { GlFormGroup, GlFormInput, GlFormRadioGroup, GlFormTextarea } from '@git
import { escape as esc } from 'lodash';
import { __, s__, sprintf } from '~/locale';
const defaultFileName = dashboard => dashboard.path.split('/').reverse()[0];
const defaultFileName = (dashboard) => dashboard.path.split('/').reverse()[0];
export default {
components: {
......
......@@ -42,7 +42,7 @@ export default {
this.loading = true;
this.alert = null;
this.duplicateSystemDashboard(this.form)
.then(createdDashboard => {
.then((createdDashboard) => {
this.loading = false;
this.alert = null;
......@@ -55,7 +55,7 @@ export default {
this.form.branch === this.defaultBranch ? createdDashboard : this.selectedDashboard;
this.$emit(events.dashboardDuplicated, dashboard);
})
.catch(error => {
.catch((error) => {
this.loading = false;
this.alert = error;
});
......
......@@ -17,7 +17,7 @@ export default {
urls: {
type: Array,
required: true,
validator: urls => urls.length > 0,
validator: (urls) => urls.length > 0,
},
},
data() {
......
......@@ -101,7 +101,7 @@ export default {
},
}),
chartHasData(chart) {
return chart.metrics.some(metric => this.metricsWithData.includes(metric.metricId));
return chart.metrics.some((metric) => this.metricsWithData.includes(metric.metricId));
},
onSidebarMutation() {
setTimeout(() => {
......
......@@ -12,7 +12,7 @@ export default {
selectedState: {
type: String,
required: true,
validator: state => Object.values(dashboardEmptyStates).includes(state),
validator: (state) => Object.values(dashboardEmptyStates).includes(state),
},
documentationPath: {
type: String,
......
......@@ -28,7 +28,7 @@ export default {
},
computed: {
text() {
const selectedOpt = this.options.values?.find(opt => opt.value === this.value);
const selectedOpt = this.options.values?.find((opt) => opt.value === this.value);
return selectedOpt?.text || this.value;
},
},
......
......@@ -66,8 +66,8 @@ const csvMetricHeaders = (axisLabel, metrics) =>
*
* @param {Array} metrics - Metrics with results
*/
const csvMetricValues = metrics =>
metrics.flatMap(({ result }) => result.map(res => res.values || []));
const csvMetricValues = (metrics) =>
metrics.flatMap(({ result }) => result.map((res) => res.values || []));
/**
* Returns headers and rows for csv, sorted by their timestamp.
......@@ -99,7 +99,7 @@ const csvData = (metricHeaders, metricValues) => {
const rows = Object.keys(rowsByTimestamp)
.sort()
.map(timestamp => {
.map((timestamp) => {
// force each row to have the same number of entries
rowsByTimestamp[timestamp].length = metricHeaders.length;
// add timestamp as the first entry
......@@ -111,7 +111,7 @@ const csvData = (metricHeaders, metricValues) => {
// appearing inside a field must be escaped by preceding it with
// another double quote."
// https://tools.ietf.org/html/rfc4180#page-2
const headers = metricHeaders.map(header => `"${header.replace(/"/g, '""')}"`);
const headers = metricHeaders.map((header) => `"${header.replace(/"/g, '""')}"`);
return {
headers: ['timestamp', ...headers],
......@@ -125,12 +125,12 @@ const csvData = (metricHeaders, metricValues) => {
* @param {Object} graphData - Panel contents
* @returns {String}
*/
export const graphDataToCsv = graphData => {
export const graphDataToCsv = (graphData) => {
const delimiter = ',';
const br = '\r\n';
const { metrics = [], y_label: axisLabel } = graphData;
const metricsWithResults = metrics.filter(metric => metric.result);
const metricsWithResults = metrics.filter((metric) => metric.result);
const metricHeaders = csvMetricHeaders(axisLabel, metricsWithResults);
const metricValues = csvMetricValues(metricsWithResults);
const { headers, rows } = csvData(metricHeaders, metricValues);
......@@ -140,7 +140,7 @@ export const graphDataToCsv = graphData => {
}
const headerLine = headers.join(delimiter) + br;
const lines = rows.map(row => row.join(delimiter));
const lines = rows.map((row) => row.join(delimiter));
return headerLine + lines.join(br) + br;
};
......@@ -3,10 +3,10 @@ import statusCodes from '~/lib/utils/http_status';
import { backOff } from '~/lib/utils/common_utils';
import { PROMETHEUS_TIMEOUT } from '../constants';
const cancellableBackOffRequest = makeRequestCallback =>
const cancellableBackOffRequest = (makeRequestCallback) =>
backOff((next, stop) => {
makeRequestCallback()
.then(resp => {
.then((resp) => {
if (resp.status === statusCodes.NO_CONTENT) {
next();
} else {
......@@ -16,19 +16,19 @@ const cancellableBackOffRequest = makeRequestCallback =>
// If the request is cancelled by axios
// then consider it as noop so that its not
// caught by subsequent catches
.catch(thrown => (axios.isCancel(thrown) ? undefined : stop(thrown)));
.catch((thrown) => (axios.isCancel(thrown) ? undefined : stop(thrown)));
}, PROMETHEUS_TIMEOUT);
export const getDashboard = (dashboardEndpoint, params) =>
cancellableBackOffRequest(() => axios.get(dashboardEndpoint, { params })).then(
axiosResponse => axiosResponse.data,
(axiosResponse) => axiosResponse.data,
);
export const getPrometheusQueryData = (prometheusEndpoint, params, opts) =>
cancellableBackOffRequest(() => axios.get(prometheusEndpoint, { params, ...opts }))
.then(axiosResponse => axiosResponse.data)
.then(prometheusResponse => prometheusResponse.data)
.catch(error => {
.then((axiosResponse) => axiosResponse.data)
.then((prometheusResponse) => prometheusResponse.data)
.catch((error) => {
// Prometheus returns errors in specific cases
// https://prometheus.io/docs/prometheus/latest/querying/api/#format-overview
const { response = {} } = error;
......
......@@ -10,7 +10,7 @@ export default class AlertsService {
}
getAlerts() {
return axios.get(this.alertsEndpoint).then(resp => mapAlert(resp.data));
return axios.get(this.alertsEndpoint).then((resp) => mapAlert(resp.data));
}
createAlert({ prometheus_metric_id, operator, threshold, runbookUrl }) {
......@@ -21,23 +21,23 @@ export default class AlertsService {
threshold,
runbook_url: runbookUrl,
})
.then(resp => mapAlert(resp.data));
.then((resp) => mapAlert(resp.data));
}
// eslint-disable-next-line class-methods-use-this
readAlert(alertPath) {
return axios.get(alertPath).then(resp => mapAlert(resp.data));
return axios.get(alertPath).then((resp) => mapAlert(resp.data));
}
// eslint-disable-next-line class-methods-use-this
updateAlert(alertPath, { operator, threshold, runbookUrl }) {
return axios
.put(alertPath, { operator, threshold, runbook_url: runbookUrl })
.then(resp => mapAlert(resp.data));
.then((resp) => mapAlert(resp.data));
}
// eslint-disable-next-line class-methods-use-this
deleteAlert(alertPath) {
return axios.delete(alertPath).then(resp => resp.data);
return axios.delete(alertPath).then((resp) => resp.data);
}
}
export const metricsWithData = (state, getters, rootState, rootGetters) =>
state.modules.map(module => rootGetters[`${module}/metricsWithData`]().length);
state.modules.map((module) => rootGetters[`${module}/metricsWithData`]().length);
......@@ -15,9 +15,9 @@ import { optionsFromSeriesData } from './variable_mapping';
*/
const findMetricInDashboard = (metricId, dashboard) => {
let res = null;
dashboard.panelGroups.forEach(group => {
group.panels.forEach(panel => {
panel.metrics.forEach(metric => {
dashboard.panelGroups.forEach((group) => {
group.panels.forEach((panel) => {
panel.metrics.forEach((metric) => {
if (metric.metricId === metricId) {
res = metric;
}
......@@ -31,7 +31,7 @@ const findMetricInDashboard = (metricId, dashboard) => {
* Maps a backened error state to a `metricStates` constant
* @param {Object} error - Error from backend response
*/
const emptyStateFromError = error => {
const emptyStateFromError = (error) => {
if (!error) {
return metricStates.UNKNOWN_ERROR;
}
......@@ -53,7 +53,7 @@ const emptyStateFromError = error => {
return metricStates.UNKNOWN_ERROR;
};
export const metricStateFromData = data => {
export const metricStateFromData = (data) => {
if (data?.result?.length) {
const result = normalizeQueryResponseData(data);
return { state: metricStates.OK, result: Object.freeze(result) };
......@@ -93,7 +93,7 @@ export default {
state.isUpdatingStarredValue = true;
},
[types.RECEIVE_DASHBOARD_STARRING_SUCCESS](state, { selectedDashboard, newStarredValue }) {
const index = state.allDashboards.findIndex(d => d === selectedDashboard);
const index = state.allDashboards.findIndex((d) => d === selectedDashboard);
state.isUpdatingStarredValue = false;
......@@ -196,7 +196,7 @@ export default {
state.showErrorBanner = enabled;
},
[types.SET_PANEL_GROUP_METRICS](state, payload) {
const panelGroup = state.dashboard.panelGroups.find(pg => payload.key === pg.key);
const panelGroup = state.dashboard.panelGroups.find((pg) => payload.key === pg.key);
panelGroup.panels = payload.panels;
},
[types.SET_ENVIRONMENTS_FILTER](state, searchTerm) {
......@@ -207,7 +207,7 @@ export default {
state.expandedPanel.panel = panel;
},
[types.UPDATE_VARIABLE_VALUE](state, { name, value }) {
const variable = state.variables.find(v => v.name === name);
const variable = state.variables.find((v) => v.name === name);
if (variable) {
Object.assign(variable, {
value,
......
......@@ -40,7 +40,7 @@ export const uniqMetricsId = ({ metric_id, id }) => `${metric_id || NOT_IN_DB_PR
* @param {String} str String with leading slash
* @returns {String}
*/
export const removeLeadingSlash = str => (str || '').replace(/^\/+/, '');
export const removeLeadingSlash = (str) => (str || '').replace(/^\/+/, '');
/**
* GraphQL environments API returns only id and name.
......@@ -52,7 +52,7 @@ export const removeLeadingSlash = str => (str || '').replace(/^\/+/, '');
* @returns {Array}
*/
export const parseEnvironmentsResponse = (response = [], projectPath) =>
(response || []).map(env => {
(response || []).map((env) => {
const id = getIdFromGraphQLId(env.id);
return {
...env,
......@@ -75,11 +75,11 @@ export const parseEnvironmentsResponse = (response = [], projectPath) =>
* @param {Array} response annotations response
* @returns {Array} parsed responses
*/
export const parseAnnotationsResponse = response => {
export const parseAnnotationsResponse = (response) => {
if (!response) {
return [];
}
return response.map(annotation => ({
return response.map((annotation) => ({
...annotation,
startingAt: new Date(annotation.startingAt),
endingAt: annotation.endingAt ? new Date(annotation.endingAt) : null,
......@@ -99,7 +99,7 @@ export const parseAnnotationsResponse = response => {
* @param {Array} metrics - Array of prometheus metrics
* @returns {Object}
*/
const mapToMetricsViewModel = metrics =>
const mapToMetricsViewModel = (metrics) =>
metrics.map(({ label, id, metric_id, query_range, prometheus_endpoint_path, ...metric }) => ({
label,
queryRange: query_range,
......@@ -230,7 +230,7 @@ const mapToPanelGroupViewModel = ({ group = '', panels = [] }, i) => {
* @param {Object} timeRange
* @returns {Object}
*/
export const convertToGrafanaTimeRange = timeRange => {
export const convertToGrafanaTimeRange = (timeRange) => {
const timeRangeType = getRangeType(timeRange);
if (timeRangeType === DATETIME_RANGE_TYPES.fixed) {
return {
......@@ -272,7 +272,7 @@ export const convertTimeRanges = (timeRange, type) => {
* @param {Object} metadata
* @returns {Function}
*/
export const addDashboardMetaDataToLink = metadata => link => {
export const addDashboardMetaDataToLink = (metadata) => (link) => {
let modifiedLink = { ...link };
if (metadata.timeRange) {
modifiedLink = {
......@@ -307,7 +307,7 @@ export const mapToDashboardViewModel = ({
// Prometheus Results Parsing
const dateTimeFromUnixTime = unixTime => new Date(unixTime * 1000).toISOString();
const dateTimeFromUnixTime = (unixTime) => new Date(unixTime * 1000).toISOString();
const mapScalarValue = ([unixTime, value]) => [dateTimeFromUnixTime(unixTime), Number(value)];
......@@ -324,7 +324,7 @@ const mapStringValue = ([unixTime, value]) => [dateTimeFromUnixTime(unixTime), v
* @param {array} result
* @returns {array}
*/
const normalizeScalarResult = result => [
const normalizeScalarResult = (result) => [
{
metric: {},
value: mapScalarValue(result),
......@@ -344,7 +344,7 @@ const normalizeScalarResult = result => [
* @param {array} result
* @returns {array}
*/
const normalizeStringResult = result => [
const normalizeStringResult = (result) => [
{
metric: {},
value: mapStringValue(result),
......@@ -379,7 +379,7 @@ const normalizeStringResult = result => [
* @param {array} result
* @returns {array}
*/
const normalizeVectorResult = result =>
const normalizeVectorResult = (result) =>
result.map(({ metric, value }) => {
const scalar = mapScalarValue(value);
// Add a single element to `values`, to support matrix
......@@ -407,7 +407,7 @@ const normalizeVectorResult = result =>
* @param {array} result
* @returns {object} Normalized result.
*/
const normalizeResultMatrix = result =>
const normalizeResultMatrix = (result) =>
result.map(({ metric, values }) => {
const mappedValues = values.map(mapScalarValue);
return {
......@@ -440,7 +440,7 @@ const normalizeResultMatrix = result =>
* ]
*
*/
export const normalizeQueryResponseData = data => {
export const normalizeQueryResponseData = (data) => {
const { resultType, result } = data;
if (resultType === 'vector') {
return normalizeVectorResult(result);
......@@ -466,7 +466,7 @@ export const normalizeQueryResponseData = data => {
* @param {String} name Variable key that needs to be prefixed
* @returns {String}
*/
export const addPrefixToCustomVariableParams = name => `variables[${name}]`;
export const addPrefixToCustomVariableParams = (name) => `variables[${name}]`;
/**
* Normalize custom dashboard paths. This method helps support
......
......@@ -21,7 +21,7 @@ import { VARIABLE_TYPES } from '../constants';
* @param {String|Object} simpleTextVar
* @returns {Object}
*/
const textSimpleVariableParser = simpleTextVar => ({
const textSimpleVariableParser = (simpleTextVar) => ({
type: VARIABLE_TYPES.text,
label: null,
value: simpleTextVar,
......@@ -34,7 +34,7 @@ const textSimpleVariableParser = simpleTextVar => ({
* @param {Object} advTextVar
* @returns {Object}
*/
const textAdvancedVariableParser = advTextVar => ({
const textAdvancedVariableParser = (advTextVar) => ({
type: VARIABLE_TYPES.text,
label: advTextVar.label,
value: advTextVar.options.default_value,
......@@ -62,9 +62,9 @@ const normalizeVariableValues = ({ default: defaultOpt = false, text, value = nu
* @param {Object} advVariable advanced custom variable
* @returns {Object}
*/
const customAdvancedVariableParser = advVariable => {
const customAdvancedVariableParser = (advVariable) => {
const values = (advVariable?.options?.values ?? []).map(normalizeVariableValues);
const defaultValue = values.find(opt => opt.default === true) || values[0];
const defaultValue = values.find((opt) => opt.default === true) || values[0];
return {
type: VARIABLE_TYPES.custom,
label: advVariable.label,
......@@ -82,7 +82,7 @@ const customAdvancedVariableParser = advVariable => {
* @param {String} opt option from simple custom variable
* @returns {Object}
*/
export const parseSimpleCustomValues = opt => ({ text: opt, value: opt });
export const parseSimpleCustomValues = (opt) => ({ text: opt, value: opt });
/**
* Custom simple variables are rendered as dropdown elements in the dashboard
......@@ -96,7 +96,7 @@ export const parseSimpleCustomValues = opt => ({ text: opt, value: opt });
* @param {Array} customVariable array of options
* @returns {Object}
*/
const customSimpleVariableParser = simpleVar => {
const customSimpleVariableParser = (simpleVar) => {
const values = (simpleVar || []).map(parseSimpleCustomValues);
return {
type: VARIABLE_TYPES.custom,
......@@ -126,7 +126,7 @@ const metricLabelValuesVariableParser = ({ label, options = {} }) => ({
* @param {Array|Object} customVar Array if simple, object if advanced
* @returns {Boolean} true if simple, false if advanced
*/
const isSimpleCustomVariable = customVar => Array.isArray(customVar);
const isSimpleCustomVariable = (customVar) => Array.isArray(customVar);
/**
* This method returns a parser based on the type of the variable.
......@@ -137,7 +137,7 @@ const isSimpleCustomVariable = customVar => Array.isArray(customVar);
* @param {Array|Object} variable
* @return {Function} parser method
*/
const getVariableParser = variable => {
const getVariableParser = (variable) => {
if (isString(variable)) {
return textSimpleVariableParser;
} else if (isSimpleCustomVariable(variable)) {
......@@ -200,7 +200,7 @@ export const parseTemplatingVariables = (ymlVariables = {}) =>
*/
export const mergeURLVariables = (parsedYmlVariables = []) => {
const varsFromURL = templatingVariablesFromUrl();
parsedYmlVariables.forEach(variable => {
parsedYmlVariables.forEach((variable) => {
const { name } = variable;
if (Object.prototype.hasOwnProperty.call(varsFromURL, name)) {
Object.assign(variable, { value: varsFromURL[name] });
......
......@@ -81,15 +81,15 @@ export const graphDataValidatorForValues = (isValues, graphData) => {
const responseValueKeyName = isValues ? 'value' : 'values';
return (
Array.isArray(graphData.metrics) &&
graphData.metrics.filter(query => {
graphData.metrics.filter((query) => {
if (Array.isArray(query.result)) {
return (
query.result.filter(res => Array.isArray(res[responseValueKeyName])).length ===
query.result.filter((res) => Array.isArray(res[responseValueKeyName])).length ===
query.result.length
);
}
return false;
}).length === graphData.metrics.filter(query => query.result).length
}).length === graphData.metrics.filter((query) => query.result).length
);
};
......@@ -106,7 +106,7 @@ const isClusterHealthBoard = () => (document.body.dataset.page || '').includes('
* @param {String} chart link that will be sent as a property for the event
* @return {Object} config object for event tracking
*/
export const generateLinkToChartOptions = chartLink => {
export const generateLinkToChartOptions = (chartLink) => {
const isCLusterHealthBoard = isClusterHealthBoard();
const category = isCLusterHealthBoard
......@@ -124,7 +124,7 @@ export const generateLinkToChartOptions = chartLink => {
* @param {String} chart title that will be sent as a property for the event
* @return {Object} config object for event tracking
*/
export const downloadCSVOptions = title => {
export const downloadCSVOptions = (title) => {
const isCLusterHealthBoard = isClusterHealthBoard();
const category = isCLusterHealthBoard
......@@ -157,7 +157,7 @@ export const getAddMetricTrackingOptions = () => ({
* @param {Object} graphData the graph data response from a prometheus request
* @returns {boolean} true if the data is valid
*/
export const graphDataValidatorForAnomalyValues = graphData => {
export const graphDataValidatorForAnomalyValues = (graphData) => {
const anomalySeriesCount = 3; // metric, upper, lower
return (
graphData.metrics &&
......@@ -186,7 +186,7 @@ export const timeRangeFromUrl = (search = window.location.search) => {
* @param {String} label label for the template variable
* @returns {String}
*/
export const addPrefixToLabel = label => `${VARIABLE_PREFIX}${label}`;
export const addPrefixToLabel = (label) => `${VARIABLE_PREFIX}${label}`;
/**
* Before the templating variables are passed to the backend the
......@@ -197,7 +197,7 @@ export const addPrefixToLabel = label => `${VARIABLE_PREFIX}${label}`;
* @param {String} label label to remove prefix from
* @returns {String}
*/
export const removePrefixFromLabel = label =>
export const removePrefixFromLabel = (label) =>
(label || '').replace(new RegExp(`^${VARIABLE_PREFIX}`), '');
/**
......@@ -210,7 +210,7 @@ export const removePrefixFromLabel = label =>
* @param {Object} variables
* @returns {Object}
*/
export const convertVariablesForURL = variables =>
export const convertVariablesForURL = (variables) =>
variables.reduce((acc, { name, value }) => {
if (value !== null) {
acc[addPrefixToLabel(name)] = value;
......@@ -241,7 +241,7 @@ export const templatingVariablesFromUrl = (search = window.location.search) => {
*
* @param {Object} variables user defined variables
*/
export const setCustomVariablesFromUrl = variables => {
export const setCustomVariablesFromUrl = (variables) => {
// prep the variables to append to URL
const parsedVariables = convertVariablesForURL(variables);
// update the URL
......@@ -353,7 +353,7 @@ export const panelToUrl = (
* @param {Array} values data points
* @returns {Number}
*/
const metricValueMapper = values => values[0]?.[1];
const metricValueMapper = (values) => values[0]?.[1];
/**
* Get the metric name from metric object
......@@ -364,7 +364,7 @@ const metricValueMapper = values => values[0]?.[1];
* @param {Object} metric metric object
* @returns {String}
*/
const metricNameMapper = metric => Object.values(metric)?.[0];
const metricNameMapper = (metric) => Object.values(metric)?.[0];
/**
* Parse metric object to extract metric value and name in
......
import { isSafeURL } from '~/lib/utils/url_utility';
const isRunbookUrlValid = runbookUrl => {
const isRunbookUrlValid = (runbookUrl) => {
if (!runbookUrl) {
return true;
}
......@@ -21,7 +21,7 @@ const isRunbookUrlValid = runbookUrl => {
// }
// }
export function alertsValidator(value) {
return Object.keys(value).every(key => {
return Object.keys(value).every((key) => {
const alert = value[key];
return (
alert.alert_path &&
......@@ -49,7 +49,7 @@ export function alertsValidator(value) {
// ]
export function queriesValidator(value) {
return value.every(
query =>
(query) =>
query.metricId && typeof query.metricId === 'string' && typeof query.label === 'string',
);
}
......@@ -33,7 +33,7 @@ export default () => {
computed: {
...mapGetters(['discussionTabCounter']),
...mapState({
activeTab: state => state.page.activeTab,
activeTab: (state) => state.page.activeTab,
}),
isShowTabActive() {
return this.activeTab === 'show';
......
// Note: this getter is important because
// `noteableData` is namespaced under `notes` for `~/mr_notes/stores`
// while `noteableData` is directly available as `state.noteableData` for `~/notes/stores`
export const getNoteableData = state => state.notes.noteableData;
export const getNoteableData = (state) => state.notes.noteableData;
export default {
isLoggedIn(state, getters) {
......
......@@ -72,7 +72,7 @@ export default {
apollo: {
mergeRequest: {
query,
update: data => data.project.mergeRequest,
update: (data) => data.project.mergeRequest,
variables() {
const { projectPath, mergeRequestIID } = this;
......
......@@ -42,7 +42,7 @@ const handleMRPopoverMount = ({ apolloProvider, projectPath, mrTitle, iid }) =>
}, 200); // 200ms delay so not every mouseover triggers Popover + API Call
};
export default elements => {
export default (elements) => {
const mrLinks = elements || [...document.querySelectorAll('.gfm-merge_request')];
if (mrLinks.length > 0) {
Vue.use(VueApollo);
......@@ -52,7 +52,7 @@ export default elements => {
});
const listenerAddedAttr = 'data-mr-listener-added';
mrLinks.forEach(el => {
mrLinks.forEach((el) => {
const { projectPath, mrTitle, iid } = el.dataset;
if (!el.getAttribute(listenerAddedAttr) && projectPath && mrTitle && iid) {
......
......@@ -25,7 +25,7 @@ export default class NamespaceSelect {
return `${selected.kind}: ${selected.full_path}`;
},
data(term, dataCallback) {
return Api.namespaces(term, namespaces => {
return Api.namespaces(term, (namespaces) => {
if (isFilter) {
const anyNamespace = {
text: __('Any namespace'),
......
......@@ -66,12 +66,12 @@ export default class BranchGraph {
collectParents() {
const ref = this.commits;
const results = [];
ref.forEach(c => {
ref.forEach((c) => {
this.mtime = Math.max(this.mtime, c.time);
this.mspace = Math.max(this.mspace, c.space);
const ref1 = c.parents;
const results1 = [];
ref1.forEach(p => {
ref1.forEach((p) => {
this.parents[p[0]] = true;
results1.push((this.mspace = Math.max(this.mspace, p[1])));
});
......
......@@ -60,7 +60,7 @@ export default class NewBranchForm {
return values;
};
const formatter = function (values, restriction) {
const formatted = values.map(value => {
const formatted = values.map((value) => {
switch (false) {
case !/\s/.test(value):
return 'spaces';
......
......@@ -77,11 +77,11 @@ function renderKatex(t) {
}
return [text, numInline > 0];
}
renderer.paragraph = t => {
renderer.paragraph = (t) => {
const [text, inline] = renderKatex(t);
return `<p class="${inline ? 'inline-katex' : ''}">${text}</p>`;
};
renderer.listitem = t => {
renderer.listitem = (t) => {
const [text, inline] = renderKatex(t);
return `<li class="${inline ? 'inline-katex' : ''}">${text}</li>`;
};
......
......@@ -345,7 +345,7 @@ export default class Notes {
votesBlock = $('.js-awards-block').eq(0);
loadAwardsHandler()
.then(awardsHandler => {
.then((awardsHandler) => {
awardsHandler.addAwardToEmojiBar(votesBlock, noteEntity.commands_changes.emoji_award);
awardsHandler.scrollToAwards();
})
......@@ -1396,7 +1396,7 @@ export default class Notes {
let tempFormContent;
// Identify executed quick actions from `formContent`
const executedCommands = availableQuickActions.filter(command => {
const executedCommands = availableQuickActions.filter((command) => {
const commandRegex = new RegExp(`/${command.name}`);
return commandRegex.test(formContent);
});
......@@ -1583,7 +1583,7 @@ export default class Notes {
// Make request to submit comment on server
return axios
.post(`${formAction}?html=true`, formData)
.then(res => {
.then((res) => {
const note = res.data;
$submitBtn.prop('disabled', false);
......
......@@ -31,7 +31,7 @@ export default {
},
computed: {
...mapState({
projectPath: state => state.diffs.projectPath,
projectPath: (state) => state.diffs.projectPath,
}),
diffMode() {
return getDiffMode(this.discussion.diff_file);
......
......@@ -42,10 +42,10 @@ export default {
return this.glFeatures.hideJumpToNextUnresolvedInThreads;
},
resolvableNotes() {
return this.discussion.notes.filter(x => x.resolvable);
return this.discussion.notes.filter((x) => x.resolvable);
},
userCanResolveDiscussion() {
return this.resolvableNotes.every(note => note.current_user?.can_resolve_discussion);
return this.resolvableNotes.every((note) => note.current_user?.can_resolve_discussion);
},
},
};
......
......@@ -32,10 +32,10 @@ export default {
return this.getNoteableData.create_issue_to_resolve_discussions_path;
},
toggeableDiscussions() {
return this.discussions.filter(discussion => !discussion.individual_note);
return this.discussions.filter((discussion) => !discussion.individual_note);
},
allExpanded() {
return this.toggeableDiscussions.every(discussion => discussion.expanded);
return this.toggeableDiscussions.every((discussion) => discussion.expanded);
},
lineResolveClass() {
return this.allResolved ? 'line-resolve-btn is-active' : 'line-resolve-text';
......@@ -48,7 +48,7 @@ export default {
...mapActions(['setExpandDiscussions']),
handleExpandDiscussions() {
this.setExpandDiscussions({
discussionIds: this.toggeableDiscussions.map(discussion => discussion.id),
discussionIds: this.toggeableDiscussions.map((discussion) => discussion.id),
expanded: !this.allExpanded,
});
},
......
......@@ -42,7 +42,7 @@ export default {
...mapGetters(['getNotesDataByProp', 'timelineEnabled']),
currentFilter() {
if (!this.currentValue) return this.filters[0];
return this.filters.find(filter => filter.value === this.currentValue);
return this.filters.find((filter) => filter.value === this.currentValue);
},
},
created() {
......
......@@ -48,11 +48,11 @@ export function getLineClasses(line) {
export function commentLineOptions(diffLines, startingLine, lineCode, side = 'left') {
const preferredSide = side === 'left' ? 'old_line' : 'new_line';
const fallbackSide = preferredSide === 'new_line' ? 'old_line' : 'new_line';
const notMatchType = l => l.type !== 'match';
const notMatchType = (l) => l.type !== 'match';
const linesCopy = [...diffLines]; // don't mutate the argument
const startingLineCode = startingLine.line_code;
const currentIndex = linesCopy.findIndex(line => line.line_code === lineCode);
const currentIndex = linesCopy.findIndex((line) => line.line_code === lineCode);
// We're limiting adding comments to only lines above the current line
// to make rendering simpler. Future interations will use a more
......@@ -66,10 +66,10 @@ export function commentLineOptions(diffLines, startingLine, lineCode, side = 'le
// If the selected line is "hidden" in an unchanged line block
// or "above" the current group of lines add it to the array so
// that the drop down is not defaulted to empty
const selectedIndex = lines.findIndex(line => line.line_code === startingLineCode);
const selectedIndex = lines.findIndex((line) => line.line_code === startingLineCode);
if (selectedIndex < 0) lines.unshift(startingLine);
return lines.map(l => {
return lines.map((l) => {
const { line_code, type, old_line, new_line } = l;
return {
value: { line_code, type, old_line, new_line },
......@@ -103,7 +103,7 @@ export function getCommentedLines(selectedCommentPosition, diffLines) {
};
}
const findLineCodeIndex = line => position => {
const findLineCodeIndex = (line) => (position) => {
return [position.line_code, position.left?.line_code, position.right?.line_code].includes(
line.line_code,
);
......
......@@ -206,14 +206,14 @@ export default {
const { project_id, iid } = this.getNoteableData;
if (this.isUserAssigned) {
assignees = assignees.filter(assignee => assignee.id !== this.author.id);
assignees = assignees.filter((assignee) => assignee.id !== this.author.id);
} else {
assignees.push({ id: this.author.id });
}
if (this.targetType === 'issue') {
Api.updateIssue(project_id, iid, {
assignee_ids: assignees.map(assignee => assignee.id),
assignee_ids: assignees.map((assignee) => assignee.id),
})
.then(() => this.handleAssigneeUpdate(assignees))
.catch(() => flash(__('Something went wrong while updating assignees')));
......
......@@ -52,7 +52,7 @@ export default {
return this.getDiscussion(this.note.discussion_id);
},
...mapState({
batchSuggestionsInfo: state => state.notes.batchSuggestionsInfo,
batchSuggestionsInfo: (state) => state.notes.batchSuggestionsInfo,
}),
noteBody() {
return this.note.note;
......
......@@ -115,7 +115,7 @@ export default {
'getUserDataByProp',
]),
...mapState({
withBatchComments: state => state.batchComments?.withBatchComments,
withBatchComments: (state) => state.batchComments?.withBatchComments,
}),
...mapGetters('batchComments', ['hasDrafts']),
showBatchCommentsActions() {
......@@ -126,8 +126,8 @@ export default {
return (
this.discussion?.notes
.filter(n => n.resolvable)
.some(n => n.current_user?.can_resolve_discussion) || this.isDraft
.filter((n) => n.resolvable)
.some((n) => n.current_user?.can_resolve_discussion) || this.isDraft
);
},
noteHash() {
......
......@@ -201,14 +201,14 @@ export default {
};
this.saveNote(replyData)
.then(res => {
.then((res) => {
if (res.hasFlash !== true) {
this.isReplying = false;
clearDraft(this.autosaveKey);
}
callback();
})
.catch(err => {
.catch((err) => {
this.removePlaceholderNotes();
const msg = __(
'Your comment could not be submitted! Please check your network connection and try again.',
......
......@@ -296,7 +296,7 @@ export default {
this.updateSuccess();
callback();
})
.catch(response => {
.catch((response) => {
if (response.status === httpStatusCodes.GONE) {
this.removeNote(this.note);
this.updateSuccess();
......
......@@ -130,7 +130,7 @@ export default {
const { parentElement } = this.$el;
if (parentElement && parentElement.classList.contains('js-vue-notes-event')) {
parentElement.addEventListener('toggleAward', event => {
parentElement.addEventListener('toggleAward', (event) => {
const { awardName, noteId } = event.detail;
this.toggleAward({ awardName, noteId });
});
......@@ -217,7 +217,7 @@ export default {
const noteId = hash && hash.replace(/^note_/, '');
if (noteId) {
const discussion = this.discussions.find(d => d.notes.some(({ id }) => id === noteId));
const discussion = this.discussions.find((d) => d.notes.some(({ id }) => id === noteId));
if (discussion) {
this.expandDiscussion({ discussionId: discussion.id });
......
......@@ -26,9 +26,9 @@ export default {
return this.replies[this.replies.length - 1];
},
uniqueAuthors() {
const authors = this.replies.map(reply => reply.author || {});
const authors = this.replies.map((reply) => reply.author || {});
return uniqBy(authors, author => author.username);
return uniqBy(authors, (author) => author.username);
},
className() {
return this.collapsed ? 'collapsed' : 'expanded';
......
import Vue from 'vue';
import DiscussionFilter from './components/discussion_filter.vue';
export default store => {
export default (store) => {
const discussionFilterEl = document.getElementById('js-vue-discussion-filter');
if (discussionFilterEl) {
const { defaultFilter, notesFilters } = discussionFilterEl.dataset;
const filterValues = notesFilters ? JSON.parse(notesFilters) : {};
const filters = Object.keys(filterValues).map(entry => ({
const filters = Object.keys(filterValues).map((entry) => ({
title: entry,
value: filterValues[entry],
}));
......
......@@ -9,9 +9,9 @@ import { formatLineRange } from '~/notes/components/multiline_comment_utils';
export default {
computed: {
...mapState({
noteableData: state => state.notes.noteableData,
notesData: state => state.notes.notesData,
withBatchComments: state => state.batchComments?.withBatchComments,
noteableData: (state) => state.notes.noteableData,
notesData: (state) => state.notes.notesData,
withBatchComments: (state) => state.batchComments?.withBatchComments,
}),
...mapGetters('diffs', ['getDiffFileByHash']),
...mapGetters('batchComments', ['shouldRenderDraftRowInDiscussion', 'draftForDiscussion']),
......
......@@ -99,7 +99,7 @@ export default {
'getDiscussion',
]),
...mapState({
currentDiscussionId: state => state.notes.currentDiscussionId,
currentDiscussionId: (state) => state.notes.currentDiscussionId,
}),
},
methods: {
......
......@@ -15,7 +15,7 @@ export default {
if (notes) {
// Decide resolved state using store. Only valid for discussions.
return notes.filter(note => !note.system).every(note => note.resolved);
return notes.filter((note) => !note.system).every((note) => note.resolved);
}
return resolved;
......
import Vue from 'vue';
import SortDiscussion from './components/sort_discussion.vue';
export default store => {
export default (store) => {
const el = document.getElementById('js-vue-sort-issue-discussions');
if (!el) return null;
......
......@@ -141,7 +141,7 @@ export const updateNote = ({ commit, dispatch }, { endpoint, note }) =>
export const updateOrCreateNotes = ({ commit, state, getters, dispatch }, notes) => {
const { notesById } = getters;
const debouncedFetchDiscussions = isFetching => {
const debouncedFetchDiscussions = (isFetching) => {
if (!isFetching) {
commit(types.SET_FETCHING_DISCUSSIONS, true);
dispatch('fetchDiscussions', { path: state.notesData.discussionsPath });
......@@ -159,7 +159,7 @@ export const updateOrCreateNotes = ({ commit, state, getters, dispatch }, notes)
}
};
notes.forEach(note => {
notes.forEach((note) => {
if (notesById[note.id]) {
commit(types.UPDATE_NOTE, note);
} else if (note.type === constants.DISCUSSION_NOTE || note.type === constants.DIFF_NOTE) {
......@@ -329,7 +329,7 @@ export const saveNote = ({ commit, dispatch }, noteData) => {
}
}
const processQuickActions = res => {
const processQuickActions = (res) => {
const { errors: { commands_only: message } = { commands_only: null } } = res;
/*
The following reply means that quick actions have been successfully applied:
......@@ -347,7 +347,7 @@ export const saveNote = ({ commit, dispatch }, noteData) => {
return res;
};
const processEmojiAward = res => {
const processEmojiAward = (res) => {
const { commands_changes: commandsChanges } = res;
const { emoji_award: emojiAward } = commandsChanges || {};
if (!emojiAward) {
......@@ -357,7 +357,7 @@ export const saveNote = ({ commit, dispatch }, noteData) => {
const votesBlock = $('.js-awards-block').eq(0);
return loadAwardsHandler()
.then(awardsHandler => {
.then((awardsHandler) => {
awardsHandler.addAwardToEmojiBar(votesBlock, emojiAward);
awardsHandler.scrollToAwards();
})
......@@ -371,7 +371,7 @@ export const saveNote = ({ commit, dispatch }, noteData) => {
.then(() => res);
};
const processTimeTracking = res => {
const processTimeTracking = (res) => {
const { commands_changes: commandsChanges } = res;
const { spend_time: spendTime, time_estimate: timeEstimate } = commandsChanges || {};
if (spendTime != null || timeEstimate != null) {
......@@ -383,7 +383,7 @@ export const saveNote = ({ commit, dispatch }, noteData) => {
return res;
};
const removePlaceholder = res => {
const removePlaceholder = (res) => {
if (replyId) {
commit(types.REMOVE_PLACEHOLDER_NOTES);
}
......@@ -391,7 +391,7 @@ export const saveNote = ({ commit, dispatch }, noteData) => {
return res;
};
const processErrors = error => {
const processErrors = (error) => {
if (error.response) {
const {
response: { data = {} },
......@@ -435,7 +435,7 @@ const pollSuccessCallBack = (resp, commit, state, getters, dispatch) => {
return resp;
};
const getFetchDataParams = state => {
const getFetchDataParams = (state) => {
const endpoint = state.notesData.notesPath;
const options = {
headers: {
......@@ -570,7 +570,7 @@ export const submitSuggestion = (
return Api.applySuggestion(suggestionId)
.then(() => commit(types.APPLY_SUGGESTION, { discussionId, noteId, suggestionId }))
.then(dispatchResolveDiscussion)
.catch(err => {
.catch((err) => {
const defaultMessage = __(
'Something went wrong while applying the suggestion. Please try again.',
);
......@@ -591,12 +591,12 @@ export const submitSuggestionBatch = ({ commit, dispatch, state }, { flashContai
const suggestionIds = state.batchSuggestionsInfo.map(({ suggestionId }) => suggestionId);
const applyAllSuggestions = () =>
state.batchSuggestionsInfo.map(suggestionInfo =>
state.batchSuggestionsInfo.map((suggestionInfo) =>
commit(types.APPLY_SUGGESTION, suggestionInfo),
);
const resolveAllDiscussions = () =>
state.batchSuggestionsInfo.map(suggestionInfo => {
state.batchSuggestionsInfo.map((suggestionInfo) => {
const { discussionId } = suggestionInfo;
return dispatch('resolveDiscussion', { discussionId }).catch(() => {});
});
......@@ -609,7 +609,7 @@ export const submitSuggestionBatch = ({ commit, dispatch, state }, { flashContai
.then(() => Promise.all(applyAllSuggestions()))
.then(() => Promise.all(resolveAllDiscussions()))
.then(() => commit(types.CLEAR_SUGGESTION_BATCH))
.catch(err => {
.catch((err) => {
const defaultMessage = __(
'Something went wrong while applying the batch of suggestions. Please try again.',
);
......@@ -652,10 +652,10 @@ export const fetchDescriptionVersion = ({ dispatch }, { endpoint, startingVersio
return axios
.get(requestUrl)
.then(res => {
.then((res) => {
dispatch('receiveDescriptionVersion', { descriptionVersion: res.data, versionId });
})
.catch(error => {
.catch((error) => {
dispatch('receiveDescriptionVersionError', error);
Flash(__('Something went wrong while fetching description changes. Please try again.'));
});
......@@ -687,7 +687,7 @@ export const softDeleteDescriptionVersion = (
.then(() => {
dispatch('receiveDeleteDescriptionVersion', versionId);
})
.catch(error => {
.catch((error) => {
dispatch('receiveDeleteDescriptionVersionError', error);
Flash(__('Something went wrong while deleting description changes. Please try again.'));
......
......@@ -18,7 +18,7 @@ export const getTimeDifferenceMinutes = (noteBeggining, noteEnd) => {
* @param {Object} note
* @returns {Boolean}
*/
export const isDescriptionSystemNote = note => note.system && note.note === DESCRIPTION_TYPE;
export const isDescriptionSystemNote = (note) => note.system && note.note === DESCRIPTION_TYPE;
/**
* Collapses the system notes of a description type, e.g. Changed the description, n minutes ago
......@@ -29,7 +29,7 @@ export const isDescriptionSystemNote = note => note.system && note.note === DESC
* @param {Array} notes
* @returns {Array}
*/
export const collapseSystemNotes = notes => {
export const collapseSystemNotes = (notes) => {
let lastDescriptionSystemNote = null;
let lastDescriptionSystemNoteIndex = -1;
......
......@@ -2,14 +2,14 @@ import { flattenDeep, clone } from 'lodash';
import * as constants from '../constants';
import { collapseSystemNotes } from './collapse_utils';
export const discussions = state => {
export const discussions = (state) => {
let discussionsInState = clone(state.discussions);
// NOTE: not testing bc will be removed when backend is finished.
if (state.isTimelineEnabled) {
discussionsInState = discussionsInState
.reduce((acc, discussion) => {
const transformedToIndividualNotes = discussion.notes.map(note => ({
const transformedToIndividualNotes = discussion.notes.map((note) => ({
...discussion,
id: note.id,
created_at: note.created_at,
......@@ -29,52 +29,52 @@ export const discussions = state => {
return collapseSystemNotes(discussionsInState);
};
export const convertedDisscussionIds = state => state.convertedDisscussionIds;
export const convertedDisscussionIds = (state) => state.convertedDisscussionIds;
export const targetNoteHash = state => state.targetNoteHash;
export const targetNoteHash = (state) => state.targetNoteHash;
export const getNotesData = state => state.notesData;
export const getNotesData = (state) => state.notesData;
export const isNotesFetched = state => state.isNotesFetched;
export const isNotesFetched = (state) => state.isNotesFetched;
/*
* WARNING: This is an example of an "unnecessary" getter
* more info found here: https://gitlab.com/groups/gitlab-org/-/epics/2913.
*/
export const sortDirection = state => state.discussionSortOrder;
export const sortDirection = (state) => state.discussionSortOrder;
export const persistSortOrder = state => state.persistSortOrder;
export const persistSortOrder = (state) => state.persistSortOrder;
export const timelineEnabled = state => state.isTimelineEnabled;
export const timelineEnabled = (state) => state.isTimelineEnabled;
export const isLoading = state => state.isLoading;
export const isLoading = (state) => state.isLoading;
export const getNotesDataByProp = state => prop => state.notesData[prop];
export const getNotesDataByProp = (state) => (prop) => state.notesData[prop];
export const getNoteableData = state => state.noteableData;
export const getNoteableData = (state) => state.noteableData;
export const getNoteableDataByProp = state => prop => state.noteableData[prop];
export const getNoteableDataByProp = (state) => (prop) => state.noteableData[prop];
export const getBlockedByIssues = state => state.noteableData.blocked_by_issues;
export const getBlockedByIssues = (state) => state.noteableData.blocked_by_issues;
export const userCanReply = state => Boolean(state.noteableData.current_user.can_create_note);
export const userCanReply = (state) => Boolean(state.noteableData.current_user.can_create_note);
export const openState = state => state.noteableData.state;
export const openState = (state) => state.noteableData.state;
export const getUserData = state => state.userData || {};
export const getUserData = (state) => state.userData || {};
export const getUserDataByProp = state => prop => state.userData && state.userData[prop];
export const getUserDataByProp = (state) => (prop) => state.userData && state.userData[prop];
export const descriptionVersions = state => state.descriptionVersions;
export const descriptionVersions = (state) => state.descriptionVersions;
export const notesById = state =>
export const notesById = (state) =>
state.discussions.reduce((acc, note) => {
note.notes.every(n => Object.assign(acc, { [n.id]: n }));
note.notes.every((n) => Object.assign(acc, { [n.id]: n }));
return acc;
}, {});
export const noteableType = state => {
export const noteableType = (state) => {
const { ISSUE_NOTEABLE_TYPE, MERGE_REQUEST_NOTEABLE_TYPE, EPIC_NOTEABLE_TYPE } = constants;
if (state.noteableData.noteableType === EPIC_NOTEABLE_TYPE) {
......@@ -84,21 +84,21 @@ export const noteableType = state => {
return state.noteableData.merge_params ? MERGE_REQUEST_NOTEABLE_TYPE : ISSUE_NOTEABLE_TYPE;
};
const reverseNotes = array => array.slice(0).reverse();
const reverseNotes = (array) => array.slice(0).reverse();
const isLastNote = (note, state) =>
!note.system && state.userData && note.author && note.author.id === state.userData.id;
export const getCurrentUserLastNote = state =>
flattenDeep(reverseNotes(state.discussions).map(note => reverseNotes(note.notes))).find(el =>
export const getCurrentUserLastNote = (state) =>
flattenDeep(reverseNotes(state.discussions).map((note) => reverseNotes(note.notes))).find((el) =>
isLastNote(el, state),
);
export const getDiscussionLastNote = state => discussion =>
reverseNotes(discussion.notes).find(el => isLastNote(el, state));
export const getDiscussionLastNote = (state) => (discussion) =>
reverseNotes(discussion.notes).find((el) => isLastNote(el, state));
export const unresolvedDiscussionsCount = state => state.unresolvedDiscussionsCount;
export const resolvableDiscussionsCount = state => state.resolvableDiscussionsCount;
export const unresolvedDiscussionsCount = (state) => state.unresolvedDiscussionsCount;
export const resolvableDiscussionsCount = (state) => state.resolvableDiscussionsCount;
export const showJumpToNextDiscussion = (state, getters) => (mode = 'discussion') => {
const orderedDiffs =
......@@ -109,20 +109,20 @@ export const showJumpToNextDiscussion = (state, getters) => (mode = 'discussion'
return orderedDiffs.length > 1;
};
export const isDiscussionResolved = (state, getters) => discussionId =>
export const isDiscussionResolved = (state, getters) => (discussionId) =>
getters.resolvedDiscussionsById[discussionId] !== undefined;
export const allResolvableDiscussions = state =>
state.discussions.filter(d => !d.individual_note && d.resolvable);
export const allResolvableDiscussions = (state) =>
state.discussions.filter((d) => !d.individual_note && d.resolvable);
export const resolvedDiscussionsById = state => {
export const resolvedDiscussionsById = (state) => {
const map = {};
state.discussions
.filter(d => d.resolvable)
.forEach(n => {
.filter((d) => d.resolvable)
.forEach((n) => {
if (n.notes) {
const resolved = n.notes.filter(note => note.resolvable).every(note => note.resolved);
const resolved = n.notes.filter((note) => note.resolvable).every((note) => note.resolved);
if (resolved) {
map[n.id] = n;
......@@ -136,7 +136,7 @@ export const resolvedDiscussionsById = state => {
// Gets Discussions IDs ordered by the date of their initial note
export const unresolvedDiscussionsIdsByDate = (state, getters) =>
getters.allResolvableDiscussions
.filter(d => !d.resolved)
.filter((d) => !d.resolved)
.sort((a, b) => {
const aDate = new Date(a.notes[0].created_at);
const bDate = new Date(b.notes[0].created_at);
......@@ -147,7 +147,7 @@ export const unresolvedDiscussionsIdsByDate = (state, getters) =>
return aDate === bDate ? 0 : 1;
})
.map(d => d.id);
.map((d) => d.id);
// Gets Discussions IDs ordered by their position in the diff
//
......@@ -156,7 +156,7 @@ export const unresolvedDiscussionsIdsByDate = (state, getters) =>
// line numbers.
export const unresolvedDiscussionsIdsByDiff = (state, getters) =>
getters.allResolvableDiscussions
.filter(d => !d.resolved && d.active)
.filter((d) => !d.resolved && d.active)
.sort((a, b) => {
if (!a.diff_file || !b.diff_file) {
return 0;
......@@ -176,7 +176,7 @@ export const unresolvedDiscussionsIdsByDiff = (state, getters) =>
? -1
: 1;
})
.map(d => d.id);
.map((d) => d.id);
export const resolvedDiscussionCount = (state, getters) => {
const resolvedMap = getters.resolvedDiscussionsById;
......@@ -184,16 +184,16 @@ export const resolvedDiscussionCount = (state, getters) => {
return Object.keys(resolvedMap).length;
};
export const discussionTabCounter = state =>
export const discussionTabCounter = (state) =>
state.discussions.reduce(
(acc, discussion) =>
acc + discussion.notes.filter(note => !note.system && !note.placeholder).length,
acc + discussion.notes.filter((note) => !note.system && !note.placeholder).length,
0,
);
// Returns the list of discussion IDs ordered according to given parameter
// @param {Boolean} diffOrder - is ordered by diff?
export const unresolvedDiscussionsIdsOrdered = (state, getters) => diffOrder => {
export const unresolvedDiscussionsIdsOrdered = (state, getters) => (diffOrder) => {
if (diffOrder) {
return getters.unresolvedDiscussionsIdsByDiff;
}
......@@ -241,17 +241,17 @@ export const previousUnresolvedDiscussionId = (state, getters) => (discussionId,
getters.findUnresolvedDiscussionIdNeighbor({ discussionId, diffOrder, step: -1 });
// @param {Boolean} diffOrder - is ordered by diff?
export const firstUnresolvedDiscussionId = (state, getters) => diffOrder => {
export const firstUnresolvedDiscussionId = (state, getters) => (diffOrder) => {
if (diffOrder) {
return getters.unresolvedDiscussionsIdsByDiff[0];
}
return getters.unresolvedDiscussionsIdsByDate[0];
};
export const getDiscussion = state => discussionId =>
state.discussions.find(discussion => discussion.id === discussionId);
export const getDiscussion = (state) => (discussionId) =>
state.discussions.find((discussion) => discussion.id === discussionId);
export const commentsDisabled = state => state.commentsDisabled;
export const commentsDisabled = (state) => state.commentsDisabled;
export const suggestionsCount = (state, getters) =>
Object.values(getters.notesById).filter(n => n.suggestions.length).length;
Object.values(getters.notesById).filter((n) => n.suggestions.length).length;
......@@ -7,7 +7,7 @@ export default {
[types.ADD_NEW_NOTE](state, data) {
const note = data.discussion ? data.discussion.notes[0] : data;
const { discussion_id, type } = note;
const [exists] = state.discussions.filter(n => n.id === note.discussion_id);
const [exists] = state.discussions.filter((n) => n.id === note.discussion_id);
const isDiscussion = type === constants.DISCUSSION_NOTE || type === constants.DIFF_NOTE;
if (!exists) {
......@@ -128,7 +128,7 @@ export default {
// To support legacy notes, should be very rare case.
if (discussion.individual_note && discussion.notes.length > 1) {
discussion.notes.forEach(n => {
discussion.notes.forEach((n) => {
acc.push({
...discussion,
...diffData,
......@@ -183,7 +183,7 @@ export default {
const { id, name, username } = state.userData;
const hasEmojiAwardedByCurrentUser = note.award_emoji.filter(
emoji => `${emoji.name}` === `${data.awardName}` && emoji.user.id === id,
(emoji) => `${emoji.name}` === `${data.awardName}` && emoji.user.id === id,
);
if (hasEmojiAwardedByCurrentUser.length) {
......@@ -206,7 +206,7 @@ export default {
[types.SET_EXPAND_DISCUSSIONS](state, { discussionIds, expanded }) {
if (discussionIds?.length) {
discussionIds.forEach(discussionId => {
discussionIds.forEach((discussionId) => {
const discussion = utils.findNoteObjectById(state.discussions, discussionId);
Object.assign(discussion, { expanded });
});
......@@ -236,7 +236,7 @@ export default {
const noteObj = utils.findNoteObjectById(state.discussions, discussionId);
const comment = utils.findNoteObjectById(noteObj.notes, noteId);
comment.suggestions = comment.suggestions.map(suggestion => ({
comment.suggestions = comment.suggestions.map((suggestion) => ({
...suggestion,
applied: suggestion.applied || suggestion.id === suggestionId,
appliable: false,
......@@ -244,13 +244,13 @@ export default {
},
[types.SET_APPLYING_BATCH_STATE](state, isApplyingBatch) {
state.batchSuggestionsInfo.forEach(suggestionInfo => {
state.batchSuggestionsInfo.forEach((suggestionInfo) => {
const { discussionId, noteId, suggestionId } = suggestionInfo;
const noteObj = utils.findNoteObjectById(state.discussions, discussionId);
const comment = utils.findNoteObjectById(noteObj.notes, noteId);
comment.suggestions = comment.suggestions.map(suggestion => ({
comment.suggestions = comment.suggestions.map((suggestion) => ({
...suggestion,
is_applying_batch: suggestion.id === suggestionId && isApplyingBatch,
}));
......@@ -278,7 +278,7 @@ export default {
[types.UPDATE_DISCUSSION](state, noteData) {
const note = noteData;
const selectedDiscussion = state.discussions.find(disc => disc.id === note.id);
const selectedDiscussion = state.discussions.find((disc) => disc.id === note.id);
note.expanded = true; // override expand flag to prevent collapse
if (note.diff_file) {
Object.assign(note, {
......@@ -289,7 +289,7 @@ export default {
},
[types.UPDATE_DISCUSSION_POSITION](state, { discussionId, position }) {
const selectedDiscussion = state.discussions.find(disc => disc.id === discussionId);
const selectedDiscussion = state.discussions.find((disc) => disc.id === discussionId);
if (selectedDiscussion) Object.assign(selectedDiscussion.position, { ...position });
},
......@@ -341,13 +341,13 @@ export default {
},
[types.UPDATE_RESOLVABLE_DISCUSSIONS_COUNTS](state) {
state.resolvableDiscussionsCount = state.discussions.filter(
discussion => !discussion.individual_note && discussion.resolvable,
(discussion) => !discussion.individual_note && discussion.resolvable,
).length;
state.unresolvedDiscussionsCount = state.discussions.filter(
discussion =>
(discussion) =>
!discussion.individual_note &&
discussion.resolvable &&
discussion.notes.some(note => note.resolvable && !note.resolved),
discussion.notes.some((note) => note.resolvable && !note.resolved),
).length;
},
......
......@@ -6,13 +6,13 @@ import createGqClient, { fetchPolicies } from '~/lib/graphql';
// factory function because global flag makes RegExp stateful
const createQuickActionsRegex = () => /^\/\w+.*$/gm;
export const findNoteObjectById = (notes, id) => notes.filter(n => n.id === id)[0];
export const findNoteObjectById = (notes, id) => notes.filter((n) => n.id === id)[0];
export const getQuickActionText = note => {
export const getQuickActionText = (note) => {
let text = __('Applying command');
const quickActions = AjaxCache.get(gl.GfmAutoComplete.dataSources.commands) || [];
const executedCommands = quickActions.filter(command => {
const executedCommands = quickActions.filter((command) => {
const commandRegex = new RegExp(`/${command.name}`);
return commandRegex.test(note);
});
......@@ -29,12 +29,12 @@ export const getQuickActionText = note => {
return text;
};
export const hasQuickActions = note => createQuickActionsRegex().test(note);
export const hasQuickActions = (note) => createQuickActionsRegex().test(note);
export const stripQuickActions = note => note.replace(createQuickActionsRegex(), '').trim();
export const stripQuickActions = (note) => note.replace(createQuickActionsRegex(), '').trim();
export const prepareDiffLines = diffLines =>
diffLines.map(line => ({ ...trimFirstCharOfLineContent(line) }));
export const prepareDiffLines = (diffLines) =>
diffLines.map((line) => ({ ...trimFirstCharOfLineContent(line) }));
export const gqClient = createGqClient(
{},
......
......@@ -4,7 +4,7 @@
* Tracks snowplow event when User toggles timeline view
* @param {Boolean} enabled that will be send as a property for the event
*/
export const trackToggleTimelineView = enabled => ({
export const trackToggleTimelineView = (enabled) => ({
category: 'Incident Management',
action: 'toggle_incident_comments_into_timeline_view',
label: 'Status',
......
......@@ -23,7 +23,7 @@ export default function notificationsDropdown() {
Rails.fire(form[0], 'submit');
});
$(document).on('ajax:success', '.notification-form', e => {
$(document).on('ajax:success', '.notification-form', (e) => {
const data = e.detail[0];
if (data.saved) {
......
......@@ -57,7 +57,7 @@ const showPopover = (el, path, footer, options) => {
.popover('show');
// The previous popover actions have been taken, don't show those popovers anymore.
Object.keys(settings).forEach(pathSetting => {
Object.keys(settings).forEach((pathSetting) => {
if (path !== pathSetting) {
settings[pathSetting] = false;
} else {
......@@ -71,7 +71,7 @@ const showPopover = (el, path, footer, options) => {
}
};
export const showLearnGitLabGroupItemPopover = id => {
export const showLearnGitLabGroupItemPopover = (id) => {
const el = document.querySelector(`#group-${id} .group-text a`);
if (!el) return;
......
......@@ -21,7 +21,7 @@ export const saveChanges = ({ state, dispatch }) =>
},
})
.then(() => dispatch('receiveSaveChangesSuccess'))
.catch(error => dispatch('receiveSaveChangesError', error));
.catch((error) => dispatch('receiveSaveChangesError', error));
export const receiveSaveChangesSuccess = () => {
/**
......
......@@ -6,7 +6,7 @@ import mutations from './mutations';
Vue.use(Vuex);
export const createStore = initialState =>
export const createStore = (initialState) =>
new Vuex.Store({
state: createState(initialState),
actions,
......
......@@ -25,14 +25,14 @@ export default {
},
computed: {
filesTableRows() {
return this.packageFiles.map(pf => ({
return this.packageFiles.map((pf) => ({
...pf,
size: this.formatSize(pf.size),
pipeline: last(pf.pipelines),
}));
},
showCommitColumn() {
return this.filesTableRows.some(row => Boolean(row.pipeline?.id));
return this.filesTableRows.some((row) => Boolean(row.pipeline?.id));
},
filesTableHeaderFields() {
return [
......@@ -55,7 +55,7 @@ export default {
label: __('Created'),
class: 'gl-text-right',
},
].filter(c => !c.hide);
].filter((c) => !c.hide);
},
},
methods: {
......
......@@ -24,10 +24,10 @@ export default {
},
computed: {
...mapState({
perPage: state => state.pagination.perPage,
totalItems: state => state.pagination.total,
page: state => state.pagination.page,
isGroupPage: state => state.config.isGroupPage,
perPage: (state) => state.pagination.perPage,
totalItems: (state) => state.pagination.total,
page: (state) => state.pagination.page,
isGroupPage: (state) => state.config.isGroupPage,
isLoading: 'isLoading',
}),
...mapGetters({ list: 'getList' }),
......
......@@ -25,12 +25,12 @@ export default {
},
computed: {
...mapState({
emptyListIllustration: state => state.config.emptyListIllustration,
emptyListHelpUrl: state => state.config.emptyListHelpUrl,
filterQuery: state => state.filterQuery,
selectedType: state => state.selectedType,
packageHelpUrl: state => state.config.packageHelpUrl,
packagesCount: state => state.pagination?.total,
emptyListIllustration: (state) => state.config.emptyListIllustration,
emptyListHelpUrl: (state) => state.config.emptyListHelpUrl,
filterQuery: (state) => state.filterQuery,
selectedType: (state) => state.selectedType,
packageHelpUrl: (state) => state.config.packageHelpUrl,
packagesCount: (state) => state.pagination?.total,
}),
tabsToRender() {
return PACKAGE_REGISTRY_TABS;
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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