mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
[Fleet] Hide enrollment token for hosted policies (#99253)
closes #98886 ## Hide hosted policy names from select menu per https://github.com/elastic/kibana/issues/98886#issuecomment-830270965 <details><summary>Screenshots</summary> <h3><code>master</code></h3> <img width="1313" alt="Screen Shot 2021-05-04 at 2 22 54 PM" src="https://user-images.githubusercontent.com/57655/117060152-9c55e180-acee-11eb-97d0-5cab98436dd6.png"> <h3>PR</h3> <img width="1071" alt="Screen Shot 2021-05-04 at 3 25 13 PM" src="https://user-images.githubusercontent.com/57655/117059705-15a10480-acee-11eb-871c-fe1aaad7db75.png"> </details> ## Don't show enrollment keys in table if they are for a hosted policy per https://github.com/elastic/kibana/issues/98886#issuecomment-831099524 <details><summary>Screenshots</summary> <h3><code>master</code></h3> <img width="1150" alt="Screen Shot 2021-05-04 at 3 40 02 PM" src="https://user-images.githubusercontent.com/57655/117060639-1be3b080-acef-11eb-95e4-33a212454608.png"> <h3>PR</h3> <img width="1074" alt="Screen Shot 2021-05-04 at 3 07 52 PM" src="https://user-images.githubusercontent.com/57655/117060427-eb9c1200-acee-11eb-973f-273b05a27547.png"> </details>
This commit is contained in:
parent
a72b0393f3
commit
09d81cfd81
2 changed files with 22 additions and 8 deletions
|
@ -116,10 +116,12 @@ export const NewEnrollmentTokenFlyout: React.FunctionComponent<Props> = ({
|
|||
required={true}
|
||||
defaultValue={policyIdDefaultValue}
|
||||
{...form.policyIdInput.props}
|
||||
options={agentPolicies.map((agentPolicy) => ({
|
||||
value: agentPolicy.id,
|
||||
text: agentPolicy.name,
|
||||
}))}
|
||||
options={agentPolicies
|
||||
.filter((agentPolicy) => !agentPolicy.is_managed)
|
||||
.map((agentPolicy) => ({
|
||||
value: agentPolicy.id,
|
||||
text: agentPolicy.name,
|
||||
}))}
|
||||
/>
|
||||
</EuiFormRow>
|
||||
<EuiButton type="submit" fill isLoading={form.isLoading}>
|
||||
|
|
|
@ -31,7 +31,7 @@ import {
|
|||
useStartServices,
|
||||
sendDeleteOneEnrollmentAPIKey,
|
||||
} from '../../../hooks';
|
||||
import type { EnrollmentAPIKey } from '../../../types';
|
||||
import type { EnrollmentAPIKey, GetAgentPoliciesResponseItem } from '../../../types';
|
||||
import { SearchBar } from '../../../components/search_bar';
|
||||
|
||||
import { NewEnrollmentTokenFlyout } from './components/new_enrollment_key_flyout';
|
||||
|
@ -171,9 +171,21 @@ export const EnrollmentTokenListPage: React.FunctionComponent<{}> = () => {
|
|||
});
|
||||
|
||||
const agentPolicies = agentPoliciesRequest.data ? agentPoliciesRequest.data.items : [];
|
||||
const agentPoliciesById = agentPolicies.reduce(
|
||||
(acc: { [key: string]: GetAgentPoliciesResponseItem }, policy) => {
|
||||
acc[policy.id] = policy;
|
||||
return acc;
|
||||
},
|
||||
{}
|
||||
);
|
||||
|
||||
const total = enrollmentAPIKeysRequest?.data?.total ?? 0;
|
||||
const items = enrollmentAPIKeysRequest?.data?.list ?? [];
|
||||
const rowItems =
|
||||
enrollmentAPIKeysRequest?.data?.list.filter((enrollmentKey) => {
|
||||
if (!agentPolicies.length || !enrollmentKey.policy_id) return false;
|
||||
const agentPolicy = agentPoliciesById[enrollmentKey.policy_id];
|
||||
return !agentPolicy?.is_managed;
|
||||
}) || [];
|
||||
|
||||
const columns = [
|
||||
{
|
||||
|
@ -203,7 +215,7 @@ export const EnrollmentTokenListPage: React.FunctionComponent<{}> = () => {
|
|||
defaultMessage: 'Agent policy',
|
||||
}),
|
||||
render: (policyId: string) => {
|
||||
const agentPolicy = agentPolicies.find((c) => c.id === policyId);
|
||||
const agentPolicy = agentPoliciesById[policyId];
|
||||
const value = agentPolicy ? agentPolicy.name : policyId;
|
||||
return (
|
||||
<span className="eui-textTruncate" title={value}>
|
||||
|
@ -314,7 +326,7 @@ export const EnrollmentTokenListPage: React.FunctionComponent<{}> = () => {
|
|||
/>
|
||||
)
|
||||
}
|
||||
items={total ? items : []}
|
||||
items={total ? rowItems : []}
|
||||
itemId="id"
|
||||
columns={columns}
|
||||
pagination={{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue