Skip to content

Commit

Permalink
feat(legacy-plugin-chart-markup): add controls to markup chart (apach…
Browse files Browse the repository at this point in the history
…e#479)

* add controls to markup chart

* Update controlPanel.js

Co-authored-by: Phillip Kelley-Dotson <pkd@pkd.lan>
  • Loading branch information
2 people authored and zhaoyongjie committed Nov 17, 2021
1 parent cbb3725 commit b81a6cd
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@
},
"peerDependencies": {
"@superset-ui/chart": "^0.13.0",
"@superset-ui/control-utils": "^0.13.9",
"@superset-ui/translation": "^0.13.0",
"@superset-ui/validator": "^0.13.0",
"react": "^15 || ^16"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF 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 { t } from '@superset-ui/translation';
import { validateNonEmpty } from '@superset-ui/validator';
import { formatSelectOptions } from '@superset-ui/control-utils';

export default {
controlPanelSections: [
{
label: t('Code'),
expanded: true,
controlSetRows: [
[
{
name: 'markup_type',
config: {
type: 'SelectControl',
label: t('Markup Type'),
clearable: false,
choices: formatSelectOptions(['markdown', 'html']),
default: 'markdown',
validators: [validateNonEmpty],
description: t('Pick your favorite markup language'),
},
},
],
[
{
name: 'code',
config: {
type: 'TextAreaControl',
label: t('Code'),
description: t('Put your code here'),
mapStateToProps: state => ({
language:
state.controls && state.controls.markup_type
? state.controls.markup_type.value
: 'markdown',
}),
default: '',
},
},
],
],
},
],
sectionOverrides: {
druidTimeSeries: {
controlSetRows: [],
},
sqlaTimeSeries: {
controlSetRows: [],
},
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { t } from '@superset-ui/translation';
import { ChartMetadata, ChartPlugin } from '@superset-ui/chart';
import thumbnail from './images/thumbnail.png';
import transformProps from './transformProps';
import controlPanel from './controlPanel';

const metadata = new ChartMetadata({
description: 'HTML Markup',
Expand All @@ -34,6 +35,7 @@ export default class IframeChartPlugin extends ChartPlugin {
loadChart: () => import('./Markup'),
metadata,
transformProps,
controlPanel,
});
}
}

0 comments on commit b81a6cd

Please sign in to comment.