forked from datahub-project/datahub
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into mysql_logging
- Loading branch information
Showing
25 changed files
with
1,970 additions
and
1,308 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
Oops, something went wrong.