From 9afa05789ba25449cf1bd973507feff396eb6a16 Mon Sep 17 00:00:00 2001 From: dacoaster Date: Sat, 12 Aug 2023 20:11:29 -0700 Subject: [PATCH 1/9] Fix JIRA errors and number casting in fields --- src/components/jira/JiraAddIssue.vue | 73 +++++++++++++--------- src/integrations/JiraIntegrationHelpers.js | 14 ++--- 2 files changed, 50 insertions(+), 37 deletions(-) diff --git a/src/components/jira/JiraAddIssue.vue b/src/components/jira/JiraAddIssue.vue index 9077471a..f5a9702d 100644 --- a/src/components/jira/JiraAddIssue.vue +++ b/src/components/jira/JiraAddIssue.vue @@ -377,19 +377,6 @@ - - {{ snackBar.message }} - - @@ -442,14 +429,13 @@ export default { newIssue: { fields: {}, }, + blankIssue: { + fields: {}, + }, valid: true, rules: [(v) => !!v || "This field is required"], dateMenu: false, issueConfirmDialog: false, - snackBar: { - enabled: false, - message: "", - }, fieldMappings: { description: { type: "text", @@ -485,6 +471,9 @@ export default { this.newIssue = { fields: {}, }; + this.blankIssue = { + fields: {}, + }; }, async handleSave() { const isValid = this.$refs.form.validate(); @@ -495,6 +484,29 @@ export default { const issueType = { id: this.issueTypeId, }; + + for (const [key, value] of Object.entries(this.newIssue.fields)) { + let thisField = this.issueFields.filter((field) => field.key === key); + if (thisField.length > 0) { + if ( + thisField[0]?.schema?.type === "number" && + value.constructor === String && + value.length > 0 + ) { + this.$set(this.newIssue.fields, key, parseFloat(value)); + } + if (value === this.blankIssue.fields[key]) { + if ( + !thisField[0]?.required && + ["number", "string"].includes(thisField[0]?.schema?.type) + ) { + // Remove unrequired simple fields that haven't changed. + this.$delete(this.newIssue.fields, key); + } + } + } + } + this.$set(this.newIssue.fields, "project", project); this.$set(this.newIssue.fields, "issuetype", issueType); this.loading = true; @@ -506,10 +518,10 @@ export default { ); if (response?.error) { this.loading = false; - this.snackBar.enabled = true; - this.snackBar.message = response.error.message + let message = response.error.message ? response.error.message : this.$tc("message.api_error", 1); + this.$root.$emit("set-snackbar", message); if (response.error?.checkAuth) { this.$root.$emit("update-auth", []); } @@ -559,8 +571,8 @@ export default { } } } else { - this.snackBar.enabled = true; - this.snackBar.message = this.$tc("message.please_fill_required", 1); + let message = this.$tc("message.please_fill_required", 1); + this.$root.$emit("set-snackbar", message); } }, async showDialog() { @@ -600,10 +612,10 @@ export default { this.loading = false; if (response?.error) { - this.snackBar.enabled = true; - this.snackBar.message = response.error.message + let message = response.error.message ? response.error.message : this.$tc("message.api_error", 1); + this.$root.$emit("set-snackbar", message); if (response.error?.checkAuth) { this.$root.$emit("update-auth", []); } @@ -616,15 +628,16 @@ export default { this.projectId, this.issueTypeId ); - this.newIssue = response.blankIssue; + this.blankIssue.fields = Object.assign({}, response.blankIssue.fields); + this.newIssue = Object.assign({}, response.blankIssue); this.issueFields = response.fieldData; this.loading = false; if (response?.error) { - this.snackBar.enabled = true; - this.snackBar.message = response.error.message + let message = response.error.message ? response.error.message : this.$tc("message.api_error", 1); + this.$root.$emit("set-snackbar", message); if (response.error?.checkAuth) { this.$root.$emit("update-auth", []); } @@ -640,10 +653,10 @@ export default { this.userLoading = false; if (response?.error) { - this.snackBar.enabled = true; - this.snackBar.message = response.error.message + let message = response.error.message ? response.error.message : this.$tc("message.api_error", 1); + this.$root.$emit("set-snackbar", message); if (response.error?.checkAuth) { this.$root.$emit("update-auth", []); } @@ -659,10 +672,10 @@ export default { this.issueLoading = false; if (response?.error) { - this.snackBar.enabled = true; - this.snackBar.message = response.error.message + let message = response.error.message ? response.error.message : this.$tc("message.api_error", 1); + this.$root.$emit("set-snackbar", message); if (response.error?.checkAuth) { this.$root.$emit("update-auth", []); } diff --git a/src/integrations/JiraIntegrationHelpers.js b/src/integrations/JiraIntegrationHelpers.js index 95a4c069..67b46b88 100644 --- a/src/integrations/JiraIntegrationHelpers.js +++ b/src/integrations/JiraIntegrationHelpers.js @@ -129,7 +129,7 @@ export default { }) .catch((error) => { returnResponse.error = { - message: error.message, + message: JSON.stringify(error.response.data.errors), }; if ( @@ -168,7 +168,7 @@ export default { }) .catch((error) => { returnResponse.error = { - message: error.message, + message: JSON.stringify(error.response.data.errors), }; if ( @@ -226,7 +226,7 @@ export default { }) .catch((error) => { returnResponse.error = { - message: error.message, + message: JSON.stringify(error.response.data.errors), }; if ( @@ -261,7 +261,7 @@ export default { }) .catch((error) => { returnResponse.error = { - message: error.message, + message: JSON.stringify(error.response.data.errors), }; if ( @@ -328,7 +328,7 @@ export default { }) .catch((error) => { returnResponse.error = { - message: error.message, + message: JSON.stringify(error.response.data.errors), }; if ( @@ -359,7 +359,7 @@ export default { let returnResponse = {}; await axios.post(url, formData, options).catch((error) => { returnResponse.error = { - message: error.message, + message: JSON.stringify(error.response.data.errors), }; if ( @@ -403,7 +403,7 @@ export default { }) .catch((error) => { returnResponse.error = { - message: error.message, + message: JSON.stringify(error.response.data.errors), }; if ( From bf1a8bf8c33aac88431607addb729338c4404824 Mon Sep 17 00:00:00 2001 From: dacoaster Date: Sat, 12 Aug 2023 20:35:28 -0700 Subject: [PATCH 2/9] Reverting menu changes for Mac copy/paste --- package.json | 2 +- src/menu.js | 24 ++++++++++++------------ 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/package.json b/package.json index 88d0167f..024a1ae9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "yattie", - "version": "0.9.0", + "version": "0.9.1", "engines": { "npm": ">=8.0.0 <9.0.0", "node": ">=16.0.0 <17.0.0" diff --git a/src/menu.js b/src/menu.js index 10858d6d..bb3dd334 100644 --- a/src/menu.js +++ b/src/menu.js @@ -71,18 +71,18 @@ const createMenu = (win) => { }, ], }, - //{ - // label: i18n.t("menu.edit"), - // submenu: [ - // { label: i18n.t("menu.undo"), accelerator: "Ctrl+Z" }, - // { label: i18n.t("menu.redo"), accelerator: "Ctrl+Shift+Z" }, - // { type: "separator" }, - // { label: i18n.t("menu.cut"), accelerator: "Ctrl+X" }, - // { label: i18n.t("menu.copy"), accelerator: "Ctrl+C" }, - // { label: i18n.t("menu.paste"), accelerator: "Ctrl+V" }, - // { label: i18n.t("menu.select_all"), accelerator: "Ctrl+A" }, - // ], - //}, + { + label: i18n.t("menu.edit"), + submenu: [ + { label: i18n.t("menu.undo"), accelerator: "CtrlOrCmd+Z" }, + { label: i18n.t("menu.redo"), accelerator: "CtrlOrCmd+Y" }, + { type: "separator" }, + { label: i18n.t("menu.cut"), accelerator: "CtrlOrCmd+X" }, + { label: i18n.t("menu.copy"), accelerator: "CtrlOrCmd+C" }, + { label: i18n.t("menu.paste"), accelerator: "CtrlOrCmd+V" }, + { label: i18n.t("menu.select_all"), accelerator: "CtrlOrCmd+A" }, + ], + }, { label: "Help", submenu: [ From fe6bc664471cc6232526033366bbdbe6b988f74a Mon Sep 17 00:00:00 2001 From: dacoaster Date: Sat, 12 Aug 2023 21:31:54 -0700 Subject: [PATCH 3/9] Fix key names for menu --- src/menu.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/menu.js b/src/menu.js index bb3dd334..442b7852 100644 --- a/src/menu.js +++ b/src/menu.js @@ -74,13 +74,13 @@ const createMenu = (win) => { { label: i18n.t("menu.edit"), submenu: [ - { label: i18n.t("menu.undo"), accelerator: "CtrlOrCmd+Z" }, - { label: i18n.t("menu.redo"), accelerator: "CtrlOrCmd+Y" }, + { label: i18n.t("menu.undo"), accelerator: "CmdOrCtrl+Z" }, + { label: i18n.t("menu.redo"), accelerator: "CmdOrCtrl+Y" }, { type: "separator" }, - { label: i18n.t("menu.cut"), accelerator: "CtrlOrCmd+X" }, - { label: i18n.t("menu.copy"), accelerator: "CtrlOrCmd+C" }, - { label: i18n.t("menu.paste"), accelerator: "CtrlOrCmd+V" }, - { label: i18n.t("menu.select_all"), accelerator: "CtrlOrCmd+A" }, + { label: i18n.t("menu.cut"), accelerator: "CmdOrCtrl+X" }, + { label: i18n.t("menu.copy"), accelerator: "CmdOrCtrl+C" }, + { label: i18n.t("menu.paste"), accelerator: "CmdOrCtrl+V" }, + { label: i18n.t("menu.select_all"), accelerator: "CmdOrCtrl+A" }, ], }, { From 2dc39aaf7912e45a8a58799c2a72282ca63b3c29 Mon Sep 17 00:00:00 2001 From: dacoaster Date: Sat, 12 Aug 2023 22:12:18 -0700 Subject: [PATCH 4/9] Initial fix for Jira sprints and linting --- src/background.js | 2 +- src/components/jira/JiraAddIssue.vue | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/background.js b/src/background.js index f2f3b6f1..5ae9bf96 100644 --- a/src/background.js +++ b/src/background.js @@ -25,7 +25,7 @@ databaseUtility.initializeSession(); const startupConfig = databaseUtility.getConfig(); if (startupConfig.devMode) { isDevelopment = true; - windowUtility.setDevMode({enabled: true}); + windowUtility.setDevMode({ enabled: true }); } // Scheme must be registered before the app is ready diff --git a/src/components/jira/JiraAddIssue.vue b/src/components/jira/JiraAddIssue.vue index f5a9702d..4a740095 100644 --- a/src/components/jira/JiraAddIssue.vue +++ b/src/components/jira/JiraAddIssue.vue @@ -498,7 +498,9 @@ export default { if (value === this.blankIssue.fields[key]) { if ( !thisField[0]?.required && - ["number", "string"].includes(thisField[0]?.schema?.type) + (["number", "string"].includes(thisField[0]?.schema?.type) || + (thisField[0]?.schema?.type === "array" && + thisField[0]?.schema?.items === "json")) //CTODO ) { // Remove unrequired simple fields that haven't changed. this.$delete(this.newIssue.fields, key); From 7ec85f5ad85de52a63f78ab4181061d6ff8ab6d2 Mon Sep 17 00:00:00 2001 From: dacoaster Date: Sat, 12 Aug 2023 22:13:34 -0700 Subject: [PATCH 5/9] Spacing --- src/components/jira/JiraAddIssue.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/jira/JiraAddIssue.vue b/src/components/jira/JiraAddIssue.vue index 4a740095..7602055a 100644 --- a/src/components/jira/JiraAddIssue.vue +++ b/src/components/jira/JiraAddIssue.vue @@ -500,7 +500,7 @@ export default { !thisField[0]?.required && (["number", "string"].includes(thisField[0]?.schema?.type) || (thisField[0]?.schema?.type === "array" && - thisField[0]?.schema?.items === "json")) //CTODO + thisField[0]?.schema?.items === "json")) //CTODO ) { // Remove unrequired simple fields that haven't changed. this.$delete(this.newIssue.fields, key); From 00953b199062220b67053aceffec105a3a41ffaf Mon Sep 17 00:00:00 2001 From: dacoaster Date: Sun, 13 Aug 2023 09:52:13 -0700 Subject: [PATCH 6/9] Add roles to accelerators --- src/menu.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/menu.js b/src/menu.js index 442b7852..920259ef 100644 --- a/src/menu.js +++ b/src/menu.js @@ -74,13 +74,13 @@ const createMenu = (win) => { { label: i18n.t("menu.edit"), submenu: [ - { label: i18n.t("menu.undo"), accelerator: "CmdOrCtrl+Z" }, - { label: i18n.t("menu.redo"), accelerator: "CmdOrCtrl+Y" }, + { label: i18n.t("menu.undo"), accelerator: "CmdOrCtrl+Z", role: "undo" }, + { label: i18n.t("menu.redo"), accelerator: "CmdOrCtrl+Y", role: "redo" }, { type: "separator" }, - { label: i18n.t("menu.cut"), accelerator: "CmdOrCtrl+X" }, - { label: i18n.t("menu.copy"), accelerator: "CmdOrCtrl+C" }, - { label: i18n.t("menu.paste"), accelerator: "CmdOrCtrl+V" }, - { label: i18n.t("menu.select_all"), accelerator: "CmdOrCtrl+A" }, + { label: i18n.t("menu.cut"), accelerator: "CmdOrCtrl+X", role: "cut" }, + { label: i18n.t("menu.copy"), accelerator: "CmdOrCtrl+C", role: "copy" }, + { label: i18n.t("menu.paste"), accelerator: "CmdOrCtrl+V", role: "paste" }, + { label: i18n.t("menu.select_all"), accelerator: "CmdOrCtrl+A", role: "selectAll" }, ], }, { From 90b54b0467383485b0814a0c019f8a056aa43988 Mon Sep 17 00:00:00 2001 From: dacoaster Date: Sun, 13 Aug 2023 13:34:29 -0700 Subject: [PATCH 7/9] Clear old ai config structure --- src/components/TestWrapper.vue | 2 +- src/components/dialogs/NoteDialog.vue | 2 +- src/components/dialogs/SummaryDialog.vue | 2 +- src/components/settings/AddonsTab.vue | 6 +++--- src/views/AddEvidence.vue | 2 +- src/views/EditEvidence.vue | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/components/TestWrapper.vue b/src/components/TestWrapper.vue index 2fa6dfc9..6578fd05 100644 --- a/src/components/TestWrapper.vue +++ b/src/components/TestWrapper.vue @@ -271,7 +271,7 @@ export default { }, computed: { aiAssistEnabled() { - return this?.config?.aiAssist || false; + return this?.config?.ai?.enabled || false; }, currentTheme() { if (this.$vuetify.theme.dark) { diff --git a/src/components/dialogs/NoteDialog.vue b/src/components/dialogs/NoteDialog.vue index d4d2d41e..3b4b2290 100644 --- a/src/components/dialogs/NoteDialog.vue +++ b/src/components/dialogs/NoteDialog.vue @@ -281,7 +281,7 @@ export default { }, computed: { aiAssistEnabled() { - return this?.config?.aiAssist || false; + return this?.config?.ai?.enabled || false; }, currentTheme() { if (this.$vuetify.theme.dark) { diff --git a/src/components/dialogs/SummaryDialog.vue b/src/components/dialogs/SummaryDialog.vue index 1566b0f1..96e59373 100644 --- a/src/components/dialogs/SummaryDialog.vue +++ b/src/components/dialogs/SummaryDialog.vue @@ -189,7 +189,7 @@ export default { }, computed: { aiAssistEnabled() { - return this?.config?.aiAssist || false; + return this?.config?.ai?.enabled || false; }, currentTheme() { if (this.$vuetify.theme.dark) { diff --git a/src/components/settings/AddonsTab.vue b/src/components/settings/AddonsTab.vue index 7a7aa197..b9de21f9 100755 --- a/src/components/settings/AddonsTab.vue +++ b/src/components/settings/AddonsTab.vue @@ -33,7 +33,7 @@ solo :rules="[rules.rightLength, rules.noAsterisk]" :errorMessages="customErrors" - :disabled="!config.aiAssist" + :disabled="!config.ai.enabled" @focus="emptyKeyOnFocus" > @@ -45,7 +45,7 @@ color="white" class="text-capitalize" :style="{ color: currentTheme.black }" - :disabled="!config.aiAssist" + :disabled="!config?.ai?.enabled" @click="handleCancelOpenAIKey" > {{ $tc("caption.cancel", 1) }} @@ -57,7 +57,7 @@ block color="primary" class="text-capitalize" - :disabled="!config.aiAssist" + :disabled="!config?.ai?.enabled" @click="handleOpenAIKey" > {{ $tc("caption.save", 1) }} diff --git a/src/views/AddEvidence.vue b/src/views/AddEvidence.vue index 66558290..907c5c8e 100644 --- a/src/views/AddEvidence.vue +++ b/src/views/AddEvidence.vue @@ -266,7 +266,7 @@ export default { }, computed: { aiAssistEnabled() { - return this?.config?.aiAssist || false; + return this?.config?.ai?.enabled || false; }, fileSuffix() { let splitName = []; diff --git a/src/views/EditEvidence.vue b/src/views/EditEvidence.vue index f4ce81a3..67267af3 100644 --- a/src/views/EditEvidence.vue +++ b/src/views/EditEvidence.vue @@ -322,7 +322,7 @@ export default { }, computed: { aiAssistEnabled() { - return this?.config?.aiAssist || false; + return this?.config?.ai?.enabled || false; }, fileSuffix() { let splitName = []; From eba1ab1429546ac2979ce6bc23c259c000500495 Mon Sep 17 00:00:00 2001 From: dacoaster Date: Sun, 13 Aug 2023 13:50:09 -0700 Subject: [PATCH 8/9] Remove duplicate icon --- src/components/dialogs/NoteDialog.vue | 1 - 1 file changed, 1 deletion(-) diff --git a/src/components/dialogs/NoteDialog.vue b/src/components/dialogs/NoteDialog.vue index 3b4b2290..adbf8857 100644 --- a/src/components/dialogs/NoteDialog.vue +++ b/src/components/dialogs/NoteDialog.vue @@ -67,7 +67,6 @@ ? "mdi-robot-off-outline" : "mdi-robot-outline" }} - mdi-robot-outline From 98d2ac73fd86413ff940f89269ca549a739c0ed7 Mon Sep 17 00:00:00 2001 From: dacoaster Date: Sun, 13 Aug 2023 17:04:45 -0700 Subject: [PATCH 9/9] Remove complex JIRA fields --- src/components/jira/JiraAddIssue.vue | 7 ++++++- src/integrations/JiraIntegrationHelpers.js | 5 +++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/components/jira/JiraAddIssue.vue b/src/components/jira/JiraAddIssue.vue index 7602055a..6b8741e3 100644 --- a/src/components/jira/JiraAddIssue.vue +++ b/src/components/jira/JiraAddIssue.vue @@ -500,7 +500,12 @@ export default { !thisField[0]?.required && (["number", "string"].includes(thisField[0]?.schema?.type) || (thisField[0]?.schema?.type === "array" && - thisField[0]?.schema?.items === "json")) //CTODO + thisField[0]?.schema?.items === "json")) + // This second set of parameters are to filter JIRA fields + // like "Sprints" which need the data pulled from the api. + // I have removed Sprints from incoming fields though, so + // this may not be necessary. But it may prevent issues + // with similar fields in the future. ) { // Remove unrequired simple fields that haven't changed. this.$delete(this.newIssue.fields, key); diff --git a/src/integrations/JiraIntegrationHelpers.js b/src/integrations/JiraIntegrationHelpers.js index 67b46b88..c63f2502 100644 --- a/src/integrations/JiraIntegrationHelpers.js +++ b/src/integrations/JiraIntegrationHelpers.js @@ -303,9 +303,14 @@ export default { item && item.key !== "issuetype" && item.key !== "project" && + item.name !== "Sprint" && item.schema.type !== "any" && !["attachment", "issuelinks"].includes(item.schema.system) ) { + // We exclude fields we will add back in later (projects) and + // those that need to have options pulled from the API separately + // (Sprints). We may want to renable the latter at some point + // and handle it in a generic way. returnResponse.fieldData.push(item); if (item.key === "reporter") { const reporter = {