ktmud commented on a change in pull request #17202:
URL: https://github.com/apache/superset/pull/17202#discussion_r743929535
##########
File path:
superset-frontend/src/explore/components/controls/MetricControl/AdhocMetricEditPopover/index.jsx
##########
@@ -337,6 +341,13 @@ export default class AdhocMetricEditPopover extends
React.PureComponent {
) &&
savedMetric?.metric_name !== propsSavedMetric?.metric_name);
+ let extra = {};
+ if (datasource?.extra) {
+ try {
+ extra = JSON.parse(datasource.extra);
+ } catch {} // eslint-disable-line no-empty
+ }
Review comment:
Can the API return `extra` as a JSON object itself? Even if the API
doesn't, this feels like something should be handled earlier than in the metric
popover.
##########
File path:
superset-frontend/src/explore/components/controls/MetricControl/AdhocMetricEditPopover/index.jsx
##########
@@ -370,7 +381,23 @@ export default class AdhocMetricEditPopover extends
React.PureComponent {
/>
</FormItem>
</Tabs.TabPane>
- <Tabs.TabPane key={EXPRESSION_TYPES.SIMPLE} tab={t('Simple')}>
+ <Tabs.TabPane
+ key={EXPRESSION_TYPES.SIMPLE}
+ tab={
+ extra.disallow_adhoc_metrics ? (
+ <Tooltip
+ title={t(
+ 'Simple ad-hoc metrics are not enabled for this dataset',
Review comment:
How about use the same message for both "SIMPLE" and "CUSTOM SQL":
```
Ad-hoc metrics are not supported by this dataset, use saved metrics instead.
```
Having different messages kind of means one can disallow SIMPLE and CUSTOM
SQL separately.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]