fectrain commented on code in PR #16371:
URL: https://github.com/apache/druid/pull/16371#discussion_r1605665193


##########
web-console/src/components/segment-timeline/segment-timeline.tsx:
##########
@@ -528,6 +530,58 @@ ORDER BY "start" DESC`;
     const { capabilities } = this.props;
     const { datasources, activeDataType, activeDatasource, startDate, endDate 
} = this.state;
 
+    const filterDatasource: ItemPredicate<string> = (query, val, _index, 
exactMatch) => {
+      const normalizedTitle = val.toLowerCase();
+      const normalizedQuery = query.toLowerCase();
+
+      if (exactMatch) {
+        return normalizedTitle === normalizedQuery;
+      } else {
+        return ` ${normalizedTitle}`.includes(normalizedQuery);
+      }
+    };
+
+    const datasourceRenderer: ItemRenderer<string> = (
+      val,
+      { handleClick, handleFocus, modifiers },
+    ) => {
+      if (!modifiers.matchesPredicate) {
+        return null;
+      }
+      return (
+        <MenuItem
+          key={val}
+          disabled={modifiers.disabled}
+          active={modifiers.active}
+          onClick={handleClick}
+          onFocus={handleFocus}
+          roleStructure="listoption"
+          text={val}
+        />
+      );
+    };
+
+    const DatasourceSelect: React.FC = () => {
+      const showAll = 'Show all';
+      const handleItemSelected = (selectedItem: string) => {
+        this.setState({
+          activeDatasource: selectedItem === showAll ? null : selectedItem,
+        });
+      };
+      const datasourcesWzAll = [showAll].concat(datasources);
+      return (
+        <Select2<string>
+          items={datasourcesWzAll}
+          onItemSelect={handleItemSelected}
+          itemRenderer={datasourceRenderer}
+          noResults={<MenuItem disabled text="No results." 
roleStructure="listoption" />}
+          itemPredicate={filterDatasource}
+        >
+          <Button text={activeDatasource === null ? showAll : 
activeDatasource} />

Review Comment:
   done



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