-
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.
[lens] Add more complete initial state
- Loading branch information
1 parent
8d685d4
commit 63c5b3c
Showing
15 changed files
with
448 additions
and
54 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 was deleted.
Oops, something went wrong.
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.
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,73 @@ | ||
/* | ||
* 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 Joi from 'joi'; | ||
import { Server } from 'hapi'; | ||
import { resolve } from 'path'; | ||
|
||
import { PLUGIN_ID } from './common'; | ||
|
||
const NOT_INTERNATIONALIZED_PRODUCT_NAME = 'Lens Visualizations'; | ||
|
||
export const visualizationLens = (kibana: any) => { | ||
return new kibana.Plugin({ | ||
id: PLUGIN_ID, | ||
configPrefix: `xpack.${PLUGIN_ID}`, | ||
require: ['kibana', 'elasticsearch', 'xpack_main', 'interpreter'], | ||
publicDir: resolve(__dirname, 'public'), | ||
|
||
uiExports: { | ||
app: { | ||
title: NOT_INTERNATIONALIZED_PRODUCT_NAME, | ||
description: 'Explore and visualize data.', | ||
main: `plugins/${PLUGIN_ID}/app`, | ||
icon: 'plugins/kibana/assets/visualize.svg', | ||
euiIconType: 'visualizeApp', | ||
order: 8950, // Uptime is 8900 | ||
}, | ||
styleSheetPaths: resolve(__dirname, 'public/index.scss'), | ||
}, | ||
|
||
config: () => { | ||
return Joi.object({ | ||
enabled: Joi.boolean().default(true), | ||
}).default(); | ||
}, | ||
|
||
init(server: Server) { | ||
server.plugins.xpack_main.registerFeature({ | ||
id: PLUGIN_ID, | ||
name: NOT_INTERNATIONALIZED_PRODUCT_NAME, | ||
icon: 'visualizeApp', | ||
navLinkId: PLUGIN_ID, | ||
app: [PLUGIN_ID, 'kibana'], | ||
catalogue: [PLUGIN_ID], | ||
privileges: { | ||
all: { | ||
api: [PLUGIN_ID], | ||
catalogue: [PLUGIN_ID], | ||
savedObject: { | ||
all: [], | ||
read: [], | ||
}, | ||
ui: ['show'], | ||
}, | ||
read: { | ||
api: [PLUGIN_ID], | ||
catalogue: [PLUGIN_ID], | ||
savedObject: { | ||
all: [], | ||
read: [], | ||
}, | ||
ui: ['show'], | ||
}, | ||
}, | ||
}); | ||
}, | ||
}); | ||
}; | ||
|
||
export { editorFrame } from './public'; |
4 changes: 2 additions & 2 deletions
4
...plugins/visualization_editor/package.json → ...k/plugins/visualization_lens/package.json
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 |
---|---|---|
@@ -1,11 +1,11 @@ | ||
{ | ||
"author": "Elastic", | ||
"name": "visualization_editor", | ||
"name": "visualization_lens", | ||
"version": "7.0.0", | ||
"private": true, | ||
"license": "Elastic-License", | ||
"devDependencies": {}, | ||
"dependencies": { | ||
"@elastic/charts": "^3.11.0" | ||
"@elastic/charts": "^4.0.0" | ||
} | ||
} |
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,70 @@ | ||
/* | ||
* 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 React, { useCallback } from 'react'; | ||
import { render } from 'react-dom'; | ||
import { Datasource, Visualization, EditorFrameAPI } from './types'; | ||
|
||
function EditorFrameComponent(props: { | ||
datasources: Array<Datasource<unknown>>; | ||
visualizations: Array<Visualization<unknown>>; | ||
}) { | ||
const renderDatasource = (datasource: Datasource<unknown>) => { | ||
return useCallback( | ||
node => { | ||
datasource.renderDataPanel({ | ||
domElement: node, | ||
}); | ||
}, | ||
[datasource] | ||
); | ||
}; | ||
|
||
return ( | ||
<div> | ||
<h2>Editor Frame</h2> | ||
|
||
{props.datasources.map((datasource, index) => ( | ||
<div key={index} ref={renderDatasource(datasource)} /> | ||
))} | ||
</div> | ||
); | ||
} | ||
|
||
class EditorFrame { | ||
constructor() {} | ||
|
||
private datasources: Array<Datasource<unknown>> = []; | ||
private visualizations: Array<Visualization<unknown>> = []; | ||
|
||
public setup(): EditorFrameAPI { | ||
return { | ||
render: (domElement: Element) => { | ||
render( | ||
<EditorFrameComponent | ||
datasources={this.datasources} | ||
visualizations={this.visualizations} | ||
/>, | ||
domElement | ||
); | ||
}, | ||
registerDatasource: (datasource: Datasource<unknown>) => { | ||
this.datasources.push(datasource); | ||
}, | ||
registerVisualization: (visualization: Visualization<unknown>) => { | ||
this.visualizations.push(visualization); | ||
}, | ||
}; | ||
} | ||
|
||
public stop() { | ||
return {}; | ||
} | ||
} | ||
|
||
export { EditorFrame }; | ||
|
||
export const editorFrame = new EditorFrame().setup(); |
File renamed without changes.
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 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
export * from './editor_frame'; | ||
export * from './types'; |
14 changes: 14 additions & 0 deletions
14
x-pack/plugins/visualization_lens/public/indexpattern_datasource/index.ts
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 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
// TODO: Figure out how to separate this out into another plugin | ||
import { editorFrame } from '../../'; | ||
|
||
import { indexPatternDatasource } from './indexpattern'; | ||
|
||
editorFrame.registerDatasource(indexPatternDatasource); | ||
|
||
export * from './indexpattern'; |
67 changes: 67 additions & 0 deletions
67
x-pack/plugins/visualization_lens/public/indexpattern_datasource/indexpattern.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,67 @@ | ||
/* | ||
* 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 React from 'react'; | ||
import { render } from 'react-dom'; | ||
import { Datasource, Operation, DataType } from '../'; | ||
|
||
interface IndexPatternPrivateState { | ||
query: object; | ||
} | ||
|
||
class IndexPatternDatasource implements Datasource<IndexPatternPrivateState> { | ||
private state?: IndexPatternPrivateState; | ||
|
||
constructor(state?: IndexPatternPrivateState) { | ||
if (state) { | ||
this.state = state; | ||
} | ||
} | ||
|
||
toExpression() { | ||
return ''; | ||
} | ||
|
||
renderDataPanel({ domElement }: { domElement: Element }) { | ||
render(<div>Index Pattern Data Source</div>, domElement); | ||
} | ||
|
||
getPublicAPI() { | ||
return { | ||
getTableSpec: () => [], | ||
getOperationForColumnId: () => ({ | ||
id: '', | ||
// User-facing label for the operation | ||
label: '', | ||
dataType: 'string' as DataType, | ||
// A bucketed operation has many values the same | ||
isBucketed: false, | ||
}), | ||
|
||
// Called by dimension | ||
getDimensionPanelComponent: (props: any) => ( | ||
domElement: Element, | ||
operations: Operation[] | ||
) => {}, | ||
|
||
removeColumnInTableSpec: (columnId: string) => [], | ||
moveColumnTo: (columnId: string, targetIndex: number) => {}, | ||
duplicateColumn: (columnId: string) => [], | ||
}; | ||
} | ||
|
||
getDatasourceSuggestionsForField() { | ||
return []; | ||
} | ||
|
||
getDatasourceSuggestionsFromCurrentState() { | ||
return []; | ||
} | ||
} | ||
|
||
export { IndexPatternDatasource }; | ||
|
||
export const indexPatternDatasource = new IndexPatternDatasource(); |
Oops, something went wrong.