Skip to content
This repository has been archived by the owner on Dec 10, 2021. It is now read-only.

feat(legacy-plugin-chart-markup): add controls to markup chart #479

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions plugins/legacy-plugin-chart-markup/package.json
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"
}
}
71 changes: 71 additions & 0 deletions plugins/legacy-plugin-chart-markup/src/controlPanel.js
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: {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this section needed?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kristw I think they are needed (or at least relevant). There are a few plugins that do this... iframe, markup, and separator. It appears this basically removes the time_range control that's seemingly injected automatically in some cases as part of the druidTimeSeries. Maybe we can find a better way of addressing this in the future, but it seems out of the scope of this PR, which is just to migrate the code that's there already.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

got it

druidTimeSeries: {
controlSetRows: [],
},
sqlaTimeSeries: {
controlSetRows: [],
},
},
};
2 changes: 2 additions & 0 deletions plugins/legacy-plugin-chart-markup/src/index.js
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,
});
}
}