Skip to content

Commit 0d0297c

Browse files
committed
Migrated sample_action to NP. Panel action tests returned to the test flow.
1 parent afd1179 commit 0d0297c

File tree

8 files changed

+76
-41
lines changed

8 files changed

+76
-41
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"id": "kbn_sample_panel_action",
3+
"version": "0.0.1",
4+
"kibanaVersion": "kibana",
5+
"configPath": ["kbn_sample_panel_action"],
6+
"server": false,
7+
"ui": true,
8+
"requiredPlugins": ["uiActions", "embeddable"]
9+
}

test/plugin_functional/plugins/kbn_tp_sample_panel_action/package.json renamed to test/plugin_functional/plugins/kbn_sample_panel_action/package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
2-
"name": "kbn_tp_sample_panel_action",
2+
"name": "kbn_sample_panel_action",
33
"version": "1.0.0",
4-
"main": "target/test/plugin_functional/plugins/kbn_tp_sample_panel_action",
4+
"main": "target/test/plugin_functional/plugins/kbn_sample_panel_action",
55
"kibana": {
66
"version": "kibana",
77
"templateVersion": "1.0.0"
@@ -16,7 +16,6 @@
1616
"build": "rm -rf './target' && tsc"
1717
},
1818
"devDependencies": {
19-
"@kbn/plugin-helpers": "9.0.2",
2019
"typescript": "3.7.2"
2120
}
2221
}

test/plugin_functional/plugins/kbn_tp_sample_panel_action/index.ts renamed to test/plugin_functional/plugins/kbn_sample_panel_action/public/index.ts

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -17,24 +17,14 @@
1717
* under the License.
1818
*/
1919

20-
import { resolve } from 'path';
20+
import { PluginInitializer } from 'kibana/public';
21+
import {
22+
SampelPanelActionTestPlugin,
23+
SampelPanelActionTestPluginSetup,
24+
SampelPanelActionTestPluginStart,
25+
} from './plugin';
2126

22-
// TODO: use something better once https://github.com/elastic/kibana/issues/26555 is
23-
// figured out.
24-
type KibanaPlugin = any;
25-
26-
function samplePanelAction(kibana: KibanaPlugin) {
27-
return new kibana.Plugin({
28-
publicDir: resolve(__dirname, './public'),
29-
uiExports: {
30-
embeddableActions: [
31-
'plugins/kbn_tp_sample_panel_action/sample_panel_action',
32-
'plugins/kbn_tp_sample_panel_action/sample_panel_link',
33-
],
34-
},
35-
});
36-
}
37-
38-
module.exports = (kibana: KibanaPlugin) => {
39-
return [samplePanelAction(kibana)];
40-
};
27+
export const plugin: PluginInitializer<
28+
SampelPanelActionTestPluginSetup,
29+
SampelPanelActionTestPluginStart
30+
> = () => new SampelPanelActionTestPlugin();
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/*
2+
* Licensed to Elasticsearch B.V. under one or more contributor
3+
* license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright
5+
* ownership. Elasticsearch B.V. licenses this file to you under
6+
* the Apache License, Version 2.0 (the "License"); you may
7+
* not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
import { CoreSetup, Plugin } from 'kibana/public';
21+
import { UiActionsSetup } from '../../../../../src/plugins/ui_actions/public';
22+
import { CONTEXT_MENU_TRIGGER } from '../../../../../src/plugins/embeddable/public';
23+
import { createSamplePanelAction } from './sample_panel_action';
24+
import { createSamplePanelLink } from './sample_panel_link';
25+
26+
export class SampelPanelActionTestPlugin
27+
implements Plugin<SampelPanelActionTestPluginSetup, SampelPanelActionTestPluginStart> {
28+
public setup(core: CoreSetup, { uiActions }: { uiActions: UiActionsSetup }) {
29+
const samplePanelAction = createSamplePanelAction(core.getStartServices);
30+
31+
uiActions.registerAction(samplePanelAction);
32+
uiActions.attachAction(CONTEXT_MENU_TRIGGER, samplePanelAction);
33+
34+
const samplePanelLink = createSamplePanelLink();
35+
36+
uiActions.registerAction(samplePanelLink);
37+
uiActions.attachAction(CONTEXT_MENU_TRIGGER, samplePanelLink);
38+
39+
return {};
40+
}
41+
42+
public start() {}
43+
public stop() {}
44+
}
45+
46+
export type SampelPanelActionTestPluginSetup = ReturnType<SampelPanelActionTestPlugin['setup']>;
47+
export type SampelPanelActionTestPluginStart = ReturnType<SampelPanelActionTestPlugin['start']>;
Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,31 +16,32 @@
1616
* specific language governing permissions and limitations
1717
* under the License.
1818
*/
19+
import { CoreSetup } from 'kibana/public';
1920
import { EuiFlyoutBody, EuiFlyoutHeader, EuiTitle } from '@elastic/eui';
2021
import React from 'react';
21-
import { npStart, npSetup } from 'ui/new_platform';
2222

