diff --git a/CHANGELOG.md b/CHANGELOG.md index 4ebf090b6f..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 diff --git a/public/components/agents/sca/inventory.tsx b/public/components/agents/sca/inventory.tsx index 5facb1c9e8..2605f29a73 100644 --- a/public/components/agents/sca/inventory.tsx +++ b/public/components/agents/sca/inventory.tsx @@ -155,16 +155,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 }); } } @@ -258,6 +263,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 = []; } } @@ -303,7 +310,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 @@ -311,7 +318,7 @@ export class Inventory extends Component { ) ) ) - + toggleDetails = item => { const itemIdToExpandedRowMap = { ...this.state.itemIdToExpandedRowMap };