Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ui/data-contract): Data contract UI under Validation Tab #10625

Merged
merged 32 commits into from
Jun 19, 2024
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
bdd9667
feat(graphql) data contract resolvers for graphql
jayacryl May 30, 2024
a240d12
feat(data-contract): Add initial file for data contract on validation…
amit-apptware May 30, 2024
2704ca7
feat(data-contract): add datacontract tab file and its graphql files
amit-apptware May 31, 2024
6785fc9
feat(data-contract): add modal files to create contract
amit-apptware May 31, 2024
e89e384
spotless
jayacryl Jun 1, 2024
10c7568
wired contracts to resolver
jayacryl Jun 1, 2024
292a936
added schema file
jayacryl Jun 1, 2024
437b63c
Merge branch 'master' into jp--datacontract-tab
jayacryl Jun 1, 2024
3a6b3ef
feat(ui/data-contract): remove acryl file and use datahub component f…
amit-apptware Jun 2, 2024
23669a0
Merge remote-tracking branch 'upstream/jp--datacontract-tab' into ag-…
amit-apptware Jun 2, 2024
3882ece
feat(ui/data-contract): remove other acryl files and create OSS files
amit-apptware Jun 4, 2024
25536da
feat(ui/data-contract): add condtional rendering the assertion list i…
amit-apptware Jun 5, 2024
0cb37e2
feat(ui/data-contract): removed unwanted code for data contract
amit-apptware Jun 6, 2024
2d872c8
feat(ui/data-contract): add datacontract image for assertion list
amit-apptware Jun 6, 2024
7915c5f
feat(ui/data-contract): add contract icon assigned to assertion
amit-apptware Jun 7, 2024
0555c61
feat(ui/data-contract): change graphql request to update the status a…
amit-apptware Jun 7, 2024
21e148a
feat(ui/data-contract): removed unwanted code
amit-apptware Jun 10, 2024
8c7d796
feat(ui/data-contract): Merge latest code from master
amit-apptware Jun 10, 2024
0bd62b1
feat(ui/data-contract): resolved PR comments
amit-apptware Jun 11, 2024
b1278f9
feat(ui/data-contract): resolved PR comments
amit-apptware Jun 11, 2024
364d508
feat(ui/data-contract): resolved PR comments
amit-apptware Jun 12, 2024
c8e71e7
feat(ui/data-contract): resolved PR comments
amit-apptware Jun 12, 2024
036cdf3
feat(ui/data-contract): create util function for the volume
amit-apptware Jun 14, 2024
abadacb
merge master into feature
amit-apptware Jun 14, 2024
f74169a
feat(feature-flags): data contract feature flag
jayacryl Jun 14, 2024
f74b7d9
feat(ui/data-contracct): remove yarn lock file changes
amit-apptware Jun 14, 2024
b598719
nit fix
jayacryl Jun 14, 2024
26c99d7
disable data contracts by default
jayacryl Jun 14, 2024
8761259
WIP: a240d125adb feat(data-contract): Add initial file for data contr…
amit-apptware Jun 18, 2024
5dd3125
feat(ui/data-contract): fix lint issues
amit-apptware Jun 18, 2024
650ac95
feat(ui/data-contract): fix lint issues
amit-apptware Jun 18, 2024
2b407d2
Merge branch 'master' into ag--datacontract-tab
amit-apptware Jun 19, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion datahub-web-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"@apollo/client": "^3.3.19",
"@graphql-codegen/fragment-matcher": "^5.0.0",
"@monaco-editor/react": "^4.3.1",
"@mui/icons-material": "^5.15.2",
amit-apptware marked this conversation as resolved.
Show resolved Hide resolved
"@react-hook/window-size": "^3.0.7",
"@react-spring/web": "^9.7.3",
"@remirror/pm": "^2.0.3",
Expand Down Expand Up @@ -150,4 +151,4 @@
"prosemirror-transform": "1.2.2",
"prosemirror-view": "1.13.4"
}
}
}
amit-apptware marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { DatasetAssertionsList } from './DatasetAssertionsList';
import { DatasetAssertionsSummary } from './DatasetAssertionsSummary';
import { sortAssertions } from './assertionUtils';
import { combineEntityDataWithSiblings, useIsSeparateSiblingsMode } from '../../../siblingUtils';
import { useGetDatasetContractQuery } from '../../../../../../graphql/contract.generated';

