Skip to content

Commit

Permalink
[Index Management] Disable index actions using contextRef (#163475)
Browse files Browse the repository at this point in the history
## Summary
Follow up to #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="https://github.com/elastic/kibana/assets/6585477/527ce600-8758-44b4-bd41-c93723254646">

Serverless (no changes), index actions disabled

<img width="622" alt="Screenshot 2023-08-09 at 12 09 45"
src="https://github.com/elastic/kibana/assets/6585477/80190375-6cea-445d-8a75-3b354a447e9d">
  • Loading branch information
yuliacech authored Aug 10, 2023
1 parent c97d496 commit 39e11ff
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/index_management/public/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@ export interface ClientConfigType {
ui: {
enabled: boolean;
};
enableIndexActions: boolean;
enableIndexActions?: boolean;
}
9 changes: 8 additions & 1 deletion x-pack/plugins/index_management/server/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
);
Expand Down

0 comments on commit 39e11ff

Please sign in to comment.