diff options
Diffstat (limited to 'app/assets')
3 files changed, 21 insertions, 22 deletions
diff --git a/app/assets/javascripts/content_editor/services/upload_helpers.js b/app/assets/javascripts/content_editor/services/upload_helpers.js index 960f28747b0..70fbb9bea42 100644 --- a/app/assets/javascripts/content_editor/services/upload_helpers.js +++ b/app/assets/javascripts/content_editor/services/upload_helpers.js @@ -1,3 +1,4 @@ +import { uniqueId } from 'lodash'; import { VARIANT_DANGER } from '~/alert'; import axios from '~/lib/utils/axios_utils'; import { __, sprintf } from '~/locale'; @@ -7,17 +8,17 @@ import { ALERT_EVENT } from '../constants'; const chain = (editor) => editor.chain().setMeta('preventAutolink', true); -const findUploadedFilePosition = (editor, filename) => { +const findUploadedFilePosition = (editor, fileId) => { let position; editor.view.state.doc.descendants((descendant, pos) => { - if (descendant.attrs.uploading === filename) { + if (descendant.attrs.uploading === fileId) { position = pos; return false; } for (const mark of descendant.marks) { - if (mark.type.name === 'link' && mark.attrs.uploading === filename) { + if (mark.type.name === 'link' && mark.attrs.uploading === fileId) { position = pos + 1; return false; } @@ -142,11 +143,12 @@ const uploadMedia = async ({ type, editor, file, uploadsPath, renderMarkdown, ev const objectUrl = URL.createObjectURL(file); const { selection } = editor.view.state; const currentNode = selection.$to.node(); + const fileId = uniqueId(type); let position = selection.to; let content = { type, - attrs: { uploading: file.name, src: objectUrl, alt: file.name }, + attrs: { uploading: fileId, src: objectUrl, alt: file.name }, }; let selectionIncrement = 0; @@ -170,9 +172,9 @@ const uploadMedia = async ({ type, editor, file, uploadsPath, renderMarkdown, ev }) .then(({ canonicalSrc }) => { // the position might have changed while uploading, so we need to find it again - position = findUploadedFilePosition(editor, file.name); + position = findUploadedFilePosition(editor, fileId); - uploadingStates[file.name] = true; + uploadingStates[fileId] = true; editor.view.dispatch( editor.state.tr.setMeta('preventAutolink', true).setNodeMarkup(position, undefined, { @@ -186,7 +188,7 @@ const uploadMedia = async ({ type, editor, file, uploadsPath, renderMarkdown, ev chain(editor).setNodeSelection(position).run(); }) .catch((e) => { - position = findUploadedFilePosition(editor, file.name); + position = findUploadedFilePosition(editor, fileId); chain(editor) .deleteRange({ from: position, to: position + 1 }) @@ -203,14 +205,15 @@ const uploadAttachment = async ({ editor, file, uploadsPath, renderMarkdown, eve const objectUrl = URL.createObjectURL(file); const { selection } = editor.view.state; const currentNode = selection.$to.node(); + const fileId = uniqueId('file'); - uploadingStates[file.name] = true; + uploadingStates[fileId] = true; let position = selection.to; let content = { type: 'text', text: file.name, - marks: [{ type: 'link', attrs: { href: objectUrl, uploading: file.name } }], + marks: [{ type: 'link', attrs: { href: objectUrl, uploading: fileId } }], }; // if the current node is not empty, we need to wrap the content in a new paragraph @@ -229,7 +232,7 @@ const uploadAttachment = async ({ editor, file, uploadsPath, renderMarkdown, eve }) .then(({ src, canonicalSrc }) => { // the position might have changed while uploading, so we need to find it again - position = findUploadedFilePosition(editor, file.name); + position = findUploadedFilePosition(editor, fileId); chain(editor) .setTextSelection(position) @@ -238,7 +241,7 @@ const uploadAttachment = async ({ editor, file, uploadsPath, renderMarkdown, eve .run(); }) .catch((e) => { - position = findUploadedFilePosition(editor, file.name); + position = findUploadedFilePosition(editor, fileId); chain(editor) .setTextSelection(position) diff --git a/app/assets/javascripts/vue_merge_request_widget/components/merge_checks.vue b/app/assets/javascripts/vue_merge_request_widget/components/merge_checks.vue index 89095a55a11..9afed170097 100644 --- a/app/assets/javascripts/vue_merge_request_widget/components/merge_checks.vue +++ b/app/assets/javascripts/vue_merge_request_widget/components/merge_checks.vue @@ -99,15 +99,11 @@ export default { return this.state.mergeabilityChecks || []; }, sortedChecks() { - return [...this.checks] - .sort((a, b) => { - if (a.status === 'FAILED' && b.status !== 'FAILED') return -1; - if (a.status === 'SUCCESS' && b.status !== 'SUCCESS') - return b.status === 'FAILED' ? 1 : -1; + const order = ['FAILED', 'SUCCESS']; - return 0; - }) - .filter((s) => s.status !== 'INACTIVE'); + return [...this.checks] + .filter((s) => s.status !== 'INACTIVE') + .sort((a, b) => order.indexOf(a.status) - order.indexOf(b.status)); }, failedChecks() { return this.checks.filter((c) => c.status.toLowerCase() === 'failed'); diff --git a/app/assets/javascripts/vue_shared/components/filtered_search_bar/filtered_search_utils.js b/app/assets/javascripts/vue_shared/components/filtered_search_bar/filtered_search_utils.js index d33c0bb4708..ce4a46fe3dd 100644 --- a/app/assets/javascripts/vue_shared/components/filtered_search_bar/filtered_search_utils.js +++ b/app/assets/javascripts/vue_shared/components/filtered_search_bar/filtered_search_utils.js @@ -76,9 +76,9 @@ export function processFilters(filters) { type = FILTERED_SEARCH_TERM; value = token; } else { - type = token.type; - operator = token.value.operator; - value = token.value.data; + type = token?.type; + operator = token?.value?.operator; + value = token?.value?.data; } if (!acc[type]) { |