Skip to content
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
9 changes: 5 additions & 4 deletions superset/assets/javascripts/components/MetricOption.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,18 @@ import InfoTooltipWithTrigger from './InfoTooltipWithTrigger';
const propTypes = {
metric: PropTypes.object.isRequired,
showFormula: PropTypes.bool,
url: PropTypes.string,
};
const defaultProps = {
showFormula: true,
};

export default function MetricOption({ metric, showFormula }) {
export default function MetricOption({ metric, showFormula, url }) {
const verbose = metric.verbose_name || metric.metric_name;
const link = url ? <a href={url}>{verbose}</a> : verbose;
return (
<div>
<span className="m-r-5 option-label">
{metric.verbose_name || metric.metric_name}
</span>
<span className="m-r-5 option-label">{link}</span>
{metric.description &&
<InfoTooltipWithTrigger
className="m-r-5 text-muted"
Expand Down
6 changes: 6 additions & 0 deletions superset/assets/javascripts/explore/stores/visTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -378,13 +378,19 @@ export const visTypes = {
controlSetRows: [
['groupby', 'metrics'],
['column_collection'],
['url'],
],
},
],
controlOverrides: {
groupby: {
multiple: false,
},
url: {
label: t(
"Templated link, it's possible to include {{ metric }} " +
'or other values coming from the controls.'),
},
},
},

Expand Down
8 changes: 6 additions & 2 deletions superset/assets/visualizations/time_table.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import propTypes from 'prop-types';
import { Table, Thead, Th } from 'reactable';
import d3 from 'd3';
import { Sparkline, LineSeries } from '@data-ui/sparkline';
import Mustache from 'mustache';

import MetricOption from '../javascripts/components/MetricOption';
import TooltipWrapper from '../javascripts/components/TooltipWrapper';
Expand Down Expand Up @@ -55,10 +56,13 @@ function viz(slice, payload) {
}
const tableData = metrics.map((metric) => {
let leftCell;
const context = Object.assign({}, fd, { metric });
const url = fd.url ? Mustache.render(fd.url, context) : null;

if (!payload.data.is_group_by) {
leftCell = <MetricOption metric={metricMap[metric]} showFormula={false} />;
leftCell = <MetricOption metric={metricMap[metric]} url={url}showFormula={false} />;
} else {
leftCell = metric;
leftCell = url ? <a href={url}>{metric}</a> : metric;
}
const row = { metric: leftCell };
fd.column_collection.forEach((c) => {
Expand Down