diff --git a/datahub-web-react/src/app/ProtectedRoutes.tsx b/datahub-web-react/src/app/ProtectedRoutes.tsx index d5cc8a673ee325..c7230c256caf10 100644 --- a/datahub-web-react/src/app/ProtectedRoutes.tsx +++ b/datahub-web-react/src/app/ProtectedRoutes.tsx @@ -1,48 +1,21 @@ import React from 'react'; -import { Switch, Route, Redirect } from 'react-router-dom'; +import { Switch, Route } from 'react-router-dom'; import { Layout } from 'antd'; -import { BrowseResultsPage } from './browse/BrowseResultsPage'; -import { EntityPage } from './entity/EntityPage'; -import { PageRoutes } from '../conf/Global'; -import { useEntityRegistry } from './useEntityRegistry'; import { HomePage } from './home/HomePage'; -import { SearchPage } from './search/SearchPage'; -import { AnalyticsPage } from './analyticsDashboard/components/AnalyticsPage'; import AppConfigProvider from '../AppConfigProvider'; -import { ManageIngestionPage } from './ingest/ManageIngestionPage'; -import { ManageDomainsPage } from './domain/ManageDomainsPage'; -import BusinessGlossaryPage from './glossary/BusinessGlossaryPage'; -import { SettingsPage } from './settings/SettingsPage'; -import { NoPageFound } from './shared/NoPageFound'; +import { SearchRoutes } from './SearchRoutes'; /** * Container for all views behind an authentication wall. */ export const ProtectedRoutes = (): JSX.Element => { - const entityRegistry = useEntityRegistry(); return ( } /> - {entityRegistry.getEntities().map((entity) => ( - } - /> - ))} - } /> - } /> - } /> - } /> - } /> - } /> - } /> - } /> - } /> - + } /> diff --git a/datahub-web-react/src/app/analyticsDashboard/components/AnalyticsPage.tsx b/datahub-web-react/src/app/analyticsDashboard/components/AnalyticsPage.tsx index 7f019fb8322fca..76bd2e34eddeaa 100644 --- a/datahub-web-react/src/app/analyticsDashboard/components/AnalyticsPage.tsx +++ b/datahub-web-react/src/app/analyticsDashboard/components/AnalyticsPage.tsx @@ -2,8 +2,6 @@ import React, { useState } from 'react'; import styled from 'styled-components'; import { Alert, Divider, Input, Select } from 'antd'; import { SearchOutlined } from '@ant-design/icons'; - -import { SearchablePage } from '../../search/SearchablePage'; import { ChartGroup } from './ChartGroup'; import { useGetAnalyticsChartsQuery, useGetMetadataAnalyticsChartsQuery } from '../../../graphql/analytics.generated'; import { useGetHighlightsQuery } from '../../../graphql/highlights.generated'; @@ -85,7 +83,7 @@ export const AnalyticsPage = () => { }); return ( - + <> {highlightLoading && ( @@ -179,6 +177,6 @@ export const AnalyticsPage = () => { ))} - + ); }; diff --git a/datahub-web-react/src/app/authorization/UnauthorizedPage.tsx b/datahub-web-react/src/app/authorization/UnauthorizedPage.tsx index 5312f4e09d3ab2..2a5d9d9d251e3d 100644 --- a/datahub-web-react/src/app/authorization/UnauthorizedPage.tsx +++ b/datahub-web-react/src/app/authorization/UnauthorizedPage.tsx @@ -1,11 +1,10 @@ import { Result } from 'antd'; import React from 'react'; -import { SearchablePage } from '../search/SearchablePage'; export const UnauthorizedPage = () => { return ( - + <> - + ); }; diff --git a/datahub-web-react/src/app/browse/BrowsableEntityPage.tsx b/datahub-web-react/src/app/browse/BrowsableEntityPage.tsx index a16af634611c56..4cb9845d008b39 100644 --- a/datahub-web-react/src/app/browse/BrowsableEntityPage.tsx +++ b/datahub-web-react/src/app/browse/BrowsableEntityPage.tsx @@ -1,6 +1,5 @@ import * as React from 'react'; import { Affix } from 'antd'; -import { SearchablePage } from '../search/SearchablePage'; import { LegacyBrowsePath } from './LegacyBrowsePath'; import { useGetBrowsePathsQuery } from '../../graphql/browse.generated'; import { EntityType } from '../../types.generated'; @@ -26,7 +25,7 @@ export const BrowsableEntityPage = ({ const { data } = useGetBrowsePathsQuery({ variables: { input: { urn: _urn, type: _type } } }); return ( - + <> {data && data.browsePaths && data.browsePaths.length > 0 && ( )} {_children} - + ); }; diff --git a/datahub-web-react/src/app/browse/BrowseResultsPage.tsx b/datahub-web-react/src/app/browse/BrowseResultsPage.tsx index 485667b8f26342..aab4d3505d82d0 100644 --- a/datahub-web-react/src/app/browse/BrowseResultsPage.tsx +++ b/datahub-web-react/src/app/browse/BrowseResultsPage.tsx @@ -4,7 +4,6 @@ import * as QueryString from 'query-string'; import { Affix, Alert } from 'antd'; import { BrowseCfg } from '../../conf'; import { BrowseResults } from './BrowseResults'; -import { SearchablePage } from '../search/SearchablePage'; import { useGetBrowseResultsQuery } from '../../graphql/browse.generated'; import { LegacyBrowsePath } from './LegacyBrowsePath'; import { PageRoutes } from '../../conf/Global'; @@ -56,7 +55,7 @@ export const BrowseResultsPage = () => { } return ( - + <> @@ -74,6 +73,6 @@ export const BrowseResultsPage = () => { onChangePage={onChangePage} /> )} - + ); }; diff --git a/datahub-web-react/src/app/domain/ManageDomainsPage.tsx b/datahub-web-react/src/app/domain/ManageDomainsPage.tsx index e6800dc0695055..6172ac0246f58e 100644 --- a/datahub-web-react/src/app/domain/ManageDomainsPage.tsx +++ b/datahub-web-react/src/app/domain/ManageDomainsPage.tsx @@ -1,7 +1,6 @@ import { Typography } from 'antd'; import React from 'react'; import styled from 'styled-components'; -import { SearchablePage } from '../search/SearchablePage'; import { DomainsList } from './DomainsList'; const PageContainer = styled.div` @@ -24,18 +23,16 @@ const ListContainer = styled.div``; export const ManageDomainsPage = () => { return ( - - - - Domains - - View your DataHub Domains. Take administrative actions. - - - - - - - + + + Domains + + View your DataHub Domains. Take administrative actions. + + + + + + ); }; diff --git a/datahub-web-react/src/app/entity/EntityPage.tsx b/datahub-web-react/src/app/entity/EntityPage.tsx index 6a4015a21e2fa3..6ba12e8e6242d8 100644 --- a/datahub-web-react/src/app/entity/EntityPage.tsx +++ b/datahub-web-react/src/app/entity/EntityPage.tsx @@ -5,7 +5,6 @@ import { EntityType } from '../../types.generated'; import { BrowsableEntityPage } from '../browse/BrowsableEntityPage'; import LineageExplorer from '../lineage/LineageExplorer'; import useIsLineageMode from '../lineage/utils/useIsLineageMode'; -import { SearchablePage } from '../search/SearchablePage'; import { useEntityRegistry } from '../useEntityRegistry'; import analytics, { EventType } from '../analytics'; import { decodeUrn } from './shared/utils'; @@ -32,7 +31,6 @@ export const EntityPage = ({ entityType }: Props) => { const entity = entityRegistry.getEntity(entityType); const isBrowsable = entity.isBrowseEnabled(); const isLineageSupported = entity.isLineageEnabled(); - const ContainerPage = isBrowsable || isLineageSupported ? BrowsableEntityPage : SearchablePage; const isLineageMode = useIsLineageMode(); const authenticatedUserUrn = useGetAuthenticatedUserUrn(); const { loading, error, data } = useGetGrantedPrivilegesQuery({ @@ -74,8 +72,8 @@ export const EntityPage = ({ entityType }: Props) => { {error && } {data && !canViewEntityPage && } {canViewEntityPage && - ((showNewPage && {entityRegistry.renderProfile(entityType, urn)}) || ( - {entityRegistry.renderProfile(entityType, urn)}) || ( + { ) : ( entityRegistry.renderProfile(entityType, urn) )} - + ))} ); diff --git a/datahub-web-react/src/app/glossary/BusinessGlossaryPage.tsx b/datahub-web-react/src/app/glossary/BusinessGlossaryPage.tsx index 868dad3f375106..47395eff5aa3f2 100644 --- a/datahub-web-react/src/app/glossary/BusinessGlossaryPage.tsx +++ b/datahub-web-react/src/app/glossary/BusinessGlossaryPage.tsx @@ -5,7 +5,6 @@ import styled from 'styled-components/macro'; import { useGetRootGlossaryNodesQuery, useGetRootGlossaryTermsQuery } from '../../graphql/glossary.generated'; import TabToolbar from '../entity/shared/components/styled/TabToolbar'; -import { SearchablePage } from '../search/SearchablePage'; import GlossaryEntitiesPath from './GlossaryEntitiesPath'; import GlossaryEntitiesList from './GlossaryEntitiesList'; import GlossaryBrowser from './GlossaryBrowser/GlossaryBrowser'; @@ -55,39 +54,37 @@ function BusinessGlossaryPage() { return ( <> - - - - - - - - setBrowserWidth(Math.min(Math.max(width, MIN_BROWSWER_WIDTH), MAX_BROWSER_WIDTH)) - } - initialSize={browserWidth} - isSidebarOnLeft - /> - - - - Glossary -
- - -
-
- {hasTermsOrNodes && } - {!hasTermsOrNodes && ( - - )} -
-
-
+ + + + + + + setBrowserWidth(Math.min(Math.max(width, MIN_BROWSWER_WIDTH), MAX_BROWSER_WIDTH)) + } + initialSize={browserWidth} + isSidebarOnLeft + /> + + + + Glossary +
+ + +
+
+ {hasTermsOrNodes && } + {!hasTermsOrNodes && ( + + )} +
+
{isCreateTermModalVisible && ( { }; return ( - - - - Manage Ingestion - - Create, schedule, and run DataHub ingestion pipelines. - - - onClickTab(tab)}> - - - - - {selectedTab === TabType.Sources ? : } - - - + + + Manage Ingestion + + Create, schedule, and run DataHub ingestion pipelines. + + + onClickTab(tab)}> + + + + {selectedTab === TabType.Sources ? : } + ); }; diff --git a/datahub-web-react/src/app/search/SearchPage.tsx b/datahub-web-react/src/app/search/SearchPage.tsx index 15769b3e29b914..203810536d9aec 100644 --- a/datahub-web-react/src/app/search/SearchPage.tsx +++ b/datahub-web-react/src/app/search/SearchPage.tsx @@ -2,8 +2,6 @@ import React, { useEffect, useState } from 'react'; import * as QueryString from 'query-string'; import { useHistory, useLocation, useParams } from 'react-router'; import { Alert } from 'antd'; - -import { SearchablePage } from './SearchablePage'; import { useEntityRegistry } from '../useEntityRegistry'; import { FacetFilterInput, EntityType } from '../../types.generated'; import useFilters from './utils/useFilters'; @@ -81,20 +79,6 @@ export const SearchPage = () => { } }, [query, data, loading]); - const onSearch = (q: string, type?: EntityType) => { - if (q.trim().length === 0) { - return; - } - analytics.event({ - type: EventType.SearchEvent, - query: q, - entityTypeFilter: activeType, - pageNumber: 1, - originPath: window.location.pathname, - }); - navigateToSearchUrl({ type: type || activeType, query: q, page: 1, history }); - }; - const onChangeFilters = (newFilters: Array) => { navigateToSearchUrl({ type: activeType, query, page: 1, filters: newFilters, history }); }; @@ -104,7 +88,7 @@ export const SearchPage = () => { }; return ( - + <> {!loading && error && ( )} @@ -123,6 +107,6 @@ export const SearchPage = () => { numResultsPerPage={numResultsPerPage} setNumResultsPerPage={setNumResultsPerPage} /> - + ); }; diff --git a/datahub-web-react/src/app/search/SearchablePage.tsx b/datahub-web-react/src/app/search/SearchablePage.tsx index 0d79b75339ecba..4daadf63cec241 100644 --- a/datahub-web-react/src/app/search/SearchablePage.tsx +++ b/datahub-web-react/src/app/search/SearchablePage.tsx @@ -1,7 +1,7 @@ import React, { useEffect } from 'react'; -import { useHistory } from 'react-router'; +import { useHistory, useLocation } from 'react-router'; +import * as QueryString from 'query-string'; import { useTheme } from 'styled-components'; - import { SearchHeader } from './SearchHeader'; import { useEntityRegistry } from '../useEntityRegistry'; import { EntityType } from '../../types.generated'; @@ -21,13 +21,11 @@ const styles = { }; interface Props extends React.PropsWithChildren { - initialQuery?: string; onSearch?: (query: string, type?: EntityType) => void; onAutoComplete?: (query: string) => void; } const defaultProps = { - initialQuery: '', onSearch: undefined, onAutoComplete: undefined, }; @@ -35,7 +33,11 @@ const defaultProps = { /** * A page that includes a sticky search header (nav bar) */ -export const SearchablePage = ({ initialQuery, onSearch, onAutoComplete, children }: Props) => { +export const SearchablePage = ({ onSearch, onAutoComplete, children }: Props) => { + const location = useLocation(); + const params = QueryString.parse(location.search, { arrayFormat: 'comma' }); + const currentQuery: string = decodeURIComponent(params.query ? (params.query as string) : ''); + const history = useHistory(); const entityRegistry = useEntityRegistry(); const themeConfig = useTheme(); @@ -75,21 +77,21 @@ export const SearchablePage = ({ initialQuery, onSearch, onAutoComplete, childre // Load correct autocomplete results on initial page load. useEffect(() => { - if (initialQuery && initialQuery.trim() !== '') { + if (currentQuery && currentQuery.trim() !== '') { getAutoCompleteResults({ variables: { input: { - query: initialQuery, + query: currentQuery, }, }, }); } - }, [initialQuery, getAutoCompleteResults]); + }, [currentQuery, getAutoCompleteResults]); return ( <> { const showUsersGroups = (isIdentityManagementEnabled && me && me.platformPrivileges.manageIdentities) || false; return ( - - - - - Settings - Manage your DataHub settings. - - - { - history.push(`${url}/${newPath.key}`); - }} - > - - - - Access Tokens - + + + + Settings + Manage your DataHub settings. + + + { + history.push(`${url}/${newPath.key}`); + }} + > + + + + Access Tokens + + + {(showPolicies || showUsersGroups) && ( + + {showPolicies && ( + + + Users & Groups + + )} + {showUsersGroups && ( + + + Privileges + + )} - {(showPolicies || showUsersGroups) && ( - - {showPolicies && ( - - - Users & Groups - - )} - {showUsersGroups && ( - - - Privileges - - )} - - )} - - - - - - - {PATHS.map((p) => ( - p.content} key={p.path} /> - ))} - - - + )} + + + + + + + {PATHS.map((p) => ( + p.content} key={p.path} /> + ))} + + ); };