/**
* Returns a status summary for the assertions associated with a Dataset.
Expand Down Expand Up @@ -46,6 +47,11 @@ export const Assertions = () => {
const combinedData = isHideSiblingMode ? data : combineEntityDataWithSiblings(data);
const [removedUrns, setRemovedUrns] = useState<string[]>([]);

const { data: contractData, refetch: contractRefetch } = useGetDatasetContractQuery({
variables: { urn },
fetchPolicy: 'cache-first',
});
const contract = contractData?.dataset?.contract as any;
const assertions =
(combinedData && combinedData.dataset?.assertions?.assertions?.map((assertion) => assertion as Assertion)) ||
[];
Expand All @@ -67,6 +73,7 @@ export const Assertions = () => {
setRemovedUrns([...removedUrns, assertionUrn]);
setTimeout(() => refetch(), 3000);
}}
contract={contract}
/>
)}
</>
Expand Down
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice, for context john - Amit did a minimal set of changes to make the existing assertion list in OSS selectable (check/uncheck option). This will work for OSS until we get to porting over our acryl assertion list code.

Original file line number Diff line number Diff line change
@@ -1,15 +1,28 @@
import { Button, Dropdown, Empty, Image, message, Modal, Tag, Tooltip, Typography } from 'antd';
import { Button, Dropdown, Empty, Image, message, Modal, Tag, Tooltip, Typography, Checkbox } from 'antd';
import React from 'react';
import styled from 'styled-components';
import { DeleteOutlined, DownOutlined, MoreOutlined, RightOutlined, StopOutlined } from '@ant-design/icons';
import {
DeleteOutlined,
DownOutlined,
MoreOutlined,
RightOutlined,
StopOutlined,
AuditOutlined,
} from '@ant-design/icons';
import { DatasetAssertionDescription } from './DatasetAssertionDescription';
import { StyledTable } from '../../../components/styled/StyledTable';
import { DatasetAssertionDetails } from './DatasetAssertionDetails';
import { Assertion, AssertionRunStatus } from '../../../../../../types.generated';
import { Assertion, AssertionRunStatus, DataContract, EntityType } from '../../../../../../types.generated';
import { getResultColor, getResultIcon, getResultText } from './assertionUtils';
import { useDeleteAssertionMutation } from '../../../../../../graphql/assertion.generated';
import { capitalizeFirstLetterOnly } from '../../../../../shared/textUtil';
import AssertionMenu from './AssertionMenu';
import { Link, useParams } from 'react-router-dom';
import { REDESIGN_COLORS } from '../../../constants';
import { useEntityRegistry } from '../../../../../useEntityRegistry';
import { isAssertionPartOfContract } from './contract/utils';
import { decodeUrn } from '../../../utils';
import { useEntityData } from '../../../EntityContext';

const ResultContainer = styled.div`
display: flex;
Expand All @@ -35,9 +48,26 @@ const StyledMoreOutlined = styled(MoreOutlined)`
font-size: 18px;
`;

const AssertionSelectCheckbox = styled(Checkbox)`
margin-right: 12px;
`;

const DataContractLogo = styled(AuditOutlined)`
margin-left: 8px;
font-size: 16px;
color: ${REDESIGN_COLORS.BLUE};
`;

type Props = {
assertions: Array<Assertion>;
onDelete?: (urn: string) => void;
contract?: DataContract;
// required for enabling menu/actions
showMenu?: boolean;
onSelect?: (assertionUrn: string) => void;
// required for enabling selection logic
showSelect?: boolean;
selectedUrns?: string[];
};

/**
Expand All @@ -46,8 +76,18 @@ type Props = {
*
* Currently this component supports rendering Dataset Assertions only.
*/
export const DatasetAssertionsList = ({ assertions, onDelete }: Props) => {
export const DatasetAssertionsList = ({
assertions,
onDelete,
showMenu = true,
showSelect,
onSelect,
selectedUrns,
contract,
}: Props) => {
const entityData = useEntityData();
const [deleteAssertionMutation] = useDeleteAssertionMutation();
const entityRegistry = useEntityRegistry();

const deleteAssertion = async (urn: string) => {
try {
Expand Down Expand Up @@ -102,9 +142,19 @@ export const DatasetAssertionsList = ({ assertions, onDelete }: Props) => {
const resultColor = (record.lastExecResult && getResultColor(record.lastExecResult)) || 'default';
const resultText = (record.lastExecResult && getResultText(record.lastExecResult)) || 'No Evaluations';
const resultIcon = (record.lastExecResult && getResultIcon(record.lastExecResult)) || <StopOutlined />;
const selected = selectedUrns?.some((selectedUrn) => selectedUrn === record.urn);
const isPartOfContract = contract && isAssertionPartOfContract(record, contract);

const { description } = record;
return (
<ResultContainer>
{showSelect ? (
<AssertionSelectCheckbox
checked={selected}
onClick={(e) => e.stopPropagation()}
onChange={() => onSelect?.(record.urn as string)}
/>
) : undefined}
<div>
<Tooltip title={(localTime && `Last evaluated on ${localTime}`) || 'No Evaluations'}>
<Tag style={{ borderColor: resultColor }}>
Expand All @@ -117,6 +167,34 @@ export const DatasetAssertionsList = ({ assertions, onDelete }: Props) => {
description={description}
assertionInfo={record.datasetAssertionInfo}
/>
{(isPartOfContract && entityData?.urn && (
<Tooltip
title={
<>
Part of Data Contract{' '}
<Link
to={`${entityRegistry.getEntityUrl(
EntityType.Dataset,
entityData.urn,
)}/Validation/Data Contract`}
style={{ color: REDESIGN_COLORS.BLUE }}
>
view
</Link>
</>
}
>
<Link
to={`${entityRegistry.getEntityUrl(
EntityType.Dataset,
entityData.urn,
)}/Validation/Data Contract`}
>
<DataContractLogo />
</Link>
</Tooltip>
)) ||
undefined}
</ResultContainer>
);
},
Expand All @@ -125,37 +203,44 @@ export const DatasetAssertionsList = ({ assertions, onDelete }: Props) => {
title: '',
dataIndex: '',
key: '',
render: (_, record: any) => (
<ActionButtonContainer>
<Tooltip
title={
record.platform.properties?.displayName || capitalizeFirstLetterOnly(record.platform.name)
}
>
<PlatformContainer>
{(record.platform.properties?.logoUrl && (
<Image
preview={false}
height={20}
width={20}
src={record.platform.properties?.logoUrl}
/>
)) || (
<Typography.Text>
{record.platform.properties?.displayName ||
capitalizeFirstLetterOnly(record.platform.name)}
</Typography.Text>
)}
</PlatformContainer>
</Tooltip>
<Button onClick={() => onDeleteAssertion(record.urn)} type="text" shape="circle" danger>
<DeleteOutlined />
</Button>
<Dropdown overlay={<AssertionMenu urn={record.urn} />} trigger={['click']}>
<StyledMoreOutlined />
</Dropdown>
</ActionButtonContainer>
),
render: (_, record: any) => {
return (
amit-apptware marked this conversation as resolved.
Show resolved Hide resolved
<>
{showMenu && (
<ActionButtonContainer>
<Tooltip
title={
record.platform.properties?.displayName ||
capitalizeFirstLetterOnly(record.platform.name)
}
>
<PlatformContainer>
{(record.platform.properties?.logoUrl && (
<Image
preview={false}
height={20}
width={20}
src={record.platform.properties?.logoUrl}
/>
)) || (
<Typography.Text>
{record.platform.properties?.displayName ||
capitalizeFirstLetterOnly(record.platform.name)}
</Typography.Text>
)}
</PlatformContainer>
</Tooltip>
<Button onClick={() => onDeleteAssertion(record.urn)} type="text" shape="circle" danger>
<DeleteOutlined />
</Button>
<Dropdown overlay={<AssertionMenu urn={record.urn} />} trigger={['click']}>
<StyledMoreOutlined />
</Dropdown>
</ActionButtonContainer>
)}
</>
);
},
},
];

Expand All @@ -168,18 +253,36 @@ export const DatasetAssertionsList = ({ assertions, onDelete }: Props) => {
locale={{
emptyText: <Empty description="No Assertions Found :(" image={Empty.PRESENTED_IMAGE_SIMPLE} />,
}}
expandable={{
defaultExpandAllRows: false,
expandRowByClick: true,
expandedRowRender: (record) => {
return <DatasetAssertionDetails urn={record.urn} lastEvaluatedAtMillis={record.lastExecTime} />;
},
expandIcon: ({ expanded, onExpand, record }: any) =>
expanded ? (
<DownOutlined style={{ fontSize: 8 }} onClick={(e) => onExpand(record, e)} />
) : (
<RightOutlined style={{ fontSize: 8 }} onClick={(e) => onExpand(record, e)} />
),
expandable={
showSelect
? {}
: {
defaultExpandAllRows: false,
expandRowByClick: true,
expandedRowRender: (record) => {
return (
<DatasetAssertionDetails
urn={record.urn}
lastEvaluatedAtMillis={record.lastExecTime}
/>
);
},
expandIcon: ({ expanded, onExpand, record }: any) =>
expanded ? (
<DownOutlined style={{ fontSize: 8 }} onClick={(e) => onExpand(record, e)} />
) : (
<RightOutlined style={{ fontSize: 8 }} onClick={(e) => onExpand(record, e)} />
),
}
}
onRow={(record) => {
return {
onClick: (_) => {
if (showSelect) {
onSelect?.(record.urn as string);
}
},
};
amit-apptware marked this conversation as resolved.
Show resolved Hide resolved
}}
showHeader={false}
pagination={false}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import React from 'react';
import { Typography } from 'antd';
// import { FieldAssertionInfo } from '../../../../../../types.generated';
amit-apptware marked this conversation as resolved.
Show resolved Hide resolved
import {
getFieldDescription,
getFieldOperatorDescription,
getFieldParametersDescription,
getFieldTransformDescription,
} from './fieldDescriptionUtils';

type Props = {
assertionInfo: any;
};

/**
* A human-readable description of a Field Assertion.
*/
export const FieldAssertionDescription = ({ assertionInfo }: Props) => {
const field = getFieldDescription(assertionInfo);
const operator = getFieldOperatorDescription(assertionInfo);
const transform = getFieldTransformDescription(assertionInfo);
const parameters = getFieldParametersDescription(assertionInfo);

return (
<Typography.Text>
{transform}
{transform ? ' of ' : ''}
<Typography.Text code>{field}</Typography.Text> {operator} {parameters}
</Typography.Text>
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import React from 'react';
import { Typography } from 'antd';
import { AssertionInfo } from '../../../../../../types.generated';

type Props = {
assertionInfo: AssertionInfo;
};

/**
* A human-readable description of a SQL Assertion.
*/
export const SqlAssertionDescription = ({ assertionInfo }: Props) => {
const { description } = assertionInfo;

return <Typography.Text>{description}</Typography.Text>;
};
Loading