jdbranham commented on a change in pull request #17903:
URL: https://github.com/apache/superset/pull/17903#discussion_r785361465
##########
File path:
superset-frontend/plugins/plugin-chart-handlebars/src/plugin/controls/handlebarTemplate.tsx
##########
@@ -0,0 +1,60 @@
+import {
+ ControlConfig,
+ ControlSetItem,
+ CustomControlConfig,
+ sharedControls,
+} from '@superset-ui/chart-controls';
+import { t, validateNonEmpty } from '@superset-ui/core';
+import React from 'react';
+import { CodeEditor } from '../../components/CodeEditor/CodeEditor';
+import { ControlHeader } from '../../components/ControlHeader/controlHeader';
+
+interface HandlebarsCustomControlProps {
+ value: string;
+}
+
+const HandlebarsTemplateControl = (
+ props: CustomControlConfig<HandlebarsCustomControlProps>,
+) => {
+ const val = String(
+ props?.value ? props?.value : props?.default ? props?.default : '',
+ );
+
+ const updateConfig = (source: string) => {
+ props.onChange(source);
+ };
+ return (
+ <div>
+ <ControlHeader>{props.label}</ControlHeader>
+ <CodeEditor
+ theme="dark"
+ value={val}
+ onChange={source => {
+ updateConfig(source || '');
+ }}
+ />
+ </div>
+ );
+};
+const handlebarsTemplateControlConfig: ControlConfig<any> = {
+ ...sharedControls.entity,
+ type: HandlebarsTemplateControl,
+ label: t('Handlebars Template'),
+ description: t('A handlebars template that is applied to the data'),
+ default: `<ul class="data_list">
+ {{#each data}}
+ <li>{{this}}</li>
+ {{/each}}
+ </ul>`,
+ isInt: false,
+
+ validators: [validateNonEmpty],
+ mapStateToProps: ({ controls }) => ({
+ value: controls?.handlebars_template?.value,
+ }),
+};
+
+export const HandlebarsTemplateControlSetItem: ControlSetItem = {
Review comment:
If we make it camelCase, it would be different then the other
ControlSetItems 🤔
https://github.com/apache/superset/pull/17903/files#diff-c424dd95a62b793c9f111b432e365b8cb478f2320675a7d76c05afc917c109dfR133-R153
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]