mirror of
https://github.com/datahub-project/datahub.git
synced 2025-12-27 09:58:14 +00:00
feat(ui): Adding Explore all button on home page search (#6468)
This commit is contained in:
parent
3daeaccb2b
commit
added63437
@ -22,6 +22,7 @@ export enum EventType {
|
||||
RecommendationImpressionEvent,
|
||||
RecommendationClickEvent,
|
||||
HomePageRecommendationClickEvent,
|
||||
HomePageExploreAllClickEvent,
|
||||
SearchAcrossLineageEvent,
|
||||
SearchAcrossLineageResultsViewEvent,
|
||||
DownloadAsCsvEvent,
|
||||
@ -338,6 +339,10 @@ export interface ShowStandardHomepageEvent extends BaseEvent {
|
||||
type: EventType.ShowStandardHomepageEvent;
|
||||
}
|
||||
|
||||
export interface HomePageExploreAllClickEvent extends BaseEvent {
|
||||
type: EventType.HomePageExploreAllClickEvent;
|
||||
}
|
||||
|
||||
// Business glossary events
|
||||
|
||||
export interface CreateGlossaryEntityEvent extends BaseEvent {
|
||||
@ -389,6 +394,7 @@ export type Event =
|
||||
| ResetCredentialsEvent
|
||||
| SearchEvent
|
||||
| HomePageSearchEvent
|
||||
| HomePageExploreAllClickEvent
|
||||
| SearchResultsViewEvent
|
||||
| SearchResultClickEvent
|
||||
| BrowseResultClickEvent
|
||||
|
||||
@ -2,7 +2,7 @@ import React, { useEffect, useMemo, useState } from 'react';
|
||||
import { useHistory } from 'react-router';
|
||||
import { Typography, Image, Row, Button, Tag } from 'antd';
|
||||
import styled, { useTheme } from 'styled-components';
|
||||
|
||||
import { RightOutlined } from '@ant-design/icons';
|
||||
import { ManageAccount } from '../shared/ManageAccount';
|
||||
import { useGetAuthenticatedUser } from '../useGetAuthenticatedUser';
|
||||
import { useEntityRegistry } from '../useEntityRegistry';
|
||||
@ -68,6 +68,12 @@ const SuggestionsContainer = styled.div`
|
||||
align-items: start;
|
||||
`;
|
||||
|
||||
const SuggestionsHeader = styled.div`
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
width: 100%;
|
||||
`;
|
||||
|
||||
const SuggestionTagContainer = styled.div`
|
||||
display: flex;
|
||||
justify-content: left;
|
||||
@ -102,6 +108,22 @@ const SearchBarContainer = styled.div`
|
||||
text-align: center;
|
||||
`;
|
||||
|
||||
const ExploreAllButton = styled(Button)`
|
||||
&& {
|
||||
padding: 0px;
|
||||
margin: 0px;
|
||||
height: 16px;
|
||||
}
|
||||
`;
|
||||
|
||||
const StyledRightOutlined = styled(RightOutlined)`
|
||||
&&& {
|
||||
font-size: 7px;
|
||||
margin-left: 4px;
|
||||
padding: 0px;
|
||||
}
|
||||
`;
|
||||
|
||||
function truncate(input, length) {
|
||||
if (input.length > length) {
|
||||
return `${input.substring(0, length)}...`;
|
||||
@ -157,6 +179,16 @@ export const HomePageHeader = () => {
|
||||
}
|
||||
};
|
||||
|
||||
const onClickExploreAll = () => {
|
||||
analytics.event({
|
||||
type: EventType.HomePageExploreAllClickEvent,
|
||||
});
|
||||
navigateToSearchUrl({
|
||||
query: '*',
|
||||
history,
|
||||
});
|
||||
};
|
||||
|
||||
// Fetch results
|
||||
const { data: searchResultsData } = useGetSearchResultsForMultipleQuery({
|
||||
variables: {
|
||||
@ -228,7 +260,12 @@ export const HomePageHeader = () => {
|
||||
/>
|
||||
{searchResultsToShow && searchResultsToShow.length > 0 && (
|
||||
<SuggestionsContainer>
|
||||
<SuggestedQueriesText strong>Try searching for</SuggestedQueriesText>
|
||||
<SuggestionsHeader>
|
||||
<SuggestedQueriesText strong>Try searching for</SuggestedQueriesText>
|
||||
<ExploreAllButton type="link" onClick={onClickExploreAll}>
|
||||
Explore all <StyledRightOutlined />
|
||||
</ExploreAllButton>
|
||||
</SuggestionsHeader>
|
||||
<SuggestionTagContainer>
|
||||
{searchResultsToShow.slice(0, 3).map((suggestion) => (
|
||||
<SuggestionButton
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user