From 4825ab1a2959604915e8d1827b837e74879e333c Mon Sep 17 00:00:00 2001 From: Muhsin Keloth Date: Mon, 13 May 2024 18:34:40 +0530 Subject: [PATCH] chore: code cleanup --- .../conversation/linear/CreateOrLinkIssue.vue | 144 +----------------- .../conversation/linear/LinkIssue.vue | 7 +- .../dashboard/conversation/linear/index.vue | 51 ++++--- 3 files changed, 37 insertions(+), 165 deletions(-) diff --git a/app/javascript/dashboard/routes/dashboard/conversation/linear/CreateOrLinkIssue.vue b/app/javascript/dashboard/routes/dashboard/conversation/linear/CreateOrLinkIssue.vue index b67cbc346..c46c4902c 100644 --- a/app/javascript/dashboard/routes/dashboard/conversation/linear/CreateOrLinkIssue.vue +++ b/app/javascript/dashboard/routes/dashboard/conversation/linear/CreateOrLinkIssue.vue @@ -26,14 +26,12 @@ -
- +
+
@@ -41,7 +39,6 @@ diff --git a/app/javascript/dashboard/routes/dashboard/conversation/linear/LinkIssue.vue b/app/javascript/dashboard/routes/dashboard/conversation/linear/LinkIssue.vue index 57b1e4bf3..f18a24c5d 100644 --- a/app/javascript/dashboard/routes/dashboard/conversation/linear/LinkIssue.vue +++ b/app/javascript/dashboard/routes/dashboard/conversation/linear/LinkIssue.vue @@ -61,6 +61,7 @@ export default { }, isFetching: false, isLinking: false, + searchQuery: '', }; }, computed: { @@ -68,6 +69,9 @@ export default { if (this.isFetching) { return 'Loading...'; } + if (this.searchQuery) { + return ''; + } return 'No results found'; }, isSubmitDisabled() { @@ -80,7 +84,7 @@ export default { }, async handleSearchChange(value) { if (!value) return; - + this.searchQuery = value; try { this.isFetching = true; const response = await LinearAPI.searchIssues(value); @@ -109,6 +113,7 @@ export default { this.showAlert( this.$t('INTEGRATION_SETTINGS.LINEAR.ADD_OR_LINK.CREATE_SUCCESS') ); + this.searchQuery = ''; this.onClose(); } catch (error) { this.showAlert( diff --git a/app/javascript/dashboard/routes/dashboard/conversation/linear/index.vue b/app/javascript/dashboard/routes/dashboard/conversation/linear/index.vue index 5a1779a72..6aa4c2d44 100644 --- a/app/javascript/dashboard/routes/dashboard/conversation/linear/index.vue +++ b/app/javascript/dashboard/routes/dashboard/conversation/linear/index.vue @@ -2,7 +2,7 @@
-
+
{{ $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(