Skip to content

Commit

Permalink
Add triggers_action_ui
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisronline committed Aug 12, 2021
1 parent 87cf604 commit e931208
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 1 deletion.
42 changes: 42 additions & 0 deletions x-pack/plugins/triggers_actions_ui/server/index.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
import { config } from './index';
import { applyDeprecations, configDeprecationFactory } from '@kbn/config';

const CONFIG_PATH = 'xpack.trigger_actions_ui';
const applyStackAlertDeprecations = (settings: Record<string, unknown> = {}) => {
const deprecations = config.deprecations!(configDeprecationFactory);
const deprecationMessages: string[] = [];
const _config = {
[CONFIG_PATH]: settings,
};
const { config: migrated } = applyDeprecations(
_config,
deprecations.map((deprecation) => ({
deprecation,
path: CONFIG_PATH,
})),
() => ({ message }) => deprecationMessages.push(message)
);
return {
messages: deprecationMessages,
migrated,
};
};

describe('index', () => {
describe('deprecations', () => {
it('should deprecate .enabled flag', () => {
const { messages } = applyStackAlertDeprecations({ enabled: false });
expect(messages).toMatchInlineSnapshot(`
Array [
"\\"xpack.trigger_actions_ui.enabled\\" is deprecated. The ability to disable this plugin will be removed in 8.0.0.",
]
`);
});
});
});
15 changes: 14 additions & 1 deletion x-pack/plugins/triggers_actions_ui/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import { get } from 'lodash';
import { PluginConfigDescriptor, PluginInitializerContext } from 'kibana/server';
import { configSchema, ConfigSchema } from '../config';
import { TriggersActionsPlugin } from './plugin';
Expand All @@ -26,6 +26,19 @@ export const config: PluginConfigDescriptor<ConfigSchema> = {
enableGeoTrackingThresholdAlert: true,
},
schema: configSchema,
deprecations: () => [
(settings, fromPath, addDeprecation) => {
const triggersActionsUi = get(settings, fromPath);
if (triggersActionsUi?.enabled === false || triggersActionsUi?.enabled === true) {
addDeprecation({
message: `"xpack.trigger_actions_ui.enabled" is deprecated. The ability to disable this plugin will be removed in 8.0.0.`,
correctiveActions: {
manualSteps: [`Remove "xpack.trigger_actions_ui.enabled" from your kibana configs.`],
},
});
}
},
],
};

export const plugin = (ctx: PluginInitializerContext) => new TriggersActionsPlugin(ctx);

0 comments on commit e931208

Please sign in to comment.