+
{{ $t('INTEGRATION_SETTINGS.LINEAR.LOADING') }}
-
@@ -62,44 +60,51 @@ export default {
},
data() {
return {
- isLoading: false,
- showAddPopup: false,
- issues: [],
+ isFetching: false,
+ showPopup: false,
+ linkedIssue: null,
};
},
computed: {
...mapGetters({
currentAccountId: 'getCurrentAccountId',
}),
+ shouldShowAddButton() {
+ return !this.isFetching && !this.linkedIssue;
+ },
+ shouldShowItem() {
+ return !this.isFetching && this.linkedIssue;
+ },
},
mounted() {
- this.loadIssues();
+ this.loadLinkedIssue();
},
methods: {
showCreateIssuePopup() {
- this.showAddPopup = true;
+ this.showPopup = true;
},
- hideAddPopup() {
- this.showAddPopup = false;
- this.loadIssues();
+ closePopup() {
+ this.showPopup = false;
+ this.loadLinkedIssue();
},
- async loadIssues() {
+ async loadLinkedIssue() {
try {
- this.isLoading = true;
+ this.isFetching = true;
const response = await LinearAPI.getLinkedIssue(this.conversationId);
- this.issues = response.data;
+ const { issues } = response.data;
+ this.linkedIssue = issues.length ? issues[0] : null;
} catch (error) {
this.showAlert(
this.$t('INTEGRATION_SETTINGS.LINEAR.ADD_OR_LINK.LOADING_ERROR')
);
} finally {
- this.isLoading = false;
+ this.isFetching = false;
}
},
async unlinkIssue(linkId) {
try {
await LinearAPI.unlinkIssue(linkId);
- this.issues = [];
+ this.linkedIssue = null;
this.showAlert(this.$t('INTEGRATION_SETTINGS.LINEAR.UNLINK.SUCCESS'));
} catch (error) {
this.showAlert(