Skip to content

Commit

Permalink
feat(data-contract): Add initial file for data contract on validation…
Browse files Browse the repository at this point in the history
… tab
  • Loading branch information
amit-apptware committed May 30, 2024
1 parent bdd9667 commit a240d12
Show file tree
Hide file tree
Showing 3 changed files with 144 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@ import React, { useEffect } from 'react';
import { Button } from 'antd';
import { useHistory, useLocation } from 'react-router';
import styled from 'styled-components';
import { FileDoneOutlined, FileProtectOutlined } from '@ant-design/icons';
import { AuditOutlined, FileDoneOutlined, FileProtectOutlined } from '@ant-design/icons';
import { useEntityData } from '../../../EntityContext';
import { TestResults } from './TestResults';
import { Assertions } from './Assertions';
import TabToolbar from '../../../components/styled/TabToolbar';
import { useGetValidationsTab } from './useGetValidationsTab';
import { ANTD_GRAY } from '../../../constants';
import { useAppConfig } from '../../../../../useAppConfig';
import { DataContractTab } from './contract/DataContractTab';

const TabTitle = styled.span`
margin-left: 4px;
Expand All @@ -22,6 +24,7 @@ const TabButton = styled(Button)<{ selected: boolean }>`
enum TabPaths {
ASSERTIONS = 'Assertions',
TESTS = 'Tests',
DATA_CONTRACT = 'Data Contract',
}

const DEFAULT_TAB = TabPaths.ASSERTIONS;
Expand All @@ -33,6 +36,7 @@ export const ValidationsTab = () => {
const { entityData } = useEntityData();
const history = useHistory();
const { pathname } = useLocation();
const appConfig = useAppConfig();

const totalAssertions = (entityData as any)?.assertions?.total;
const passingTests = (entityData as any)?.testResults?.passing || [];
Expand Down Expand Up @@ -77,6 +81,26 @@ export const ValidationsTab = () => {
},
];

// if (appConfig.config.featureFlags?.dataContractsEnabled) {
// If contracts feature is enabled, add to list.

tabs.push({
title: (
<>
<AuditOutlined />

<TabTitle>Data Contract</TabTitle>
</>
),

path: TabPaths.DATA_CONTRACT,

content: <DataContractTab />,

disabled: false,
});
// }

return (
<>
<TabToolbar>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
import React, { useState } from 'react';
import styled from 'styled-components';
// import { useGetDatasetContractQuery } from '../../../../../../../graphql/contract.generated';
// import { DataContractState } from '../../../../../../../types.generated';
import { useEntityData } from '../../../../EntityContext';
// import { DataContractSummary } from './DataContractSummary';
// import { DataQualityContractSummary } from './DataQualityContractSummary';
// import { SchemaContractSummary } from './SchemaContractSummary';
// import { FreshnessContractSummary } from './FreshnessContractSummary';
// import { DataContractBuilderModal } from './builder/DataContractBuilderModal';
// import { createBuilderState } from './builder/utils';
// import { getAssertionsSummary } from '../DatahubUtility';

const Container = styled.div`
display: flex;
`;

const LeftColumn = styled.div`
width: 50%;
`;

const RightColumn = styled.div`
width: 50%;
`;

/**
* Component used for rendering the Data Contract Tab on the Assertions parent tab.
*/
export const DataContractTab = () => {
// const { urn, entityType } = useEntityData();

// const { data, refetch } = useGetDatasetContractQuery({
// variables: {
// urn,
// },
// });
// const [showContractBuilder, setShowContractBuilder] = useState(false);

// const contract = data?.dataset?.contract;
// const schemaContracts = data?.dataset?.contract?.properties?.schema || [];
// const freshnessContracts = data?.dataset?.contract?.properties?.freshness || [];
// const dataQualityContracts = data?.dataset?.contract?.properties?.dataQuality || [];
// const schemaAssertions = schemaContracts.map((c) => c.assertion);
// const freshnessAssertions = freshnessContracts.map((c) => c.assertion);
// const dataQualityAssertions = dataQualityContracts.map((c) => c.assertion);
// const assertionsSummary = getAssertionsSummary([
// ...schemaAssertions,
// ...freshnessAssertions,
// ...dataQualityAssertions,
// ] as any);
// const contractState = data?.dataset?.contract?.status?.state || DataContractState.Active;
// const hasFreshnessContract = freshnessContracts && freshnessContracts?.length;
// const hasSchemaContract = schemaContracts && schemaContracts?.length;
// const hasDataQualityContract = dataQualityContracts && dataQualityContracts?.length;
// const showLeftColumn = hasFreshnessContract || hasSchemaContract || undefined;

// const onContractUpdate = () => {
// if (contract) {
// // Contract exists, just refetch.
// refetch();
// } else {
// // no contract yet, wait for indxing,
// setTimeout(() => refetch(), 3000);
// }
// setShowContractBuilder(false);
// };

// return (
// <>
// {data?.dataset?.contract && (
// <>
// <DataContractSummary
// state={contractState}
// summary={assertionsSummary}
// showContractBuilder={() => setShowContractBuilder(true)}
// />
// <Container>
// {showLeftColumn && (
// <LeftColumn>
// {(hasFreshnessContract && (
// <FreshnessContractSummary
// contracts={freshnessContracts as any}
// showAction={false}
// />
// )) ||
// undefined}
// {(hasSchemaContract && (
// <SchemaContractSummary contracts={schemaContracts as any} showAction={false} />
// )) ||
// undefined}
// </LeftColumn>
// )}
// <RightColumn>
// {(hasDataQualityContract && (
// <DataQualityContractSummary
// contracts={dataQualityContracts as any}
// showAction={false}
// />
// )) ||
// undefined}
// </RightColumn>
// </Container>
// </>
// )}
// {showContractBuilder && (
// <DataContractBuilderModal
// initialState={createBuilderState(data?.dataset?.contract as any)}
// entityUrn={urn}
// onCancel={() => setShowContractBuilder(false)}
// onPropose={onContractUpdate}
// onSubmit={onContractUpdate}
// entityType={entityType}
// />
// )}
// </>
// );
return <div>DataContractTab</div>;
};
1 change: 1 addition & 0 deletions datahub-web-react/src/appConfigContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export const DEFAULT_APP_CONFIG = {
nestedDomainsEnabled: true,
platformBrowseV2: false,
businessAttributeEntityEnabled: false,
dataContractsEnabled: true,
},
};

Expand Down

0 comments on commit a240d12

Please sign in to comment.