mirror of
https://github.com/elastic/kibana.git
synced 2025-06-27 18:51:07 -04:00
Ui Actions explorer example (#57006)
* wip * Move action registration out of AppMountContext fn * Move all registration to setup * Fix type error
This commit is contained in:
parent
62e3189c34
commit
2ae70d9592
21 changed files with 929 additions and 1 deletions
8
examples/ui_action_examples/README.md
Normal file
8
examples/ui_action_examples/README.md
Normal file
|
@ -0,0 +1,8 @@
|
|||
## Ui actions examples
|
||||
|
||||
These ui actions examples shows how to:
|
||||
- Register new actions
|
||||
- Register custom triggers
|
||||
- Attach an action to a trigger
|
||||
|
||||
To run this example, use the command `yarn start --run-examples`.
|
10
examples/ui_action_examples/kibana.json
Normal file
10
examples/ui_action_examples/kibana.json
Normal file
|
@ -0,0 +1,10 @@
|
|||
{
|
||||
"id": "uiActionsExamples",
|
||||
"version": "0.0.1",
|
||||
"kibanaVersion": "kibana",
|
||||
"configPath": ["ui_actions_examples"],
|
||||
"server": false,
|
||||
"ui": true,
|
||||
"requiredPlugins": ["uiActions"],
|
||||
"optionalPlugins": []
|
||||
}
|
17
examples/ui_action_examples/package.json
Normal file
17
examples/ui_action_examples/package.json
Normal file
|
@ -0,0 +1,17 @@
|
|||
{
|
||||
"name": "ui_actions_examples",
|
||||
"version": "1.0.0",
|
||||
"main": "target/examples/ui_actions_examples",
|
||||
"kibana": {
|
||||
"version": "kibana",
|
||||
"templateVersion": "1.0.0"
|
||||
},
|
||||
"license": "Apache-2.0",
|
||||
"scripts": {
|
||||
"kbn": "node ../../scripts/kbn.js",
|
||||
"build": "rm -rf './target' && tsc"
|
||||
},
|
||||
"devDependencies": {
|
||||
"typescript": "3.5.3"
|
||||
}
|
||||
}
|
43
examples/ui_action_examples/public/hello_world_action.tsx
Normal file
43
examples/ui_action_examples/public/hello_world_action.tsx
Normal file
|
@ -0,0 +1,43 @@
|
|||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
import React from 'react';
|
||||
import { EuiText, EuiModalBody, EuiButton } from '@elastic/eui';
|
||||
import { OverlayStart } from '../../../src/core/public';
|
||||
import { createAction } from '../../../src/plugins/ui_actions/public';
|
||||
import { toMountPoint } from '../../../src/plugins/kibana_react/public';
|
||||
|
||||
export const HELLO_WORLD_ACTION_TYPE = 'HELLO_WORLD_ACTION_TYPE';
|
||||
|
||||
export const createHelloWorldAction = (openModal: OverlayStart['openModal']) =>
|
||||
createAction<{}>({
|
||||
type: HELLO_WORLD_ACTION_TYPE,
|
||||
getDisplayName: () => 'Hello World!',
|
||||
execute: async () => {
|
||||
const overlay = openModal(
|
||||
toMountPoint(
|
||||
<EuiModalBody>
|
||||
<EuiText data-test-subj="helloWorldActionText">Hello world!</EuiText>
|
||||
<EuiButton data-test-subj="closeModal" onClick={() => overlay.close()}>
|
||||
Close
|
||||
</EuiButton>
|
||||
</EuiModalBody>
|
||||
)
|
||||
);
|
||||
},
|
||||
});
|
28
examples/ui_action_examples/public/hello_world_trigger.ts
Normal file
28
examples/ui_action_examples/public/hello_world_trigger.ts
Normal file
|
@ -0,0 +1,28 @@
|
|||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
import { Trigger } from '../../../src/plugins/ui_actions/public';
|
||||
import { HELLO_WORLD_ACTION_TYPE } from './hello_world_action';
|
||||
|
||||
export const HELLO_WORLD_TRIGGER_ID = 'HELLO_WORLD_TRIGGER_ID';
|
||||
|
||||
export const helloWorldTrigger: Trigger = {
|
||||
id: HELLO_WORLD_TRIGGER_ID,
|
||||
actionIds: [HELLO_WORLD_ACTION_TYPE],
|
||||
};
|
26
examples/ui_action_examples/public/index.ts
Normal file
26
examples/ui_action_examples/public/index.ts
Normal file
|
@ -0,0 +1,26 @@
|
|||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
import { UiActionExamplesPlugin } from './plugin';
|
||||
import { PluginInitializer } from '../../../src/core/public';
|
||||
|
||||
export const plugin: PluginInitializer<void, void> = () => new UiActionExamplesPlugin();
|
||||
|
||||
export { HELLO_WORLD_TRIGGER_ID } from './hello_world_trigger';
|
||||
export { HELLO_WORLD_ACTION_TYPE } from './hello_world_action';
|
45
examples/ui_action_examples/public/plugin.ts
Normal file
45
examples/ui_action_examples/public/plugin.ts
Normal file
|
@ -0,0 +1,45 @@
|
|||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
import { Plugin, CoreSetup, CoreStart } from '../../../src/core/public';
|
||||
import { UiActionsSetup, UiActionsStart } from '../../../src/plugins/ui_actions/public';
|
||||
import { createHelloWorldAction } from './hello_world_action';
|
||||
import { helloWorldTrigger } from './hello_world_trigger';
|
||||
|
||||
interface UiActionExamplesSetupDependencies {
|
||||
uiActions: UiActionsSetup;
|
||||
}
|
||||
|
||||
interface UiActionExamplesStartDependencies {
|
||||
uiActions: UiActionsStart;
|
||||
}
|
||||
|
||||
export class UiActionExamplesPlugin
|
||||
implements
|
||||
Plugin<void, void, UiActionExamplesSetupDependencies, UiActionExamplesStartDependencies> {
|
||||
public setup(core: CoreSetup, deps: UiActionExamplesSetupDependencies) {
|
||||
deps.uiActions.registerTrigger(helloWorldTrigger);
|
||||
}
|
||||
|
||||
public start(coreStart: CoreStart, deps: UiActionExamplesStartDependencies) {
|
||||
deps.uiActions.registerAction(createHelloWorldAction(coreStart.overlays.openModal));
|
||||
}
|
||||
|
||||
public stop() {}
|
||||
}
|
15
examples/ui_action_examples/tsconfig.json
Normal file
15
examples/ui_action_examples/tsconfig.json
Normal file
|
@ -0,0 +1,15 @@
|
|||
{
|
||||
"extends": "../../tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"outDir": "./target",
|
||||
"skipLibCheck": true
|
||||
},
|
||||
"include": [
|
||||
"index.ts",
|
||||
"public/**/*.ts",
|
||||
"public/**/*.tsx",
|
||||
"server/**/*.ts",
|
||||
"../../typings/**/*",
|
||||
],
|
||||
"exclude": []
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue