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

[Fleet] Filter hosted policies from menu #97380

Merged
merged 8 commits into from
Apr 19, 2021
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,18 @@ import { usePackageIconType } from '../hooks';

export const PackageIcon: React.FunctionComponent<
UsePackageIconType & Omit<EuiIconProps, 'type'>
> = ({ packageName, version, icons, tryApi, ...euiIconProps }) => {
> = ({ size = 's', packageName, version, icons, tryApi, ...euiIconProps }) => {
const iconType = usePackageIconType({ packageName, version, icons, tryApi });
return <EuiIcon size="s" type={iconType} {...euiIconProps} />;
return (
<EuiIcon
// when a custom SVG is used the logo is rendered with <img class="euiIcon euiIcon--small">
// this collides with some EuiText (+img) CSS from the EuiIcon component
// which makes the button large, wide, and poorly layed out
// override those styles until the bug is fixed or we find a better approach
style={{ margin: 'unset', width: 'unset' }}
size={size}
type={iconType}
{...euiIconProps}
/>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,11 @@ export const StepSelectAgentPolicy: React.FunctionComponent<{
sortOrder: 'asc',
full: true,
});
const agentPolicies = useMemo(() => agentPoliciesData?.items || [], [agentPoliciesData?.items]);
const agentPolicies = useMemo(
() => agentPoliciesData?.items.filter((policy) => !policy.is_managed) || [],
[agentPoliciesData?.items]
);

const agentPoliciesById = useMemo(() => {
return agentPolicies.reduce((acc: { [key: string]: GetAgentPoliciesResponseItem }, policy) => {
acc[policy.id] = policy;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { useCapabilities, useKibanaVersion } from '../../../../hooks';
import { ContextMenuActions } from '../../../../components';
import {
AgentUnenrollAgentModal,
AgentReassignAgentPolicyFlyout,
AgentReassignAgentPolicyModal,
AgentUpgradeAgentModal,
} from '../../components';
import { useAgentRefresh } from '../hooks';
Expand Down Expand Up @@ -45,7 +45,7 @@ export const AgentDetailsActionMenu: React.FunctionComponent<{
<>
{isReassignFlyoutOpen && (
<EuiPortal>
<AgentReassignAgentPolicyFlyout agents={[agent]} onClose={onClose} />
<AgentReassignAgentPolicyModal agents={[agent]} onClose={onClose} />
</EuiPortal>
)}
{isUnenrollModalOpen && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { FormattedMessage, FormattedNumber } from '@kbn/i18n/react';
import { SO_SEARCH_LIMIT } from '../../../../constants';
import type { Agent } from '../../../../types';
import {
AgentReassignAgentPolicyFlyout,
AgentReassignAgentPolicyModal,
AgentUnenrollAgentModal,
AgentUpgradeAgentModal,
} from '../../components';
Expand Down Expand Up @@ -161,7 +161,7 @@ export const AgentBulkActions: React.FunctionComponent<{
<>
{isReassignFlyoutOpen && (
<EuiPortal>
<AgentReassignAgentPolicyFlyout
<AgentReassignAgentPolicyModal
agents={agents}
onClose={() => {
setIsReassignFlyoutOpen(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ import { AgentPolicySummaryLine, ContextMenuActions } from '../../../components'
import { AgentStatusKueryHelper, isAgentUpgradeable } from '../../../services';
import { AGENT_SAVED_OBJECT_TYPE } from '../../../constants';
import {
AgentReassignAgentPolicyFlyout,
AgentReassignAgentPolicyModal,
AgentHealth,
AgentUnenrollAgentModal,
AgentUpgradeAgentModal,
Expand Down Expand Up @@ -379,7 +379,7 @@ export const AgentListPage: React.FunctionComponent<{}> = () => {

return (
<EuiFlexGroup gutterSize="s" alignItems="center" style={{ minWidth: 0 }}>
<AgentPolicySummaryLine policy={agentPolicy} />
{agentPolicy && <AgentPolicySummaryLine policy={agentPolicy} />}
{showWarning && (
<EuiFlexItem grow={false}>
<EuiText color="subdued" size="xs" className="eui-textNoWrap">
Expand Down Expand Up @@ -488,7 +488,7 @@ export const AgentListPage: React.FunctionComponent<{}> = () => {
) : null}
{agentToReassign && (
<EuiPortal>
<AgentReassignAgentPolicyFlyout
<AgentReassignAgentPolicyModal
agents={[agentToReassign]}
onClose={() => {
setAgentToReassign(undefined);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,16 @@ export const AgentPolicySelectionStep = ({
setSelectedAPIKeyId?: (key: string) => void;
setSelectedPolicyId?: (policyId: string) => void;
}) => {
const regularAgentPolicies = Array.isArray(agentPolicies)
? agentPolicies.filter((policy) => policy && !policy.is_managed)
: [];
return {
title: i18n.translate('xpack.fleet.agentEnrollment.stepChooseAgentPolicyTitle', {
defaultMessage: 'Choose an agent policy',
}),
children: (
<EnrollmentStepAgentPolicy
agentPolicies={agentPolicies}
agentPolicies={regularAgentPolicies}
withKeySelection={setSelectedAPIKeyId ? true : false}
onKeyChange={setSelectedAPIKeyId}
onAgentPolicyChange={setSelectedPolicyId}
Expand Down

This file was deleted.

Loading