villebro commented on a change in pull request #12095:
URL:
https://github.com/apache/incubator-superset/pull/12095#discussion_r544996373
##########
File path:
superset-frontend/spec/javascripts/explore/components/AdhocFilterControl_spec.jsx
##########
@@ -21,14 +21,15 @@ import React from 'react';
import sinon from 'sinon';
import { shallow } from 'enzyme';
-import Select from 'src/components/Select';
import AdhocFilter, {
EXPRESSION_TYPES,
CLAUSES,
} from 'src/explore/AdhocFilter';
import AdhocFilterControl from
'src/explore/components/controls/AdhocFilterControl';
import AdhocMetric from 'src/explore/AdhocMetric';
import { AGGREGATES, OPERATORS } from 'src/explore/constants';
+import { supersetTheme } from '@superset-ui/core';
+import { LabelsContainer } from
'../../../../src/explore/components/OptionControls';
Review comment:
nit:
```suggestion
import { LabelsContainer } from '.src/explore/components/OptionControls';
```
##########
File path:
superset-frontend/spec/javascripts/explore/components/MetricsControl_spec.jsx
##########
@@ -150,138 +153,52 @@ describe('MetricsControl', () => {
});
describe('onChange', () => {
- it('handles saved metrics being selected', () => {
- const { wrapper, onChange } = setup();
- const select = wrapper.find(Select);
- select.simulate('change', [{ metric_name: 'sum__value' }]);
+ it('handles creating a new metric', () => {
+ const { component, onChange } = setup();
+ component.instance().onNewMetric({ metric_name: 'sum__value' });
Review comment:
We probably need not add the capability of selecting a saved
(=datasource) metric in the "Simple" tab so that saved metrics show up in the
columns dropdown, and when selected, it hides the "Aggregate" select.
##########
File path: superset-frontend/src/explore/components/controls/MetricsControl.jsx
##########
@@ -103,58 +109,25 @@ function coerceAdhocMetrics(value) {
});
}
-function getDefaultAggregateForColumn(column) {
- const { type } = column;
- if (typeof type !== 'string') {
- return AGGREGATES.COUNT;
- }
- if (type === '' || type === 'expression') {
- return AGGREGATES.SUM;
- }
- if (
- type.match(/.*char.*/i) ||
- type.match(/string.*/i) ||
- type.match(/.*text.*/i)
- ) {
- return AGGREGATES.COUNT_DISTINCT;
- }
- if (
- type.match(/.*int.*/i) ||
- type === 'LONG' ||
- type === 'DOUBLE' ||
- type === 'FLOAT'
- ) {
- return AGGREGATES.SUM;
- }
- if (type.match(/.*bool.*/i)) {
- return AGGREGATES.MAX;
- }
- if (type.match(/.*time.*/i)) {
- return AGGREGATES.COUNT;
- }
- if (type.match(/unknown/i)) {
- return AGGREGATES.COUNT;
- }
- return null;
-}
Review comment:
I wonder if we could still leverage this logic for setting the default
aggregate if it's unset and the user chooses the column first (the usual case)?
##########
File path: superset-frontend/images/icons/fx.svg
##########
@@ -0,0 +1,21 @@
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied. See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+<svg width="16" height="11" viewBox="0 0 16 11" fill="none"
xmlns="http://www.w3.org/2000/svg">
+<path fill-rule="evenodd" clip-rule="evenodd" d="M4.82355 4.0072L3.96417
8.04041C3.81118 8.76307 3.48891 9.35388 2.99738 9.81287C2.50584 10.2719 1.99966
10.5013 1.47882 10.5013C1.19236 10.5013 0.981588 10.4468 0.846497
10.3378C0.711405 10.2287 0.64386 10.0912 0.64386 9.92517C0.64386 9.7852
0.686177 9.6615 0.770813 9.55408C0.855449 9.44666 0.977518 9.39295 1.13702
9.39295C1.23794 9.39295 1.32664 9.41573 1.40314 9.4613C1.47963 9.50688 1.54718
9.56384 1.60577 9.6322C1.65135 9.68754 1.70262 9.76241 1.75958 9.85681C1.81655
9.95121 1.86619 10.0326 1.90851 10.101C2.15916 10.0814 2.37319 9.91215 2.5506
9.59314C2.72801 9.27413 2.88181 8.8184 3.01202 8.22595L3.91046
4.0072H2.95831L3.06085 3.56287H4.00323L4.07159 3.23084C4.14972 2.85323 4.27342
2.51306 4.44269 2.21033C4.61196 1.90759 4.80402 1.65043 5.01886 1.43884C5.23045
1.23051 5.47052 1.06694 5.73907 0.94812C6.00763 0.829304 6.2656 0.769897 6.513
0.769897C6.79946 0.769897 7.01023 0.824422 7.14532 0.933472C7.28042 1.04252
7.34796 1.18005 7.
34796 1.34607C7.34796 1.48604 7.30809 1.60974 7.22833 1.71716C7.14858 1.82459
7.02407 1.8783 6.8548 1.8783C6.75389 1.8783 6.666 1.85632 6.59113
1.81238C6.51626 1.76843 6.44952 1.71065 6.39093 1.63904C6.32583 1.55766 6.27374
1.48116 6.23468 1.40955C6.19562 1.33793 6.14679 1.25818 6.0882 1.17029C5.86358
1.18005 5.66502 1.32816 5.49249 1.61462C5.31997 1.90108 5.16372 2.37797 5.02374
3.04529L4.91632 3.56287H6.14191L6.03937 4.0072H4.82355ZM6.67739 5.89197C6.67739
4.42712 7.05174 3.23897 7.83299 2.20544H8.42706C7.84926 2.946 7.3976 4.51664
7.3976 5.89197C7.3976 7.27543 7.84519 8.842 8.42706 9.58256H7.83299C7.05174
8.54903 6.67739 7.36088 6.67739 5.89197ZM11.0841 6.68949H11.019L9.97736
8.34558H9.1839L10.6854 6.15239L9.16762 3.95919H10.0018L11.0434
5.59086H11.1085L12.138 3.95919H12.9315L11.4422 6.1239L12.9518
8.34558H12.1217L11.0841 6.68949ZM15.442 5.89604C15.442 7.36088 15.0677 8.54903
14.2864 9.58256H13.6924C14.2702 8.842 14.7218 7.27136 14.7218 5.89604C14.7218
4.51257 14.2742 2.946 13.69
24 2.20544H14.2864C15.0677 3.23897 15.442 4.42712 15.442 5.89604Z"
fill="#323232"/>
+</svg>
Review comment:
Nit: `function_x.svg` or similar might be a more explicit name, as
someone (=me 😄 ) might think "effects" when seeing `fx.svg`
##########
File path:
superset-frontend/src/explore/components/controls/AdhocFilterControl.jsx
##########
@@ -113,13 +124,14 @@ export default class AdhocFilterControl extends
React.Component {
Object.keys(partitions.cols).length === 1
) {
const partitionColumn = partitions.cols[0];
- this.valueRenderer = adhocFilter => (
+ this.valueRenderer = (adhocFilter, index) => (
<AdhocFilterOption
adhocFilter={adhocFilter}
onFilterEdit={this.onFilterEdit}
options={this.state.options}
datasource={this.props.datasource}
partitionColumn={partitionColumn}
+ onRemoveFilter={() => this.onRemoveFilter(index)}
Review comment:
Should we add `key={index}` here?
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]