-
Notifications
You must be signed in to change notification settings - Fork 187
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* refactor(healthcheck): Adapt the refactorized health check component to last changes - Added monitoring and statistics index patterns checks - Added logic to retry the checks with a refresh button - Apply the retry to API connection check - Export react services in index file - Create appConfig in the Redux store * feat(healtcheck): Replace health check initial state to waiting * fet(healthcheck): Add can retry to healthcheck checks * fix(menu): Fix error in toast from WzMenu and revome unnecessary return in PatternHandler * fix(health-check): Fix create index pattern when change the setting in Settings > Configuration and loop in health check * fix(health-check): renamed files from appConfig Redux actions and reducer * fix(frontend): Replace config singleton saving to Redux * fix(health-check): Fix infinite loop rendering component when a check is disabled in the configuration * fix(health-check): Rename health checks titles * fix(health-check): Fix the tests for Health check * refactor(health-check): Request changes, add max buckets check and some improvements - Request changes - Added the max buckets check when the component is mounted - Created the `useRootScope` hook - Improved the export in the HOCs and hooks index files - Removed the `lib` folder - Removed the `health-check` old component
- Loading branch information
Showing
36 changed files
with
1,289 additions
and
647 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/* | ||
* Wazuh app - React hook for app configuration | ||
* Copyright (C) 2015-2021 Wazuh, Inc. | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; either version 2 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* Find more information about this on the LICENSE file. | ||
*/ | ||
|
||
import { AppRootState } from '../../../redux/types'; | ||
import { useSelector } from 'react-redux'; | ||
|
||
export const useAppConfig = () => { | ||
const appConfig = useSelector((state: AppRootState) => state.appConfig); | ||
return appConfig; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/* | ||
* Wazuh app - React hook to get the AngularJS $rootScope | ||
* Copyright (C) 2015-2021 Wazuh, Inc. | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; either version 2 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* Find more information about this on the LICENSE file. | ||
*/ | ||
import { useEffect, useRef } from 'react'; | ||
import { getAngularModule } from '../../../kibana-services'; | ||
|
||
export function useRootScope(){ | ||
const refRootScope = useRef(); | ||
useEffect(() => { | ||
const app = getAngularModule(); | ||
refRootScope.current = app.$injector.get('$rootScope'); | ||
},[]); | ||
return refRootScope.current; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
public/components/health-check/components/__snapshots__/check-result.test.tsx.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`Check result component should render a Check result screen 1`] = ` | ||
<CheckResult | ||
awaitFor={Array []} | ||
canRetry={true} | ||
check={true} | ||
checksReady={Object {}} | ||
cleanErrors={ | ||
[MockFunction] { | ||
"calls": Array [ | ||
Array [ | ||
"test", | ||
], | ||
], | ||
"results": Array [ | ||
Object { | ||
"type": "return", | ||
"value": undefined, | ||
}, | ||
], | ||
} | ||
} | ||
handleCheckReady={[MockFunction]} | ||
handleErrors={[MockFunction]} | ||
isLoading={false} | ||
name="test" | ||
title="test chest" | ||
validationService={ | ||
[MockFunction] { | ||
"calls": Array [ | ||
Array [], | ||
], | ||
"results": Array [ | ||
Object { | ||
"type": "return", | ||
"value": Object { | ||
"errors": Array [], | ||
}, | ||
}, | ||
], | ||
} | ||
} | ||
> | ||
<EuiDescriptionListTitle> | ||
<dt | ||
className="euiDescriptionList__title" | ||
> | ||
test chest | ||
</dt> | ||
</EuiDescriptionListTitle> | ||
<EuiDescriptionListDescription> | ||
<dd | ||
className="euiDescriptionList__description" | ||
> | ||
<span> | ||
<EuiLoadingSpinner | ||
size="m" | ||
> | ||
<span | ||
className="euiLoadingSpinner euiLoadingSpinner--medium" | ||
/> | ||
</EuiLoadingSpinner> | ||
Checking... | ||
</span> | ||
</dd> | ||
</EuiDescriptionListDescription> | ||
</CheckResult> | ||
`; |
88 changes: 88 additions & 0 deletions
88
public/components/health-check/components/check-result.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
/* | ||
* Wazuh app - Check Result Component - Test | ||
* | ||
* Copyright (C) 2015-2021 Wazuh, Inc. | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; either version 2 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* Find more information about this on the LICENSE file. | ||
* | ||
*/ | ||
import React from 'react'; | ||
import { mount } from 'enzyme'; | ||
import { CheckResult } from './check-result'; | ||
|
||
describe('Check result component', () => { | ||
const validationService = jest.fn(); | ||
const handleErrors = jest.fn(); | ||
const handleCheckReady = jest.fn(); | ||
const cleanErrors = jest.fn(); | ||
|
||
test('should render a Check result screen', () => { | ||
validationService.mockImplementation(() => ({ errors: [] })); | ||
const component = mount( | ||
<CheckResult | ||
name={'test'} | ||
title={'Check Test'} | ||
awaitFor={[]} | ||
check={true} | ||
validationService={validationService} | ||
handleErrors={handleErrors} | ||
isLoading={false} | ||
handleCheckReady={handleCheckReady} | ||
checksReady={{}} | ||
cleanErrors={cleanErrors} | ||
canRetry={true} | ||
/> | ||
); | ||
|
||
expect(component).toMatchSnapshot(); | ||
}); | ||
|
||
test('should print ready', () => { | ||
validationService.mockImplementation(() => ({ errors: [] })); | ||
const component = mount( | ||
<CheckResult | ||
name={'test'} | ||
title={'Check Test'} | ||
awaitFor={[]} | ||
check={true} | ||
validationService={validationService} | ||
handleErrors={handleErrors} | ||
isLoading={false} | ||
handleCheckReady={handleCheckReady} | ||
checksReady={{}} | ||
cleanErrors={cleanErrors} | ||
canRetry={true} | ||
/> | ||
); | ||
setImmediate(() => { | ||
expect(component.find('EuiDescriptionListDescription').find('span').at(0).text().trim()).toBe('Ready'); | ||
}); | ||
}); | ||
|
||
test('should print error', () => { | ||
validationService.mockImplementation(() => ({ errors: ['error'] })); | ||
const component = mount( | ||
<CheckResult | ||
name={'test'} | ||
title={'Check Test'} | ||
awaitFor={[]} | ||
check={true} | ||
validationService={validationService} | ||
handleErrors={handleErrors} | ||
isLoading={false} | ||
handleCheckReady={handleCheckReady} | ||
checksReady={{}} | ||
cleanErrors={cleanErrors} | ||
canRetry={true} | ||
/> | ||
); | ||
setImmediate(() => { | ||
expect(component.find('EuiDescriptionListDescription').find('span').at(0).text().trim()).toBe('Error'); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.