[Index Management] Disable index actions using contextRef (#163475)

## Summary
Follow up to https://github.com/elastic/kibana/pull/161528 

This PR leverages the [schema.contextRef('serverless')
check](https://www.elastic.co/guide/en/kibana/master/configuration-service.html#validating-your-configuration-based-on-context-references)
to prevent the config `enableIndexActions` from leaking to self-managed.

### Screenshots
Stateful (no changes), index actions enabled

<img width="916" alt="Screenshot 2023-08-09 at 12 15 31"
src="527ce600-8758-44b4-bd41-c93723254646">

Serverless (no changes), index actions disabled

<img width="622" alt="Screenshot 2023-08-09 at 12 09 45"
src="80190375-6cea-445d-8a75-3b354a447e9d">
This commit is contained in:
Yulia Čech 2023-08-10 14:42:49 +02:00 committed by GitHub
parent c97d4960bf
commit 39e11ffbac
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 11 additions and 4 deletions

View file

@ -239,7 +239,7 @@ export default function ({ getService }: PluginFunctionalProviderContext) {
'xpack.graph.savePolicy (alternatives)',
'xpack.ilm.ui.enabled (boolean)',
'xpack.index_management.ui.enabled (boolean)',
'xpack.index_management.enableIndexActions (boolean)',
'xpack.index_management.enableIndexActions (any)',
'xpack.infra.sources.default.fields.message (array)',
/**
* xpack.infra.logs is conditional and will resolve to an object of properties

View file

@ -53,7 +53,7 @@ export async function mountManagementSection(
extensionsService: ExtensionsService,
isFleetEnabled: boolean,
kibanaVersion: SemVer,
enableIndexActions: boolean
enableIndexActions: boolean = true
) {
const { element, setBreadcrumbs, history, theme$ } = params;
const [core, startDependencies] = await coreSetup.getStartServices();

View file

@ -28,5 +28,5 @@ export interface ClientConfigType {
ui: {
enabled: boolean;
};
enableIndexActions: boolean;
enableIndexActions?: boolean;
}

View file

@ -22,7 +22,14 @@ const schemaLatest = schema.object(
ui: schema.object({
enabled: schema.boolean({ defaultValue: true }),
}),
enableIndexActions: schema.boolean({ defaultValue: true }),
enableIndexActions: schema.conditional(
schema.contextRef('serverless'),
true,
// Index actions are disabled in serverless; refer to the serverless.yml file as the source of truth
// We take this approach in order to have a central place (serverless.yml) for serverless config across Kibana
schema.boolean({ defaultValue: true }),
schema.never()
),
},
{ defaultValue: undefined }
);