Skip to content

Commit

Permalink
fix(UI) Fix multiple UI usability issues (#4975)
Browse files Browse the repository at this point in the history
  • Loading branch information
chriscollins3456 authored May 23, 2022
1 parent 39fb7e5 commit 3aa841c
Show file tree
Hide file tree
Showing 18 changed files with 289 additions and 98 deletions.
108 changes: 108 additions & 0 deletions datahub-web-react/src/Mocks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1774,6 +1774,14 @@ export const mocks = [
displayName: 'origin',
aggregations: [{ value: 'PROD', count: 3, entity: null }],
},
{
field: 'entity',
displayName: 'Type',
aggregations: [
{ count: 37, entity: null, value: 'DATASET', __typename: 'AggregationMetadata' },
{ count: 7, entity: null, value: 'CHART', __typename: 'AggregationMetadata' },
],
},
{
field: 'platform',
displayName: 'platform',
Expand Down Expand Up @@ -1837,6 +1845,14 @@ export const mocks = [
},
],
},
{
field: 'entity',
displayName: 'Type',
aggregations: [
{ count: 37, entity: null, value: 'DATASET', __typename: 'AggregationMetadata' },
{ count: 7, entity: null, value: 'CHART', __typename: 'AggregationMetadata' },
],
},
{
__typename: 'FacetMetadata',
field: 'platform',
Expand Down Expand Up @@ -1895,6 +1911,14 @@ export const mocks = [
},
],
},
{
field: 'entity',
displayName: 'Type',
aggregations: [
{ count: 37, entity: null, value: 'DATASET', __typename: 'AggregationMetadata' },
{ count: 7, entity: null, value: 'CHART', __typename: 'AggregationMetadata' },
],
},
{
field: 'platform',
displayName: 'platform',
Expand Down Expand Up @@ -1987,6 +2011,14 @@ export const mocks = [
},
],
},
{
field: 'entity',
displayName: 'Type',
aggregations: [
{ count: 37, entity: null, value: 'DATASET', __typename: 'AggregationMetadata' },
{ count: 7, entity: null, value: 'CHART', __typename: 'AggregationMetadata' },
],
},
{
field: 'platform',
displayName: 'platform',
Expand Down Expand Up @@ -2143,6 +2175,14 @@ export const mocks = [
},
],
},
{
field: 'entity',
displayName: 'Type',
aggregations: [
{ count: 37, entity: null, value: 'DATASET', __typename: 'AggregationMetadata' },
{ count: 7, entity: null, value: 'CHART', __typename: 'AggregationMetadata' },
],
},
{
field: 'platform',
displayName: 'platform',
Expand Down Expand Up @@ -2208,6 +2248,14 @@ export const mocks = [
},
],
},
{
field: 'entity',
displayName: 'Type',
aggregations: [
{ count: 37, entity: null, value: 'DATASET', __typename: 'AggregationMetadata' },
{ count: 7, entity: null, value: 'CHART', __typename: 'AggregationMetadata' },
],
},
{
field: 'platform',
displayName: 'platform',
Expand Down Expand Up @@ -2490,6 +2538,26 @@ export const mocks = [
},
],
},
// {
// displayName: 'Domain',
// field: 'domains',
// __typename: 'FacetMetadata',
// aggregations: [
// {
// value: 'urn:li:domain:baedb9f9-98ef-4846-8a0c-2a88680f213e',
// count: 1,
// __typename: 'AggregationMetadata',
// },
// ],
// },
{
field: 'entity',
displayName: 'Type',
aggregations: [
{ count: 37, entity: null, value: 'DATASET', __typename: 'AggregationMetadata' },
{ count: 7, entity: null, value: 'CHART', __typename: 'AggregationMetadata' },
],
},
{
__typename: 'FacetMetadata',
field: 'platform',
Expand Down Expand Up @@ -2665,6 +2733,14 @@ export const mocks = [
},
],
},
{
field: 'entity',
displayName: 'Type',
aggregations: [
{ count: 37, entity: null, value: 'DATASET', __typename: 'AggregationMetadata' },
{ count: 7, entity: null, value: 'CHART', __typename: 'AggregationMetadata' },
],
},
{
field: 'platform',
displayName: 'platform',
Expand Down Expand Up @@ -2730,6 +2806,14 @@ export const mocks = [
},
],
},
{
field: 'entity',
displayName: 'Type',
aggregations: [
{ count: 37, entity: null, value: 'DATASET', __typename: 'AggregationMetadata' },
{ count: 7, entity: null, value: 'CHART', __typename: 'AggregationMetadata' },
],
},
{
field: 'platform',
displayName: 'platform',
Expand Down Expand Up @@ -2796,6 +2880,14 @@ export const mocks = [
},
],
},
{
field: 'entity',
displayName: 'Type',
aggregations: [
{ count: 37, entity: null, value: 'DATASET', __typename: 'AggregationMetadata' },
{ count: 7, entity: null, value: 'CHART', __typename: 'AggregationMetadata' },
],
},
{
field: 'platform',
displayName: 'platform',
Expand Down Expand Up @@ -2862,6 +2954,14 @@ export const mocks = [
},
],
},
{
field: 'entity',
displayName: 'Type',
aggregations: [
{ count: 37, entity: null, value: 'DATASET', __typename: 'AggregationMetadata' },
{ count: 7, entity: null, value: 'CHART', __typename: 'AggregationMetadata' },
],
},
{
field: 'platform',
displayName: 'platform',
Expand Down Expand Up @@ -3096,6 +3196,14 @@ export const mocks = [
},
],
},
{
field: 'entity',
displayName: 'Type',
aggregations: [
{ count: 37, entity: null, value: 'DATASET', __typename: 'AggregationMetadata' },
{ count: 7, entity: null, value: 'CHART', __typename: 'AggregationMetadata' },
],
},
{
field: 'platform',
displayName: 'platform',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,24 @@ import getAvatarColor from '../../../shared/avatar/getAvatarColor';

export type Props = {
users?: (UserUsageCounts | null)[] | null;
maxNumberDisplayed?: number;
};

const AvatarStyled = styled(Avatar)<{ backgroundColor: string }>`
color: #fff;
background-color: ${(props) => props.backgroundColor};
`;

export default function UsageFacepile({ users }: Props) {
export default function UsageFacepile({ users, maxNumberDisplayed }: Props) {
const sortedUsers = useMemo(() => users?.slice().sort((a, b) => (b?.count || 0) - (a?.count || 0)), [users]);
let displayedUsers = sortedUsers;
if (maxNumberDisplayed) {
displayedUsers = displayedUsers?.slice(0, maxNumberDisplayed);
}

return (
<SpacedAvatarGroup maxCount={2}>
{sortedUsers?.map((user) => (
{displayedUsers?.map((user) => (
<Tooltip title={user?.userEmail}>
<AvatarStyled backgroundColor={getAvatarColor(user?.userEmail || undefined)}>
{user?.userEmail?.charAt(0).toUpperCase()}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export const SidebarStatsSection = () => {
) : null}
{(usageStats?.aggregations?.users?.length || 0) > 0 ? (
<InfoItem title="Top Users" width={INFO_ITEM_WIDTH_PX}>
<UsageFacepile users={usageStats?.aggregations?.users} />
<UsageFacepile users={usageStats?.aggregations?.users} maxNumberDisplayed={10} />
</InfoItem>
) : null}
</StatsRow>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export default function TableStats({
{users && (
<InfoItem title="Top Users">
<div style={{ paddingTop: 8 }}>
<UsageFacepile users={users} />
<UsageFacepile users={users} maxNumberDisplayed={10} />
</div>
</InfoItem>
)}
Expand Down
7 changes: 4 additions & 3 deletions datahub-web-react/src/app/home/HomePageHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const styles = {
navBar: { padding: '24px' },
searchContainer: { width: '100%', marginTop: '40px' },
logoImage: { width: 140 },
searchBox: { width: '40vw', minWidth: 400, margin: '40px 0px', marginBottom: '12px' },
searchBox: { width: '47vw', minWidth: 400, margin: '40px 0px', marginBottom: '12px', maxWidth: '650px' },
subtitle: { marginTop: '28px', color: '#FFFFFF', fontSize: 12 },
};

Expand All @@ -58,8 +58,9 @@ const NavGroup = styled.div`
`;

const SuggestionsContainer = styled.div`
padding: 0px 30px;
max-width: 540px;
margin: 0px 30px;
max-width: 650px;
width: 47vw;
display: flex;
flex-direction: column;
justify-content: left;
Expand Down
18 changes: 14 additions & 4 deletions datahub-web-react/src/app/lineage/LineageEntityNode.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import React, { useContext, useMemo, useState } from 'react';
import React, { useContext, useEffect, useMemo, useState } from 'react';
import { Group } from '@vx/group';
import { LinkHorizontal } from '@vx/shape';
import styled from 'styled-components';

import { useEntityRegistry } from '../useEntityRegistry';
import { IconStyleType } from '../entity/Entity';
import { NodeData, Direction, VizNode, EntitySelectParams } from './types';
import { NodeData, Direction, VizNode, EntitySelectParams, EntityAndType } from './types';
import { ANTD_GRAY } from '../entity/shared/constants';
import { capitalizeFirstLetter } from '../shared/textUtil';
import { nodeHeightFromTitleLength } from './utils/nodeHeightFromTitleLength';
import { LineageExplorerContext } from './utils/LineageExplorerContext';
import useLazyGetEntityQuery from './utils/useLazyGetEntityQuery';

const CLICK_DELAY_THRESHOLD = 1000;
const DRAG_DISTANCE_THRESHOLD = 20;
Expand Down Expand Up @@ -81,13 +82,20 @@ export default function LineageEntityNode({
onEntityCenter: (EntitySelectParams) => void;
onHover: (EntitySelectParams) => void;
onDrag: (params: EntitySelectParams, event: React.MouseEvent) => void;
onExpandClick: (LineageExpandParams) => void;
onExpandClick: (data: EntityAndType) => void;
direction: Direction;
nodesToRenderByUrn: Record<string, VizNode>;
}) {
const { expandTitles } = useContext(LineageExplorerContext);
const [isExpanding, setIsExpanding] = useState(false);
const [expandHover, setExpandHover] = useState(false);
const { getAsyncEntity, asyncData } = useLazyGetEntityQuery();

useEffect(() => {
if (asyncData) {
onExpandClick(asyncData);
}
}, [asyncData, onExpandClick]);

const entityRegistry = useEntityRegistry();
const unexploredHiddenChildren =
Expand Down Expand Up @@ -139,7 +147,9 @@ export default function LineageEntityNode({
<Group
onClick={() => {
setIsExpanding(true);
onExpandClick({ urn: node.data.urn, type: node.data.type, direction });
if (node.data.urn && node.data.type) {
getAsyncEntity(node.data.urn, node.data.type);
}
}}
onMouseOver={() => {
setExpandHover(true);
Expand Down
13 changes: 4 additions & 9 deletions datahub-web-react/src/app/lineage/LineageExplorer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@ import styled from 'styled-components';
import { Message } from '../shared/Message';
import { useEntityRegistry } from '../useEntityRegistry';
import CompactContext from '../shared/CompactContext';
import { EntityAndType, EntitySelectParams, FetchedEntities, LineageExpandParams } from './types';
import { EntityAndType, EntitySelectParams, FetchedEntities } from './types';
import LineageViz from './LineageViz';
import extendAsyncEntities from './utils/extendAsyncEntities';
import useLazyGetEntityQuery from './utils/useLazyGetEntityQuery';
import useGetEntityQuery from './utils/useGetEntityQuery';
import { EntityType } from '../../types.generated';
import { capitalizeFirstLetter } from '../shared/textUtil';
Expand Down Expand Up @@ -58,7 +57,6 @@ export default function LineageExplorer({ urn, type }: Props) {
const entityRegistry = useEntityRegistry();

const { loading, error, data } = useGetEntityQuery(urn, type);
const { getAsyncEntity, asyncData } = useLazyGetEntityQuery();

const [isDrawerVisible, setIsDrawVisible] = useState(false);
const [selectedEntity, setSelectedEntity] = useState<EntitySelectParams | undefined>(undefined);
Expand Down Expand Up @@ -94,10 +92,7 @@ export default function LineageExplorer({ urn, type }: Props) {
if (type && data) {
maybeAddAsyncLoadedEntity(data);
}
if (asyncData) {
maybeAddAsyncLoadedEntity(asyncData);
}
}, [data, asyncData, asyncEntities, setAsyncEntities, maybeAddAsyncLoadedEntity, urn, previousUrn, type]);
}, [data, asyncEntities, setAsyncEntities, maybeAddAsyncLoadedEntity, urn, previousUrn, type]);

if (error || (!loading && !error && !data)) {
return <Alert type="error" message={error?.message || 'Entity failed to load'} />;
Expand All @@ -124,8 +119,8 @@ export default function LineageExplorer({ urn, type }: Props) {
`${entityRegistry.getEntityUrl(params.type, params.urn)}/?is_lineage_mode=true`,
);
}}
onLineageExpand={(params: LineageExpandParams) => {
getAsyncEntity(params.urn, params.type);
onLineageExpand={(asyncData: EntityAndType) => {
maybeAddAsyncLoadedEntity(asyncData);
}}
/>
</div>
Expand Down
4 changes: 2 additions & 2 deletions datahub-web-react/src/app/lineage/LineageTree.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { useContext, useEffect, useMemo, useState } from 'react';
import { TransformMatrix } from '@vx/zoom/lib/types';

import { NodeData, Direction, EntitySelectParams, TreeProps } from './types';
import { NodeData, Direction, EntitySelectParams, TreeProps, EntityAndType } from './types';
import LineageTreeNodeAndEdgeRenderer from './LineageTreeNodeAndEdgeRenderer';
import layoutTree from './utils/layoutTree';
import { LineageExplorerContext } from './utils/LineageExplorerContext';
Expand All @@ -13,7 +13,7 @@ type LineageTreeProps = {
};
onEntityClick: (EntitySelectParams) => void;
onEntityCenter: (EntitySelectParams) => void;
onLineageExpand: (LineageExpandParams) => void;
onLineageExpand: (data: EntityAndType) => void;
selectedEntity?: EntitySelectParams;
hoveredEntity?: EntitySelectParams;
setHoveredEntity: (EntitySelectParams) => void;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { curveBasis } from '@vx/curve';
import { LinePath } from '@vx/shape';
import { TransformMatrix } from '@vx/zoom/lib/types';

import { NodeData, Direction, EntitySelectParams, TreeProps, VizNode, VizEdge } from './types';
import { NodeData, Direction, EntitySelectParams, TreeProps, VizNode, VizEdge, EntityAndType } from './types';
import LineageEntityNode from './LineageEntityNode';
import { ANTD_GRAY } from '../entity/shared/constants';

Expand All @@ -15,7 +15,7 @@ type Props = {
};
onEntityClick: (EntitySelectParams) => void;
onEntityCenter: (EntitySelectParams) => void;
onLineageExpand: (LineageExpandParams) => void;
onLineageExpand: (data: EntityAndType) => void;
selectedEntity?: EntitySelectParams;
hoveredEntity?: EntitySelectParams;
setHoveredEntity: (EntitySelectParams) => void;
Expand Down
2 changes: 1 addition & 1 deletion datahub-web-react/src/app/lineage/LineageVizInsideZoom.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ type Props = {
fetchedEntities: { [x: string]: FetchedEntity };
onEntityClick: (EntitySelectParams) => void;
onEntityCenter: (EntitySelectParams) => void;
onLineageExpand: (LineageExpandParams) => void;
onLineageExpand: (data: EntityAndType) => void;
selectedEntity?: EntitySelectParams;
zoom: ProvidedZoom & {
transformMatrix: TransformMatrix;
Expand Down
Loading

0 comments on commit 3aa841c

Please sign in to comment.