mirror of
https://github.com/apache/superset.git
synced 2026-04-19 08:04:53 +00:00
add build query as part of plugin (#6146)
This commit is contained in:
committed by
Chris Williams
parent
bc4dfad6c8
commit
fc3422eaeb
@@ -1,6 +1,7 @@
|
||||
import Plugin from './Plugin';
|
||||
import isRequired from '../../../utils/isRequired';
|
||||
import getChartMetadataRegistry from '../registries/ChartMetadataRegistrySingleton';
|
||||
import getChartBuildQueryRegistry from '../registries/ChartBuildQueryRegistrySingleton';
|
||||
import getChartComponentRegistry from '../registries/ChartComponentRegistrySingleton';
|
||||
import getChartTransformPropsRegistry from '../registries/ChartTransformPropsRegistrySingleton';
|
||||
|
||||
@@ -10,6 +11,11 @@ export default class ChartPlugin extends Plugin {
|
||||
constructor({
|
||||
metadata = isRequired('metadata'),
|
||||
|
||||
// use buildQuery for immediate value
|
||||
buildQuery = IDENTITY,
|
||||
// use loadBuildQuery for dynamic import (lazy-loading)
|
||||
loadBuildQuery,
|
||||
|
||||
// use transformProps for immediate value
|
||||
transformProps = IDENTITY,
|
||||
// use loadTransformProps for dynamic import (lazy-loading)
|
||||
@@ -22,6 +28,7 @@ export default class ChartPlugin extends Plugin {
|
||||
} = {}) {
|
||||
super();
|
||||
this.metadata = metadata;
|
||||
this.loadBuildQuery = loadBuildQuery || (() => buildQuery);
|
||||
this.loadTransformProps = loadTransformProps || (() => transformProps);
|
||||
|
||||
if (loadChart) {
|
||||
@@ -36,6 +43,7 @@ export default class ChartPlugin extends Plugin {
|
||||
register() {
|
||||
const { key = isRequired('config.key') } = this.config;
|
||||
getChartMetadataRegistry().registerValue(key, this.metadata);
|
||||
getChartBuildQueryRegistry().registerLoader(key, this.loadBuildQuery);
|
||||
getChartComponentRegistry().registerLoader(key, this.loadChart);
|
||||
getChartTransformPropsRegistry().registerLoader(key, this.loadTransformProps);
|
||||
return this;
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
import Registry from '../../../modules/Registry';
|
||||
import makeSingleton from '../../../utils/makeSingleton';
|
||||
|
||||
class ChartBuildQueryRegistry extends Registry {
|
||||
constructor() {
|
||||
super('ChartBuildQuery');
|
||||
}
|
||||
}
|
||||
|
||||
const getInstance = makeSingleton(ChartBuildQueryRegistry);
|
||||
|
||||
export default getInstance;
|
||||
Reference in New Issue
Block a user