-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Fleet] Make add agent action more obvious in integration policy table (
#112936) * add agent button changes * remove unused imports * move cell to separatre component and add tests * fix conflicting i18n defaults * remove tests for old layout Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
- Loading branch information
1 parent
d75df38
commit 467e585
Showing
5 changed files
with
102 additions
and
86 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
43 changes: 43 additions & 0 deletions
43
...tions/sections/epm/screens/detail/policies/components/package_policy_agents_cell.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,43 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import React from 'react'; | ||
|
||
import { act } from '@testing-library/react'; | ||
|
||
import { createIntegrationsTestRendererMock } from '../../../../../../../../mock'; | ||
|
||
import { PackagePolicyAgentsCell } from './package_policy_agents_cell'; | ||
|
||
function renderCell({ agentCount = 0, agentPolicyId = '123', onAddAgent = () => {} }) { | ||
const renderer = createIntegrationsTestRendererMock(); | ||
|
||
return renderer.render( | ||
<PackagePolicyAgentsCell | ||
agentCount={agentCount} | ||
agentPolicyId={agentPolicyId} | ||
onAddAgent={onAddAgent} | ||
/> | ||
); | ||
} | ||
|
||
describe('PackagePolicyAgentsCell', () => { | ||
test('it should display add agent if count is 0', async () => { | ||
const utils = renderCell({ agentCount: 0 }); | ||
await act(async () => { | ||
expect(utils.queryByText('Add agent')).toBeInTheDocument(); | ||
}); | ||
}); | ||
|
||
test('it should display only count if count > 0', async () => { | ||
const utils = renderCell({ agentCount: 9999 }); | ||
await act(async () => { | ||
expect(utils.queryByText('Add agent')).not.toBeInTheDocument(); | ||
expect(utils.queryByText('9999')).toBeInTheDocument(); | ||
}); | ||
}); | ||
}); |
42 changes: 42 additions & 0 deletions
42
...tegrations/sections/epm/screens/detail/policies/components/package_policy_agents_cell.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,42 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import React from 'react'; | ||
|
||
import { EuiButton } from '@elastic/eui'; | ||
import { FormattedMessage } from '@kbn/i18n/react'; | ||
|
||
import { LinkedAgentCount } from '../../../../../../components'; | ||
|
||
export const PackagePolicyAgentsCell = ({ | ||
agentPolicyId, | ||
agentCount = 0, | ||
onAddAgent, | ||
}: { | ||
agentPolicyId: string; | ||
agentCount?: number; | ||
onAddAgent: () => void; | ||
}) => { | ||
if (agentCount > 0) { | ||
return ( | ||
<LinkedAgentCount | ||
count={agentCount} | ||
agentPolicyId={agentPolicyId} | ||
className="eui-textTruncate" | ||
/> | ||
); | ||
} | ||
|
||
return ( | ||
<EuiButton iconType="plusInCircle" data-test-subj="addAgentButton" onClick={onAddAgent}> | ||
<FormattedMessage | ||
id="xpack.fleet.epm.packageDetails.integrationList.addAgent" | ||
defaultMessage="Add 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