chore: add create comment api

This commit is contained in:
Muhsin Keloth
2024-05-20 15:34:38 +05:30
parent 6b86b6f87d
commit 95d2a57a81
8 changed files with 78 additions and 4 deletions
@@ -41,6 +41,10 @@ class LinearAPI extends ApiClient {
searchIssues(query) {
return axios.get(`${this.url}/search_issue?q=${query}`);
}
createComment(data) {
return axios.post(`${this.url}/create_comment`, data);
}
}
export default new LinearAPI();
@@ -1,5 +1,5 @@
<template>
<div class="resolve-actions relative flex items-center justify-end">
<div class="relative flex items-center justify-end resolve-actions">
<div class="button-group">
<woot-button
v-if="isOpen"
@@ -94,6 +94,7 @@ import keyboardEventListenerMixins from 'shared/mixins/keyboardEventListenerMixi
import { findSnoozeTime } from 'dashboard/helper/snoozeHelpers';
import WootDropdownItem from 'shared/components/ui/dropdown/DropdownItem.vue';
import WootDropdownMenu from 'shared/components/ui/dropdown/DropdownMenu.vue';
import LinearAPI from 'dashboard/api/integrations/linear';
import wootConstants from 'dashboard/constants/globals';
import {
@@ -119,7 +120,10 @@ export default {
};
},
computed: {
...mapGetters({ currentChat: 'getSelectedChat' }),
...mapGetters({
currentChat: 'getSelectedChat',
currentUser: 'getCurrentUser',
}),
isOpen() {
return this.currentChat.status === wootConstants.STATUS_TYPE.OPEN;
},
@@ -248,6 +252,7 @@ export default {
snoozedUntil,
})
.then(() => {
this.updateLinearComment(status);
this.showAlert(this.$t('CONVERSATION.CHANGE_STATUS'));
this.isLoading = false;
});
@@ -256,6 +261,20 @@ export default {
const ninja = document.querySelector('ninja-keys');
ninja.open({ parent: 'snooze_conversation' });
},
async updateLinearComment(status) {
if (status !== 'resolved') {
return;
}
const response = await LinearAPI.getLinkedIssue(this.currentChat.id);
const { data: issues } = response;
const linkedIssue = issues && issues.length ? issues[0] : null;
if (linkedIssue) {
await LinearAPI.createComment({
issue_id: linkedIssue.issue.id,
comment: `*The conversation has been resolved by **${this.currentUser.name}***`,
});
}
},
},
};
</script>
@@ -21,5 +21,6 @@ defineProps({
size="18"
class="flex-shrink-0 text-slate-900 dark:text-slate-50"
/>
<slot name="dropdown" />
</button>
</template>