-
Notifications
You must be signed in to change notification settings - Fork 8.1k
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
1 parent
c8b1fc5
commit 98a8b6b
Showing
36 changed files
with
474 additions
and
99 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
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
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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,14 @@ | ||
## Developer examples | ||
|
||
Owner: Kibana application architecture team | ||
|
||
Register your API services, a description, and add links to examples and READMEs. These | ||
will appear in the Developer portal app when Kibana in dev mode, is run via : | ||
|
||
``` | ||
yarn start --run-examples | ||
``` | ||
|
||
<img src="./navigation.png" height="400px" /> | ||
|
||
<img src="./developer_examples.png" height="300px" /> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,9 @@ | ||
{ | ||
"id": "developerExamples", | ||
"version": "0.0.1", | ||
"kibanaVersion": "kibana", | ||
"server": false, | ||
"ui": true, | ||
"requiredPlugins": [], | ||
"optionalPlugins": [] | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,115 @@ | ||
/* | ||
* 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, { useState } from 'react'; | ||
import ReactDOM from 'react-dom'; | ||
|
||
import { | ||
EuiText, | ||
EuiPageContent, | ||
EuiCard, | ||
EuiPageContentHeader, | ||
EuiFlexGroup, | ||
EuiFlexItem, | ||
EuiFieldSearch, | ||
EuiListGroup, | ||
EuiHighlight, | ||
EuiLink, | ||
EuiButtonIcon, | ||
} from '@elastic/eui'; | ||
import { AppMountParameters } from '../../../src/core/public'; | ||
import { ExampleDefinition } from './types'; | ||
|
||
interface Props { | ||
examples: ExampleDefinition[]; | ||
navigateToApp: (appId: string) => void; | ||
getUrlForApp: (appId: string) => string; | ||
} | ||
|
||
function DeveloperExamples({ examples, navigateToApp, getUrlForApp }: Props) { | ||
const [search, setSearch] = useState<string>(''); | ||
|
||
const lcSearch = search.toLowerCase(); | ||
const filteredExamples = !lcSearch | ||
? examples | ||
: examples.filter((def) => { | ||
if (def.description.toLowerCase().indexOf(lcSearch) >= 0) return true; | ||
if (def.title.toLowerCase().indexOf(lcSearch) >= 0) return true; | ||
return false; | ||
}); | ||
|
||
return ( | ||
<EuiPageContent> | ||
<EuiPageContentHeader> | ||
<EuiText> | ||
<h1>Developer examples</h1> | ||
<p> | ||
The following examples showcase services and APIs that are available to developers. | ||
<EuiFieldSearch | ||
placeholder="Search" | ||
value={search} | ||
onChange={(e) => setSearch(e.target.value)} | ||
isClearable={true} | ||
aria-label="Search developer examples" | ||
/> | ||
</p> | ||
</EuiText> | ||
</EuiPageContentHeader> | ||
<EuiFlexGroup wrap> | ||
{filteredExamples.map((def) => ( | ||
<EuiFlexItem style={{ minWidth: 300, maxWidth: 500 }} key={def.appId}> | ||
<EuiCard | ||
description={ | ||
<EuiHighlight search={search} highlightAll={true}> | ||
{def.description} | ||
</EuiHighlight> | ||
} | ||
title={ | ||
<React.Fragment> | ||
<EuiLink | ||
onClick={() => { | ||
navigateToApp(def.appId); | ||
}} | ||
> | ||
<EuiHighlight search={search} highlightAll={true}> | ||
{def.title} | ||
</EuiHighlight> | ||
</EuiLink> | ||
<EuiButtonIcon | ||
iconType="popout" | ||
onClick={() => window.open(getUrlForApp(def.appId), '_blank')} | ||
> | ||
Open in new tab | ||
</EuiButtonIcon> | ||
</React.Fragment> | ||
} | ||
image={def.image} | ||
footer={def.links ? <EuiListGroup size={'s'} listItems={def.links} /> : undefined} | ||
/> | ||
</EuiFlexItem> | ||
))} | ||
</EuiFlexGroup> | ||
</EuiPageContent> | ||
); | ||
} | ||
|
||
export const renderApp = (props: Props, element: AppMountParameters['element']) => { | ||
ReactDOM.render(<DeveloperExamples {...props} />, element); | ||
|
||
return () => ReactDOM.unmountComponentAtNode(element); | ||
}; |
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
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,68 @@ | ||
/* | ||
* 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 { | ||
CoreSetup, | ||
Plugin, | ||
AppMountParameters, | ||
DEFAULT_APP_CATEGORIES, | ||
} from '../../../src/core/public'; | ||
|
||
import { ExampleDefinition } from './types'; | ||
|
||
export interface DeveloperExamplesSetup { | ||
register: (def: ExampleDefinition) => void; | ||
} | ||
|
||
export class DeveloperExamplesPlugin implements Plugin<DeveloperExamplesSetup, void> { | ||
private examplesRegistry: ExampleDefinition[] = []; | ||
|
||
public setup(core: CoreSetup) { | ||
const examples = this.examplesRegistry; | ||
core.application.register({ | ||
id: 'developerExamples', | ||
title: 'Developer examples', | ||
order: -2000, | ||
category: DEFAULT_APP_CATEGORIES.kibana, | ||
async mount(params: AppMountParameters) { | ||
const { renderApp } = await import('./app'); | ||
const [coreStart] = await core.getStartServices(); | ||
return renderApp( | ||
{ | ||
examples, | ||
navigateToApp: (appId: string) => coreStart.application.navigateToApp(appId), | ||
getUrlForApp: (appId: string) => coreStart.application.getUrlForApp(appId), | ||
}, | ||
params.element | ||
); | ||
}, | ||
}); | ||
|
||
const api: DeveloperExamplesSetup = { | ||
register: (def) => { | ||
this.examplesRegistry.push(def); | ||
}, | ||
}; | ||
return api; | ||
} | ||
|
||
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
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 @@ | ||
{ | ||
"extends": "../../tsconfig.json", | ||
"compilerOptions": { | ||
"outDir": "./target", | ||
"skipLibCheck": true | ||
}, | ||
"include": [ | ||
"index.ts", | ||
"public/**/*.ts", | ||
"public/**/*.tsx", | ||
"server/**/*.ts", | ||
"../../typings/**/*", | ||
], | ||
"exclude": [] | ||
} |
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.