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

Change agents summary no results #7041

Merged
merged 11 commits into from
Oct 2, 2024
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ All notable changes to the Wazuh app project will be documented in this file.
- Update malware detection group values in data sources [#6963](https://github.com/wazuh/wazuh-dashboard-plugins/issues/6963)
- Changed the registration id of the Settings application for compatibility with OpenSearch Dashboard 2.16.0 [#6938](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6938)
- Changed Malware detection dashboard visualizations [#6964](https://github.com/wazuh/wazuh-dashboard-plugins/issues/6964)
- Changed the agents summary in overview with no results to an agent deployment help message. [#7041](https://github.com/wazuh/wazuh-dashboard-plugins/pull/7041)
- Changed malware feature description [#7036](https://github.com/wazuh/wazuh-dashboard-plugins/pull/7036)
- Changed the font size of the kpi subtitles and the features descriptions [#7033](https://github.com/wazuh/wazuh-dashboard-plugins/pull/7033)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,47 +25,52 @@ exports[`Stats component renders correctly to match the snapshot 1`] = `
class="euiCard__children"
>
<div
class="wazuh-visualization-layout"
style="width: 100%; height: 150px;"
class="euiEmptyPrompt"
>
<div
class="euiEmptyPrompt"
<span
class="euiTextColor euiTextColor--subdued"
>
<svg
aria-hidden="true"
class="euiIcon euiIcon--xxLarge euiIcon--subdued euiIcon-isLoading"
focusable="false"
height="16"
role="img"
viewBox="0 0 16 16"
width="16"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M5.277 10.088c.02.014.04.03.057.047.582.55 1.134.812 1.666.812.586 0 1.84-.293 3.713-.88L9 6.212V2H7v4.212l-1.723 3.876Zm-.438.987L3.539 14h8.922l-1.32-2.969C9.096 11.677 7.733 12 7 12c-.74 0-1.463-.315-2.161-.925ZM6 2H5V1h6v1h-1v4l3.375 7.594A1 1 0 0 1 12.461 15H3.54a1 1 0 0 1-.914-1.406L6 6V2Z"
/>
</svg>
<div
class="euiSpacer euiSpacer--m"
/>
<h4
class="euiTitle euiTitle--medium"
class="euiText euiText--medium"
>
No results
</h4>
<p>
This instance has no agents registered.
<br />
Please deploy agents to begin monitoring your endpoints.
</p>
</div>
</span>
<div
class="euiSpacer euiSpacer--l"
/>
<button
class="euiButton euiButton--primary euiButton--fill"
type="button"
>
<span
class="euiTextColor euiTextColor--subdued"
class="euiButtonContent euiButton__content"
>
<div
class="euiSpacer euiSpacer--m"
/>
<div
class="euiText euiText--medium"
<svg
aria-hidden="true"
class="euiIcon euiIcon--medium euiIcon--inherit euiIcon-isLoading euiButtonContent__icon"
focusable="false"
height="16"
role="img"
viewBox="0 0 16 16"
width="16"
xmlns="http://www.w3.org/2000/svg"
>
No results were found.
</div>
<path
d="M5.277 10.088c.02.014.04.03.057.047.582.55 1.134.812 1.666.812.586 0 1.84-.293 3.713-.88L9 6.212V2H7v4.212l-1.723 3.876Zm-.438.987L3.539 14h8.922l-1.32-2.969C9.096 11.677 7.733 12 7 12c-.74 0-1.463-.315-2.161-.925ZM6 2H5V1h6v1h-1v4l3.375 7.594A1 1 0 0 1 12.461 15H3.54a1 1 0 0 1-.914-1.406L6 6V2Z"
/>
</svg>
<span
class="euiButton__text"
>
Deploy new agent
</span>
</span>
</div>
</button>
</div>
</div>
</div>
Expand Down
59 changes: 46 additions & 13 deletions plugins/main/public/controllers/overview/components/stats.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
EuiFlexGroup,
EuiPage,
EuiToolTip,
EuiEmptyPrompt,
} from '@elastic/eui';
import { withErrorBoundary } from '../../../components/common/hocs';
import { API_NAME_AGENT_STATUS } from '../../../../common/constants';
Expand All @@ -30,6 +31,8 @@ import { LastAlertsStat } from './last-alerts-stat';
import { VisualizationBasic } from '../../../components/common/charts/visualizations/basic';
import NavigationService from '../../../react-services/navigation-service';
import './stats.scss';
import { WzButtonPermissions } from '../../../components/common/permissions/button';

export const Stats = withErrorBoundary(
class Stats extends Component {
constructor(props) {
Expand Down Expand Up @@ -81,19 +84,19 @@ export const Stats = withErrorBoundary(
const hasResults = this.agentStatus.some(
({ status }) => this.props[status],
);

return (
<EuiPage>
<EuiFlexGroup>
<EuiFlexItem grow={false}>
<EuiCard betaBadgeLabel='Agents summary' title=''>
<VisualizationBasic
isLoading={this.state.loadingSummary}
type='donut'
size={{ width: '100%', height: '150px' }}
showLegend
data={
hasResults &&
this.agentStatus.map(
{hasResults ? (
<VisualizationBasic
isLoading={this.state.loadingSummary}
type='donut'
size={{ width: '100%', height: '150px' }}
showLegend
data={this.agentStatus.map(
({ status, label, color, onClick }) => ({
onClick,
label,
Expand All @@ -103,11 +106,41 @@ export const Stats = withErrorBoundary(
: 0,
color,
}),
)
}
noDataTitle='No results'
noDataMessage='No results were found.'
/>
)}
/>
) : (
!hasResults &&
this.props !== undefined && (
<EuiEmptyPrompt
body={
<p>
This instance has no agents registered.
<br />
Please deploy agents to begin monitoring your
endpoints.
</p>
}
actions={
<WzButtonPermissions
color='primary'
fill
permissions={[
{ action: 'agent:create', resource: '*:*:*' },
]}
iconType='plusInCircle'
href={NavigationService.getInstance().getUrlForApp(
endpointSummary.id,
{
path: `#${endpointSummary.redirectTo()}deploy`,
},
)}
JuanGarriuz marked this conversation as resolved.
Show resolved Hide resolved
>
Deploy new agent
</WzButtonPermissions>
}
/>
)
)}
</EuiCard>
</EuiFlexItem>
<EuiFlexItem>
Expand Down
31 changes: 31 additions & 0 deletions plugins/main/public/controllers/overview/components/stats.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,37 @@ import React from 'react';
import { render, act } from '@testing-library/react';
import '@testing-library/jest-dom';
import { Stats } from './stats';
import jsonBeautifier from '../../../utils/json-beautifier';

jest.mock('../../../react-services/navigation-service', () => {
return {
getInstance() {
return {
getUrlForApp() {
return '';
},
};
},
};
});

jest.mock('../../../components/common/hooks/use-user-is-admin', () => {
return {
useUserPermissionsIsAdminRequirements() {
console.log('UserPermisionsIsAdmin');
return ['', []];
},
};
});

jest.mock('../../../components/common/hooks/useUserPermissions', () => {
return {
useUserPermissionsRequirements() {
console.log('UserPermisions');
return [false, []];
},
};
});

jest.mock(
'../../../../../../node_modules/@elastic/eui/lib/services/accessibility/html_id_generator',
Expand Down
Loading