+
+ {t('Simple')}
+
+ ) : (
+ t('Simple')
+ )
+ }
+ disabled={extra.disallow_adhoc_metrics}
+ >
+ {t('Custom SQL')}
+
+ ) : (
+ t('Custom SQL')
+ )
+ }
data-test="adhoc-metric-edit-tab#custom"
+ disabled={
+ extra.disallow_adhoc_metrics ||
+ this.props.datasource?.type === 'druid'
+ }
>
- {this.props.datasourceType !== 'druid' ? (
-
- ) : (
-
- Custom SQL Metrics are not available on druid datasources
-
- )}
+
diff --git a/superset-frontend/src/explore/components/controls/MetricControl/AdhocMetricOption.jsx b/superset-frontend/src/explore/components/controls/MetricControl/AdhocMetricOption.jsx
index bbe544dd8fed6..352480f222205 100644
--- a/superset-frontend/src/explore/components/controls/MetricControl/AdhocMetricOption.jsx
+++ b/superset-frontend/src/explore/components/controls/MetricControl/AdhocMetricOption.jsx
@@ -32,7 +32,7 @@ const propTypes = {
columns: PropTypes.arrayOf(columnType),
savedMetricsOptions: PropTypes.arrayOf(savedMetricType),
savedMetric: savedMetricType,
- datasourceType: PropTypes.string,
+ datasource: PropTypes.object,
onMoveLabel: PropTypes.func,
onDropLabel: PropTypes.func,
index: PropTypes.number,
@@ -58,7 +58,7 @@ class AdhocMetricOption extends React.PureComponent {
columns,
savedMetricsOptions,
savedMetric,
- datasourceType,
+ datasource,
onMoveLabel,
onDropLabel,
index,
@@ -73,7 +73,7 @@ class AdhocMetricOption extends React.PureComponent {
columns={columns}
savedMetricsOptions={savedMetricsOptions}
savedMetric={savedMetric}
- datasourceType={datasourceType}
+ datasource={datasource}
>
{
const [value, setValue] = useState(coerceAdhocMetrics(propsValue));
@@ -232,9 +231,8 @@ const MetricsControl = ({
onMetricEdit={onNewMetric}
columns={columns}
savedMetricsOptions={savedMetricOptions}
- datasource={datasource}
savedMetric={emptySavedMetric}
- datasourceType={datasourceType}
+ datasource={datasource}
>
{trigger}
@@ -243,7 +241,6 @@ const MetricsControl = ({
[
columns,
datasource,
- datasourceType,
isAddNewMetricDisabled,
newAdhocMetric,
onNewMetric,
@@ -295,7 +292,6 @@ const MetricsControl = ({
value,
value?.[index],
)}
- datasourceType={datasourceType}
onMoveLabel={moveLabel}
onDropLabel={onDropLabel}
multi={multi}
@@ -304,7 +300,6 @@ const MetricsControl = ({
[
columns,
datasource,
- datasourceType,
moveLabel,
multi,
onDropLabel,
diff --git a/superset-frontend/src/explore/controls.jsx b/superset-frontend/src/explore/controls.jsx
index e2f82c91613f4..c22393397f0cd 100644
--- a/superset-frontend/src/explore/controls.jsx
+++ b/superset-frontend/src/explore/controls.jsx
@@ -156,7 +156,7 @@ const metrics = {
return {
columns: datasource ? datasource.columns : [],
savedMetrics: datasource ? datasource.metrics : [],
- datasourceType: datasource && datasource.type,
+ datasource,
};
},
description: t('One or many metrics to display'),
@@ -395,7 +395,7 @@ export const controls = {
mapStateToProps: state => ({
columns: state.datasource ? state.datasource.columns : [],
savedMetrics: state.datasource ? state.datasource.metrics : [],
- datasourceType: state.datasource && state.datasource.type,
+ datasource: state.datasource,
}),
},