From 3ae7d32caa7a907b6888ee7b141e6ce386bc5b01 Mon Sep 17 00:00:00 2001 From: Krist Wongsuphasawat Date: Wed, 23 Jan 2019 10:21:57 -0800 Subject: [PATCH] Add iframe and markup legacy plugin (#6741) * Add iframe plugin * Use lazy load and add description * remove unintended files * Add markup * minor adjustment --- superset/assets/package-lock.json | 2 +- .../src/visualizations/Iframe/Iframe.jsx | 58 +++++++++++++ .../Iframe/IframeChartPlugin.js | 38 +++++++++ .../Iframe/images/thumbnail.png | Bin 0 -> 50998 bytes .../{iframe.js => Iframe/transformProps.js} | 20 ++--- .../{markup.css => Markup/Markup.css} | 12 +-- .../src/visualizations/Markup/Markup.jsx | 76 ++++++++++++++++++ .../Markup/MarkupChartPlugin.js | 38 +++++++++ .../Markup/images/thumbnail.png | Bin 0 -> 23186 bytes .../visualizations/Markup/transformProps.js | 33 ++++++++ superset/assets/src/visualizations/markup.js | 58 ------------- .../presets/LegacyChartPreset.js | 5 ++ 12 files changed, 260 insertions(+), 80 deletions(-) create mode 100644 superset/assets/src/visualizations/Iframe/Iframe.jsx create mode 100644 superset/assets/src/visualizations/Iframe/IframeChartPlugin.js create mode 100644 superset/assets/src/visualizations/Iframe/images/thumbnail.png rename superset/assets/src/visualizations/{iframe.js => Iframe/transformProps.js} (64%) rename superset/assets/src/visualizations/{markup.css => Markup/Markup.css} (78%) create mode 100644 superset/assets/src/visualizations/Markup/Markup.jsx create mode 100644 superset/assets/src/visualizations/Markup/MarkupChartPlugin.js create mode 100644 superset/assets/src/visualizations/Markup/images/thumbnail.png create mode 100644 superset/assets/src/visualizations/Markup/transformProps.js delete mode 100644 superset/assets/src/visualizations/markup.js diff --git a/superset/assets/package-lock.json b/superset/assets/package-lock.json index 5a1ce4248..7bc8fbc8f 100644 --- a/superset/assets/package-lock.json +++ b/superset/assets/package-lock.json @@ -2228,7 +2228,7 @@ "dependencies": { "whatwg-fetch": { "version": "2.0.4", - "resolved": "https://registry.npmjs.org/whatwg-fetch/-/whatwg-fetch-2.0.4.tgz", + "resolved": "http://registry.npmjs.org/whatwg-fetch/-/whatwg-fetch-2.0.4.tgz", "integrity": "sha512-dcQ1GWpOD/eEQ97k66aiEVpNnapVj90/+R+SXTPYGHpYBBypfKJEQjLrvMZ7YXbKm21gXd4NcuxUTjiv1YtLng==" } } diff --git a/superset/assets/src/visualizations/Iframe/Iframe.jsx b/superset/assets/src/visualizations/Iframe/Iframe.jsx new file mode 100644 index 000000000..eca92d629 --- /dev/null +++ b/superset/assets/src/visualizations/Iframe/Iframe.jsx @@ -0,0 +1,58 @@ +/** + * 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 Mustache from 'mustache'; +import React from 'react'; +import PropTypes from 'prop-types'; + +const propTypes = { + className: PropTypes.string, + width: PropTypes.number.isRequired, + height: PropTypes.number.isRequired, + url: PropTypes.string, +}; +const defaultProps = { + className: '', +}; + +class Iframe extends React.PureComponent { + render() { + const { className, url, width, height } = this.props; + const completeUrl = Mustache.render(url, { + width, + height, + }); + + return ( +