-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
oatkiller
committed
Nov 14, 2019
1 parent
ab9aa3e
commit 9299846
Showing
7 changed files
with
137 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"id": "endpoint", | ||
"version": "1.0.0", | ||
"kibanaVersion": "kibana", | ||
"configPath": ["x-pack", "endpoint"], | ||
"server": true, | ||
"ui": true | ||
} |
26 changes: 26 additions & 0 deletions
26
x-pack/plugins/endpoint/public/applications/endpoint/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import * as React from 'react'; | ||
import ReactDOM from 'react-dom'; | ||
import { AppMountContext, AppMountParameters } from 'kibana/public'; | ||
|
||
/** | ||
* This module will be loaded asynchronously to reduce the bundle size of your plugin's main bundle. | ||
*/ | ||
export function renderApp(appMountContext: AppMountContext, { element }: AppMountParameters) { | ||
appMountContext.core.http.get('/endpoint/hello-world'); | ||
|
||
ReactDOM.render(<AppRoot />, element); | ||
|
||
return function() { | ||
ReactDOM.unmountComponentAtNode(element); | ||
}; | ||
} | ||
|
||
const AppRoot = React.memo(function Root() { | ||
return <h1>Welcome to Endpoint</h1>; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { PluginInitializer } from 'kibana/public'; | ||
import { schema } from '@kbn/config-schema'; | ||
import { EndpointPlugin } from './plugin'; | ||
|
||
export const config = { | ||
schema: schema.object({ enabled: schema.boolean({ defaultValue: false }) }), | ||
}; | ||
|
||
export const plugin: PluginInitializer<{}, {}> = () => new EndpointPlugin(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { Plugin, CoreSetup } from 'kibana/public'; | ||
|
||
export class EndpointPlugin implements Plugin<{}, {}> { | ||
public setup(core: CoreSetup) { | ||
core.application.register({ | ||
id: 'endpoint', | ||
title: 'Endpoint', | ||
async mount(context, params) { | ||
const { renderApp } = await import('./applications/endpoint'); | ||
return renderApp(context, params); | ||
}, | ||
}); | ||
return {}; | ||
} | ||
|
||
public start() { | ||
return {}; | ||
} | ||
|
||
public stop() {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { schema } from '@kbn/config-schema'; | ||
import { EndpointPlugin } from './plugin'; | ||
|
||
export const config = { | ||
schema: schema.object({ enabled: schema.boolean({ defaultValue: false }) }), | ||
}; | ||
|
||
export function plugin() { | ||
return new EndpointPlugin(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { Plugin, CoreSetup } from 'kibana/server'; | ||
import { addRoutes } from './routes'; | ||
|
||
export class EndpointPlugin implements Plugin { | ||
public setup(core: CoreSetup) { | ||
const router = core.http.createRouter(); | ||
addRoutes(router); | ||
} | ||
|
||
public start() {} | ||
public stop() {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { IRouter, KibanaResponseFactory } from 'kibana/server'; | ||
|
||
export function addRoutes(router: IRouter) { | ||
router.get( | ||
{ | ||
path: '/endpoint/hello-world', | ||
validate: false, | ||
}, | ||
greetingIndex | ||
); | ||
} | ||
|
||
async function greetingIndex(...passedArgs: [unknown, unknown, KibanaResponseFactory]) { | ||
const [, , response] = passedArgs; | ||
return response.ok({ | ||
body: JSON.stringify({ hello: 'world' }), | ||
headers: { | ||
'Content-Type': 'application/json', | ||
}, | ||
}); | ||
} |