Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disabled loading inventory #3026

Merged
merged 4 commits into from
Mar 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
31 changes: 19 additions & 12 deletions public/components/agents/sca/inventory.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
}
}
Expand Down Expand Up @@ -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 = [];
}
}
Expand Down Expand Up @@ -303,15 +310,15 @@ 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
: check[filter.field].toLowerCase().includes(filter.value.toLowerCase())
)
)
)

toggleDetails = item => {
const itemIdToExpandedRowMap = { ...this.state.itemIdToExpandedRowMap };

Expand Down