From 1ebc3c7455c470094dd82c159f2e212a99a66876 Mon Sep 17 00:00:00 2001 From: Grzegorz Grzybek Date: Mon, 9 Sep 2024 14:28:01 +0200 Subject: [PATCH] [Fixes #1101] Upgrade to Jolokia 2.1.3 with hawtio-adjusted types --- packages/hawtio/package.json | 4 +-- .../src/plugins/shared/connect-service.ts | 2 +- .../src/plugins/shared/jolokia-service.ts | 18 +++++------ .../hawtio/src/plugins/shared/workspace.ts | 2 +- yarn.lock | 30 +++++++++---------- 5 files changed, 28 insertions(+), 28 deletions(-) diff --git a/packages/hawtio/package.json b/packages/hawtio/package.json index a1e0616e..2b3edd72 100644 --- a/packages/hawtio/package.json +++ b/packages/hawtio/package.json @@ -35,7 +35,7 @@ "dependencies": { "@hawtio/camel-model-v4_0": "npm:@hawtio/camel-model@~4.0.5", "@hawtio/camel-model-v4_4": "npm:@hawtio/camel-model@~4.4.2", - "@jolokia.js/simple": "^2.1.2", + "@jolokia.js/simple": "^2.1.3", "@module-federation/utilities": "^3.1.6", "@patternfly/react-charts": "~7.3.0", "@patternfly/react-code-editor": "~5.3.3", @@ -56,7 +56,7 @@ "@types/react-router-dom": "^5.3.3", "dagre": "^0.8.5", "eventemitter3": "^5.0.1", - "jolokia.js": "^2.1.2", + "jolokia.js": "^2.1.3", "jquery": "^3.7.1", "js-logger": "^1.6.1", "jwt-decode": "^4.0.0", diff --git a/packages/hawtio/src/plugins/shared/connect-service.ts b/packages/hawtio/src/plugins/shared/connect-service.ts index f6f91772..4f3ab379 100644 --- a/packages/hawtio/src/plugins/shared/connect-service.ts +++ b/packages/hawtio/src/plugins/shared/connect-service.ts @@ -353,7 +353,7 @@ class ConnectService implements IConnectService { { success: () => resolve({ type: 'success' }), error: () => resolve({ type: 'failure' }), - ajaxError: (response: Response | null, error: DOMException | TypeError | string | null) => { + fetchError: (response: Response | null, error: DOMException | TypeError | string | null) => { if (response) { log.debug('Login error:', response.status, response.statusText) if (response.status === 429) { diff --git a/packages/hawtio/src/plugins/shared/jolokia-service.ts b/packages/hawtio/src/plugins/shared/jolokia-service.ts index 74868e73..83f86ec2 100644 --- a/packages/hawtio/src/plugins/shared/jolokia-service.ts +++ b/packages/hawtio/src/plugins/shared/jolokia-service.ts @@ -295,9 +295,9 @@ class JolokiaService implements IJolokiaService { } const options = await this.loadJolokiaOptions() - if (!options.ajaxError) { - // Default fetch() error handler (still called "ajaxError" in Jolokia 2.1.x for compatibility reasons) - options.ajaxError = this.fetchError() + if (!options.fetchError) { + // Default fetch() error handler (called "fetchError" in Jolokia 2.1.x, called "ajaxError" in 2.0.x and earlier) + options.fetchError = this.fetchError() } const jolokia = new Jolokia(options) @@ -445,7 +445,7 @@ class JolokiaService implements IJolokiaService { jolokia.list( escapeMBeanPath(this.config.mbean), - onListSuccessAndError(successFn, errorFn, { ajaxError: this.fetchError(resolve) }), + onListSuccessAndError(successFn, errorFn, { fetchError: this.fetchError(resolve) }), ) }) } @@ -513,13 +513,13 @@ class JolokiaService implements IJolokiaService { const { method, mbean } = this.config - const { success, error: errorFn, ajaxError } = options + const { success, error: errorFn, fetchError } = options return new Promise((resolve, reject) => { - // Override ajaxError to make sure it terminates in case of ajax error - options.ajaxError = (response, error) => { - if (ajaxError !== "ignore") { - ajaxError?.(response, error) + // Override fetchError to make sure it terminates in case of ajax error + options.fetchError = (response, error) => { + if (fetchError !== "ignore") { + fetchError?.(response, error) } reject(error) } diff --git a/packages/hawtio/src/plugins/shared/workspace.ts b/packages/hawtio/src/plugins/shared/workspace.ts index cf37a9a2..66121e81 100644 --- a/packages/hawtio/src/plugins/shared/workspace.ts +++ b/packages/hawtio/src/plugins/shared/workspace.ts @@ -59,7 +59,7 @@ class Workspace implements IWorkspace { error: (response: JolokiaErrorResponse) => { log.debug('Error - fetching JMX tree:', response) }, - ajaxError: (response: Response | null, error: DOMException | TypeError | string | null) => { + fetchError: (response: Response | null, error: DOMException | TypeError | string | null) => { const text = response?.statusText || error log.debug('Ajax error - fetching JMX tree:', text, '-', error) }, diff --git a/yarn.lock b/yarn.lock index ac249b83..26d0bd21 100644 --- a/yarn.lock +++ b/yarn.lock @@ -804,6 +804,7 @@ __metadata: dependencies: "@hawtio/camel-model-v4_0": "npm:@hawtio/camel-model@~4.0.5" "@hawtio/camel-model-v4_4": "npm:@hawtio/camel-model@~4.4.2" + "@jolokia.js/simple": "npm:^2.1.3" "@module-federation/utilities": "npm:^3.1.6" "@patternfly/react-charts": "npm:~7.3.0" "@patternfly/react-code-editor": "npm:~5.3.3" @@ -830,7 +831,7 @@ __metadata: jest-environment-jsdom: "npm:^29.7.0" jest-fetch-mock: "npm:^3.0.3" jest-watch-typeahead: "npm:^2.2.2" - jolokia.js: "npm:^2.0.3" + jolokia.js: "npm:^2.1.3" jquery: "npm:^3.7.1" js-logger: "npm:^1.6.1" jwt-decode: "npm:^4.0.0" @@ -1159,6 +1160,15 @@ __metadata: languageName: node linkType: hard +"@jolokia.js/simple@npm:^2.1.3": + version: 2.1.3 + resolution: "@jolokia.js/simple@npm:2.1.3" + dependencies: + jolokia.js: "npm:^2.1.3" + checksum: 10/bb0e3157be2605b1466cf824e758925d03e7342cf8647be35ab799be8a1e6b320bc1a25912971252b0dab1adea744f556b3d92f070286d155e459866e97b2cbb + languageName: node + linkType: hard + "@jridgewell/gen-mapping@npm:^0.3.0, @jridgewell/gen-mapping@npm:^0.3.2, @jridgewell/gen-mapping@npm:^0.3.5": version: 0.3.5 resolution: "@jridgewell/gen-mapping@npm:0.3.5" @@ -8745,20 +8755,10 @@ __metadata: languageName: node linkType: hard -"jolokia.js@npm:^2.0.3": - version: 2.0.3 - resolution: "jolokia.js@npm:2.0.3" - dependencies: - jquery: "npm:^3.7.1" - peerDependencies: - cubism: ^1.6.0 - jsdom: ^22.1.0 - peerDependenciesMeta: - cubism: - optional: true - jsdom: - optional: true - checksum: 10/0410a7563b5a2fb2b947309ff0fe863bd5df4ec4acf52e8184df8f92765b707a89398ad94aac138965911abf7639821ced8c4116b8a9fbf9e3f8c60fca1a9982 +"jolokia.js@npm:^2.1.3": + version: 2.1.3 + resolution: "jolokia.js@npm:2.1.3" + checksum: 10/15dfaa7b646a02b54c80ae531c798f038710cf9ac091af049627c2890085aa5c8fcac05bd622ff1a1fa4ce3fc00b05f15eaf0ecb400861181e8ee16ae410e104 languageName: node linkType: hard