23-
import { CONTEXT_MENU_TRIGGER, IEmbeddable } from '../../../../../src/plugins/embeddable/public';
23+
import { IEmbeddable } from '../../../../../src/plugins/embeddable/public';
2424
import { createAction, ActionType } from '../../../../../src/plugins/ui_actions/public';
2525
import { toMountPoint } from '../../../../../src/plugins/kibana_react/public';
2626

2727
// Casting to ActionType is a hack - in a real situation use
2828
// declare module and add this id to ActionContextMapping.
29-
export const SAMPLE_PANEL_ACTION = 'SAMPLE_PANEL_ACTION' as ActionType;
29+
export const SAMPLE_PANEL_ACTION = 'samplePanelAction' as ActionType;
3030

3131
export interface SamplePanelActionContext {
3232
embeddable: IEmbeddable;
3333
}
3434

35-
function createSamplePanelAction() {
35+
export function createSamplePanelAction(getStartServices: CoreSetup['getStartServices']) {
3636
return createAction<typeof SAMPLE_PANEL_ACTION>({
3737
type: SAMPLE_PANEL_ACTION,
3838
getDisplayName: () => 'Sample Panel Action',
3939
execute: async ({ embeddable }: SamplePanelActionContext) => {
4040
if (!embeddable) {
4141
return;
4242
}
43-
npStart.core.overlays.openFlyout(
43+
const openFlyout = (await getStartServices())[0].overlays.openFlyout;
44+
openFlyout(
4445
toMountPoint(
4546
<React.Fragment>
4647
<EuiFlyoutHeader>
@@ -60,7 +61,3 @@ function createSamplePanelAction() {
6061
},
6162
});
6263
}
63-
64-
const action = createSamplePanelAction();
65-
npSetup.plugins.uiActions.registerAction(action);
66-
npSetup.plugins.uiActions.attachAction(CONTEXT_MENU_TRIGGER, action);
Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@
1616
* specific language governing permissions and limitations
1717
* under the License.
1818
*/
19-
import { npStart } from 'ui/new_platform';
2019
import { Action, createAction, ActionType } from '../../../../../src/plugins/ui_actions/public';
21-
import { CONTEXT_MENU_TRIGGER } from '../../../../../src/plugins/embeddable/public';
2220

2321
// Casting to ActionType is a hack - in a real situation use
2422
// declare module and add this id to ActionContextMapping.
@@ -31,7 +29,3 @@ export const createSamplePanelLink = (): Action =>
3129
execute: async () => {},
3230
getHref: () => 'https://example.com/kibana/test',
3331
});
34-
35-
const action = createSamplePanelLink();
36-
npStart.plugins.uiActions.registerAction(action);
37-
npStart.plugins.uiActions.attachAction(CONTEXT_MENU_TRIGGER, action);

test/plugin_functional/test_suites/panel_actions/index.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,9 @@ export default function({ getService, getPageObjects, loadTestFile }) {
3232
const browser = getService('browser');
3333
const esArchiver = getService('esArchiver');
3434
const kibanaServer = getService('kibanaServer');
35-
const PageObjects = getPageObjects(['dashboard']);
35+
const PageObjects = getPageObjects(['common', 'dashboard']);
3636

37-
// FLAKY: https://github.com/elastic/kibana/issues/41050
38-
describe.skip('pluggable panel actions', function() {
37+
describe('pluggable panel actions', function() {
3938
before(async () => {
4039
await browser.setWindowSize(1300, 900);
4140
await esArchiver.load(KIBANA_ARCHIVE_PATH);

0 commit comments

Comments
 (0)