-
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.
Merge remote-tracking branch 'upstream/main'
- Loading branch information
Showing
174 changed files
with
1,972 additions
and
1,609 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
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
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,3 @@ | ||
## Unified Doc Viewer | ||
|
||
An example plugin showing usage of the unified doc viewer plugin (plugins/unified_doc_viewer) and package (@kbn/unified-doc-viewer). |
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 @@ | ||
{ | ||
"type": "plugin", | ||
"id": "@kbn/unified-doc-viewer-examples", | ||
"owner": "@elastic/kibana-core", | ||
"description": "Examples showing usage of the unified doc viewer.", | ||
"plugin": { | ||
"id": "unifiedDocViewerExamples", | ||
"server": false, | ||
"browser": true, | ||
"requiredPlugins": [ | ||
"data", | ||
"developerExamples", | ||
"unifiedDocViewer" | ||
] | ||
} | ||
} |
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,72 @@ | ||
/* | ||
* 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 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import React, { useEffect, useState } from 'react'; | ||
import ReactDOM from 'react-dom'; | ||
import type { AppMountParameters, CoreStart } from '@kbn/core/public'; | ||
import { buildDataTableRecord } from '@kbn/discover-utils'; | ||
import type { DataTableRecord } from '@kbn/discover-utils/types'; | ||
import type { DataView } from '@kbn/data-views-plugin/common'; | ||
import { UnifiedDocViewer } from '@kbn/unified-doc-viewer-plugin/public'; | ||
import { DataPublicPluginStart } from '@kbn/data-plugin/public'; | ||
import type { StartDeps } from './plugin'; | ||
|
||
export const renderApp = ( | ||
core: CoreStart, | ||
{ data }: StartDeps, | ||
{ element }: AppMountParameters | ||
) => { | ||
ReactDOM.render(<UnifiedDocViewerExamplesApp data={data} />, element); | ||
|
||
return () => { | ||
ReactDOM.unmountComponentAtNode(element); | ||
}; | ||
}; | ||
|
||
function UnifiedDocViewerExamplesApp({ data }: { data: DataPublicPluginStart }) { | ||
const [dataView, setDataView] = useState<DataView | null>(); | ||
const [hit, setHit] = useState<DataTableRecord | null>(); | ||
|
||
useEffect(() => { | ||
data.dataViews.getDefault().then((defaultDataView) => setDataView(defaultDataView)); | ||
}, [data]); | ||
|
||
useEffect(() => { | ||
const setDefaultHit = async () => { | ||
if (!dataView?.id) return; | ||
const response = await data.search | ||
.search({ | ||
params: { | ||
index: dataView?.getIndexPattern(), | ||
body: { | ||
fields: ['*'], | ||
_source: false, | ||
}, | ||
}, | ||
}) | ||
.toPromise(); | ||
const docs = response?.rawResponse?.hits?.hits ?? []; | ||
if (docs.length > 0) { | ||
const record = buildDataTableRecord(docs[0], dataView); | ||
setHit(record); | ||
} | ||
}; | ||
|
||
setDefaultHit(); | ||
}, [data, dataView]); | ||
|
||
return ( | ||
<> | ||
{dataView?.id && hit ? ( | ||
<UnifiedDocViewer hit={hit} dataView={dataView} /> | ||
) : ( | ||
'Loading... (make sure you have a default data view and at least one matching document)' | ||
)} | ||
</> | ||
); | ||
} |
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,12 @@ | ||
/* | ||
* 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 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
import { UnifiedDocViewerExamplesPlugin } from './plugin'; | ||
|
||
export function plugin() { | ||
return new UnifiedDocViewerExamplesPlugin(); | ||
} |
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,49 @@ | ||
/* | ||
* 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 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
import { AppMountParameters, CoreSetup, CoreStart, Plugin } from '@kbn/core/public'; | ||
import { DeveloperExamplesSetup } from '@kbn/developer-examples-plugin/public'; | ||
import type { DataPublicPluginStart } from '@kbn/data-plugin/public'; | ||
|
||
export interface SetupDeps { | ||
developerExamples: DeveloperExamplesSetup; | ||
} | ||
|
||
export interface StartDeps { | ||
data: DataPublicPluginStart; | ||
} | ||
|
||
export class UnifiedDocViewerExamplesPlugin implements Plugin<void, void, SetupDeps, StartDeps> { | ||
public setup(core: CoreSetup<StartDeps>, deps: SetupDeps) { | ||
// Register an application into the side navigation menu | ||
core.application.register({ | ||
id: 'unifiedDocViewer', | ||
title: 'Unified Doc Viewer Examples', | ||
async mount(params: AppMountParameters) { | ||
// Load application bundle | ||
const { renderApp } = await import('./application'); | ||
// Get start services as specified in kibana.json | ||
const [coreStart, depsStart] = await core.getStartServices(); | ||
// Render the application | ||
return renderApp(coreStart, depsStart, params); | ||
}, | ||
}); | ||
|
||
// This section is only needed to get this example plugin to show up in our Developer Examples. | ||
deps.developerExamples.register({ | ||
appId: 'unifiedDocViewer', | ||
title: 'Unified Doc Viewer Examples', | ||
description: 'Examples showcasing the unified doc viewer.', | ||
}); | ||
} | ||
|
||
public start(core: CoreStart) { | ||
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,24 @@ | ||
{ | ||
"extends": "../../tsconfig.base.json", | ||
"compilerOptions": { | ||
"outDir": "target/types" | ||
}, | ||
"include": [ | ||
"index.ts", | ||
"common/**/*.ts", | ||
"public/**/*.ts", | ||
"public/**/*.tsx", | ||
"../../typings/**/*" | ||
], | ||
"exclude": [ | ||
"target/**/*", | ||
], | ||
"kbn_references": [ | ||
"@kbn/core", | ||
"@kbn/data-plugin", | ||
"@kbn/data-views-plugin", | ||
"@kbn/developer-examples-plugin", | ||
"@kbn/discover-utils", | ||
"@kbn/unified-doc-viewer-plugin", | ||
] | ||
} |
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
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
File renamed without changes.
Oops, something went wrong.