-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
feat(ui): allow to display date in absolute format #12986
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ import * as React from 'react'; | |
|
||
import {ago} from '../duration'; | ||
|
||
export function Timestamp({date}: {date: Date | string | number}) { | ||
export function Timestamp({date, displayFullDate = false}: {date: Date | string | number; displayFullDate?: boolean}) { | ||
const tooltip = (utc: Date | string | number) => { | ||
return utc.toString() + '\n' + new Date(utc.toString()).toLocaleString(); | ||
}; | ||
|
@@ -13,7 +13,7 @@ export function Timestamp({date}: {date: Date | string | number}) { | |
'-' | ||
) : ( | ||
<span title={tooltip(date)}> | ||
<Ticker intervalMs={1000}>{() => ago(new Date(date))}</Ticker> | ||
<Ticker intervalMs={1000}>{() => (displayFullDate ? new Date(date).toISOString() : ago(new Date(date)))}</Ticker> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This displays how long ago a date was, not the date itself. If anything you'd want to do this conversion on the date after |
||
</span> | ||
)} | ||
</span> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -81,6 +81,7 @@ export function WorkflowsList({match, location, history}: RouteComponentProps<an | |
const [links, setLinks] = useState<models.Link[]>([]); | ||
const [columns, setColumns] = useState<models.Column[]>([]); | ||
const [error, setError] = useState<Error>(); | ||
const [displayFullDate, setDisplayFullDate] = useState(false); | ||
|
||
const batchActionDisabled = useMemo<Actions.OperationDisabled>(() => { | ||
const nowDisabled: any = {...allBatchActionsEnabled}; | ||
|
@@ -278,6 +279,7 @@ export function WorkflowsList({match, location, history}: RouteComponentProps<an | |
key={wf.metadata.uid} | ||
checked={selectedWorkflows.has(wf.metadata.uid)} | ||
columns={columns} | ||
displayFullDate={displayFullDate} | ||
onChange={key => { | ||
const value = `${key}=${wf.metadata?.labels[key]}`; | ||
let newLabels: string[]; | ||
|
@@ -308,6 +310,16 @@ export function WorkflowsList({match, location, history}: RouteComponentProps<an | |
); | ||
})} | ||
</div> | ||
<label htmlFor='date_format_checkbox'>Show absolute date</label> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why should this be isolated to the WorkflowsList page? There are other pages with dates. In #12943 (comment), I suggested in a global settings page, and also storing that in |
||
<input | ||
id='date_format_checkbox' | ||
type='checkbox' | ||
checked={displayFullDate} | ||
onClick={e => { | ||
e.stopPropagation(); | ||
}} | ||
onChange={() => setDisplayFullDate(!displayFullDate)} | ||
/> | ||
<PaginationPanel onChange={setPagination} pagination={pagination} numRecords={(filteredWorkflows || []).length} /> | ||
</> | ||
)} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be passed through context, as it should be a global, not a prop passed through many components