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] UI changes on hosted policy detail view #96337

Merged
merged 13 commits into from
Apr 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ export const AgentPolicyForm: React.FunctionComponent<Props> = ({
isInvalid={Boolean(touchedFields[name] && validation[name])}
>
<EuiFieldText
disabled={agentPolicy.is_managed === true}
fullWidth
value={agentPolicy[name]}
onChange={(e) => updateAgentPolicy({ [name]: e.target.value })}
Expand Down Expand Up @@ -283,7 +284,7 @@ export const AgentPolicyForm: React.FunctionComponent<Props> = ({
}}
/>
</EuiDescribedFormGroup>
{isEditing && 'id' in agentPolicy ? (
{isEditing && 'id' in agentPolicy && agentPolicy.is_managed !== true ? (
<EuiDescribedFormGroup
title={
<h4>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,42 +167,45 @@ export const PackagePoliciesTable: React.FunctionComponent<Props> = ({
}),
actions: [
{
render: (packagePolicy: InMemoryPackagePolicy) => (
<ContextMenuActions
items={[
// FIXME: implement View package policy action
// <EuiContextMenuItem
// disabled
// icon="inspect"
// onClick={() => {}}
// key="packagePolicyView"
// >
// <FormattedMessage
// id="xpack.fleet.policyDetails.packagePoliciesTable.viewActionTitle"
// defaultMessage="View integration"
// />
// </EuiContextMenuItem>,
<EuiContextMenuItem
disabled={!hasWriteCapabilities}
icon="pencil"
href={getHref('edit_integration', {
policyId: agentPolicy.id,
packagePolicyId: packagePolicy.id,
})}
key="packagePolicyEdit"
>
<FormattedMessage
id="xpack.fleet.policyDetails.packagePoliciesTable.editActionTitle"
defaultMessage="Edit integration"
/>
</EuiContextMenuItem>,
// FIXME: implement Copy package policy action
// <EuiContextMenuItem disabled icon="copy" onClick={() => {}} key="packagePolicyCopy">
// <FormattedMessage
// id="xpack.fleet.policyDetails.packagePoliciesTable.copyActionTitle"
// defaultMessage="Copy integration"
// />
// </EuiContextMenuItem>,
render: (packagePolicy: InMemoryPackagePolicy) => {
const menuItems = [
// FIXME: implement View package policy action
// <EuiContextMenuItem
// disabled
// icon="inspect"
// onClick={() => {}}
// key="packagePolicyView"
// >
// <FormattedMessage
// id="xpack.fleet.policyDetails.packagePoliciesTable.viewActionTitle"
// defaultMessage="View integration"
// />
// </EuiContextMenuItem>,
<EuiContextMenuItem
disabled={!hasWriteCapabilities}
icon="pencil"
href={getHref('edit_integration', {
policyId: agentPolicy.id,
packagePolicyId: packagePolicy.id,
})}
key="packagePolicyEdit"
>
<FormattedMessage
id="xpack.fleet.policyDetails.packagePoliciesTable.editActionTitle"
defaultMessage="Edit integration"
/>
</EuiContextMenuItem>,
// FIXME: implement Copy package policy action
// <EuiContextMenuItem disabled icon="copy" onClick={() => {}} key="packagePolicyCopy">
// <FormattedMessage
// id="xpack.fleet.policyDetails.packagePoliciesTable.copyActionTitle"
// defaultMessage="Copy integration"
// />
// </EuiContextMenuItem>,
];

if (!agentPolicy.is_managed) {
menuItems.push(
<PackagePolicyDeleteProvider agentPolicy={agentPolicy} key="packagePolicyDelete">
{(deletePackagePoliciesPrompt) => {
return (
Expand All @@ -220,10 +223,11 @@ export const PackagePoliciesTable: React.FunctionComponent<Props> = ({
</DangerEuiContextMenuItem>
);
}}
</PackagePolicyDeleteProvider>,
]}
/>
),
</PackagePolicyDeleteProvider>
);
}
return <ContextMenuActions items={menuItems} />;
},
},
],
},
Expand All @@ -244,19 +248,21 @@ export const PackagePoliciesTable: React.FunctionComponent<Props> = ({
}}
{...rest}
search={{
toolsRight: [
<EuiButton
key="addPackagePolicyButton"
isDisabled={!hasWriteCapabilities}
iconType="plusInCircle"
href={getHref('add_integration_from_policy', { policyId: agentPolicy.id })}
>
<FormattedMessage
id="xpack.fleet.policyDetails.addPackagePolicyButtonText"
defaultMessage="Add integration"
/>
</EuiButton>,
],
toolsRight: agentPolicy.is_managed
? []
: [
<EuiButton
key="addPackagePolicyButton"
isDisabled={!hasWriteCapabilities}
iconType="plusInCircle"
href={getHref('add_integration_from_policy', { policyId: agentPolicy.id })}
>
<FormattedMessage
id="xpack.fleet.policyDetails.addPackagePolicyButtonText"
defaultMessage="Add integration"
/>
</EuiButton>,
],
box: {
incremental: true,
schema: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import { FormattedMessage, FormattedDate } from '@kbn/i18n/react';
import {
EuiFlexGroup,
EuiFlexItem,
EuiIconTip,
EuiTitle,
EuiText,
EuiSpacer,
EuiButtonEmpty,
Expand Down Expand Up @@ -84,23 +86,42 @@ export const AgentPolicyDetailsPage: React.FunctionComponent = () => {
</EuiButtonEmpty>
</EuiFlexItem>
<EuiFlexItem>
<EuiText className="eui-textBreakWord">
<h1>
{isLoading ? (
<Loading />
) : (
(agentPolicy && agentPolicy.name) || (
<FormattedMessage
id="xpack.fleet.policyDetails.policyDetailsTitle"
defaultMessage="Policy '{id}'"
values={{
id: policyId,
}}
{isLoading ? (
<Loading />
) : (
<EuiFlexGroup alignItems="center" wrap responsive={false} gutterSize="s">
<EuiFlexItem>
<EuiTitle>
<h1>
{(agentPolicy && agentPolicy.name) || (
<FormattedMessage
id="xpack.fleet.policyDetails.policyDetailsTitle"
defaultMessage="Policy '{id}'"
values={{ id: policyId }}
/>
)}
</h1>
</EuiTitle>
</EuiFlexItem>
{agentPolicy?.is_managed && (
<EuiFlexItem grow={false}>
<EuiIconTip
title="Managed agent policy"
content={i18n.translate(
'xpack.fleet.policyDetails.policyDetailsManagedPolicyTooltip',
{
defaultMessage:
'This policy is managed outside of Fleet. Most actions related to this policy are unavailable.',
}
)}
type="lock"
size="l"
color="subdued"
/>
)
</EuiFlexItem>
)}
</h1>
</EuiText>
</EuiFlexGroup>
)}
</EuiFlexItem>

{agentPolicy && agentPolicy.description ? (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,17 +194,18 @@ export const AgentDetailsPage: React.FunctionComponent = () => {
),
},
{
content: (
<AgentDetailsActionMenu
agent={agentData.item}
assignFlyoutOpenByDefault={openReassignFlyoutOpenByDefault}
onCancelReassign={
routeState && routeState.onDoneNavigateTo
? reassignCancelClickHandler
: undefined
}
/>
),
content:
isAgentPolicyLoading || agentPolicyData?.item?.is_managed ? undefined : (
<AgentDetailsActionMenu
agent={agentData.item}
assignFlyoutOpenByDefault={openReassignFlyoutOpenByDefault}
onCancelReassign={
routeState && routeState.onDoneNavigateTo
? reassignCancelClickHandler
: undefined
}
/>
),
},
].map((item, index) => (
<EuiFlexItem grow={false} key={index}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -341,9 +341,10 @@ export const AgentListPage: React.FunctionComponent<{}> = () => {

const isAgentSelectable = (agent: Agent) => {
if (!agent.active) return false;
if (!agent.policy_id) return true;

const agentPolicy = agentPolicies.find((p) => p.id === agent.policy_id);
const isManaged = agent.policy_id && agentPolicy?.is_managed === true;
const agentPolicy = agentPoliciesIndexedById[agent.policy_id];
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nchaulet This is the follow up mentioned in #96160 (comment)

const isManaged = agentPolicy?.is_managed === true;
return !isManaged;
};

Expand Down