-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(assertion-v2): changed Validation tab to Quality and created new…
… Governance tab (#10935)
- Loading branch information
1 parent
fdbcb68
commit d85da39
Showing
15 changed files
with
166 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
85 changes: 85 additions & 0 deletions
85
datahub-web-react/src/app/entity/shared/tabs/Dataset/Governance/GovernanceTab.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
import React, { useEffect } from 'react'; | ||
import { Button } from 'antd'; | ||
import { useHistory, useLocation } from 'react-router'; | ||
import styled from 'styled-components'; | ||
import { FileDoneOutlined } from '@ant-design/icons'; | ||
import { useEntityData } from '../../../EntityContext'; | ||
import { TestResults } from './TestResults'; | ||
import TabToolbar from '../../../components/styled/TabToolbar'; | ||
import { ANTD_GRAY } from '../../../constants'; | ||
import { useGetValidationsTab } from '../Validations/useGetValidationsTab'; | ||
|
||
const TabTitle = styled.span` | ||
margin-left: 4px; | ||
`; | ||
|
||
const TabButton = styled(Button)<{ selected: boolean }>` | ||
background-color: ${(props) => (props.selected && ANTD_GRAY[3]) || 'none'}; | ||
margin-left: 4px; | ||
`; | ||
|
||
enum TabPaths { | ||
TESTS = 'Tests', | ||
} | ||
|
||
const DEFAULT_TAB = TabPaths.TESTS; | ||
|
||
/** | ||
* Component used for rendering the Entity Governance Tab. | ||
*/ | ||
export const GovernanceTab = () => { | ||
const { entityData } = useEntityData(); | ||
const history = useHistory(); | ||
const { pathname } = useLocation(); | ||
|
||
const passingTests = (entityData as any)?.testResults?.passing || []; | ||
const maybeFailingTests = (entityData as any)?.testResults?.failing || []; | ||
const totalTests = maybeFailingTests.length + passingTests.length; | ||
|
||
const { selectedTab, basePath } = useGetValidationsTab(pathname, Object.values(TabPaths)); | ||
|
||
// If no tab was selected, select a default tab. | ||
useEffect(() => { | ||
if (!selectedTab) { | ||
// Route to the default tab. | ||
history.replace(`${basePath}/${DEFAULT_TAB}`); | ||
} | ||
}, [selectedTab, basePath, history]); | ||
|
||
/** | ||
* The top-level Toolbar tabs to display. | ||
*/ | ||
const tabs = [ | ||
{ | ||
title: ( | ||
<> | ||
<FileDoneOutlined /> | ||
<TabTitle>Tests ({totalTests})</TabTitle> | ||
</> | ||
), | ||
path: TabPaths.TESTS, | ||
disabled: totalTests === 0, | ||
content: <TestResults passing={passingTests} failing={maybeFailingTests} />, | ||
}, | ||
]; | ||
|
||
return ( | ||
<> | ||
<TabToolbar> | ||
<div> | ||
{tabs.map((tab) => ( | ||
<TabButton | ||
type="text" | ||
disabled={tab.disabled} | ||
selected={selectedTab === tab.path} | ||
onClick={() => history.replace(`${basePath}/${tab.path}`)} | ||
> | ||
{tab.title} | ||
</TabButton> | ||
))} | ||
</div> | ||
</TabToolbar> | ||
{tabs.filter((tab) => tab.path === selectedTab).map((tab) => tab.content)} | ||
</> | ||
); | ||
}; |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/** | ||
* | ||
* as per the new route object | ||
* We are redirecting older routes to new one | ||
* e.g. | ||
* { | ||
'/Validation/Assertions': '/Quality/List', | ||
} | ||
* */ | ||
|
||
export const getRedirectUrl = (newRoutes: { [key: string]: string }) => { | ||
let newPathname = `${window.location.pathname}${window.location.search}`; | ||
if (!newRoutes) { | ||
return newPathname; | ||
} | ||
|
||
// eslint-disable-next-line no-restricted-syntax | ||
for (const path of Object.keys(newRoutes)) { | ||
if (newPathname.indexOf(path) !== -1) { | ||
newPathname = newPathname.replace(path, newRoutes[path]); | ||
break; | ||
} | ||
} | ||
|
||
return `${newPathname}${window.location.search}`; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters