mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
moving renderers registry to OSS (#28986)
This commit is contained in:
parent
bc6bdb4574
commit
cb1e1b829c
9 changed files with 98 additions and 48 deletions
|
@ -20,3 +20,4 @@
|
|||
export { loadBrowserRegistries } from './browser_registries';
|
||||
export { createSocket } from './socket';
|
||||
export { initializeInterpreter } from './interpreter';
|
||||
export { RenderFunctionsRegistry } from './render_functions_registry';
|
||||
|
|
42
packages/kbn-interpreter/src/public/render_function.js
Normal file
42
packages/kbn-interpreter/src/public/render_function.js
Normal file
|
@ -0,0 +1,42 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
export function RenderFunction(config) {
|
||||
// This must match the name of the function that is used to create the `type: render` object
|
||||
this.name = config.name;
|
||||
|
||||
// Use this to set a more friendly name
|
||||
this.displayName = config.displayName || this.name;
|
||||
|
||||
// A sentence or few about what this element does
|
||||
this.help = config.help;
|
||||
|
||||
// used to validate the data before calling the render function
|
||||
this.validate = config.validate || function validate() {};
|
||||
|
||||
// tell the renderer if the dom node should be reused, it's recreated each time by default
|
||||
this.reuseDomNode = Boolean(config.reuseDomNode);
|
||||
|
||||
// the function called to render the data
|
||||
this.render =
|
||||
config.render ||
|
||||
function render(domNode, data, done) {
|
||||
done();
|
||||
};
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
/*
|
||||
* 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 { Registry } from '../common';
|
||||
import { RenderFunction } from './render_function';
|
||||
|
||||
class RenderFunctionsRegistry extends Registry {
|
||||
wrapper(obj) {
|
||||
return new RenderFunction(obj);
|
||||
}
|
||||
}
|
||||
|
||||
export { RenderFunctionsRegistry };
|
|
@ -23,11 +23,13 @@ import chrome from 'ui/chrome';
|
|||
import { functions } from './functions';
|
||||
import { functionsRegistry } from './functions_registry';
|
||||
import { typesRegistry } from './types_registry';
|
||||
import { renderFunctionsRegistry } from './render_functions_registry';
|
||||
|
||||
const basePath = chrome.getBasePath();
|
||||
|
||||
const types = {
|
||||
browserFunctions: functionsRegistry,
|
||||
renderers: renderFunctionsRegistry,
|
||||
types: typesRegistry
|
||||
};
|
||||
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
/*
|
||||
* 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 { RenderFunctionsRegistry } from '@kbn/interpreter/public';
|
||||
|
||||
export const renderFunctionsRegistry = new RenderFunctionsRegistry();
|
|
@ -15,7 +15,7 @@ import { loadPrivateBrowserFunctions } from '../../lib/load_private_browser_func
|
|||
import { elementsRegistry } from '../../lib/elements_registry';
|
||||
import { templatesRegistry } from '../../lib/templates_registry';
|
||||
import { tagsRegistry } from '../../lib/tags_registry';
|
||||
import { renderFunctionsRegistry } from '../../lib/render_functions_registry';
|
||||
|
||||
import {
|
||||
argTypeRegistry,
|
||||
datasourceRegistry,
|
||||
|
@ -38,7 +38,6 @@ const mapStateToProps = state => {
|
|||
|
||||
const types = {
|
||||
elements: elementsRegistry,
|
||||
renderers: renderFunctionsRegistry,
|
||||
transformUIs: transformRegistry,
|
||||
datasourceUIs: datasourceRegistry,
|
||||
modelUIs: modelRegistry,
|
||||
|
|
|
@ -4,11 +4,11 @@
|
|||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
|
||||
import { renderFunctionsRegistry } from 'plugins/interpreter/render_functions_registry';
|
||||
import PropTypes from 'prop-types';
|
||||
import { connect } from 'react-redux';
|
||||
import { compose, withProps } from 'recompose';
|
||||
import { get } from 'lodash';
|
||||
import { renderFunctionsRegistry } from '../../lib/render_functions_registry';
|
||||
import { getSelectedPage, getPageById } from '../../state/selectors/workpad';
|
||||
import { ElementContent as Component } from './element_content';
|
||||
|
||||
|
|
|
@ -1,29 +0,0 @@
|
|||
/*
|
||||
* 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 function RenderFunction(config) {
|
||||
// This must match the name of the function that is used to create the `type: render` object
|
||||
this.name = config.name;
|
||||
|
||||
// Use this to set a more friendly name
|
||||
this.displayName = config.displayName || this.name;
|
||||
|
||||
// A sentence or few about what this element does
|
||||
this.help = config.help;
|
||||
|
||||
// used to validate the data before calling the render function
|
||||
this.validate = config.validate || function validate() {};
|
||||
|
||||
// tell the renderer if the dom node should be reused, it's recreated each time by default
|
||||
this.reuseDomNode = Boolean(config.reuseDomNode);
|
||||
|
||||
// the function called to render the data
|
||||
this.render =
|
||||
config.render ||
|
||||
function render(domNode, data, done) {
|
||||
done();
|
||||
};
|
||||
}
|
|
@ -1,16 +0,0 @@
|
|||
/*
|
||||
* 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 { Registry } from '@kbn/interpreter/common';
|
||||
import { RenderFunction } from './render_function';
|
||||
|
||||
class RenderFunctionsRegistry extends Registry {
|
||||
wrapper(obj) {
|
||||
return new RenderFunction(obj);
|
||||
}
|
||||
}
|
||||
|
||||
export const renderFunctionsRegistry = new RenderFunctionsRegistry();
|
Loading…
Add table
Add a link
Reference in a new issue