[Fleet] Allow user-configured namespace for managed policies (#116523)

* Disable agent monitoring settings in UI for managed policies

* Allow namespace to be changed for preconfigured managed policies

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
Jen Huang 2021-11-01 11:22:18 -07:00 committed by GitHub
parent 2c887539d5
commit e793b3a225
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 1 deletions

View file

@ -237,6 +237,7 @@ export const AgentPolicyForm: React.FunctionComponent<Props> = ({
}
>
<EuiCheckboxGroup
disabled={agentPolicy.is_managed === true}
options={[
{
id: dataTypes.Logs,

View file

@ -547,6 +547,17 @@ describe('comparePreconfiguredPolicyToCurrent', () => {
);
expect(hasChanged).toBe(false);
});
it('should not return hasChanged when only namespace field changes', () => {
const { hasChanged } = comparePreconfiguredPolicyToCurrent(
{
...baseConfig,
namespace: 'newnamespace',
},
basePackagePolicy
);
expect(hasChanged).toBe(false);
});
});
describe('output preconfiguration', () => {

View file

@ -389,7 +389,9 @@ export function comparePreconfiguredPolicyToCurrent(
policyFromConfig: PreconfiguredAgentPolicy,
currentPolicy: AgentPolicy
) {
const configTopLevelFields = omit(policyFromConfig, 'package_policies', 'id');
// Namespace is omitted from being compared because even for managed policies, we still
// want users to be able to pick their own namespace: https://github.com/elastic/kibana/issues/110533
const configTopLevelFields = omit(policyFromConfig, 'package_policies', 'id', 'namespace');
const currentTopLevelFields = pick(currentPolicy, ...Object.keys(configTopLevelFields));
return {