diff options
Diffstat (limited to 'app/assets/javascripts/design_management/pages')
-rw-r--r-- | app/assets/javascripts/design_management/pages/design/index.vue | 29 | ||||
-rw-r--r-- | app/assets/javascripts/design_management/pages/index.vue | 11 |
2 files changed, 25 insertions, 15 deletions
diff --git a/app/assets/javascripts/design_management/pages/design/index.vue b/app/assets/javascripts/design_management/pages/design/index.vue index 17b72e73127..c6225c516e2 100644 --- a/app/assets/javascripts/design_management/pages/design/index.vue +++ b/app/assets/javascripts/design_management/pages/design/index.vue @@ -19,6 +19,8 @@ import { extractDiscussions, extractDesign, updateImageDiffNoteOptimisticResponse, + toDiffNoteGid, + extractDesignNoteId, } from '../../utils/design_management_utils'; import { updateStoreAfterAddImageDiffNote, @@ -31,6 +33,7 @@ import { DESIGN_NOT_FOUND_ERROR, DESIGN_VERSION_NOT_EXIST_ERROR, UPDATE_NOTE_ERROR, + TOGGLE_TODO_ERROR, designDeletionError, } from '../../utils/error_messages'; import { trackDesignDetailView } from '../../utils/tracking'; @@ -145,8 +148,11 @@ export default { mounted() { Mousetrap.bind('esc', this.closeDesign); this.trackEvent(); - // We need to reset the active discussion when opening a new design - this.updateActiveDiscussion(); + + // Set active discussion immediately. + // This will ensure that, if a note is specified in the URL hash, + // the browser will scroll to, and highlight, the note in the UI + this.updateActiveDiscussionFromUrl(); }, beforeDestroy() { Mousetrap.unbind('esc', this.closeDesign); @@ -221,7 +227,7 @@ export default { }, onError(message, e) { this.errorMessage = message; - throw e; + if (e) throw e; }, onCreateImageDiffNoteError(e) { this.onError(ADD_IMAGE_DIFF_NOTE_ERROR, e); @@ -241,6 +247,9 @@ export default { onResolveDiscussionError(e) { this.onError(UPDATE_IMAGE_DIFF_NOTE_ERROR, e); }, + onTodoError(e) { + this.onError(e?.message || TOGGLE_TODO_ERROR, e); + }, openCommentForm(annotationCoordinates) { this.annotationCoordinates = annotationCoordinates; if (this.$refs.newDiscussionForm) { @@ -266,15 +275,20 @@ export default { this.isLatestVersion, ); }, - updateActiveDiscussion(id) { + updateActiveDiscussion(id, source = ACTIVE_DISCUSSION_SOURCE_TYPES.discussion) { this.$apollo.mutate({ mutation: updateActiveDiscussionMutation, variables: { id, - source: ACTIVE_DISCUSSION_SOURCE_TYPES.discussion, + source, }, }); }, + updateActiveDiscussionFromUrl() { + const noteId = extractDesignNoteId(this.$route.hash); + const diffNoteGid = noteId ? toDiffNoteGid(noteId) : undefined; + return this.updateActiveDiscussion(diffNoteGid, ACTIVE_DISCUSSION_SOURCE_TYPES.url); + }, toggleResolvedComments() { this.resolvedDiscussionsExpanded = !this.resolvedDiscussionsExpanded; }, @@ -339,6 +353,7 @@ export default { @updateNoteError="onUpdateNoteError" @resolveDiscussionError="onResolveDiscussionError" @toggleResolvedComments="toggleResolvedComments" + @todoError="onTodoError" > <template #replyForm> <apollo-mutation @@ -357,8 +372,8 @@ export default { v-model="comment" :is-saving="loading" :markdown-preview-path="markdownPreviewPath" - @submitForm="mutate" - @cancelForm="closeCommentForm" + @submit-form="mutate" + @cancel-form="closeCommentForm" /> </apollo-mutation ></template> </design-sidebar> diff --git a/app/assets/javascripts/design_management/pages/index.vue b/app/assets/javascripts/design_management/pages/index.vue index cd68e9d6c5b..6c4c8c75054 100644 --- a/app/assets/javascripts/design_management/pages/index.vue +++ b/app/assets/javascripts/design_management/pages/index.vue @@ -281,13 +281,8 @@ export default { .mutate({ mutation: moveDesignMutation, variables: this.designMoveVariables(newIndex, element), - update: (store, { data: { designManagementMove } }) => { - return updateDesignsOnStoreAfterReorder( - store, - designManagementMove, - this.projectQueryBody, - ); - }, + update: (store, { data: { designManagementMove } }) => + updateDesignsOnStoreAfterReorder(store, designManagementMove, this.projectQueryBody), optimisticResponse: moveDesignOptimisticResponse(this.reorderedDesigns), }) .catch(() => { @@ -327,7 +322,7 @@ export default { v-if="isLatestVersion" variant="link" size="small" - class="gl-mr-3 js-select-all" + class="gl-mr-4 js-select-all" @click="toggleDesignsSelection" >{{ selectAllButtonText }} </gl-button> |