-
Notifications
You must be signed in to change notification settings - Fork 894
feat: add workspace last used #3816
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
Changes from 6 commits
aacbeb1
eeebe0c
8571215
0f31418
abbbf27
406bcbe
4c46a7a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
ALTER TABLE workspaces | ||
DROP COLUMN last_used_at; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
ALTER TABLE workspaces | ||
ADD COLUMN last_used_at timestamp NOT NULL DEFAULT '0001-01-01 00:00:00+00:00'; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { Theme, useTheme } from "@material-ui/core/styles" | ||
import { FC } from "react" | ||
|
||
import dayjs from "dayjs" | ||
import relativeTime from "dayjs/plugin/relativeTime" | ||
|
||
dayjs.extend(relativeTime) | ||
|
||
interface WorkspaceLastUsedProps { | ||
lastUsedAt: string | ||
} | ||
|
||
export const WorkspaceLastUsed: FC<WorkspaceLastUsedProps> = ({ lastUsedAt }) => { | ||
const theme: Theme = useTheme() | ||
|
||
const t = dayjs(lastUsedAt) | ||
const now = dayjs() | ||
|
||
let color = theme.palette.text.secondary | ||
let message = t.fromNow() | ||
|
||
if (t.isAfter(now.subtract(1, "hour"))) { | ||
color = theme.palette.success.main | ||
// Since the agent reports on a 10m interval, | ||
// the last_used_at can be inaccurate when recent. | ||
message = "Last Hour" | ||
} else if (t.isAfter(now.subtract(1, "day"))) { | ||
color = theme.palette.primary.main | ||
} else if (t.isAfter(now.subtract(1, "month"))) { | ||
color = theme.palette.text.secondary | ||
} else if (t.isAfter(now.subtract(100, "year"))) { | ||
color = theme.palette.warning.light | ||
} else { | ||
color = theme.palette.error.light | ||
message = "Never" | ||
} | ||
|
||
return <span style={{ color: color }}>{message}</span> | ||
} |
Uh oh!
There was an error while loading. Please reload this page.