2023-05-27 22:25:52 +05:30
|
|
|
import { createAlert } from '~/alert';
|
2018-03-27 19:54:05 +05:30
|
|
|
import { __ } from '~/locale';
|
|
|
|
|
|
|
|
export default {
|
|
|
|
computed: {
|
|
|
|
discussionResolved() {
|
2018-11-08 19:23:39 +05:30
|
|
|
if (this.discussion) {
|
2021-04-29 21:17:54 +05:30
|
|
|
return Boolean(this.discussion.resolved);
|
2018-03-27 19:54:05 +05:30
|
|
|
}
|
|
|
|
|
2018-11-08 19:23:39 +05:30
|
|
|
return this.note.resolved;
|
2018-03-27 19:54:05 +05:30
|
|
|
},
|
|
|
|
resolveButtonTitle() {
|
|
|
|
if (this.updatedNoteBody) {
|
|
|
|
if (this.discussionResolved) {
|
2019-09-30 21:07:59 +05:30
|
|
|
return __('Comment & unresolve thread');
|
2018-03-27 19:54:05 +05:30
|
|
|
}
|
|
|
|
|
2019-09-30 21:07:59 +05:30
|
|
|
return __('Comment & resolve thread');
|
2018-03-27 19:54:05 +05:30
|
|
|
}
|
2018-11-08 19:23:39 +05:30
|
|
|
|
2019-09-30 21:07:59 +05:30
|
|
|
return this.discussionResolved ? __('Unresolve thread') : __('Resolve thread');
|
2018-03-27 19:54:05 +05:30
|
|
|
},
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
resolveHandler(resolvedState = false) {
|
2019-07-07 11:18:12 +05:30
|
|
|
if (this.note && this.note.isDraft) {
|
|
|
|
return this.$emit('toggleResolveStatus');
|
|
|
|
}
|
|
|
|
|
2018-03-27 19:54:05 +05:30
|
|
|
this.isResolving = true;
|
|
|
|
const isResolved = this.discussionResolved || resolvedState;
|
|
|
|
const discussion = this.resolveAsThread;
|
2021-01-29 00:20:46 +05:30
|
|
|
let endpoint =
|
|
|
|
discussion && this.discussion ? this.discussion.resolve_path : `${this.note.path}/resolve`;
|
|
|
|
|
2021-04-29 21:17:54 +05:30
|
|
|
if (this.discussionResolvePath) {
|
2021-01-29 00:20:46 +05:30
|
|
|
endpoint = this.discussionResolvePath;
|
|
|
|
}
|
2018-03-27 19:54:05 +05:30
|
|
|
|
2019-02-15 15:39:39 +05:30
|
|
|
return this.toggleResolveNote({ endpoint, isResolved, discussion })
|
2018-03-27 19:54:05 +05:30
|
|
|
.then(() => {
|
|
|
|
this.isResolving = false;
|
|
|
|
})
|
|
|
|
.catch(() => {
|
|
|
|
this.isResolving = false;
|
2018-11-08 19:23:39 +05:30
|
|
|
|
|
|
|
const msg = __('Something went wrong while resolving this discussion. Please try again.');
|
2022-11-25 23:54:43 +05:30
|
|
|
createAlert({
|
2021-09-30 23:02:18 +05:30
|
|
|
message: msg,
|
|
|
|
parent: this.$el,
|
|
|
|
});
|
2018-03-27 19:54:05 +05:30
|
|
|
});
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|