Skip to content

Commit

Permalink
Merge branch 'master' into fetch-depth
Browse files Browse the repository at this point in the history
  • Loading branch information
anshbansal authored Aug 1, 2023
2 parents 405229a + 0593e23 commit 44f36f4
Show file tree
Hide file tree
Showing 32 changed files with 296 additions and 109 deletions.
12 changes: 6 additions & 6 deletions datahub-frontend/app/controllers/Application.java
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,11 @@ public CompletableFuture<Result> proxy(String path, Http.Request request) throws
.stream()
// Remove X-DataHub-Actor to prevent malicious delegation.
.filter(entry -> !AuthenticationConstants.LEGACY_X_DATAHUB_ACTOR_HEADER.equalsIgnoreCase(entry.getKey()))
.filter(entry -> !Http.HeaderNames.CONTENT_LENGTH.equals(entry.getKey()))
.filter(entry -> !Http.HeaderNames.CONTENT_TYPE.equals(entry.getKey()))
.filter(entry -> !Http.HeaderNames.AUTHORIZATION.equals(entry.getKey()))
.filter(entry -> !Http.HeaderNames.CONTENT_LENGTH.equalsIgnoreCase(entry.getKey()))
.filter(entry -> !Http.HeaderNames.CONTENT_TYPE.equalsIgnoreCase(entry.getKey()))
.filter(entry -> !Http.HeaderNames.AUTHORIZATION.equalsIgnoreCase(entry.getKey()))
// Remove Host s.th. service meshes do not route to wrong host
.filter(entry -> !Http.HeaderNames.HOST.equals(entry.getKey()))
.filter(entry -> !Http.HeaderNames.HOST.equalsIgnoreCase(entry.getKey()))
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue))
)
.addHeader(Http.HeaderNames.AUTHORIZATION, authorizationHeaderValue)
Expand All @@ -152,8 +152,8 @@ public CompletableFuture<Result> proxy(String path, Http.Request request) throws
final ResponseHeader header = new ResponseHeader(apiResponse.getStatus(), apiResponse.getHeaders()
.entrySet()
.stream()
.filter(entry -> !Http.HeaderNames.CONTENT_LENGTH.equals(entry.getKey()))
.filter(entry -> !Http.HeaderNames.CONTENT_TYPE.equals(entry.getKey()))
.filter(entry -> !Http.HeaderNames.CONTENT_LENGTH.equalsIgnoreCase(entry.getKey()))
.filter(entry -> !Http.HeaderNames.CONTENT_TYPE.equalsIgnoreCase(entry.getKey()))
.map(entry -> Pair.of(entry.getKey(), String.join(";", entry.getValue())))
.collect(Collectors.toMap(Pair::getFirst, Pair::getSecond)));
final HttpEntity body = new HttpEntity.Strict(apiResponse.getBodyAsBytes(), Optional.ofNullable(apiResponse.getContentType()));
Expand Down
3 changes: 2 additions & 1 deletion datahub-web-react/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ const errorLink = onError((error) => {
if (serverError.statusCode === 401) {
isLoggedInVar(false);
Cookies.remove(GlobalCfg.CLIENT_AUTH_COOKIE);
window.location.replace(PageRoutes.AUTHENTICATE);
const currentPath = window.location.pathname + window.location.search;
window.location.replace(`${PageRoutes.AUTHENTICATE}?redirect_uri=${encodeURIComponent(currentPath)}`);
}
}
if (graphQLErrors && graphQLErrors.length) {
Expand Down
6 changes: 0 additions & 6 deletions datahub-web-react/src/app/context/UserContextProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { useGetMeLazyQuery } from '../../graphql/me.generated';
import { useGetGlobalViewsSettingsLazyQuery } from '../../graphql/app.generated';
import { CorpUser, PlatformPrivileges } from '../../types.generated';
import { UserContext, LocalState, DEFAULT_STATE, State } from './userContext';
import { useInitialRedirect } from './useInitialRedirect';

// TODO: Migrate all usage of useAuthenticatedUser to using this provider.

Expand Down Expand Up @@ -125,11 +124,6 @@ const UserContextProvider = ({ children }: { children: React.ReactNode }) => {
}
}, [state, localState.selectedViewUrn, setDefaultSelectedView]);

/**
* Route to the most recently visited path once on first load of home page, if present in local storage.
*/
useInitialRedirect(state, localState, setState, updateLocalState);

