From 9296a4ec4e6c7fd622da323e21416c35644b8ef2 Mon Sep 17 00:00:00 2001 From: MattLeo Date: Tue, 9 Dec 2025 15:40:39 -0600 Subject: [PATCH] updated ka attach to work with fd app --- fd-client/.fdk/localstore | 2 +- fd-client/.fdk/store.sqlite | Bin 49152 -> 49152 bytes fd-client/.report.json | 281 +++++++++++++++++++++++++++-------- fd-client/app/index.html | 2 +- fd-client/app/scripts/app.js | 55 ++++++- 5 files changed, 266 insertions(+), 74 deletions(-) diff --git a/fd-client/.fdk/localstore b/fd-client/.fdk/localstore index 0dfbb53..91b5b0e 100644 --- a/fd-client/.fdk/localstore +++ b/fd-client/.fdk/localstore @@ -1 +1 @@ -{"fd_cli_101_101_migrate_oauth_status":true,"report_hash":"ac127cdfb4fd074868d43aef801f187105d36d777c033140b5e2dc170c0e87c8"} +{"fd_cli_101_101_migrate_oauth_status":true,"report_hash":"5571c4887009834af23ecf361d2dbf3ff79c7c7c74499711c1b923a147e0bdc2"} \ No newline at end of file diff --git a/fd-client/.fdk/store.sqlite b/fd-client/.fdk/store.sqlite index 6000867c98a20b3a35bbd5723beb2b085a69650c..dc9e5cc26ca2f317ba9023225b6d9a79636eb696 100644 GIT binary patch delta 35 icmZo@U~Xt&o**sQ$iTqB1H>?3IZ?-$v2kO?(I8n!#(Q{+Mg8cw+-v;9V diff --git a/fd-client/.report.json b/fd-client/.report.json index 647c6c9..1946a64 100644 --- a/fd-client/.report.json +++ b/fd-client/.report.json @@ -2,18 +2,28 @@ "lints": [ { "severity": 1, - "value": "app\\scripts\\app.js::2: Expected rejection to be handled.", + "value": "app\\scripts\\app.js::6: 'fdClient' declared and assigned in different scopes. Possible asynchronous race condition.", "type": "custom-js-lint" }, { "severity": 1, - "value": "app\\scripts\\app.js::72: 'isExpanded' declared and assigned in different scopes. Possible asynchronous race condition.", + "value": "app\\scripts\\app.js::11: Expected rejection to be handled.", + "type": "custom-js-lint" + }, + { + "severity": 2, + "value": "app\\scripts\\app.js::12: 'ticketData' is defined but never used.", + "type": "lint" + }, + { + "severity": 1, + "value": "app\\scripts\\app.js::17: Expected rejection to be handled.", "type": "custom-js-lint" }, { "severity": 1, - "value": "app\\scripts\\app.js::87: Expected rejection to be handled.", - "type": "custom-js-lint" + "value": "app\\scripts\\app.js::18: Too many nested callbacks (5). Maximum allowed is 4.", + "type": "lint" } ], "coverage": { @@ -26,48 +36,108 @@ "column": 0 }, "end": { - "line": 10, + "line": 31, "column": 3 } }, "1": { "start": { - "line": 2, + "line": 4, "column": 4 }, "end": { - "line": 9, - "column": 7 - } - }, - "2": { - "start": { - "line": 3, - "column": 8 - }, - "end": { - "line": 3, - "column": 38 - } - }, - "3": { - "start": { - "line": 5, - "column": 8 - }, - "end": { - "line": 7, + "line": 30, "column": 11 } }, - "4": { + "2": { "start": { "line": 6, "column": 12 }, "end": { "line": 6, - "column": 52 + "column": 30 + } + }, + "3": { + "start": { + "line": 7, + "column": 12 + }, + "end": { + "line": 7, + "column": 42 + } + }, + "4": { + "start": { + "line": 9, + "column": 12 + }, + "end": { + "line": 25, + "column": 15 + } + }, + "5": { + "start": { + "line": 11, + "column": 16 + }, + "end": { + "line": 24, + "column": 23 + } + }, + "6": { + "start": { + "line": 14, + "column": 41 + }, + "end": { + "line": 14, + "column": 48 + } + }, + "7": { + "start": { + "line": 17, + "column": 24 + }, + "end": { + "line": 23, + "column": 31 + } + }, + "8": { + "start": { + "line": 19, + "column": 32 + }, + "end": { + "line": 22, + "column": 35 + } + }, + "9": { + "start": { + "line": 28, + "column": 12 + }, + "end": { + "line": 28, + "column": 62 + } + }, + "10": { + "start": { + "line": 29, + "column": 12 + }, + "end": { + "line": 29, + "column": 83 } } }, @@ -90,7 +160,7 @@ "column": 58 }, "end": { - "line": 10, + "line": 31, "column": 1 } }, @@ -100,87 +170,168 @@ "name": "(anonymous_1)", "decl": { "start": { - "line": 2, - "column": 27 + "line": 5, + "column": 14 }, "end": { - "line": 2, - "column": 28 + "line": 5, + "column": 15 } }, "loc": { "start": { - "line": 2, - "column": 45 + "line": 5, + "column": 32 }, "end": { - "line": 9, - "column": 5 + "line": 26, + "column": 9 } }, - "line": 2 + "line": 5 }, "2": { "name": "(anonymous_2)", "decl": { "start": { - "line": 5, - "column": 75 + "line": 9, + "column": 79 }, "end": { - "line": 5, - "column": 76 + "line": 9, + "column": 80 } }, "loc": { "start": { - "line": 5, - "column": 86 + "line": 9, + "column": 90 }, "end": { - "line": 7, + "line": 25, + "column": 13 + } + }, + "line": 9 + }, + "3": { + "name": "(anonymous_3)", + "decl": { + "start": { + "line": 12, + "column": 26 + }, + "end": { + "line": 12, + "column": 27 + } + }, + "loc": { + "start": { + "line": 12, + "column": 47 + }, + "end": { + "line": 24, + "column": 21 + } + }, + "line": 12 + }, + "4": { + "name": "(anonymous_4)", + "decl": { + "start": { + "line": 18, + "column": 34 + }, + "end": { + "line": 18, + "column": 35 + } + }, + "loc": { + "start": { + "line": 18, + "column": 45 + }, + "end": { + "line": 23, + "column": 29 + } + }, + "line": 18 + }, + "5": { + "name": "(anonymous_5)", + "decl": { + "start": { + "line": 27, + "column": 15 + }, + "end": { + "line": 27, + "column": 16 + } + }, + "loc": { + "start": { + "line": 27, + "column": 31 + }, + "end": { + "line": 30, "column": 9 } }, - "line": 5 + "line": 27 } }, "branchMap": {}, "s": { - "0": 12, - "1": 12, - "2": 6, - "3": 6, - "4": 1 + "0": 2, + "1": 2, + "2": 2, + "3": 2, + "4": 2, + "5": 1, + "6": 1, + "7": 1, + "8": 0, + "9": 0, + "10": 0 }, "f": { - "0": 12, - "1": 6, - "2": 1 + "0": 2, + "1": 2, + "2": 1, + "3": 1, + "4": 0, + "5": 0 }, "b": {}, "_coverageSchema": "1a1c01bbd47fc00a2c39e90264f33305004495a9", - "hash": "18566891b473df9f163282f1310c6fc8160a5fe6" + "hash": "be7a4d54242fcac22528119b05a9a5cae58c3b78" } }, "coverageSummary": { "lines": { - "total": 5, - "covered": 5, + "total": 11, + "covered": 8, "skipped": 0, - "pct": 100 + "pct": 72.72 }, "statements": { - "total": 5, - "covered": 5, + "total": 11, + "covered": 8, "skipped": 0, - "pct": 100 + "pct": 72.72 }, "functions": { - "total": 3, - "covered": 3, + "total": 6, + "covered": 4, "skipped": 0, - "pct": 100 + "pct": 66.66 }, "branches": { "total": 0, diff --git a/fd-client/app/index.html b/fd-client/app/index.html index 5330558..b559e05 100644 --- a/fd-client/app/index.html +++ b/fd-client/app/index.html @@ -12,7 +12,7 @@ diff --git a/fd-client/app/scripts/app.js b/fd-client/app/scripts/app.js index 5f13d69..430e75c 100644 --- a/fd-client/app/scripts/app.js +++ b/fd-client/app/scripts/app.js @@ -1,10 +1,51 @@ document.addEventListener('DOMContentLoaded', function () { - app.initialized().then(function (client) { - console.log('KB initialized'); - - document.getElementById('insert-ka-btn').addEventListener('click', function() { - alert('Insert KA# - to be implemented'); - }); - + let currentKA = null; + + // Listen for messages from the KB iframe + window.addEventListener('message', function(event) { + if (event.origin !== 'https://kb.jv.com') { + return; + } + + if (event.data.type === 'ka-viewed') { + currentKA = event.data.kaNumber; + console.log('Current KA:', currentKA); + } }); + + app.initialized() + .then(function (client) { + console.log('KB initialized'); + + document.getElementById('insert-ka-btn').addEventListener('click', function() { + if (!currentKA) { + client.interface.trigger('showNotify', { + type: 'warning', + message: 'No article selected. Please view an article first.' + }); + return; + } + + client.interface.trigger("setValue", { + id: "cf_ka_number", + value: currentKA + }) + .then(function(data) { + return client.interface.trigger('showNotify', { + type: 'success', + message: currentKA + ' attached to ticket' + }); + }) + .catch(function(error) { + client.interface.trigger('showNotify', { + type: 'error', + message: 'Failed to attach KA#: ' + error.message + }); + }); + }); + }) + .catch(function(error) { + console.error('Failed to initialize app:', error); + document.body.innerHTML = '

Failed to load app. Please refresh.

'; + }); }); \ No newline at end of file