From 4172b44bafb94a066091786d23646cd99868657a Mon Sep 17 00:00:00 2001 From: gabiwassan Date: Fri, 26 Feb 2021 10:17:23 -0300 Subject: [PATCH 1/3] Disabled loading when catch error from api and added toast to show a message with the error. --- public/components/agents/sca/inventory.tsx | 31 +++++++++++++--------- 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/public/components/agents/sca/inventory.tsx b/public/components/agents/sca/inventory.tsx index 477cf9f71d..d6d90399f4 100644 --- a/public/components/agents/sca/inventory.tsx +++ b/public/components/agents/sca/inventory.tsx @@ -154,16 +154,21 @@ export class Inventory extends Component { await this.initialize(); const regex = new RegExp('redirectPolicy=' + '[^&]*'); const match = window.location.href.match(regex); - if (match && match[0]) { - this.setState({ loading: true }); - const id = match[0].split('=')[1]; - const policy = await WzRequest.apiReq( - 'GET', - `/sca/${this.props.agent.id}`, - { "q": "policy_id=" + id } - ); - await this.loadScaPolicy(((((policy || {}).data || {}).data || {}).items || [])[0]); - window.location.href = window.location.href.replace(new RegExp('redirectPolicy=' + '[^&]*'), ''); + try { + if (match && match[0]) { + this.setState({ loading: true }); + const id = match[0].split('=')[1]; + const policy = await WzRequest.apiReq( + 'GET', + `/sca/${this.props.agent.id}`, + { "q": "policy_id=" + id } + ); + await this.loadScaPolicy(((((policy || {}).data || {}).data || {}).items || [])[0]); + window.location.href = window.location.href.replace(new RegExp('redirectPolicy=' + '[^&]*'), ''); + this.setState({ loading: false }); + } + } catch (error) { + this.showToast('danger', error, 3000); this.setState({ loading: false }); } } @@ -254,6 +259,8 @@ export class Inventory extends Component { } this._isMount && this.setState({ data: models, loading: false }); } catch (error) { + this.showToast('danger', error, 3000); + this.setState({ loading: false }); this.policies = []; } } @@ -295,7 +302,7 @@ export class Inventory extends Component { } filterPolicyChecks = () => !!this.state.items && this.state.items.filter(check => - this.state.filters.every(filter => + this.state.filters.every(filter => filter.field === 'search' ? Object.keys(check).some(key => ['string', 'number'].includes(typeof check[key]) && String(check[key]).toLowerCase().includes(filter.value.toLowerCase())) : typeof check[filter.field] === 'string' && (filter.value === '' ? check[filter.field] === filter.value @@ -303,7 +310,7 @@ export class Inventory extends Component { ) ) ) - + toggleDetails = item => { const itemIdToExpandedRowMap = { ...this.state.itemIdToExpandedRowMap }; From 4ed55fef689d8a1ed2bea759ef7d58b5f0c5c286 Mon Sep 17 00:00:00 2001 From: gabiwassan Date: Mon, 1 Mar 2021 16:48:35 -0300 Subject: [PATCH 2/3] Updated CHANGELOG. --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 387af45d32..43d19ed432 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -36,6 +36,7 @@ All notable changes to the Wazuh app project will be documented in this file. - Fixed missing `&&` from macOS agent deployment command [#2989](https://github.com/wazuh/wazuh-kibana-app/issues/2989) - Fix prompt permissions on Framework of Mitre and Inventory of Integrity monitoring. [#2967](https://github.com/wazuh/wazuh-kibana-app/issues/2967) - Fix properly logout of Wazuh API when logging out of the application support x-pack [#2789](https://github.com/wazuh/wazuh-kibana-app/issues/2789) +- Fix disabled loading on inventory when request fail [#3016](https://github.com/wazuh/wazuh-kibana-app/issues/3016) ## Wazuh v4.1.0 - Kibana 7.10.0 , 7.10.2 - Revision 4101 From bf4d63e5f27ade5065fa2240a74c6e79e5c48aec Mon Sep 17 00:00:00 2001 From: gabiwassan Date: Mon, 1 Mar 2021 17:33:06 -0300 Subject: [PATCH 3/3] Update CHANGELOG --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c9c7da6dd8..3f28f4ac27 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ All notable changes to the Wazuh app project will be documented in this file. - Fix SCA policy detail showing name and check results about another policy [#3007](https://github.com/wazuh/wazuh-kibana-app/pull/3007) - Fix pagination in SCA checks table when expand some row [#3018](https://github.com/wazuh/wazuh-kibana-app/pull/3018) - Fix manager is shown in suggestions in Agents section [#3025](https://github.com/wazuh/wazuh-kibana-app/pull/3025) +- Fix disabled loading on inventory when request fail [#3016](https://github.com/wazuh/wazuh-kibana-app/issues/3016) ## Wazuh v4.1.1 - Kibana 7.10.0 , 7.10.2 - Revision 4102 @@ -44,7 +45,6 @@ All notable changes to the Wazuh app project will be documented in this file. - Fixed missing `&&` from macOS agent deployment command [#2989](https://github.com/wazuh/wazuh-kibana-app/issues/2989) - Fix prompt permissions on Framework of Mitre and Inventory of Integrity monitoring. [#2967](https://github.com/wazuh/wazuh-kibana-app/issues/2967) - Fix properly logout of Wazuh API when logging out of the application support x-pack [#2789](https://github.com/wazuh/wazuh-kibana-app/issues/2789) -- Fix disabled loading on inventory when request fail [#3016](https://github.com/wazuh/wazuh-kibana-app/issues/3016) ## Wazuh v4.1.0 - Kibana 7.10.0 , 7.10.2 - Revision 4101