Skip to content

Commit

Permalink
Manage register agent permissions
Browse files Browse the repository at this point in the history
  • Loading branch information
lucianogorza committed Dec 12, 2023
1 parent 23809b6 commit 8e01d73
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 16 deletions.
15 changes: 10 additions & 5 deletions plugins/main/public/components/common/welcome/overview-welcome.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import {
EuiFlexGrid,
EuiCallOut,
EuiPage,
EuiButtonEmpty,
} from '@elastic/eui';
import './welcome.scss';
import {
Expand All @@ -39,6 +38,7 @@ import {
} from '../../../utils/applications';
import { getCore } from '../../../kibana-services';
import { RedirectAppLinks } from '../../../../../../src/plugins/opensearch_dashboards_react/public';
import { WzButtonPermissions } from '../../common/permissions/button';

const appCategories = Applications.reduce((categories, app) => {
const existingCategory = categories.find(
Expand Down Expand Up @@ -85,16 +85,21 @@ export const OverviewWelcome = compose(
title={
<>
No agents were added to this manager.{' '}
<EuiButtonEmpty
<WzButtonPermissions
buttonType='empty'
permissions={[
{ action: 'agent:create', resource: '*:*:*' },
]}
iconType='plusInCircle'
href={getCore().application.getUrlForApp(
endpointSumary.id,
{
path: '#/agents-preview/deploy',
path: `#${endpointSumary.redirectTo()}deploy`,
},
)}
>
Add agent
</EuiButtonEmpty>
Deploy new agent
</WzButtonPermissions>
</>
}
color='warning'
Expand Down
6 changes: 3 additions & 3 deletions plugins/main/public/components/endpoints-summary/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,16 +65,16 @@ export const MainEndpointsSummary = compose(
return (
<EuiEmptyPrompt
iconType='watchesApp'
title={<h2>There are no agents</h2>}
title={<h2>No agents were added to this manager.</h2>}
body={<p>Add agents to fleet to start monitoring</p>}
actions={
<WzButtonPermissions
color='primary'
fill
permissions={[{ action: 'agent:create', resource: '*:*:*' }]}
iconType='plusInCircle'
href={getCore().application.getUrlForApp('endpoints-summary', {
path: '#/agents-preview/deploy',
href={getCore().application.getUrlForApp(endpointSumary.id, {
path: `#${endpointSumary.redirectTo()}deploy`,
})}
>
Deploy new agent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ export const RegisterAgent = compose(
{ text: endpointSumary.title, href: `#${endpointSumary.redirectTo()}` },
{ text: 'Deploy new agent' },
]),
withUserAuthorizationPrompt([
[{ action: 'agent:create', resource: '*:*:*' }],
]),
)(() => {
const configuration = useSelector(
(state: { appConfig: { data: any } }) => state.appConfig.data,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import { TableWzAPI } from '../../common/tables';
import { WzRequest } from '../../../react-services/wz-request';
import { get as getLodash } from 'lodash';
import { getCore } from '../../../kibana-services';
import { itHygiene } from '../../../utils/applications';
import { itHygiene, endpointSumary } from '../../../utils/applications';
import { RedirectAppLinks } from '../../../../../../src/plugins/opensearch_dashboards_react/public';

const searchBarWQLOptions = {
Expand Down Expand Up @@ -306,12 +306,9 @@ export const AgentsTable = withErrorBoundary(
buttonType='empty'
permissions={[{ action: 'agent:create', resource: '*:*:*' }]}
iconType='plusInCircle'
href={getCore().application.getUrlForApp(
'endpoints-summary',
{
path: '#/agents-preview/deploy',
},
)}
href={getCore().application.getUrlForApp(endpointSumary.id, {
path: `#${endpointSumary.redirectTo()}deploy`,
})}
>
Deploy new agent
</WzButtonPermissions>,
Expand Down
2 changes: 1 addition & 1 deletion plugins/main/public/controllers/agent/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const app = getAngularModule();

app
.controller('agentsController', AgentsController)
.value('RegisterAgent', RegisterAgent)
.value('ExportConfiguration', ExportConfiguration)
.value('AgentsWelcome', AgentsWelcome)
.value('Mitre', Mitre)
Expand All @@ -33,4 +34,3 @@ app
.value('MainAgentStats', MainAgentStats)
.value('MainModule', MainModule)
.value('MainEndpointsSummary', MainEndpointsSummary);
.value('RegisterAgent', RegisterAgent)

0 comments on commit 8e01d73

Please sign in to comment.