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

Add two-line timestamp and remove dayjs #1333

Merged
merged 5 commits into from
Feb 17, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
1 change: 0 additions & 1 deletion webview/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
},
"dependencies": {
"classnames": "^2.2.6",
"dayjs": "^1.9.6",
"react": "^17.0.1",
"react-beautiful-dnd": "^13.1.0",
"react-dom": "^17.0.1",
Expand Down
10 changes: 7 additions & 3 deletions webview/src/experiments/components/Experiments/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import {
Cell
} from 'react-table'
import { MessageFromWebviewType } from 'dvc/src/webview/contract'
import dayjs from '../../dayjs'
import { Table } from '../Table'
import styles from '../Table/styles.module.scss'
import buildDynamicColumns from '../../util/buildDynamicColumns'
Expand Down Expand Up @@ -73,11 +72,16 @@ const getColumns = (columns: MetricOrParam[]): Column<Experiment>[] =>
if (!value || value === '') {
return null
}
const time = dayjs(value)
const date = new Date(value)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Might be better to push this further up into data parsing, but this will do for now

Copy link
Member

Choose a reason for hiding this comment

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

Yep definitely move it in case we need to use this timestamp somewhere else. We should also standardise all dates in the extension to look the same.

Copy link
Member

Choose a reason for hiding this comment

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

Can follow up.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can do the follow-up for pushing new Date up into webview parsing, I'm not sure where else we display date timestamps though.

return (
<span className={styles.timestampCellContentsWrapper}>
<span className={styles.cellContents}>
{time.format(time.isToday() ? 'HH:mm:ss' : 'YYYY/MM/DD')}
<div className={styles.timestampTime}>
{date.toLocaleTimeString()}
</div>
<div className={styles.timestampDate}>
{date.toLocaleDateString()}
</div>
</span>
</span>
)
Expand Down
16 changes: 13 additions & 3 deletions webview/src/experiments/components/Table/styles.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ $spinner-color-light: #000;
}

%truncateLeftChild {
overflow: hidden;
text-overflow: ellipsis;
Comment on lines +61 to +62
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This fixes ellipsis truncation in the nested timestamp divs

unicode-bidi: isolate;
direction: ltr;
}
Expand Down Expand Up @@ -519,6 +521,7 @@ $spinner-color-light: #000;
padding: 0 $cell-padding;
align-items: center;
width: 100%;
height: 100%;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This fixes vertical centering in cells whose contents aren't full height via line-height

justify-content: flex-end;
&:hover {
& .copyButton {
Expand Down Expand Up @@ -547,8 +550,15 @@ $spinner-color-light: #000;
}

.timestampCellContentsWrapper {
line-height: normal;
@extend %truncateLeftParent;
.cellContents {
@extend %truncateLeftChild;
}
}

.timestampDate {
@extend %truncateLeftChild;
font-size: 0.7em;
}
.timestampTime {
@extend %truncateLeftChild;
font-size: 0.9em;
}
7 changes: 0 additions & 7 deletions webview/src/experiments/dayjs.tsx

This file was deleted.

5 changes: 0 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6533,11 +6533,6 @@ data-urls@^2.0.0:
whatwg-mimetype "^2.3.0"
whatwg-url "^8.0.0"

dayjs@^1.9.6:
version "1.10.7"
resolved "https://registry.yarnpkg.com/dayjs/-/dayjs-1.10.7.tgz#2cf5f91add28116748440866a0a1d26f3a6ce468"
integrity sha512-P6twpd70BcPK34K26uJ1KT3wlhpuOAPoMwJzpsIWUxHZ7wpmbdZL/hQqBDfz7hGurYSa5PhzdhDHtt319hL3ig==

debug@2.6.9, debug@^2.2.0, debug@^2.3.3, debug@^2.6.0, debug@^2.6.9:
version "2.6.9"
resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f"
Expand Down