mirror of
https://github.com/apache/superset.git
synced 2024-09-19 20:19:37 -04:00
1971bf653c
* Improving the Visualize flow * Fixed the timer * CTAS * Expiclit engine handling * make tab full height, stretch for longer content (#1081) * Better error handling for queries * Hooked and fixed CSV export * Linting * Tying in the dttm in the viz flow * Indicator showing when going offline * Addressing comments, fixing the build * Fixing unit tests
40 lines
893 B
JavaScript
40 lines
893 B
JavaScript
import React from 'react';
|
|
import SyntaxHighlighter from 'react-syntax-highlighter';
|
|
import { github } from 'react-syntax-highlighter/dist/styles';
|
|
|
|
const SqlShrink = (props) => {
|
|
const sql = props.sql || '';
|
|
let lines = sql.split('\n');
|
|
if (lines.length >= props.maxLines) {
|
|
lines = lines.slice(0, props.maxLines);
|
|
lines.push('{...}');
|
|
}
|
|
const shrunk = lines.map((line) => {
|
|
if (line.length > props.maxWidth) {
|
|
return line.slice(0, props.maxWidth) + '{...}';
|
|
}
|
|
return line;
|
|
})
|
|
.join('\n');
|
|
return (
|
|
<div>
|
|
<SyntaxHighlighter language="sql" style={github}>
|
|
{shrunk}
|
|
</SyntaxHighlighter>
|
|
</div>
|
|
);
|
|
};
|
|
|
|
SqlShrink.defaultProps = {
|
|
maxWidth: 60,
|
|
maxLines: 6,
|
|
};
|
|
|
|
SqlShrink.propTypes = {
|
|
sql: React.PropTypes.string,
|
|
maxWidth: React.PropTypes.integer,
|
|
maxLines: React.PropTypes.integer,
|
|
};
|
|
|
|
export default SqlShrink;
|