Commit 8869ce08 authored by Lukas Eipert's avatar Lukas Eipert

Run prettier on 17 files - 1 of 73

Part of our prettier migration; changing the arrow-parens style.
parent 2fc90710
...@@ -10,25 +10,6 @@ doc/api/graphql/reference/gitlab_schema.graphql ...@@ -10,25 +10,6 @@ doc/api/graphql/reference/gitlab_schema.graphql
*.scss *.scss
*.md *.md
## lovely-lovelace
app/assets/javascripts/alerts_settings/components/alerts_settings_wrapper.vue
app/assets/javascripts/behaviors/markdown/paste_markdown_table.js
app/assets/javascripts/boards/components/sidebar/remove_issue.vue
app/assets/javascripts/diffs/components/diff_row.vue
app/assets/javascripts/diffs/store/getters.js
app/assets/javascripts/dropzone_input.js
app/assets/javascripts/feature_flags/components/strategy.vue
app/assets/javascripts/ide/lib/create_diff.js
app/assets/javascripts/ide/stores/modules/pipelines/getters.js
app/assets/javascripts/members/components/table/members_table.vue
app/assets/javascripts/members/store/utils.js
app/assets/javascripts/monitoring/stores/actions.js
app/assets/javascripts/monitoring/stores/getters.js
app/assets/javascripts/packages/list/utils.js
app/assets/javascripts/pages/projects/forks/new/components/fork_groups_list.vue
app/assets/javascripts/pages/users/user_tabs.js
app/assets/javascripts/projects/settings/access_dropdown.js
## stoic-swirles ## stoic-swirles
app/assets/javascripts/repository/log_tree.js app/assets/javascripts/repository/log_tree.js
app/assets/javascripts/repository/utils/dom.js app/assets/javascripts/repository/utils/dom.js
......
...@@ -243,7 +243,9 @@ export default { ...@@ -243,7 +243,9 @@ export default {
}); });
}, },
editIntegration({ id }) { editIntegration({ id }) {
const currentIntegration = this.integrations.list.find(integration => integration.id === id); const currentIntegration = this.integrations.list.find(
(integration) => integration.id === id,
);
this.$apollo.mutate({ this.$apollo.mutate({
mutation: updateCurrentIntergrationMutation, mutation: updateCurrentIntergrationMutation,
variables: { variables: {
......
const maxColumnWidth = (rows, columnIndex) => Math.max(...rows.map(row => row[columnIndex].length)); const maxColumnWidth = (rows, columnIndex) =>
Math.max(...rows.map((row) => row[columnIndex].length));
export default class PasteMarkdownTable { export default class PasteMarkdownTable {
constructor(clipboardData) { constructor(clipboardData) {
...@@ -16,7 +17,7 @@ export default class PasteMarkdownTable { ...@@ -16,7 +17,7 @@ export default class PasteMarkdownTable {
this.calculateColumnWidths(); this.calculateColumnWidths();
const markdownRows = this.rows.map( const markdownRows = this.rows.map(
row => (row) =>
// | Name | Title | Email Address | // | Name | Title | Email Address |
// |--------------|-------|----------------| // |--------------|-------|----------------|
// | Jane Atler | CEO | jane@acme.com | // | Jane Atler | CEO | jane@acme.com |
...@@ -66,7 +67,7 @@ export default class PasteMarkdownTable { ...@@ -66,7 +67,7 @@ export default class PasteMarkdownTable {
return false; return false;
} }
this.rows = splitRows.map(row => row.split('\t')); this.rows = splitRows.map((row) => row.split('\t'));
this.normalizeRows(); this.normalizeRows();
// Check that the max number of columns in the HTML matches the number of // Check that the max number of columns in the HTML matches the number of
...@@ -81,10 +82,10 @@ export default class PasteMarkdownTable { ...@@ -81,10 +82,10 @@ export default class PasteMarkdownTable {
// Ensure each row has the same number of columns // Ensure each row has the same number of columns
normalizeRows() { normalizeRows() {
const rowLengths = this.rows.map(row => row.length); const rowLengths = this.rows.map((row) => row.length);
const maxLength = Math.max(...rowLengths); const maxLength = Math.max(...rowLengths);
this.rows.forEach(row => { this.rows.forEach((row) => {
while (row.length < maxLength) { while (row.length < maxLength) {
row.push(''); row.push('');
} }
...@@ -101,7 +102,7 @@ export default class PasteMarkdownTable { ...@@ -101,7 +102,7 @@ export default class PasteMarkdownTable {
const textColumnCount = this.rows[0].length; const textColumnCount = this.rows[0].length;
let htmlColumnCount = 0; let htmlColumnCount = 0;
this.doc.querySelectorAll('table tr').forEach(row => { this.doc.querySelectorAll('table tr').forEach((row) => {
htmlColumnCount = Math.max(row.cells.length, htmlColumnCount); htmlColumnCount = Math.max(row.cells.length, htmlColumnCount);
}); });
......
...@@ -42,13 +42,13 @@ export default { ...@@ -42,13 +42,13 @@ export default {
axios.patch(this.updateUrl, data).catch(() => { axios.patch(this.updateUrl, data).catch(() => {
Flash(__('Failed to remove issue from board, please try again.')); Flash(__('Failed to remove issue from board, please try again.'));
lists.forEach(list => { lists.forEach((list) => {
list.addIssue(issue); list.addIssue(issue);
}); });
}); });
// Remove from the frontend store // Remove from the frontend store
lists.forEach(list => { lists.forEach((list) => {
list.removeIssue(issue); list.removeIssue(issue);
}); });
...@@ -58,9 +58,11 @@ export default { ...@@ -58,9 +58,11 @@ export default {
* Build the default patch request. * Build the default patch request.
*/ */
buildPatchRequest(issue, lists) { buildPatchRequest(issue, lists) {
const listLabelIds = lists.map(list => list.label.id); const listLabelIds = lists.map((list) => list.label.id);
const labelIds = issue.labels.map(label => label.id).filter(id => !listLabelIds.includes(id)); const labelIds = issue.labels
.map((label) => label.id)
.filter((id) => !listLabelIds.includes(id));
return { return {
label_ids: labelIds, label_ids: labelIds,
......
...@@ -115,7 +115,9 @@ export default { ...@@ -115,7 +115,9 @@ export default {
const table = line.closest('.diff-table'); const table = line.closest('.diff-table');
table.classList.remove('left-side-selected', 'right-side-selected'); table.classList.remove('left-side-selected', 'right-side-selected');
const [lineClass] = ['left-side', 'right-side'].filter(name => line.classList.contains(name)); const [lineClass] = ['left-side', 'right-side'].filter((name) =>
line.classList.contains(name),
);
if (lineClass) { if (lineClass) {
table.classList.add(`${lineClass}-selected`); table.classList.add(`${lineClass}-selected`);
......
...@@ -9,13 +9,13 @@ import { ...@@ -9,13 +9,13 @@ import {
export * from './getters_versions_dropdowns'; export * from './getters_versions_dropdowns';
export const isParallelView = state => state.diffViewType === PARALLEL_DIFF_VIEW_TYPE; export const isParallelView = (state) => state.diffViewType === PARALLEL_DIFF_VIEW_TYPE;
export const isInlineView = state => state.diffViewType === INLINE_DIFF_VIEW_TYPE; export const isInlineView = (state) => state.diffViewType === INLINE_DIFF_VIEW_TYPE;
export const whichCollapsedTypes = state => { export const whichCollapsedTypes = (state) => {
const automatic = state.diffFiles.some(file => file.viewer?.automaticallyCollapsed); const automatic = state.diffFiles.some((file) => file.viewer?.automaticallyCollapsed);
const manual = state.diffFiles.some(file => file.viewer?.manuallyCollapsed); const manual = state.diffFiles.some((file) => file.viewer?.manuallyCollapsed);
return { return {
any: automatic || manual, any: automatic || manual,
...@@ -24,18 +24,18 @@ export const whichCollapsedTypes = state => { ...@@ -24,18 +24,18 @@ export const whichCollapsedTypes = state => {
}; };
}; };
export const commitId = state => (state.commit && state.commit.id ? state.commit.id : null); export const commitId = (state) => (state.commit && state.commit.id ? state.commit.id : null);
/** /**
* Checks if the diff has all discussions expanded * Checks if the diff has all discussions expanded
* @param {Object} diff * @param {Object} diff
* @returns {Boolean} * @returns {Boolean}
*/ */
export const diffHasAllExpandedDiscussions = (state, getters) => diff => { export const diffHasAllExpandedDiscussions = (state, getters) => (diff) => {
const discussions = getters.getDiffFileDiscussions(diff); const discussions = getters.getDiffFileDiscussions(diff);
return ( return (
(discussions && discussions.length && discussions.every(discussion => discussion.expanded)) || (discussions && discussions.length && discussions.every((discussion) => discussion.expanded)) ||
false false
); );
}; };
...@@ -45,11 +45,13 @@ export const diffHasAllExpandedDiscussions = (state, getters) => diff => { ...@@ -45,11 +45,13 @@ export const diffHasAllExpandedDiscussions = (state, getters) => diff => {
* @param {Object} diff * @param {Object} diff
* @returns {Boolean} * @returns {Boolean}
*/ */
export const diffHasAllCollapsedDiscussions = (state, getters) => diff => { export const diffHasAllCollapsedDiscussions = (state, getters) => (diff) => {
const discussions = getters.getDiffFileDiscussions(diff); const discussions = getters.getDiffFileDiscussions(diff);
return ( return (
(discussions && discussions.length && discussions.every(discussion => !discussion.expanded)) || (discussions &&
discussions.length &&
discussions.every((discussion) => !discussion.expanded)) ||
false false
); );
}; };
...@@ -59,9 +61,9 @@ export const diffHasAllCollapsedDiscussions = (state, getters) => diff => { ...@@ -59,9 +61,9 @@ export const diffHasAllCollapsedDiscussions = (state, getters) => diff => {
* @param {Object} diff * @param {Object} diff
* @returns {Boolean} * @returns {Boolean}
*/ */
export const diffHasExpandedDiscussions = () => diff => { export const diffHasExpandedDiscussions = () => (diff) => {
return diff[INLINE_DIFF_LINES_KEY].filter(l => l.discussions.length >= 1).some( return diff[INLINE_DIFF_LINES_KEY].filter((l) => l.discussions.length >= 1).some(
l => l.discussionsExpanded, (l) => l.discussionsExpanded,
); );
}; };
...@@ -70,8 +72,8 @@ export const diffHasExpandedDiscussions = () => diff => { ...@@ -70,8 +72,8 @@ export const diffHasExpandedDiscussions = () => diff => {
* @param {Boolean} diff * @param {Boolean} diff
* @returns {Boolean} * @returns {Boolean}
*/ */
export const diffHasDiscussions = () => diff => { export const diffHasDiscussions = () => (diff) => {
return diff[INLINE_DIFF_LINES_KEY].some(l => l.discussions.length >= 1); return diff[INLINE_DIFF_LINES_KEY].some((l) => l.discussions.length >= 1);
}; };
/** /**
...@@ -79,22 +81,22 @@ export const diffHasDiscussions = () => diff => { ...@@ -79,22 +81,22 @@ export const diffHasDiscussions = () => diff => {
* @param {Object} diff * @param {Object} diff
* @returns {Array} * @returns {Array}
*/ */
export const getDiffFileDiscussions = (state, getters, rootState, rootGetters) => diff => export const getDiffFileDiscussions = (state, getters, rootState, rootGetters) => (diff) =>
rootGetters.discussions.filter( rootGetters.discussions.filter(
discussion => discussion.diff_discussion && discussion.diff_file.file_hash === diff.file_hash, (discussion) => discussion.diff_discussion && discussion.diff_file.file_hash === diff.file_hash,
) || []; ) || [];
export const getDiffFileByHash = state => fileHash => export const getDiffFileByHash = (state) => (fileHash) =>
state.diffFiles.find(file => file.file_hash === fileHash); state.diffFiles.find((file) => file.file_hash === fileHash);
export const flatBlobsList = state => export const flatBlobsList = (state) =>
Object.values(state.treeEntries).filter(f => f.type === 'blob'); Object.values(state.treeEntries).filter((f) => f.type === 'blob');
export const allBlobs = (state, getters) => export const allBlobs = (state, getters) =>
getters.flatBlobsList.reduce((acc, file) => { getters.flatBlobsList.reduce((acc, file) => {
const { parentPath } = file; const { parentPath } = file;
if (parentPath && !acc.some(f => f.path === parentPath)) { if (parentPath && !acc.some((f) => f.path === parentPath)) {
acc.push({ acc.push({
path: parentPath, path: parentPath,
isHeader: true, isHeader: true,
...@@ -102,13 +104,13 @@ export const allBlobs = (state, getters) => ...@@ -102,13 +104,13 @@ export const allBlobs = (state, getters) =>
}); });
} }
acc.find(f => f.path === parentPath).tree.push(file); acc.find((f) => f.path === parentPath).tree.push(file);
return acc; return acc;
}, []); }, []);
export const getCommentFormForDiffFile = state => fileHash => export const getCommentFormForDiffFile = (state) => (fileHash) =>
state.commentForms.find(form => form.fileHash === fileHash); state.commentForms.find((form) => form.fileHash === fileHash);
/** /**
* Returns the test coverage hits for a specific line of a given file * Returns the test coverage hits for a specific line of a given file
...@@ -116,7 +118,7 @@ export const getCommentFormForDiffFile = state => fileHash => ...@@ -116,7 +118,7 @@ export const getCommentFormForDiffFile = state => fileHash =>
* @param {number} line * @param {number} line
* @returns {number} * @returns {number}
*/ */
export const fileLineCoverage = state => (file, line) => { export const fileLineCoverage = (state) => (file, line) => {
if (!state.coverageFiles.files) return {}; if (!state.coverageFiles.files) return {};
const fileCoverage = state.coverageFiles.files[file]; const fileCoverage = state.coverageFiles.files[file];
if (!fileCoverage) return {}; if (!fileCoverage) return {};
...@@ -137,13 +139,13 @@ export const fileLineCoverage = state => (file, line) => { ...@@ -137,13 +139,13 @@ export const fileLineCoverage = state => (file, line) => {
* Returns index of a currently selected diff in diffFiles * Returns index of a currently selected diff in diffFiles
* @returns {number} * @returns {number}
*/ */
export const currentDiffIndex = state => export const currentDiffIndex = (state) =>
Math.max( Math.max(
0, 0,
state.diffFiles.findIndex(diff => diff.file_hash === state.currentDiffFileId), state.diffFiles.findIndex((diff) => diff.file_hash === state.currentDiffFileId),
); );
export const diffLines = state => (file, unifiedDiffComponents) => { export const diffLines = (state) => (file, unifiedDiffComponents) => {
if (!unifiedDiffComponents && state.diffViewType === INLINE_DIFF_VIEW_TYPE) { if (!unifiedDiffComponents && state.diffViewType === INLINE_DIFF_VIEW_TYPE) {
return null; return null;
} }
...@@ -155,5 +157,5 @@ export const diffLines = state => (file, unifiedDiffComponents) => { ...@@ -155,5 +157,5 @@ export const diffLines = state => (file, unifiedDiffComponents) => {
}; };
export function fileReviews(state) { export function fileReviews(state) {
return state.diffFiles.map(file => isFileReviewed(state.mrReviews, file)); return state.diffFiles.map((file) => isFileReviewed(state.mrReviews, file));
} }
...@@ -46,7 +46,7 @@ export default function dropzoneInput(form, config = { parallelUploads: 2 }) { ...@@ -46,7 +46,7 @@ export default function dropzoneInput(form, config = { parallelUploads: 2 }) {
let uploadFile; let uploadFile;
formTextarea.wrap('<div class="div-dropzone"></div>'); formTextarea.wrap('<div class="div-dropzone"></div>');
formTextarea.on('paste', event => handlePaste(event)); formTextarea.on('paste', (event) => handlePaste(event));
// Add dropzone area to the form. // Add dropzone area to the form.
const $mdArea = formTextarea.closest('.md-area'); const $mdArea = formTextarea.closest('.md-area');
...@@ -139,7 +139,7 @@ export default function dropzoneInput(form, config = { parallelUploads: 2 }) { ...@@ -139,7 +139,7 @@ export default function dropzoneInput(form, config = { parallelUploads: 2 }) {
// removeAllFiles(true) stops uploading files (if any) // removeAllFiles(true) stops uploading files (if any)
// and remove them from dropzone files queue. // and remove them from dropzone files queue.
$cancelButton.on('click', e => { $cancelButton.on('click', (e) => {
e.preventDefault(); e.preventDefault();
e.stopPropagation(); e.stopPropagation();
Dropzone.forElement($formDropzone.get(0)).removeAllFiles(true); Dropzone.forElement($formDropzone.get(0)).removeAllFiles(true);
...@@ -149,7 +149,7 @@ export default function dropzoneInput(form, config = { parallelUploads: 2 }) { ...@@ -149,7 +149,7 @@ export default function dropzoneInput(form, config = { parallelUploads: 2 }) {
// clear dropzone files queue, change status of failed files to undefined, // clear dropzone files queue, change status of failed files to undefined,
// and add that files to the dropzone files queue again. // and add that files to the dropzone files queue again.
// addFile() adds file to dropzone files queue and upload it. // addFile() adds file to dropzone files queue and upload it.
$retryLink.on('click', e => { $retryLink.on('click', (e) => {
const dropzoneInstance = Dropzone.forElement( const dropzoneInstance = Dropzone.forElement(
e.target.closest('.js-main-target-form').querySelector('.div-dropzone'), e.target.closest('.js-main-target-form').querySelector('.div-dropzone'),
); );
...@@ -161,7 +161,7 @@ export default function dropzoneInput(form, config = { parallelUploads: 2 }) { ...@@ -161,7 +161,7 @@ export default function dropzoneInput(form, config = { parallelUploads: 2 }) {
// uploading of files that are being uploaded at the moment. // uploading of files that are being uploaded at the moment.
dropzoneInstance.removeAllFiles(true); dropzoneInstance.removeAllFiles(true);
failedFiles.map(failedFile => { failedFiles.map((failedFile) => {
const file = failedFile; const file = failedFile;
if (file.status === Dropzone.ERROR) { if (file.status === Dropzone.ERROR) {
...@@ -173,7 +173,7 @@ export default function dropzoneInput(form, config = { parallelUploads: 2 }) { ...@@ -173,7 +173,7 @@ export default function dropzoneInput(form, config = { parallelUploads: 2 }) {
}); });
}); });
// eslint-disable-next-line consistent-return // eslint-disable-next-line consistent-return
handlePaste = event => { handlePaste = (event) => {
const pasteEvent = event.originalEvent; const pasteEvent = event.originalEvent;
const { clipboardData } = pasteEvent; const { clipboardData } = pasteEvent;
if (clipboardData && clipboardData.items) { if (clipboardData && clipboardData.items) {
...@@ -198,7 +198,7 @@ export default function dropzoneInput(form, config = { parallelUploads: 2 }) { ...@@ -198,7 +198,7 @@ export default function dropzoneInput(form, config = { parallelUploads: 2 }) {
} }
}; };
isImage = data => { isImage = (data) => {
let i = 0; let i = 0;
while (i < data.clipboardData.items.length) { while (i < data.clipboardData.items.length) {
const item = data.clipboardData.items[i]; const item = data.clipboardData.items[i];
...@@ -228,7 +228,7 @@ export default function dropzoneInput(form, config = { parallelUploads: 2 }) { ...@@ -228,7 +228,7 @@ export default function dropzoneInput(form, config = { parallelUploads: 2 }) {
return formTextarea.trigger('input'); return formTextarea.trigger('input');
}; };
addFileToForm = path => { addFileToForm = (path) => {
$(form).append(`<input type="hidden" name="files[]" value="${escape(path)}">`); $(form).append(`<input type="hidden" name="files[]" value="${escape(path)}">`);
}; };
...@@ -236,7 +236,7 @@ export default function dropzoneInput(form, config = { parallelUploads: 2 }) { ...@@ -236,7 +236,7 @@ export default function dropzoneInput(form, config = { parallelUploads: 2 }) {
const closeSpinner = () => $uploadingProgressContainer.addClass('hide'); const closeSpinner = () => $uploadingProgressContainer.addClass('hide');
const showError = message => { const showError = (message) => {
$uploadingErrorContainer.removeClass('hide'); $uploadingErrorContainer.removeClass('hide');
$uploadingErrorMessage.html(message); $uploadingErrorMessage.html(message);
}; };
...@@ -269,15 +269,16 @@ export default function dropzoneInput(form, config = { parallelUploads: 2 }) { ...@@ -269,15 +269,16 @@ export default function dropzoneInput(form, config = { parallelUploads: 2 }) {
insertToTextArea(filename, md); insertToTextArea(filename, md);
closeSpinner(); closeSpinner();
}) })
.catch(e => { .catch((e) => {
showError(e.response.data.message); showError(e.response.data.message);
closeSpinner(); closeSpinner();
}); });
}; };
updateAttachingMessage = (files, messageContainer) => { updateAttachingMessage = (files, messageContainer) => {
const filesCount = files.filter(file => file.status === 'uploading' || file.status === 'queued') const filesCount = files.filter(
.length; (file) => file.status === 'uploading' || file.status === 'queued',
).length;
const attachingMessage = n__('Attaching a file', 'Attaching %d files', filesCount); const attachingMessage = n__('Attaching a file', 'Attaching %d files', filesCount);
messageContainer.text(`${attachingMessage} -`); messageContainer.text(`${attachingMessage} -`);
......
...@@ -83,7 +83,7 @@ export default { ...@@ -83,7 +83,7 @@ export default {
); );
}, },
filteredEnvironments() { filteredEnvironments() {
return this.environments.filter(e => !e.shouldBeDestroyed); return this.environments.filter((e) => !e.shouldBeDestroyed);
}, },
isPercentUserRollout() { isPercentUserRollout() {
return this.formStrategy.name === ROLLOUT_STRATEGY_PERCENT_ROLLOUT; return this.formStrategy.name === ROLLOUT_STRATEGY_PERCENT_ROLLOUT;
...@@ -91,7 +91,9 @@ export default { ...@@ -91,7 +91,9 @@ export default {
}, },
methods: { methods: {
addEnvironment(environment) { addEnvironment(environment) {
const allEnvironmentsScope = this.environments.find(scope => scope.environmentScope === '*'); const allEnvironmentsScope = this.environments.find(
(scope) => scope.environmentScope === '*',
);
if (allEnvironmentsScope) { if (allEnvironmentsScope) {
allEnvironmentsScope.shouldBeDestroyed = true; allEnvironmentsScope.shouldBeDestroyed = true;
} }
...@@ -113,7 +115,7 @@ export default { ...@@ -113,7 +115,7 @@ export default {
if (isNumber(environment.id)) { if (isNumber(environment.id)) {
Vue.set(environment, 'shouldBeDestroyed', true); Vue.set(environment, 'shouldBeDestroyed', true);
} else { } else {
this.environments = this.environments.filter(e => e !== environment); this.environments = this.environments.filter((e) => e !== environment);
} }
if (this.filteredEnvironments.length === 0) { if (this.filteredEnvironments.length === 0) {
this.environments.push({ environmentScope: '*' }); this.environments.push({ environmentScope: '*' });
......
...@@ -32,8 +32,8 @@ const filesWithChanges = ({ stagedFiles = [], changedFiles = [], entries = {} }) ...@@ -32,8 +32,8 @@ const filesWithChanges = ({ stagedFiles = [], changedFiles = [], entries = {} })
// We need to clean "move" actions, because we can only support 100% similarity moves at the moment. // We need to clean "move" actions, because we can only support 100% similarity moves at the moment.
// This is because the previous file's content might not be loaded. // This is because the previous file's content might not be loaded.
Object.values(changes) Object.values(changes)
.filter(change => change.action === commitActionTypes.move) .filter((change) => change.action === commitActionTypes.move)
.forEach(change => { .forEach((change) => {
const prev = changes[change.file.prevPath]; const prev = changes[change.file.prevPath];
if (!prev) { if (!prev) {
...@@ -51,14 +51,14 @@ const filesWithChanges = ({ stagedFiles = [], changedFiles = [], entries = {} }) ...@@ -51,14 +51,14 @@ const filesWithChanges = ({ stagedFiles = [], changedFiles = [], entries = {} })
// Next, we need to add deleted directories by looking at the parents // Next, we need to add deleted directories by looking at the parents
Object.values(changes) Object.values(changes)
.filter(change => change.action === commitActionTypes.delete && change.file.parentPath) .filter((change) => change.action === commitActionTypes.delete && change.file.parentPath)
.forEach(({ file }) => { .forEach(({ file }) => {
// Do nothing if we've already visited this directory. // Do nothing if we've already visited this directory.
if (changes[file.parentPath]) { if (changes[file.parentPath]) {
return; return;
} }
getDeletedParents(entries, file).forEach(parent => { getDeletedParents(entries, file).forEach((parent) => {
changes[parent.path] = { action: commitActionTypes.delete, file: parent }; changes[parent.path] = { action: commitActionTypes.delete, file: parent };
}); });
}); });
...@@ -66,13 +66,15 @@ const filesWithChanges = ({ stagedFiles = [], changedFiles = [], entries = {} }) ...@@ -66,13 +66,15 @@ const filesWithChanges = ({ stagedFiles = [], changedFiles = [], entries = {} })
return Object.values(changes); return Object.values(changes);
}; };
const createDiff = state => { const createDiff = (state) => {
const changes = filesWithChanges(state); const changes = filesWithChanges(state);
const toDelete = changes.filter(x => x.action === commitActionTypes.delete).map(x => x.file.path); const toDelete = changes
.filter((x) => x.action === commitActionTypes.delete)
.map((x) => x.file.path);
const patch = changes const patch = changes
.filter(x => x.action !== commitActionTypes.delete) .filter((x) => x.action !== commitActionTypes.delete)
.map(({ file, action }) => createFileDiff(file, action)) .map(({ file, action }) => createFileDiff(file, action))
.join(''); .join('');
......
import { states } from './constants'; import { states } from './constants';
export const hasLatestPipeline = state => !state.isLoadingPipeline && Boolean(state.latestPipeline); export const hasLatestPipeline = (state) =>
!state.isLoadingPipeline && Boolean(state.latestPipeline);
export const pipelineFailed = state => export const pipelineFailed = (state) =>
state.latestPipeline && state.latestPipeline.details.status.text === states.failed; state.latestPipeline && state.latestPipeline.details.status.text === states.failed;
export const failedStages = state => export const failedStages = (state) =>
state.stages state.stages
.filter(stage => stage.status.text.toLowerCase() === states.failed) .filter((stage) => stage.status.text.toLowerCase() === states.failed)
.map(stage => ({ .map((stage) => ({
...stage, ...stage,
jobs: stage.jobs.filter(job => job.status.text.toLowerCase() === states.failed), jobs: stage.jobs.filter((job) => job.status.text.toLowerCase() === states.failed),
})); }));
export const failedJobsCount = state => export const failedJobsCount = (state) =>
state.stages.reduce( state.stages.reduce(
(acc, stage) => acc + stage.jobs.filter(j => j.status.text === states.failed).length, (acc, stage) => acc + stage.jobs.filter((j) => j.status.text === states.failed).length,
0, 0,
); );
export const jobsCount = state => state.stages.reduce((acc, stage) => acc + stage.jobs.length, 0); export const jobsCount = (state) => state.stages.reduce((acc, stage) => acc + stage.jobs.length, 0);
...@@ -34,7 +34,9 @@ export default { ...@@ -34,7 +34,9 @@ export default {
computed: { computed: {
...mapState(['members', 'tableFields', 'tableAttrs', 'currentUserId', 'sourceId']), ...mapState(['members', 'tableFields', 'tableAttrs', 'currentUserId', 'sourceId']),
filteredFields() { filteredFields() {
return FIELDS.filter(field => this.tableFields.includes(field.key) && this.showField(field)); return FIELDS.filter(
(field) => this.tableFields.includes(field.key) && this.showField(field),
);
}, },
userIsLoggedIn() { userIsLoggedIn() {
return this.currentUserId !== null; return this.currentUserId !== null;
...@@ -56,7 +58,7 @@ export default { ...@@ -56,7 +58,7 @@ export default {
return false; return false;
} }
return this.members.some(member => { return this.members.some((member) => {
return ( return (
canRemove(member, this.sourceId) || canRemove(member, this.sourceId) ||
canResend(member) || canResend(member) ||
......
export const findMember = (state, memberId) => state.members.find(member => member.id === memberId); export const findMember = (state, memberId) =>
state.members.find((member) => member.id === memberId);
...@@ -114,7 +114,7 @@ export const fetchDashboard = ({ state, commit, dispatch, getters }) => { ...@@ -114,7 +114,7 @@ export const fetchDashboard = ({ state, commit, dispatch, getters }) => {
} }
return getDashboard(state.dashboardEndpoint, params) return getDashboard(state.dashboardEndpoint, params)
.then(response => { .then((response) => {
dispatch('receiveMetricsDashboardSuccess', { response }); dispatch('receiveMetricsDashboardSuccess', { response });
/** /**
* After the dashboard is fetched, there can be non-blocking invalid syntax * After the dashboard is fetched, there can be non-blocking invalid syntax
...@@ -125,7 +125,7 @@ export const fetchDashboard = ({ state, commit, dispatch, getters }) => { ...@@ -125,7 +125,7 @@ export const fetchDashboard = ({ state, commit, dispatch, getters }) => {
*/ */
dispatch('fetchDashboardValidationWarnings'); dispatch('fetchDashboardValidationWarnings');
}) })
.catch(error => { .catch((error) => {
Sentry.captureException(error); Sentry.captureException(error);
commit(types.SET_ALL_DASHBOARDS, error.response?.data?.all_dashboards ?? []); commit(types.SET_ALL_DASHBOARDS, error.response?.data?.all_dashboards ?? []);
...@@ -185,9 +185,9 @@ export const fetchDashboardData = ({ state, dispatch, getters }) => { ...@@ -185,9 +185,9 @@ export const fetchDashboardData = ({ state, dispatch, getters }) => {
dispatch('fetchVariableMetricLabelValues', { defaultQueryParams }); dispatch('fetchVariableMetricLabelValues', { defaultQueryParams });
const promises = []; const promises = [];
state.dashboard.panelGroups.forEach(group => { state.dashboard.panelGroups.forEach((group) => {
group.panels.forEach(panel => { group.panels.forEach((panel) => {
panel.metrics.forEach(metric => { panel.metrics.forEach((metric) => {
promises.push(dispatch('fetchPrometheusMetric', { metric, defaultQueryParams })); promises.push(dispatch('fetchPrometheusMetric', { metric, defaultQueryParams }));
}); });
}); });
...@@ -231,10 +231,10 @@ export const fetchPrometheusMetric = ( ...@@ -231,10 +231,10 @@ export const fetchPrometheusMetric = (
commit(types.REQUEST_METRIC_RESULT, { metricId: metric.metricId }); commit(types.REQUEST_METRIC_RESULT, { metricId: metric.metricId });
return getPrometheusQueryData(metric.prometheusEndpointPath, queryParams) return getPrometheusQueryData(metric.prometheusEndpointPath, queryParams)
.then(data => { .then((data) => {
commit(types.RECEIVE_METRIC_RESULT_SUCCESS, { metricId: metric.metricId, data }); commit(types.RECEIVE_METRIC_RESULT_SUCCESS, { metricId: metric.metricId, data });
}) })
.catch(error => { .catch((error) => {
Sentry.captureException(error); Sentry.captureException(error);
commit(types.RECEIVE_METRIC_RESULT_FAILURE, { metricId: metric.metricId, error }); commit(types.RECEIVE_METRIC_RESULT_FAILURE, { metricId: metric.metricId, error });
...@@ -251,15 +251,15 @@ export const fetchDeploymentsData = ({ state, dispatch }) => { ...@@ -251,15 +251,15 @@ export const fetchDeploymentsData = ({ state, dispatch }) => {
} }
return axios return axios
.get(state.deploymentsEndpoint) .get(state.deploymentsEndpoint)
.then(resp => resp.data) .then((resp) => resp.data)
.then(response => { .then((response) => {
if (!response || !response.deployments) { if (!response || !response.deployments) {
createFlash(s__('Metrics|Unexpected deployment data response from prometheus endpoint')); createFlash(s__('Metrics|Unexpected deployment data response from prometheus endpoint'));
} }
dispatch('receiveDeploymentsDataSuccess', response.deployments); dispatch('receiveDeploymentsDataSuccess', response.deployments);
}) })
.catch(error => { .catch((error) => {
Sentry.captureException(error); Sentry.captureException(error);
dispatch('receiveDeploymentsDataFailure'); dispatch('receiveDeploymentsDataFailure');
createFlash(s__('Metrics|There was an error getting deployment information.')); createFlash(s__('Metrics|There was an error getting deployment information.'));
...@@ -285,10 +285,10 @@ export const fetchEnvironmentsData = ({ state, dispatch }) => { ...@@ -285,10 +285,10 @@ export const fetchEnvironmentsData = ({ state, dispatch }) => {
states: [ENVIRONMENT_AVAILABLE_STATE], states: [ENVIRONMENT_AVAILABLE_STATE],
}, },
}) })
.then(resp => .then((resp) =>
parseEnvironmentsResponse(resp.data?.project?.data?.environments, state.projectPath), parseEnvironmentsResponse(resp.data?.project?.data?.environments, state.projectPath),
) )
.then(environments => { .then((environments) => {
if (!environments) { if (!environments) {
createFlash( createFlash(
s__('Metrics|There was an error fetching the environments data, please try again'), s__('Metrics|There was an error fetching the environments data, please try again'),
...@@ -297,7 +297,7 @@ export const fetchEnvironmentsData = ({ state, dispatch }) => { ...@@ -297,7 +297,7 @@ export const fetchEnvironmentsData = ({ state, dispatch }) => {
dispatch('receiveEnvironmentsDataSuccess', environments); dispatch('receiveEnvironmentsDataSuccess', environments);
}) })
.catch(err => { .catch((err) => {
Sentry.captureException(err); Sentry.captureException(err);
dispatch('receiveEnvironmentsDataFailure'); dispatch('receiveEnvironmentsDataFailure');
createFlash(s__('Metrics|There was an error getting environments information.')); createFlash(s__('Metrics|There was an error getting environments information.'));
...@@ -326,16 +326,18 @@ export const fetchAnnotations = ({ state, dispatch, getters }) => { ...@@ -326,16 +326,18 @@ export const fetchAnnotations = ({ state, dispatch, getters }) => {
startingFrom: start, startingFrom: start,
}, },
}) })
.then(resp => resp.data?.project?.environments?.nodes?.[0].metricsDashboard?.annotations.nodes) .then(
(resp) => resp.data?.project?.environments?.nodes?.[0].metricsDashboard?.annotations.nodes,
)
.then(parseAnnotationsResponse) .then(parseAnnotationsResponse)
.then(annotations => { .then((annotations) => {
if (!annotations) { if (!annotations) {
createFlash(s__('Metrics|There was an error fetching annotations. Please try again.')); createFlash(s__('Metrics|There was an error fetching annotations. Please try again.'));
} }
dispatch('receiveAnnotationsSuccess', annotations); dispatch('receiveAnnotationsSuccess', annotations);
}) })
.catch(err => { .catch((err) => {
Sentry.captureException(err); Sentry.captureException(err);
dispatch('receiveAnnotationsFailure'); dispatch('receiveAnnotationsFailure');
createFlash(s__('Metrics|There was an error getting annotations information.')); createFlash(s__('Metrics|There was an error getting annotations information.'));
...@@ -363,7 +365,7 @@ export const fetchDashboardValidationWarnings = ({ state, dispatch, getters }) = ...@@ -363,7 +365,7 @@ export const fetchDashboardValidationWarnings = ({ state, dispatch, getters }) =
dashboardPath, dashboardPath,
}, },
}) })
.then(resp => resp.data?.project?.environments?.nodes?.[0]?.metricsDashboard) .then((resp) => resp.data?.project?.environments?.nodes?.[0]?.metricsDashboard)
.then(({ schemaValidationWarnings } = {}) => { .then(({ schemaValidationWarnings } = {}) => {
const hasWarnings = schemaValidationWarnings && schemaValidationWarnings.length !== 0; const hasWarnings = schemaValidationWarnings && schemaValidationWarnings.length !== 0;
/** /**
...@@ -372,7 +374,7 @@ export const fetchDashboardValidationWarnings = ({ state, dispatch, getters }) = ...@@ -372,7 +374,7 @@ export const fetchDashboardValidationWarnings = ({ state, dispatch, getters }) =
*/ */
dispatch('receiveDashboardValidationWarningsSuccess', hasWarnings || false); dispatch('receiveDashboardValidationWarningsSuccess', hasWarnings || false);
}) })
.catch(err => { .catch((err) => {
Sentry.captureException(err); Sentry.captureException(err);
dispatch('receiveDashboardValidationWarningsFailure'); dispatch('receiveDashboardValidationWarningsFailure');
createFlash( createFlash(
...@@ -437,9 +439,9 @@ export const duplicateSystemDashboard = ({ state }, payload) => { ...@@ -437,9 +439,9 @@ export const duplicateSystemDashboard = ({ state }, payload) => {
return axios return axios
.post(state.dashboardsEndpoint, params) .post(state.dashboardsEndpoint, params)
.then(response => response.data) .then((response) => response.data)
.then(data => data.dashboard) .then((data) => data.dashboard)
.catch(error => { .catch((error) => {
Sentry.captureException(error); Sentry.captureException(error);
const { response } = error; const { response } = error;
...@@ -466,7 +468,7 @@ export const fetchVariableMetricLabelValues = ({ state, commit }, { defaultQuery ...@@ -466,7 +468,7 @@ export const fetchVariableMetricLabelValues = ({ state, commit }, { defaultQuery
const { start_time, end_time } = defaultQueryParams; const { start_time, end_time } = defaultQueryParams;
const optionsRequests = []; const optionsRequests = [];
state.variables.forEach(variable => { state.variables.forEach((variable) => {
if (variable.type === VARIABLE_TYPES.metric_label_values) { if (variable.type === VARIABLE_TYPES.metric_label_values) {
const { prometheusEndpointPath, label } = variable.options; const { prometheusEndpointPath, label } = variable.options;
...@@ -474,7 +476,7 @@ export const fetchVariableMetricLabelValues = ({ state, commit }, { defaultQuery ...@@ -474,7 +476,7 @@ export const fetchVariableMetricLabelValues = ({ state, commit }, { defaultQuery
start_time, start_time,
end_time, end_time,
}) })
.then(data => { .then((data) => {
commit(types.UPDATE_VARIABLE_METRIC_LABEL_VALUES, { variable, label, data }); commit(types.UPDATE_VARIABLE_METRIC_LABEL_VALUES, { variable, label, data });
}) })
.catch(() => { .catch(() => {
...@@ -512,7 +514,7 @@ export const fetchPanelPreview = ({ state, commit, dispatch }, panelPreviewYml) ...@@ -512,7 +514,7 @@ export const fetchPanelPreview = ({ state, commit, dispatch }, panelPreviewYml)
dispatch('fetchPanelPreviewMetrics'); dispatch('fetchPanelPreviewMetrics');
}) })
.catch(error => { .catch((error) => {
commit(types.RECEIVE_PANEL_PREVIEW_FAILURE, extractErrorMessage(error)); commit(types.RECEIVE_PANEL_PREVIEW_FAILURE, extractErrorMessage(error));
}); });
}; };
...@@ -535,10 +537,10 @@ export const fetchPanelPreviewMetrics = ({ state, commit }) => { ...@@ -535,10 +537,10 @@ export const fetchPanelPreviewMetrics = ({ state, commit }) => {
return getPrometheusQueryData(metric.prometheusEndpointPath, params, { return getPrometheusQueryData(metric.prometheusEndpointPath, params, {
cancelToken: cancelTokenSource.token, cancelToken: cancelTokenSource.token,
}) })
.then(data => { .then((data) => {
commit(types.RECEIVE_PANEL_PREVIEW_METRIC_RESULT_SUCCESS, { index, data }); commit(types.RECEIVE_PANEL_PREVIEW_METRIC_RESULT_SUCCESS, { index, data });
}) })
.catch(error => { .catch((error) => {
Sentry.captureException(error); Sentry.captureException(error);
commit(types.RECEIVE_PANEL_PREVIEW_METRIC_RESULT_FAILURE, { index, error }); commit(types.RECEIVE_PANEL_PREVIEW_METRIC_RESULT_FAILURE, { index, error });
......
...@@ -5,8 +5,10 @@ import { ...@@ -5,8 +5,10 @@ import {
normalizeCustomDashboardPath, normalizeCustomDashboardPath,
} from './utils'; } from './utils';
const metricsIdsInPanel = panel => const metricsIdsInPanel = (panel) =>
panel.metrics.filter(metric => metric.metricId && metric.result).map(metric => metric.metricId); panel.metrics
.filter((metric) => metric.metricId && metric.result)
.map((metric) => metric.metricId);
/** /**
* Returns a reference to the currently selected dashboard * Returns a reference to the currently selected dashboard
...@@ -17,8 +19,8 @@ const metricsIdsInPanel = panel => ...@@ -17,8 +19,8 @@ const metricsIdsInPanel = panel =>
export const selectedDashboard = (state, getters) => { export const selectedDashboard = (state, getters) => {
const { allDashboards } = state; const { allDashboards } = state;
return ( return (
allDashboards.find(d => d.path === getters.fullDashboardPath) || allDashboards.find((d) => d.path === getters.fullDashboardPath) ||
allDashboards.find(d => d.default) || allDashboards.find((d) => d.default) ||
null null
); );
}; };
...@@ -32,15 +34,15 @@ export const selectedDashboard = (state, getters) => { ...@@ -32,15 +34,15 @@ export const selectedDashboard = (state, getters) => {
* @returns {Function} A function that returns an array of * @returns {Function} A function that returns an array of
* states in all the metric in the dashboard or group. * states in all the metric in the dashboard or group.
*/ */
export const getMetricStates = state => groupKey => { export const getMetricStates = (state) => (groupKey) => {
let groups = state.dashboard.panelGroups; let groups = state.dashboard.panelGroups;
if (groupKey) { if (groupKey) {
groups = groups.filter(group => group.key === groupKey); groups = groups.filter((group) => group.key === groupKey);
} }
const metricStates = groups.reduce((acc, group) => { const metricStates = groups.reduce((acc, group) => {
group.panels.forEach(panel => { group.panels.forEach((panel) => {
panel.metrics.forEach(metric => { panel.metrics.forEach((metric) => {
if (metric.state) { if (metric.state) {
acc.push(metric.state); acc.push(metric.state);
} }
...@@ -64,15 +66,15 @@ export const getMetricStates = state => groupKey => { ...@@ -64,15 +66,15 @@ export const getMetricStates = state => groupKey => {
* metrics in the dashboard that contain results, optionally * metrics in the dashboard that contain results, optionally
* filtered by group key. * filtered by group key.
*/ */
export const metricsWithData = state => groupKey => { export const metricsWithData = (state) => (groupKey) => {
let groups = state.dashboard.panelGroups; let groups = state.dashboard.panelGroups;
if (groupKey) { if (groupKey) {
groups = groups.filter(group => group.key === groupKey); groups = groups.filter((group) => group.key === groupKey);
} }
const res = []; const res = [];
groups.forEach(group => { groups.forEach((group) => {
group.panels.forEach(panel => { group.panels.forEach((panel) => {
res.push(...metricsIdsInPanel(panel)); res.push(...metricsIdsInPanel(panel));
}); });
}); });
...@@ -89,7 +91,7 @@ export const metricsWithData = state => groupKey => { ...@@ -89,7 +91,7 @@ export const metricsWithData = state => groupKey => {
* https://gitlab.com/gitlab-org/gitlab/-/issues/28241 * https://gitlab.com/gitlab-org/gitlab/-/issues/28241
* https://gitlab.com/gitlab-org/gitlab/-/merge_requests/27447 * https://gitlab.com/gitlab-org/gitlab/-/merge_requests/27447
*/ */
export const metricsSavedToDb = state => { export const metricsSavedToDb = (state) => {
const metricIds = []; const metricIds = [];
state.dashboard.panelGroups.forEach(({ panels }) => { state.dashboard.panelGroups.forEach(({ panels }) => {
panels.forEach(({ metrics }) => { panels.forEach(({ metrics }) => {
...@@ -111,8 +113,8 @@ export const metricsSavedToDb = state => { ...@@ -111,8 +113,8 @@ export const metricsSavedToDb = state => {
* @param {Object} state * @param {Object} state
* @returns {Array} List of environments * @returns {Array} List of environments
*/ */
export const filteredEnvironments = state => export const filteredEnvironments = (state) =>
state.environments.filter(env => state.environments.filter((env) =>
env.name.toLowerCase().includes((state.environmentsSearchTerm || '').trim().toLowerCase()), env.name.toLowerCase().includes((state.environmentsSearchTerm || '').trim().toLowerCase()),
); );
...@@ -125,7 +127,7 @@ export const filteredEnvironments = state => ...@@ -125,7 +127,7 @@ export const filteredEnvironments = state =>
* @param {Object} state * @param {Object} state
* @returns {Array} modified array of links * @returns {Array} modified array of links
*/ */
export const linksWithMetadata = state => { export const linksWithMetadata = (state) => {
const metadata = { const metadata = {
timeRange: state.timeRange, timeRange: state.timeRange,
}; };
...@@ -152,7 +154,7 @@ export const linksWithMetadata = state => { ...@@ -152,7 +154,7 @@ export const linksWithMetadata = state => {
* in the format of {variables[key1]=value1, variables[key2]=value2} * in the format of {variables[key1]=value1, variables[key2]=value2}
*/ */
export const getCustomVariablesParams = state => export const getCustomVariablesParams = (state) =>
state.variables.reduce((acc, variable) => { state.variables.reduce((acc, variable) => {
const { name, value } = variable; const { name, value } = variable;
if (value !== null) { if (value !== null) {
...@@ -168,5 +170,5 @@ export const getCustomVariablesParams = state => ...@@ -168,5 +170,5 @@ export const getCustomVariablesParams = state =>
* @param {Object} state * @param {Object} state
* @returns {String} full dashboard path * @returns {String} full dashboard path
*/ */
export const fullDashboardPath = state => export const fullDashboardPath = (state) =>
normalizeCustomDashboardPath(state.currentDashboard, state.customDashboardBasePath); normalizeCustomDashboardPath(state.currentDashboard, state.customDashboardBasePath);
import { LIST_KEY_PROJECT, SORT_FIELDS } from './constants'; import { LIST_KEY_PROJECT, SORT_FIELDS } from './constants';
export default isGroupPage => SORT_FIELDS.filter(f => f.key !== LIST_KEY_PROJECT || isGroupPage); export default (isGroupPage) =>
SORT_FIELDS.filter((f) => f.key !== LIST_KEY_PROJECT || isGroupPage);
/** /**
* A small util function that works out if the delete action has deleted the * A small util function that works out if the delete action has deleted the
......
...@@ -31,7 +31,9 @@ export default { ...@@ -31,7 +31,9 @@ export default {
}, },
computed: { computed: {
filteredNamespaces() { filteredNamespaces() {
return this.namespaces.filter(n => n.name.toLowerCase().includes(this.filter.toLowerCase())); return this.namespaces.filter((n) =>
n.name.toLowerCase().includes(this.filter.toLowerCase()),
);
}, },
}, },
...@@ -43,7 +45,7 @@ export default { ...@@ -43,7 +45,7 @@ export default {
loadGroups() { loadGroups() {
axios axios
.get(this.endpoint) .get(this.endpoint)
.then(response => { .then((response) => {
this.namespaces = response.data.namespaces; this.namespaces = response.data.namespaces;
}) })
.catch(() => createFlash(__('There was a problem fetching groups.'))); .catch(() => createFlash(__('There was a problem fetching groups.')));
......
...@@ -100,8 +100,8 @@ export default class UserTabs { ...@@ -100,8 +100,8 @@ export default class UserTabs {
bindEvents() { bindEvents() {
this.$parentEl this.$parentEl
.off('shown.bs.tab', '.nav-links a[data-toggle="tab"]') .off('shown.bs.tab', '.nav-links a[data-toggle="tab"]')
.on('shown.bs.tab', '.nav-links a[data-toggle="tab"]', event => this.tabShown(event)) .on('shown.bs.tab', '.nav-links a[data-toggle="tab"]', (event) => this.tabShown(event))
.on('click', '.gl-pagination a', event => this.changeProjectsPage(event)); .on('click', '.gl-pagination a', (event) => this.changeProjectsPage(event));
window.addEventListener('resize', () => this.onResize()); window.addEventListener('resize', () => this.onResize());
} }
...@@ -212,17 +212,19 @@ export default class UserTabs { ...@@ -212,17 +212,19 @@ export default class UserTabs {
const calendarPath = $calendarWrap.data('calendarPath'); const calendarPath = $calendarWrap.data('calendarPath');
AjaxCache.retrieve(calendarPath) AjaxCache.retrieve(calendarPath)
.then(data => UserTabs.renderActivityCalendar(data, $calendarWrap)) .then((data) => UserTabs.renderActivityCalendar(data, $calendarWrap))
.catch(() => { .catch(() => {
const cWrap = $calendarWrap[0]; const cWrap = $calendarWrap[0];
cWrap.querySelector('.spinner').classList.add('invisible'); cWrap.querySelector('.spinner').classList.add('invisible');
cWrap.querySelector('.user-calendar-error').classList.remove('invisible'); cWrap.querySelector('.user-calendar-error').classList.remove('invisible');
cWrap.querySelector('.user-calendar-error .js-retry-load').addEventListener('click', e => { cWrap
e.preventDefault(); .querySelector('.user-calendar-error .js-retry-load')
cWrap.querySelector('.user-calendar-error').classList.add('invisible'); .addEventListener('click', (e) => {
cWrap.querySelector('.spinner').classList.remove('invisible'); e.preventDefault();
this.loadActivityCalendar(); cWrap.querySelector('.user-calendar-error').classList.add('invisible');
}); cWrap.querySelector('.spinner').classList.remove('invisible');
this.loadActivityCalendar();
});
}); });
} }
......
...@@ -25,7 +25,7 @@ export default class AccessDropdown { ...@@ -25,7 +25,7 @@ export default class AccessDropdown {
this.setSelectedItems([]); this.setSelectedItems([]);
this.persistPreselectedItems(); this.persistPreselectedItems();
this.noOneObj = this.accessLevelsData.find(level => level.id === ACCESS_LEVEL_NONE); this.noOneObj = this.accessLevelsData.find((level) => level.id === ACCESS_LEVEL_NONE);
this.initDropdown(); this.initDropdown();
} }
...@@ -45,7 +45,7 @@ export default class AccessDropdown { ...@@ -45,7 +45,7 @@ export default class AccessDropdown {
onHide(); onHide();
} }
}, },
clicked: options => { clicked: (options) => {
const { $el, e } = options; const { $el, e } = options;
const item = options.selectedObj; const item = options.selectedObj;
const fossWithMergeAccess = !this.hasLicense && this.accessLevel === ACCESS_LEVELS.MERGE; const fossWithMergeAccess = !this.hasLicense && this.accessLevel === ACCESS_LEVELS.MERGE;
...@@ -56,7 +56,7 @@ export default class AccessDropdown { ...@@ -56,7 +56,7 @@ export default class AccessDropdown {
// We're not multiselecting quite yet in "Merge" access dropdown, on FOSS: // We're not multiselecting quite yet in "Merge" access dropdown, on FOSS:
// remove all preselected items before selecting this item // remove all preselected items before selecting this item
// https://gitlab.com/gitlab-org/gitlab/-/merge_requests/37499 // https://gitlab.com/gitlab-org/gitlab/-/merge_requests/37499
this.accessLevelsData.forEach(level => { this.accessLevelsData.forEach((level) => {
this.removeSelectedItem(level); this.removeSelectedItem(level);
}); });
} }
...@@ -65,7 +65,7 @@ export default class AccessDropdown { ...@@ -65,7 +65,7 @@ export default class AccessDropdown {
if (this.noOneObj) { if (this.noOneObj) {
if (item.id === this.noOneObj.id && !fossWithMergeAccess) { if (item.id === this.noOneObj.id && !fossWithMergeAccess) {
// remove all others selected items // remove all others selected items
this.accessLevelsData.forEach(level => { this.accessLevelsData.forEach((level) => {
if (level.id !== item.id) { if (level.id !== item.id) {
this.removeSelectedItem(level); this.removeSelectedItem(level);
} }
...@@ -109,7 +109,7 @@ export default class AccessDropdown { ...@@ -109,7 +109,7 @@ export default class AccessDropdown {
return; return;
} }
const persistedItems = itemsToPreselect.map(item => { const persistedItems = itemsToPreselect.map((item) => {
const persistedItem = { ...item }; const persistedItem = { ...item };
persistedItem.persisted = true; persistedItem.persisted = true;
return persistedItem; return persistedItem;
...@@ -123,7 +123,7 @@ export default class AccessDropdown { ...@@ -123,7 +123,7 @@ export default class AccessDropdown {
} }
getSelectedItems() { getSelectedItems() {
return this.items.filter(item => !item._destroy); return this.items.filter((item) => !item._destroy);
} }
getAllSelectedItems() { getAllSelectedItems() {
...@@ -134,7 +134,7 @@ export default class AccessDropdown { ...@@ -134,7 +134,7 @@ export default class AccessDropdown {
getInputData() { getInputData() {
const selectedItems = this.getAllSelectedItems(); const selectedItems = this.getAllSelectedItems();
const accessLevels = selectedItems.map(item => { const accessLevels = selectedItems.map((item) => {
const obj = {}; const obj = {};
if (typeof item.id !== 'undefined') { if (typeof item.id !== 'undefined') {
...@@ -288,12 +288,14 @@ export default class AccessDropdown { ...@@ -288,12 +288,14 @@ export default class AccessDropdown {
$dropdownToggleText.removeClass('is-default'); $dropdownToggleText.removeClass('is-default');
if (currentItems.length === 1 && currentItems[0].type === LEVEL_TYPES.ROLE) { if (currentItems.length === 1 && currentItems[0].type === LEVEL_TYPES.ROLE) {
const roleData = this.accessLevelsData.find(data => data.id === currentItems[0].access_level); const roleData = this.accessLevelsData.find(
(data) => data.id === currentItems[0].access_level,
);
return roleData.text; return roleData.text;
} }
const labelPieces = []; const labelPieces = [];
const counts = countBy(currentItems, item => item.type); const counts = countBy(currentItems, (item) => item.type);
if (counts[LEVEL_TYPES.ROLE] > 0) { if (counts[LEVEL_TYPES.ROLE] > 0) {
labelPieces.push(n__('1 role', '%d roles', counts[LEVEL_TYPES.ROLE])); labelPieces.push(n__('1 role', '%d roles', counts[LEVEL_TYPES.ROLE]));
...@@ -336,7 +338,7 @@ export default class AccessDropdown { ...@@ -336,7 +338,7 @@ export default class AccessDropdown {
}); });
} else { } else {
this.getDeployKeys(query) this.getDeployKeys(query)
.then(deployKeysResponse => callback(this.consolidateData(deployKeysResponse.data))) .then((deployKeysResponse) => callback(this.consolidateData(deployKeysResponse.data)))
.catch(() => createFlash({ message: __('Failed to load deploy keys.') })); .catch(() => createFlash({ message: __('Failed to load deploy keys.') }));
} }
} }
...@@ -365,7 +367,7 @@ export default class AccessDropdown { ...@@ -365,7 +367,7 @@ export default class AccessDropdown {
/* /*
* Build roles * Build roles
*/ */
const roles = this.accessLevelsData.map(level => { const roles = this.accessLevelsData.map((level) => {
/* eslint-disable no-param-reassign */ /* eslint-disable no-param-reassign */
// This re-assignment is intentional as // This re-assignment is intentional as
// level.type property is being used in removeSelectedItem() // level.type property is being used in removeSelectedItem()
...@@ -389,7 +391,7 @@ export default class AccessDropdown { ...@@ -389,7 +391,7 @@ export default class AccessDropdown {
/* /*
* Build groups * Build groups
*/ */
const groups = groupsResponse.map(group => ({ const groups = groupsResponse.map((group) => ({
...group, ...group,
type: LEVEL_TYPES.GROUP, type: LEVEL_TYPES.GROUP,
})); }));
...@@ -398,8 +400,8 @@ export default class AccessDropdown { ...@@ -398,8 +400,8 @@ export default class AccessDropdown {
* Build users * Build users
*/ */
const users = selectedItems const users = selectedItems
.filter(item => item.type === LEVEL_TYPES.USER) .filter((item) => item.type === LEVEL_TYPES.USER)
.map(item => { .map((item) => {
// Save identifiers for easy-checking more later // Save identifiers for easy-checking more later
map.push(LEVEL_TYPES.USER + item.user_id); map.push(LEVEL_TYPES.USER + item.user_id);
...@@ -414,7 +416,7 @@ export default class AccessDropdown { ...@@ -414,7 +416,7 @@ export default class AccessDropdown {
// Has to be checked against server response // Has to be checked against server response
// because the selected item can be in filter results // because the selected item can be in filter results
usersResponse.forEach(response => { usersResponse.forEach((response) => {
// Add is it has not been added // Add is it has not been added
if (map.indexOf(LEVEL_TYPES.USER + response.id) === -1) { if (map.indexOf(LEVEL_TYPES.USER + response.id) === -1) {
const user = { ...response }; const user = { ...response };
...@@ -444,7 +446,7 @@ export default class AccessDropdown { ...@@ -444,7 +446,7 @@ export default class AccessDropdown {
} }
if (this.deployKeysOnProtectedBranchesEnabled) { if (this.deployKeysOnProtectedBranchesEnabled) {
const deployKeys = deployKeysResponse.map(response => { const deployKeys = deployKeysResponse.map((response) => {
const { const {
id, id,
fingerprint, fingerprint,
......
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