villebro commented on a change in pull request #13515:
URL: https://github.com/apache/superset/pull/13515#discussion_r589386332



##########
File path: 
superset-frontend/src/dashboard/components/nativeFilters/FilterBar/FilterBar.tsx
##########
@@ -295,6 +291,12 @@ const FilterBar: React.FC<FiltersBarProps> = ({
     </FilterControls>
   );
 
+  const isApplyDisabled =
+    !isInitialized || areObjectsEqual(filterData, lastAppliedFilterData);
+  console.log(
+    isInitialized,
+    areObjectsEqual(filterData, lastAppliedFilterData),
+  );

Review comment:
       leftover
   ```suggestion
   ```

##########
File path: 
superset-frontend/src/dashboard/components/nativeFilters/FilterBar/FilterSets/utils.ts
##########
@@ -0,0 +1,41 @@
+/**
+ * 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.
+ */
+
+import shortid from 'shortid';
+import { t } from '@superset-ui/core';
+
+export const generateFiltersSetId = () => `FILTERS_SET-${shortid.generate()}`;
+
+export const getFilterValueForDisplay = (
+  value?: string[] | null | string | number | object,
+): string => {
+  if (value === null || value === undefined) {
+    return '';
+  }
+  if (typeof value === 'string' || typeof value === 'number') {
+    return `${value}`;
+  }
+  if (Array.isArray(value)) {
+    return value.join(', ');
+  }
+  if (typeof value === 'object') {
+    return JSON.stringify(value);
+  }
+  return t('Unknown value');
+};

Review comment:
       It would be nice to use the same formatter here as in the filter 
indicator (perhaps implement this there?): 
https://github.com/apache/superset/blob/49eeab6f55e9e1f35b8a46e2906fe42d1cdf1f72/superset-frontend/src/dashboard/components/FiltersBadge/DetailsPanel.tsx#L50-L58

##########
File path: superset-frontend/package-lock.json
##########
@@ -306,8 +306,6 @@
       "integrity": 
"sha512-+y4ZnePpvWs1fc/LhZRTHkTesbXkyBYuOB+5CyodZqrEuETXi3zOVfpAQIdgC3lXbHLTDG9dQosxR9BhvLKDLQ==",
       "dev": true,
       "dependencies": {
-        "@nicolo-ribaudo/chokidar-2": "2.1.8-no-fsevents",

Review comment:
       we can probably revert the lock file changes

##########
File path: 
superset-frontend/src/dashboard/components/nativeFilters/FilterBar/FilterSets/FiltersHeader.tsx
##########
@@ -0,0 +1,86 @@
+/**
+ * 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.
+ */
+import React, { FC } from 'react';
+import { styled, t } from '@superset-ui/core';
+import { Collapse, Typography } from 'src/common/components';
+import { DataMaskUnitWithId } from 'src/dataMask/types';
+import { getFilterValueForDisplay } from './utils';
+import { Filter } from '../../types';
+
+const FilterHeader = styled.div`
+  display: flex;
+  align-items: center;
+  font-size: ${({ theme }) => theme.typography.sizes.s}px;
+`;
+
+const StyledCollapse = styled(Collapse)`
+  &.ant-collapse-ghost > .ant-collapse-item {
+    & > .ant-collapse-content > .ant-collapse-content-box {
+      padding: 0;
+      padding-top: 0;
+      padding-bottom: 0;
+      font-size: ${({ theme }) => theme.typography.sizes.s}px;
+    }
+    & > .ant-collapse-header {
+      padding: 0;
+      display: flex;
+      align-items: center;
+      flex-direction: row-reverse;
+      justify-content: flex-end;
+      & .ant-collapse-arrow {
+        position: static;
+        padding-left: ${({ theme }) => theme.gridUnit}px;
+      }
+  }
+`;
+
+type FiltersHeaderProps = {
+  filters: Filter[];
+  dataMask: DataMaskUnitWithId;
+};
+
+const FiltersHeader: FC<FiltersHeaderProps> = ({ filters, dataMask }) => {
+  const getFiltersHeader = () => (
+    <FilterHeader>
+      <Typography.Text type="secondary">
+        {t('Filters (%d)', filters.length)}
+      </Typography.Text>
+    </FilterHeader>
+  );
+  return (
+    <StyledCollapse
+      ghost
+      expandIconPosition="right"
+      defaultActiveKey={['filters']}
+    >
+      <Collapse.Panel header={getFiltersHeader()} key="filters">
+        {filters.map(({ id, name }) => (
+          <div>
+            <Typography.Text strong>{name}:&nbsp;</Typography.Text>
+            <Typography.Text>
+              {getFilterValueForDisplay(dataMask[id]?.currentState?.value)}
+            </Typography.Text>
+          </div>
+        ))}

Review comment:
       We can probably skip unset filters to keep this as compressed as 
possible.




----------------------------------------------------------------
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]

Reply via email to