-
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(schema) Show last observed timestamp in the schema tab (#5348)
- Loading branch information
1 parent
7872a74
commit 68fb0d8
Showing
14 changed files
with
227 additions
and
29 deletions.
There are no files selected for viewing
17 changes: 12 additions & 5 deletions
17
...l-core/src/main/java/com/linkedin/datahub/graphql/types/dataset/mappers/SchemaMapper.java
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
23 changes: 23 additions & 0 deletions
23
datahub-web-react/src/app/entity/dataset/profile/__tests__/schema/SchemaTimeStamps.test.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,23 @@ | ||
import { render } from '@testing-library/react'; | ||
import React from 'react'; | ||
import { toRelativeTimeString } from '../../../../../shared/time/timeUtils'; | ||
import SchemaTimeStamps from '../../schema/components/SchemaTimeStamps'; | ||
|
||
describe('SchemaTimeStamps', () => { | ||
it('should render last observed text if lastObserved is not null', () => { | ||
const { getByText, queryByText } = render(<SchemaTimeStamps lastUpdated={123} lastObserved={123} />); | ||
expect(getByText(`Last observed ${toRelativeTimeString(123)}`)).toBeInTheDocument(); | ||
expect(queryByText(`Reported ${toRelativeTimeString(123)}`)).toBeNull(); | ||
}); | ||
|
||
it('should render last updated text if lastObserved is null', () => { | ||
const { getByText, queryByText } = render(<SchemaTimeStamps lastUpdated={123} lastObserved={null} />); | ||
expect(queryByText(`Last observed ${toRelativeTimeString(123)}`)).toBeNull(); | ||
expect(getByText(`Reported ${toRelativeTimeString(123)}`)).toBeInTheDocument(); | ||
}); | ||
|
||
it('should return null if lastUpdated and lastObserved are both null', () => { | ||
const { container } = render(<SchemaTimeStamps lastUpdated={null} lastObserved={null} />); | ||
expect(container.firstChild).toBeNull(); | ||
}); | ||
}); |
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
64 changes: 64 additions & 0 deletions
64
datahub-web-react/src/app/entity/dataset/profile/schema/components/SchemaTimeStamps.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,64 @@ | ||
import { ClockCircleOutlined } from '@ant-design/icons'; | ||
import { Popover, Typography } from 'antd'; | ||
import React from 'react'; | ||
import styled from 'styled-components/macro'; | ||
import { toLocalDateTimeString, toRelativeTimeString } from '../../../../../shared/time/timeUtils'; | ||
import { ANTD_GRAY } from '../../../../shared/constants'; | ||
|
||
const CurrentVersionTimestampText = styled(Typography.Text)` | ||
&&& { | ||
line-height: 22px; | ||
margin-top: 10px; | ||
margin-right: 10px; | ||
color: ${ANTD_GRAY[7]}; | ||
width: max-content; | ||
} | ||
`; | ||
|
||
const TimeStampWrapper = styled.div` | ||
margin-bottom: 5px; | ||
`; | ||
|
||
const StyledClockIcon = styled(ClockCircleOutlined)` | ||
margin-right: 5px; | ||
`; | ||
|
||
interface Props { | ||
lastUpdated?: number | null; | ||
lastObserved?: number | null; | ||
} | ||
|
||
function SchemaTimeStamps(props: Props) { | ||
const { lastUpdated, lastObserved } = props; | ||
|
||
if (!lastUpdated && !lastObserved) return null; | ||
|
||
return ( | ||
<Popover | ||
content={ | ||
<> | ||
{lastObserved && ( | ||
<TimeStampWrapper>Last observed on {toLocalDateTimeString(lastObserved)}.</TimeStampWrapper> | ||
)} | ||
{lastUpdated && <div>First reported on {toLocalDateTimeString(lastUpdated)}.</div>} | ||
</> | ||
} | ||
> | ||
<CurrentVersionTimestampText> | ||
{lastObserved && ( | ||
<span> | ||
<StyledClockIcon /> Last observed {toRelativeTimeString(lastObserved)} | ||
</span> | ||
)} | ||
{!lastObserved && lastUpdated && ( | ||
<span> | ||
<StyledClockIcon /> | ||
Reported {toRelativeTimeString(lastUpdated)} | ||
</span> | ||
)} | ||
</CurrentVersionTimestampText> | ||
</Popover> | ||
); | ||
} | ||
|
||
export default SchemaTimeStamps; |
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
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.