Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-12-24 00:10:24 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-12-24 00:10:24 +0300
commit5838993b5f3e2d861d9dd7c82dfeea71506b9fc2 (patch)
treecaab6621fb79f06a355f802dc885982f746b544d /app/assets/javascripts/notes
parentb8d021cb606ac86f41a0ef9dacd133a9677f8414 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/assets/javascripts/notes')
-rw-r--r--app/assets/javascripts/notes/components/diff_with_note.vue2
-rw-r--r--app/assets/javascripts/notes/components/discussion_actions.vue4
-rw-r--r--app/assets/javascripts/notes/components/discussion_counter.vue6
-rw-r--r--app/assets/javascripts/notes/components/discussion_filter.vue2
-rw-r--r--app/assets/javascripts/notes/components/multiline_comment_utils.js10
-rw-r--r--app/assets/javascripts/notes/components/note_actions.vue4
-rw-r--r--app/assets/javascripts/notes/components/note_body.vue2
-rw-r--r--app/assets/javascripts/notes/components/note_form.vue6
-rw-r--r--app/assets/javascripts/notes/components/noteable_discussion.vue4
-rw-r--r--app/assets/javascripts/notes/components/noteable_note.vue2
-rw-r--r--app/assets/javascripts/notes/components/notes_app.vue4
-rw-r--r--app/assets/javascripts/notes/components/toggle_replies_widget.vue4
-rw-r--r--app/assets/javascripts/notes/discussion_filters.js4
-rw-r--r--app/assets/javascripts/notes/mixins/diff_line_note_form.js6
-rw-r--r--app/assets/javascripts/notes/mixins/discussion_navigation.js2
-rw-r--r--app/assets/javascripts/notes/mixins/resolvable.js2
-rw-r--r--app/assets/javascripts/notes/sort_discussions.js2
-rw-r--r--app/assets/javascripts/notes/stores/actions.js32
-rw-r--r--app/assets/javascripts/notes/stores/collapse_utils.js4
-rw-r--r--app/assets/javascripts/notes/stores/getters.js96
-rw-r--r--app/assets/javascripts/notes/stores/mutations.js24
-rw-r--r--app/assets/javascripts/notes/stores/utils.js14
-rw-r--r--app/assets/javascripts/notes/utils.js2
23 files changed, 119 insertions, 119 deletions
diff --git a/app/assets/javascripts/notes/components/diff_with_note.vue b/app/assets/javascripts/notes/components/diff_with_note.vue
index 1580c94658a..b7355d4d927 100644
--- a/app/assets/javascripts/notes/components/diff_with_note.vue
+++ b/app/assets/javascripts/notes/components/diff_with_note.vue
@@ -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);
diff --git a/app/assets/javascripts/notes/components/discussion_actions.vue b/app/assets/javascripts/notes/components/discussion_actions.vue
index 21ce608becb..7ad1538c3bb 100644
--- a/app/assets/javascripts/notes/components/discussion_actions.vue
+++ b/app/assets/javascripts/notes/components/discussion_actions.vue
@@ -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);
},
},
};
diff --git a/app/assets/javascripts/notes/components/discussion_counter.vue b/app/assets/javascripts/notes/components/discussion_counter.vue
index 2427a3f98ad..0a72627834d 100644
--- a/app/assets/javascripts/notes/components/discussion_counter.vue
+++ b/app/assets/javascripts/notes/components/discussion_counter.vue
@@ -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,
});
},
diff --git a/app/assets/javascripts/notes/components/discussion_filter.vue b/app/assets/javascripts/notes/components/discussion_filter.vue
index 08c22f0b4c6..aa61aa9b3cb 100644
--- a/app/assets/javascripts/notes/components/discussion_filter.vue
+++ b/app/assets/javascripts/notes/components/discussion_filter.vue
@@ -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() {
diff --git a/app/assets/javascripts/notes/components/multiline_comment_utils.js b/app/assets/javascripts/notes/components/multiline_comment_utils.js
index 2451400e980..4991695b97e 100644
--- a/app/assets/javascripts/notes/components/multiline_comment_utils.js
+++ b/app/assets/javascripts/notes/components/multiline_comment_utils.js
@@ -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,
);
diff --git a/app/assets/javascripts/notes/components/note_actions.vue b/app/assets/javascripts/notes/components/note_actions.vue
index fc131f548b4..b85cfa83e09 100644
--- a/app/assets/javascripts/notes/components/note_actions.vue
+++ b/app/assets/javascripts/notes/components/note_actions.vue
@@ -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')));
diff --git a/app/assets/javascripts/notes/components/note_body.vue b/app/assets/javascripts/notes/components/note_body.vue
index 65b89b94eaa..094ebe5316a 100644
--- a/app/assets/javascripts/notes/components/note_body.vue
+++ b/app/assets/javascripts/notes/components/note_body.vue
@@ -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;
diff --git a/app/assets/javascripts/notes/components/note_form.vue b/app/assets/javascripts/notes/components/note_form.vue
index 87082a64400..47202d0e241 100644
--- a/app/assets/javascripts/notes/components/note_form.vue
+++ b/app/assets/javascripts/notes/components/note_form.vue
@@ -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() {
diff --git a/app/assets/javascripts/notes/components/noteable_discussion.vue b/app/assets/javascripts/notes/components/noteable_discussion.vue
index 62ee7f30c57..0a9a3da6069 100644
--- a/app/assets/javascripts/notes/components/noteable_discussion.vue
+++ b/app/assets/javascripts/notes/components/noteable_discussion.vue
@@ -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.',
diff --git a/app/assets/javascripts/notes/components/noteable_note.vue b/app/assets/javascripts/notes/components/noteable_note.vue
index 5073922e4a4..eaa64cf7c01 100644
--- a/app/assets/javascripts/notes/components/noteable_note.vue
+++ b/app/assets/javascripts/notes/components/noteable_note.vue
@@ -296,7 +296,7 @@ export default {
this.updateSuccess();
callback();
})
- .catch(response => {
+ .catch((response) => {
if (response.status === httpStatusCodes.GONE) {
this.removeNote(this.note);
this.updateSuccess();
diff --git a/app/assets/javascripts/notes/components/notes_app.vue b/app/assets/javascripts/notes/components/notes_app.vue
index 9eaa4e422d5..e9e687a8743 100644
--- a/app/assets/javascripts/notes/components/notes_app.vue
+++ b/app/assets/javascripts/notes/components/notes_app.vue
@@ -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 });
diff --git a/app/assets/javascripts/notes/components/toggle_replies_widget.vue b/app/assets/javascripts/notes/components/toggle_replies_widget.vue
index 0628e1d8647..ab7fa793bdc 100644
--- a/app/assets/javascripts/notes/components/toggle_replies_widget.vue
+++ b/app/assets/javascripts/notes/components/toggle_replies_widget.vue
@@ -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';
diff --git a/app/assets/javascripts/notes/discussion_filters.js b/app/assets/javascripts/notes/discussion_filters.js
index cdf9a46c5aa..7c9e7703d59 100644
--- a/app/assets/javascripts/notes/discussion_filters.js
+++ b/app/assets/javascripts/notes/discussion_filters.js
@@ -1,13 +1,13 @@
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],
}));
diff --git a/app/assets/javascripts/notes/mixins/diff_line_note_form.js b/app/assets/javascripts/notes/mixins/diff_line_note_form.js
index c4a42eb1a98..5ce541781d4 100644
--- a/app/assets/javascripts/notes/mixins/diff_line_note_form.js
+++ b/app/assets/javascripts/notes/mixins/diff_line_note_form.js
@@ -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']),
diff --git a/app/assets/javascripts/notes/mixins/discussion_navigation.js b/app/assets/javascripts/notes/mixins/discussion_navigation.js
index c6932bfacae..96974c4fa2d 100644
--- a/app/assets/javascripts/notes/mixins/discussion_navigation.js
+++ b/app/assets/javascripts/notes/mixins/discussion_navigation.js
@@ -99,7 +99,7 @@ export default {
'getDiscussion',
]),
...mapState({
- currentDiscussionId: state => state.notes.currentDiscussionId,
+ currentDiscussionId: (state) => state.notes.currentDiscussionId,
}),
},
methods: {
diff --git a/app/assets/javascripts/notes/mixins/resolvable.js b/app/assets/javascripts/notes/mixins/resolvable.js
index cef4475ed1d..baada4c5ce8 100644
--- a/app/assets/javascripts/notes/mixins/resolvable.js
+++ b/app/assets/javascripts/notes/mixins/resolvable.js
@@ -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;
diff --git a/app/assets/javascripts/notes/sort_discussions.js b/app/assets/javascripts/notes/sort_discussions.js
index a06c23f5f76..ecfa3223039 100644
--- a/app/assets/javascripts/notes/sort_discussions.js
+++ b/app/assets/javascripts/notes/sort_discussions.js
@@ -1,7 +1,7 @@
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;
diff --git a/app/assets/javascripts/notes/stores/actions.js b/app/assets/javascripts/notes/stores/actions.js
index 1fe5d6c2955..2480ab82304 100644
--- a/app/assets/javascripts/notes/stores/actions.js
+++ b/app/assets/javascripts/notes/stores/actions.js
@@ -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.'));
diff --git a/app/assets/javascripts/notes/stores/collapse_utils.js b/app/assets/javascripts/notes/stores/collapse_utils.js
index f34247d4eb0..b2e2f6e2c31 100644
--- a/app/assets/javascripts/notes/stores/collapse_utils.js
+++ b/app/assets/javascripts/notes/stores/collapse_utils.js
@@ -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;
diff --git a/app/assets/javascripts/notes/stores/getters.js b/app/assets/javascripts/notes/stores/getters.js
index 5b3ffa425a0..5891a2e63e3 100644
--- a/app/assets/javascripts/notes/stores/getters.js
+++ b/app/assets/javascripts/notes/stores/getters.js
@@ -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;
diff --git a/app/assets/javascripts/notes/stores/mutations.js b/app/assets/javascripts/notes/stores/mutations.js
index 53387b2eaff..2c51ce0d970 100644
--- a/app/assets/javascripts/notes/stores/mutations.js
+++ b/app/assets/javascripts/notes/stores/mutations.js
@@ -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;
},
diff --git a/app/assets/javascripts/notes/stores/utils.js b/app/assets/javascripts/notes/stores/utils.js
index 10faac0c32b..6df926e1249 100644
--- a/app/assets/javascripts/notes/stores/utils.js
+++ b/app/assets/javascripts/notes/stores/utils.js
@@ -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(
{},
diff --git a/app/assets/javascripts/notes/utils.js b/app/assets/javascripts/notes/utils.js
index e6c2eb06a51..7966a884eab 100644
--- a/app/assets/javascripts/notes/utils.js
+++ b/app/assets/javascripts/notes/utils.js
@@ -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',