Skip to content
This repository has been archived by the owner on Jan 27, 2025. It is now read-only.

Commit

Permalink
feat(ui): Adding Explore all button on home page search (datahub-proj…
Browse files Browse the repository at this point in the history
  • Loading branch information
jjoyce0510 authored and cccs-Dustin committed Feb 1, 2023
1 parent af65ab0 commit 5936349
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 2 deletions.
6 changes: 6 additions & 0 deletions datahub-web-react/src/app/analytics/event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export enum EventType {
RecommendationImpressionEvent,
RecommendationClickEvent,
HomePageRecommendationClickEvent,
HomePageExploreAllClickEvent,
SearchAcrossLineageEvent,
SearchAcrossLineageResultsViewEvent,
DownloadAsCsvEvent,
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -389,6 +394,7 @@ export type Event =
| ResetCredentialsEvent
| SearchEvent
| HomePageSearchEvent
| HomePageExploreAllClickEvent
| SearchResultsViewEvent
| SearchResultClickEvent
| BrowseResultClickEvent
Expand Down
41 changes: 39 additions & 2 deletions datahub-web-react/src/app/home/HomePageHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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)}...`;
Expand Down Expand Up @@ -157,6 +179,16 @@ export const HomePageHeader = () => {
}
};

const onClickExploreAll = () => {
analytics.event({
type: EventType.HomePageExploreAllClickEvent,
});
navigateToSearchUrl({
query: '*',
history,
});
};

// Fetch results
const { data: searchResultsData } = useGetSearchResultsForMultipleQuery({
variables: {
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 5936349

Please sign in to comment.