-
Notifications
You must be signed in to change notification settings - Fork 186
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
[FEAT] Refactor the layout of modules #3494
Merged
Merged
Changes from 7 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
1a31bdd
feat(frontend_module_tab_buttons): Refactor as the module tab buttons…
Desvelao d09c558
feat(frontend_module_tab_buttons): Refactor `Explore agent` button
Desvelao 04d1002
Merge branch '4.3-7.10' of https://github.com/wazuh/wazuh-kibana-app …
Desvelao 0c28ccf
changelog: Add PR to changelog
Desvelao 11dec87
Fixing error generating report in security events
CPAlejandro 460d5a0
fix(frontend): Add license block to `with_module_not_for_agent.tsx` a…
Desvelao b433166
Merge branch 'feat/3485-enhance-module-tab-buttons' of https://github…
Desvelao 1d5a308
Merge branch '4.3-7.10' of https://github.com/wazuh/wazuh-kibana-app …
Desvelao 21f5f84
fix(frontend): Fixed description in license for a prompt component file
Desvelao File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
52 changes: 52 additions & 0 deletions
52
public/components/agents/prompts/prompt_module_not_for_agent.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,52 @@ | ||
/* | ||
* Wazuh app - Component for the module generate reports | ||
* 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 { useDispatch } from 'react-redux'; | ||
import { EuiButton, EuiEmptyPrompt } from '@elastic/eui'; | ||
import { updateCurrentAgentData } from '../../../redux/actions/appStateActions'; | ||
import { useFilterManager } from '../../common/hooks'; | ||
|
||
type PromptSelectAgentProps = { | ||
body?: string; | ||
title: string; | ||
agentSelectionProps: { | ||
setAgent: (agent: boolean) => void | ||
} | ||
}; | ||
|
||
export const PromptModuleNotForAgent = ({ body, title, ...agentSelectionProps }: PromptSelectAgentProps) => { | ||
const dispatch = useDispatch(); | ||
const filterManager = useFilterManager(); | ||
|
||
const unpinAgent = async () => { | ||
dispatch(updateCurrentAgentData({})); | ||
await agentSelectionProps.setAgent(false); | ||
const filters = filterManager.filters.filter(x => { | ||
return x.meta.key !== 'agent.id'; | ||
}); | ||
filterManager.setFilters(filters); | ||
}; | ||
|
||
return ( | ||
<EuiEmptyPrompt | ||
iconType="watchesApp" | ||
title={<h2>{title}</h2>} | ||
body={body && <p>{body}</p>} | ||
actions={ | ||
<EuiButton color="primary" fill onClick={unpinAgent}> | ||
Unpin agent | ||
</EuiButton> | ||
} | ||
/> | ||
); | ||
}; |
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
29 changes: 29 additions & 0 deletions
29
public/components/common/hocs/with_module_not_for_agent.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,29 @@ | ||
/* | ||
* Wazuh app - React HOC to show a prompt when a module is not available for agents and let to unpin the agent | ||
* 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. | ||
*/ | ||
|
||
Desvelao marked this conversation as resolved.
Show resolved
Hide resolved
|
||
import React from 'react'; | ||
import { compose } from 'redux'; | ||
import { connect } from 'react-redux'; | ||
import { withGuard } from './withGuard'; | ||
import { PromptModuleNotForAgent } from '../../agents/prompts'; | ||
|
||
const mapStateToProps = (state) => ({ | ||
agent: state.appStateReducers.currentAgentData, | ||
}); | ||
|
||
export const withModuleNotForAgent = WrappedComponent => compose( | ||
connect(mapStateToProps), | ||
withGuard( | ||
({agent}) => agent?.id, | ||
(props) => <PromptModuleNotForAgent title='Module not avaliable for agents' body='Remove the pinned agent.' {...props}/> | ||
) | ||
)(WrappedComponent); |
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,42 @@ | ||
/* | ||
* Wazuh app - React HOC to show a loader used for Dashboard adn Events module tabs | ||
* 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, { useEffect, useState } from 'react'; | ||
import { EuiLoadingSpinner, EuiSpacer } from '@elastic/eui'; | ||
import { useRootScope } from '../hooks'; | ||
|
||
export const withModuleTabLoader = WrappedComponent => props => { | ||
const $rootScope = useRootScope(); | ||
const [showTab, setShowTab] = useState(); | ||
useEffect(() => { | ||
if($rootScope){ | ||
$rootScope.loadingDashboard = true; | ||
$rootScope.$applyAsync(); | ||
setTimeout(() => { | ||
setShowTab(true); | ||
}, 100); | ||
return () => { | ||
$rootScope.loadingDashboard = false; | ||
$rootScope.$applyAsync(); | ||
} | ||
} | ||
},[$rootScope]); | ||
|
||
return showTab ? <WrappedComponent {...props}/> : ( | ||
<> | ||
<EuiSpacer size='xl' /> | ||
<div style={{ margin: '-8px auto', width: 32 }}> | ||
<EuiLoadingSpinner size="xl" /> | ||
</div> | ||
</> | ||
) | ||
} |
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
63 changes: 63 additions & 0 deletions
63
public/components/common/modules/buttons/generate_report.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,63 @@ | ||
/* | ||
* Wazuh app - Component for the module generate reports | ||
* 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 { useAsyncAction } from '../../hooks'; | ||
import { getUiSettings } from '../../../../kibana-services'; | ||
import { ReportingService } from '../../../../react-services'; | ||
import $ from 'jquery'; | ||
import { WzButton } from '../../../common/buttons'; | ||
|
||
|
||
export const ButtonModuleGenerateReport = ({agent, moduleID, disabledReport}) => { | ||
const action = useAsyncAction(async () => { | ||
const reportingService = new ReportingService(); | ||
const isDarkModeTheme = getUiSettings().get('theme:darkMode'); | ||
if (isDarkModeTheme) { | ||
|
||
//Patch to fix white text in dark-mode pdf reports | ||
const defaultTextColor = '#DFE5EF'; | ||
|
||
//Patch to fix dark backgrounds in visualizations dark-mode pdf reports | ||
const $labels = $('.euiButtonEmpty__text, .echLegendItem'); | ||
const $vizBackground = $('.echChartBackground'); | ||
const defaultVizBackground = $vizBackground.css('background-color'); | ||
|
||
try { | ||
$labels.css('color', 'black'); | ||
$vizBackground.css('background-color', 'transparent'); | ||
await reportingService.startVis2Png(moduleID, agent?.id || false) | ||
$vizBackground.css('background-color', defaultVizBackground); | ||
$labels.css('color', defaultTextColor); | ||
} catch (e) { | ||
$labels.css('color', defaultTextColor); | ||
$vizBackground.css('background-color', defaultVizBackground); | ||
} | ||
} else { | ||
await reportingService.startVis2Png(moduleID, agent?.id || false) | ||
} | ||
}); | ||
|
||
return ( | ||
<WzButton | ||
buttonType='empty' | ||
iconType='document' | ||
isLoading={action.running} | ||
onClick={action.run} | ||
isDisabled={disabledReport} | ||
tooltip={disabledReport ? {position: 'top', content: 'No results match for this search criteria.'} : undefined} | ||
> | ||
Generate report | ||
</WzButton> | ||
) | ||
} | ||
|
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,13 @@ | ||
/* | ||
* Wazuh app - Module buttons components | ||
* 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. | ||
*/ | ||
|
||
export * from './generate_report'; |
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This has changed in the office365 branch. Noting it so we are mindful when merging there.