etr2460 commented on a change in pull request #17410:
URL: https://github.com/apache/superset/pull/17410#discussion_r750486616



##########
File path: 
superset-frontend/src/dashboard/components/nativeFilters/FilterBar/FilterControls/FilterControls.tsx
##########
@@ -80,21 +85,32 @@ const FilterControls: FC<FilterControlsProps> = ({
   const showCollapsePanel = dashboardHasTabs && cascadeFilters.length > 0;
 
   const cascadePopoverFactory = useCallback(
-    index => (
-      <CascadePopover
-        data-test="cascade-filters-control"
-        key={cascadeFilters[index].id}
-        dataMaskSelected={dataMaskSelected}
-        visible={visiblePopoverId === cascadeFilters[index].id}
-        onVisibleChange={visible =>
-          setVisiblePopoverId(visible ? cascadeFilters[index].id : null)
-        }
-        filter={cascadeFilters[index]}
-        onFilterSelectionChange={onFilterSelectionChange}
-        directPathToChild={directPathToChild}
-        inView={false}
-      />
-    ),
+    index => {
+      const filter = cascadeFilters[index];
+      if (filter.type === NativeFilterType.DIVIDER) {
+        return (
+          <div>
+            <h3>{(filter as Divider).title}</h3>

Review comment:
       i'm very sad that the if statement above didn't guarantee that the 
typing is correct :( perhaps it's safer to do `'title' in filter && 
filter.title` here instead?

##########
File path: 
superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/FilterTitlePane.tsx
##########
@@ -28,13 +29,17 @@ interface Props {
   onRearrage: (dragIndex: number, targetIndex: number) => void;
   onRemove: (id: string) => void;
   onChange: (id: string) => void;
-  onEdit: (filterId: string, action: 'add' | 'remove') => void;
+  onAdd: (type: NativeFilterType) => void;
   removedFilters: Record<string, FilterRemoval>;
   currentFilterId: string;
   filterGroups: string[][];
   erroredFilters: string[];
 }
 
+const StyledI = styled.div`

Review comment:
       Can we have a better name for this? not sure what an `I` is

##########
File path: superset-frontend/src/dashboard/components/nativeFilters/types.ts
##########
@@ -65,10 +65,16 @@ export interface Filter {
   type: NativeFilterType;
   description: string;
 }
+export interface Divider {
+  id: string;
+  title: string;
+  description: string;
+  type: NativeFilterType;

Review comment:
       I think if you set `type: typeof NativeFilterType.DIVIDER` (or something 
like that, maybe even just `type: 'DIVIDER'`) then you won't need to do type 
coercion above anymore

##########
File path: 
superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/SectionConfigForm.tsx
##########
@@ -0,0 +1,63 @@
+/**
+ * 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 from 'react';
+import { FormItem } from 'src/components/Form';
+import { Input, TextArea } from 'src/common/components';
+import { styled, t } from '@superset-ui/core';
+import { NativeFilterType } from '../types';
+
+interface Props {
+  componentId: string;
+  section?: {
+    title: string;
+    description: string;
+  };
+}
+const Container = styled.div`
+  ${({ theme }) => `
+    padding: ${theme.gridUnit * 4}px;
+  `}
+`;
+
+const SectionConfigForm: React.FC<Props> = ({ componentId, section }) => (
+  <Container>
+    <FormItem
+      initialValue={section ? section.title : ''}
+      label={t('Title')}
+      name={['filters', componentId, 'title']}
+      rules={[{ required: true, message: t('Title is required') }]}
+    >
+      <Input />
+    </FormItem>
+    <FormItem
+      initialValue={section ? section.description : ''}
+      label={t('Description')}
+      name={['filters', componentId, 'description']}
+    >
+      <TextArea rows={4} />
+    </FormItem>
+    <FormItem
+      hidden
+      name={['filters', componentId, 'type']}
+      initialValue={NativeFilterType.DIVIDER}
+    />
+  </Container>
+);
+
+export default SectionConfigForm;

Review comment:
       should this be called `DividerConfigForm`? Let's be consistent throughout




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

Reply via email to