Skip to content
Snippets Groups Projects
Commit 5c5b3e3b authored by Allen Gilliland's avatar Allen Gilliland
Browse files

Merge pull request #2143 from metabase/fix-metric-bugs

Fix metric bugs
parents 414516aa 62b85784
No related branches found
No related tags found
No related merge requests found
......@@ -31,12 +31,12 @@ export default class ObjectRetireModal extends Component {
const { valid } = this.state;
return (
<ModalContent
title={"Retire This \"" + capitalize(objectType) + "\""}
title={"Retire This " + capitalize(objectType)}
closeFn={this.props.onClose}
>
<form className="flex flex-column flex-full">
<div className="Form-inputs pb4">
<p>Saved questions and other things that depend on this {objectType} will continue to work, but this {objectType} will no lgoner by selectable from the query builder.</p>
<p>Saved questions and other things that depend on this {objectType} will continue to work, but this {objectType} will no longer be selectable from the query builder.</p>
<p>If you're sure you want to retire this {objectType}, please write a quick explanation of why it's being retired:</p>
<textarea
ref="revision_message"
......
......@@ -94,7 +94,7 @@ export default class AggregationPopover extends Component {
let { tableMetadata } = this.props;
return (
<div className="p1">
<Tooltip tooltip={<QueryDefinitionTooltip object={metric} tableMetadata={tableMetadata} />}>
<Tooltip tooltip={<QueryDefinitionTooltip type="metric" object={metric} tableMetadata={tableMetadata} />}>
<span className="QuestionTooltipTarget" />
</Tooltip>
</div>
......@@ -121,10 +121,14 @@ export default class AggregationPopover extends Component {
})),
icon: "table2"
}];
if (tableMetadata.metrics && tableMetadata.metrics.length > 0) {
// we only want to consider active metrics, with the ONE exception that if the currently selected aggregation is a
// retired metric then we include it in the list to maintain continuity
let metrics = tableMetadata.metrics && tableMetadata.metrics.filter((mtrc) => mtrc.is_active === true || (selectedAggregation && selectedAggregation.id === mtrc.id));
if (metrics && metrics.length > 0) {
sections.push({
name: "Common Metrics",
items: tableMetadata.metrics.filter((mtrc) => mtrc.is_active === true || (selectedAggregation && selectedAggregation.id === mtrc.id)).map(metric => ({
items: metrics.map(metric => ({
name: metric.name,
value: ["METRIC", metric.id],
metric: metric
......@@ -146,6 +150,7 @@ export default class AggregationPopover extends Component {
itemIsSelected={this.itemIsSelected.bind(this)}
renderSectionIcon={(s) => <Icon name={s.icon} width="18" height="18" />}
renderItemExtra={this.renderItemExtra.bind(this)}
getItemClasses={(item) => item.metric && !item.metric.is_active ? "text-grey-3" : null }
/>
);
......
......@@ -6,18 +6,22 @@ import FieldSet from "../admin/datamodel/components/FieldSet.jsx";
import Query from "metabase/lib/query";
export default class QueryDefinitionTooltip extends Component {
static propTypes = {
type: PropTypes.string,
object: PropTypes.object.isRequired,
tableMetadata: PropTypes.object.isRequired
};
render() {
const { object, tableMetadata } = this.props;
const { type, object, tableMetadata } = this.props;
return (
<div className="p2" style={{width: 250}}>
<div className="mb2">
{object.description}
{ type && type === "metric" && !object.is_active ? "This metric has been retired. It's no longer available for use." : object.description }
</div>
<FieldSet legend="Definition" border="border-light">
<div className="TooltipFilterList">
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment