-
Notifications
You must be signed in to change notification settings - Fork 14.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add iframe and markup legacy plugin (#6741)
* Add iframe plugin * Use lazy load and add description * remove unintended files * Add markup * minor adjustment
- Loading branch information
Showing
12 changed files
with
260 additions
and
80 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 ( | ||
<iframe | ||
className={className} | ||
title="superset-iframe" | ||
src={completeUrl} | ||
style={{ | ||
width: '100%', | ||
height, | ||
}} | ||
/> | ||
); | ||
} | ||
} | ||
|
||
Iframe.propTypes = propTypes; | ||
Iframe.defaultProps = defaultProps; | ||
|
||
export default Iframe; |
38 changes: 38 additions & 0 deletions
38
superset/assets/src/visualizations/Iframe/IframeChartPlugin.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/** | ||
* 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 { ChartMetadata, ChartPlugin } from '@superset-ui/chart'; | ||
import thumbnail from './images/thumbnail.png'; | ||
import transformProps from './transformProps'; | ||
|
||
const metadata = new ChartMetadata({ | ||
name: t('IFrame'), | ||
description: 'HTML Inline Frame', | ||
thumbnail, | ||
}); | ||
|
||
export default class IframeChartPlugin extends ChartPlugin { | ||
constructor() { | ||
super({ | ||
metadata, | ||
loadChart: () => import('./Iframe.jsx'), | ||
transformProps, | ||
}); | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
/** | ||
* 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 React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import './Markup.css'; | ||
|
||
const propTypes = { | ||
className: PropTypes.string, | ||
height: PropTypes.number.isRequired, | ||
isSeparator: PropTypes.bool, | ||
html: PropTypes.string, | ||
cssFiles: PropTypes.arrayOf(PropTypes.string), | ||
}; | ||
const defaultProps = { | ||
className: '', | ||
isSeparator: false, | ||
html: '', | ||
}; | ||
|
||
const CONTAINER_STYLE = { | ||
position: 'relative', | ||
overflow: 'auto', | ||
}; | ||
|
||
class Markup extends React.PureComponent { | ||
render() { | ||
const { className, height, isSeparator, html, cssFiles } = this.props; | ||
|
||
return ( | ||
<div | ||
className={className} | ||
style={CONTAINER_STYLE} | ||
> | ||
<iframe | ||
title="superset-markup" | ||
frameBorder={0} | ||
height={isSeparator ? height - 20 : height} | ||
sandbox="allow-forms allow-popups allow-same-origin allow-scripts allow-top-navigation" | ||
srcDoc={` | ||
<html> | ||
<head> | ||
${cssFiles.map( | ||
href => `<link rel="stylesheet" type="text/css" href="${href}" />`, | ||
)} | ||
</head> | ||
<body style="background-color: transparent;"> | ||
${html} | ||
</body> | ||
</html>` | ||
} | ||
/> | ||
</div> | ||
); | ||
} | ||
} | ||
|
||
Markup.propTypes = propTypes; | ||
Markup.defaultProps = defaultProps; | ||
|
||
export default Markup; |
38 changes: 38 additions & 0 deletions
38
superset/assets/src/visualizations/Markup/MarkupChartPlugin.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/** | ||
* 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 { ChartMetadata, ChartPlugin } from '@superset-ui/chart'; | ||
import thumbnail from './images/thumbnail.png'; | ||
import transformProps from './transformProps'; | ||
|
||
const metadata = new ChartMetadata({ | ||
name: t('Markup'), | ||
description: 'HTML Markup', | ||
thumbnail, | ||
}); | ||
|
||
export default class IframeChartPlugin extends ChartPlugin { | ||
constructor() { | ||
super({ | ||
metadata, | ||
loadChart: () => import('./Markup.jsx'), | ||
transformProps, | ||
}); | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
33 changes: 33 additions & 0 deletions
33
superset/assets/src/visualizations/Markup/transformProps.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/** | ||
* 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. | ||
*/ | ||
export default function transformProps(chartProps) { | ||
const { height, payload, formData } = chartProps; | ||
const { vizType } = formData; | ||
const { | ||
theme_css: cssFiles, | ||
html, | ||
} = payload.data; | ||
|
||
return { | ||
height, | ||
cssFiles, | ||
html, | ||
isSeparator: vizType === 'separator', | ||
}; | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3ae7d32
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It can't be added into existing dashboard.