return (
<UserContext.Provider
value={{
Expand Down
52 changes: 0 additions & 52 deletions datahub-web-react/src/app/context/useInitialRedirect.ts

This file was deleted.

5 changes: 0 additions & 5 deletions datahub-web-react/src/app/context/userContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@ export type State = {
loadedPersonalDefaultViewUrn: boolean;
hasSetDefaultView: boolean;
};
/**
* Whether the initial page path has been loaded.
*/
loadedInitialPath: boolean;
};

/**
Expand Down Expand Up @@ -54,7 +50,6 @@ export const DEFAULT_STATE: State = {
loadedPersonalDefaultViewUrn: false,
hasSetDefaultView: false,
},
loadedInitialPath: false,
};

export const DEFAULT_CONTEXT = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@ export const AddGroupMembersModal = ({ urn, visible, onCloseModal, onSubmit }: P
setSelectedMembers(newUsers);
};

const onDeselectMember = (memberUrn: string) => {
const onDeselectMember = (memberUrn: { key: string; label: React.ReactNode; value: string }) => {
setInputValue('');
const newUserActors = selectedMembers.filter((user) => user !== memberUrn);
const newUserActors = selectedMembers.filter((user) => user.value !== memberUrn.value);
setSelectedMembers(newUserActors);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ const searchResultWithSiblings = [
{
entity: {
urn: 'urn:li:dataset:(urn:li:dataPlatform:bigquery,cypress_project.jaffle_shop.raw_orders,PROD)',
exists: true,
type: 'DATASET',
name: 'cypress_project.jaffle_shop.raw_orders',
origin: 'PROD',
Expand Down Expand Up @@ -328,6 +329,7 @@ const searchResultWithSiblings = [
siblings: [
{
urn: 'urn:li:dataset:(urn:li:dataPlatform:dbt,cypress_project.jaffle_shop.raw_orders,PROD)',
exists: true,
type: 'DATASET',
platform: {
urn: 'urn:li:dataPlatform:dbt',
Expand Down Expand Up @@ -376,6 +378,7 @@ const searchResultWithSiblings = [
{
entity: {
urn: 'urn:li:dataset:(urn:li:dataPlatform:dbt,cypress_project.jaffle_shop.raw_orders,PROD)',
exists: true,
type: 'DATASET',
name: 'cypress_project.jaffle_shop.raw_orders',
origin: 'PROD',
Expand Down Expand Up @@ -513,6 +516,169 @@ const searchResultWithSiblings = [
},
];

const searchResultWithGhostSiblings = [
{
entity: {
urn: 'urn:li:dataset:(urn:li:dataPlatform:bigquery,cypress_project.jaffle_shop.raw_orders,PROD)',
exists: true,
type: 'DATASET',
name: 'cypress_project.jaffle_shop.raw_orders',
origin: 'PROD',
uri: null,
platform: {
urn: 'urn:li:dataPlatform:bigquery',
type: 'DATA_PLATFORM',
name: 'bigquery',
properties: {
type: 'RELATIONAL_DB',
displayName: 'BigQuery',
datasetNameDelimiter: '.',
logoUrl: '/assets/platforms/bigquerylogo.png',
__typename: 'DataPlatformProperties',
},
displayName: null,
info: null,
__typename: 'DataPlatform',
},
dataPlatformInstance: null,
editableProperties: null,
platformNativeType: null,
properties: {
name: 'raw_orders',
description: null,
qualifiedName: null,
customProperties: [],
__typename: 'DatasetProperties',
},
ownership: null,
globalTags: null,
glossaryTerms: null,
subTypes: {
typeNames: ['table'],
__typename: 'SubTypes',
},
domain: null,
container: {
urn: 'urn:li:container:348c96555971d3f5c1ffd7dd2e7446cb',
platform: {
urn: 'urn:li:dataPlatform:bigquery',
type: 'DATA_PLATFORM',
name: 'bigquery',
properties: {
type: 'RELATIONAL_DB',
displayName: 'BigQuery',
datasetNameDelimiter: '.',
logoUrl: '/assets/platforms/bigquerylogo.png',
__typename: 'DataPlatformProperties',
},
displayName: null,
info: null,
__typename: 'DataPlatform',
},
properties: {
name: 'jaffle_shop',
__typename: 'ContainerProperties',
},
subTypes: {
typeNames: ['Dataset'],
__typename: 'SubTypes',
},
deprecation: null,
__typename: 'Container',
},
parentContainers: {
count: 2,
containers: [
{
urn: 'urn:li:container:348c96555971d3f5c1ffd7dd2e7446cb',
platform: {
urn: 'urn:li:dataPlatform:bigquery',
type: 'DATA_PLATFORM',
name: 'bigquery',
properties: {
type: 'RELATIONAL_DB',
displayName: 'BigQuery',
datasetNameDelimiter: '.',
logoUrl: '/assets/platforms/bigquerylogo.png',
__typename: 'DataPlatformProperties',
},
displayName: null,
info: null,
__typename: 'DataPlatform',
},
properties: {
name: 'jaffle_shop',
__typename: 'ContainerProperties',
},
subTypes: {
typeNames: ['Dataset'],
__typename: 'SubTypes',
},
deprecation: null,
__typename: 'Container',
},
{
urn: 'urn:li:container:b5e95fce839e7d78151ed7e0a7420d84',
platform: {
urn: 'urn:li:dataPlatform:bigquery',
type: 'DATA_PLATFORM',
name: 'bigquery',
properties: {
type: 'RELATIONAL_DB',
displayName: 'BigQuery',
datasetNameDelimiter: '.',
logoUrl: '/assets/platforms/bigquerylogo.png',
__typename: 'DataPlatformProperties',
},
displayName: null,
info: null,
__typename: 'DataPlatform',
},
properties: {
name: 'cypress_project',
__typename: 'ContainerProperties',
},
subTypes: {
typeNames: ['Project'],
__typename: 'SubTypes',
},
deprecation: null,
__typename: 'Container',
},
],
__typename: 'ParentContainersResult',
},
deprecation: null,
siblings: {
isPrimary: false,
siblings: [
{
urn: 'urn:li:dataset:(urn:li:dataPlatform:dbt,cypress_project.jaffle_shop.raw_orders,PROD)',
exists: false,
type: 'DATASET',
},
],
__typename: 'SiblingProperties',
},
__typename: 'Dataset',
},
matchedFields: [
{
name: 'name',
value: 'raw_orders',
__typename: 'MatchedField',
},
{
name: 'id',
value: 'cypress_project.jaffle_shop.raw_orders',
__typename: 'MatchedField',
},
],
insights: [],
__typename: 'SearchResult',
},
];

describe('siblingUtils', () => {
describe('combineEntityDataWithSiblings', () => {
it('combines my metadata with my siblings as primary', () => {
Expand Down Expand Up @@ -564,6 +730,18 @@ describe('siblingUtils', () => {
expect(result?.[0]?.matchedEntities?.[1]?.urn).toEqual(
'urn:li:dataset:(urn:li:dataPlatform:bigquery,cypress_project.jaffle_shop.raw_orders,PROD)',
);

expect(result?.[0]?.matchedEntities).toHaveLength(2);
});

it('will not combine an entity with a ghost node', () => {
const result = combineSiblingsInSearchResults(searchResultWithGhostSiblings as any);

expect(result).toHaveLength(1);
expect(result?.[0]?.matchedEntities?.[0]?.urn).toEqual(
'urn:li:dataset:(urn:li:dataPlatform:bigquery,cypress_project.jaffle_shop.raw_orders,PROD)',
);
expect(result?.[0]?.matchedEntities).toHaveLength(1);
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import styled from 'styled-components';
import { useDataNotCombinedWithSiblings, useEntityData } from '../../../EntityContext';
import { SidebarHeader } from './SidebarHeader';
import { CompactEntityNameList } from '../../../../../recommendations/renderer/component/CompactEntityNameList';
import { Entity } from '../../../../../../types.generated';
import { Dataset, Entity } from '../../../../../../types.generated';
import { SEPARATE_SIBLINGS_URL_PARAM, stripSiblingsFromEntity, useIsSeparateSiblingsMode } from '../../../siblingUtils';
import { GetDatasetQuery } from '../../../../../../graphql/dataset.generated';

Expand Down Expand Up @@ -36,14 +36,22 @@ export const SidebarSiblingsSection = () => {
const siblingEntities = entityData?.siblings?.siblings || [];
const entityDataWithoutSiblings = stripSiblingsFromEntity(dataNotCombinedWithSiblings.dataset);

const allSiblingsInGroup = [...siblingEntities, entityDataWithoutSiblings] as Entity[];
const allSiblingsInGroup = [...siblingEntities, entityDataWithoutSiblings] as Dataset[];

const allSiblingsInGroupThatExist = allSiblingsInGroup.filter((sibling) => sibling.exists);

// you are always going to be in the sibling group, so if the sibling group is just you do not render.
// The less than case is likely not neccessary but just there as a safety case for unexpected scenarios
if (allSiblingsInGroupThatExist.length <= 1) {
return <></>;
}

return (
<div>
<SidebarHeader title="Composed Of" />
<EntityListContainer>
<CompactEntityNameList
entities={allSiblingsInGroup}
entities={allSiblingsInGroupThatExist}
linkUrlParams={{ [SEPARATE_SIBLINGS_URL_PARAM]: true }}
showTooltips
/>
Expand Down
Loading

0 comments on commit 44f36f4

Please sign in to comment.