This is an automated email from the ASF dual-hosted git repository.
ccwilliams pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-superset.git
The following commit(s) were added to refs/heads/master by this push:
new fc3422e add build query as part of plugin (#6146)
fc3422e is described below
commit fc3422eaebce31c900229358a07485f9976fb625
Author: Krist Wongsuphasawat <[email protected]>
AuthorDate: Thu Oct 18 18:39:34 2018 -0700
add build query as part of plugin (#6146)
---
.../assets/src/visualizations/core/models/ChartPlugin.js | 8 ++++++++
.../core/registries/ChartBuildQueryRegistrySingleton.js | 12 ++++++++++++
2 files changed, 20 insertions(+)
diff --git a/superset/assets/src/visualizations/core/models/ChartPlugin.js
b/superset/assets/src/visualizations/core/models/ChartPlugin.js
index a910185..8109926 100644
--- a/superset/assets/src/visualizations/core/models/ChartPlugin.js
+++ b/superset/assets/src/visualizations/core/models/ChartPlugin.js
@@ -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;
diff --git
a/superset/assets/src/visualizations/core/registries/ChartBuildQueryRegistrySingleton.js
b/superset/assets/src/visualizations/core/registries/ChartBuildQueryRegistrySingleton.js
new file mode 100644
index 0000000..dc29df3
--- /dev/null
+++
b/superset/assets/src/visualizations/core/registries/ChartBuildQueryRegistrySingleton.js
@@ -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;