Skip to content
Open
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@
import { SearchIndex } from '../../../enums/search.enum';
import { EntityReference } from '../../../generated/entity/type';
import { searchQuery } from '../../../rest/searchAPI';
import { getEntityNodeIcon } from '../../../utils/EntityLineageNodeUtils';
import { getEntityName } from '../../../utils/EntityNameUtils';
import { getPartialNameFromTableFQN } from '../../../utils/FqnUtils';
import serviceUtilClassBase from '../../../utils/ServiceUtilClassBase';
import { getEntityIcon } from '../../../utils/TableUtils';
import { showErrorToast } from '../../../utils/ToastUtils';
import { ExploreSearchIndex } from '../../Explore/ExplorePage.interface';
import { SourceType } from '../../SearchedData/SearchedData.interface';
Expand All @@ -51,7 +51,7 @@
onSelectHandler,
}) => {
const { t } = useTranslation();
const selectRef = useRef<any>(null);

Check warning on line 54 in openmetadata-ui/src/main/resources/ui/src/components/Entity/EntityLineage/NodeSuggestions.component.tsx

View workflow job for this annotation

GitHub Actions / checkstyle

Unexpected any. Specify a different type

const [data, setData] = useState<Array<SourceType>>([]);
const [searchValue, setSearchValue] = useState<string>('');
Expand Down Expand Up @@ -156,17 +156,18 @@
getSearchResults(searchValue);
}, []);

const Icon = getEntityNodeIcon(entityType);
const entityIcon = useMemo(
() => getEntityIcon(entityType, 'tw:h-4 tw:w-4'),
[entityType]
);

return (
<Row
className="p-md items-center"
data-testid="suggestion-node"
gutter={8}
wrap={false}>
<Col>
<Icon height={16} name="entity-icon" width={16} />
</Col>
<Col>{entityIcon}</Col>
<Col flex="1">
<Select
autoFocus
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ import {
getExploreQueryFilterMust,
} from '../../utils/ExploreUtils';
import { translateWithNestedKeys } from '../../utils/i18next/LocalUtil';
import searchClassBase from '../../utils/SearchClassBase';
import { EntityIconSize } from '../../utils/TableUtils';
import { showErrorToast } from '../../utils/ToastUtils';
import SearchDropdown from '../SearchDropdown/SearchDropdown';
import { SearchDropdownOption } from '../SearchDropdown/SearchDropdown.interface';
Expand Down Expand Up @@ -60,6 +62,26 @@ const getOptionLabelFormatter = (
? formatEntityTypeLabel
: undefined;

const addEntityTypeIcons = (
key: string,
opts: SearchDropdownOption[]
): SearchDropdownOption[] => {
if (!ENTITY_TYPE_FILTER_KEYS.has(key)) {
return opts;
}

return opts.map((opt) => ({
...opt,
icon:
searchClassBase.getEntityIcon(
getCanonicalEntityType(opt.key),
'tw:text-quaternary',
{},
EntityIconSize.Size16
Comment thread
Rohit0301 marked this conversation as resolved.
) ?? undefined,
Comment thread
gitar-bot[bot] marked this conversation as resolved.
}));
};

const ExploreQuickFilters: FC<ExploreQuickFiltersProps> = ({
fields,
index,
Expand Down Expand Up @@ -154,7 +176,7 @@ const ExploreQuickFilters: FC<ExploreQuickFiltersProps> = ({
) => {
const staticOptions = getStaticOptions(key);
if (staticOptions) {
setOptions(staticOptions);
setOptions(addEntityTypeIcons(key, staticOptions));

return;
}
Expand Down Expand Up @@ -192,12 +214,15 @@ const ExploreQuickFilters: FC<ExploreQuickFiltersProps> = ({
}

setOptions(
uniqWith(
getOptionsFromAggregationBucket(
buckets,
getOptionLabelFormatter(key, untitledDropdown)
),
isEqual
addEntityTypeIcons(
key,
uniqWith(
getOptionsFromAggregationBucket(
buckets,
getOptionLabelFormatter(key, untitledDropdown)
),
isEqual
)
)
);
};
Expand All @@ -209,7 +234,7 @@ const ExploreQuickFilters: FC<ExploreQuickFiltersProps> = ({
) => {
const staticOptions = getStaticOptions(key);
if (staticOptions) {
setOptions(staticOptions);
setOptions(addEntityTypeIcons(key, staticOptions));

return;
}
Expand Down Expand Up @@ -238,7 +263,7 @@ const ExploreQuickFilters: FC<ExploreQuickFiltersProps> = ({
option.label.toLowerCase().includes(value.toLowerCase())
)
: staticOptions;
setOptions(filteredOptions);
setOptions(addEntityTypeIcons(key, filteredOptions));

return;
}
Expand Down Expand Up @@ -270,12 +295,15 @@ const ExploreQuickFilters: FC<ExploreQuickFiltersProps> = ({
const buckets =
res.data.aggregations[`sterms#${searchKeyToUse}`]?.buckets ?? [];
setOptions(
uniqWith(
getOptionsFromAggregationBucket(
buckets,
getOptionLabelFormatter(key, untitledDropdown)
),
isEqual
addEntityTypeIcons(
key,
uniqWith(
getOptionsFromAggregationBucket(
buckets,
getOptionLabelFormatter(key, untitledDropdown)
),
isEqual
)
)
);
} catch (error) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,16 @@ const QuickFilterDropdown: FC<QuickFilterDropdownProps> = ({
<Checkbox
data-testid={`${option.label}-checkbox`}
isSelected={isOptionSelected(option)}
label={option.label}
label={
option.icon ? (
<span className="tw:flex tw:items-center tw:gap-1.5">
{option.icon}
{option.label}
</span>
) : (
option.label
)
}
onChange={() => handleOptionToggle(option)}
/>
{!hideCounts && !isUndefined(option.count) && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
* limitations under the License.
*/

import { ReactNode } from 'react';
import { ExploreSearchIndex } from '../Explore/ExplorePage.interface';

export interface SearchDropdownProps {
Expand Down Expand Up @@ -49,4 +50,5 @@ export interface SearchDropdownOption {
labelKeyOptions?: Record<string, string | number | boolean>;
count?: number;
description?: string;
icon?: ReactNode;
}
Loading
Loading