forked from kubeflow/notebooks
-
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.
feat(ws): Notebooks 2.0 // Frontend // Workspaces details // Activity…
… tab kubeflow#171 Signed-off-by: Asaad Balum <asaad.balum@gmail.com>
- Loading branch information
1 parent
f9da864
commit 263118e
Showing
2 changed files
with
54 additions
and
1 deletion.
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
52 changes: 52 additions & 0 deletions
52
workspaces/frontend/src/app/pages/Workspaces/Details/WorkspaceDetailsActivity.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,52 @@ | ||
import React from 'react'; | ||
import { | ||
DescriptionList, | ||
DescriptionListTerm, | ||
DescriptionListGroup, | ||
DescriptionListDescription, | ||
} from '@patternfly/react-core'; | ||
import { Workspace } from '~/shared/types'; | ||
|
||
type WorkspaceDetailsActivityProps = { | ||
workspace: Workspace; | ||
}; | ||
|
||
// Helper function to format UNIX timestamps | ||
const formatTimestamp = (timestamp: number): string => { | ||
if (!timestamp || timestamp === 0) { | ||
return '-'; // Return a dash if timestamp is not set | ||
} | ||
const date = new Date(timestamp * 1000); // Convert to milliseconds | ||
return date.toLocaleString(); // Format as a readable string | ||
}; | ||
|
||
export const WorkspaceDetailsActivity: React.FunctionComponent<WorkspaceDetailsActivityProps> = ({ | ||
workspace, | ||
}) => ( | ||
<DescriptionList> | ||
<DescriptionListGroup> | ||
<DescriptionListTerm>Last Activity</DescriptionListTerm> | ||
<DescriptionListDescription> | ||
{formatTimestamp(workspace.status.activity.lastActivity)} | ||
</DescriptionListDescription> | ||
</DescriptionListGroup> | ||
<DescriptionListGroup> | ||
<DescriptionListTerm>Last Update</DescriptionListTerm> | ||
<DescriptionListDescription> | ||
{formatTimestamp(workspace.status.activity.lastUpdate)} | ||
</DescriptionListDescription> | ||
</DescriptionListGroup> | ||
<DescriptionListGroup> | ||
<DescriptionListTerm>Pause Time</DescriptionListTerm> | ||
<DescriptionListDescription> | ||
{formatTimestamp(workspace.status.pauseTime)} | ||
</DescriptionListDescription> | ||
</DescriptionListGroup> | ||
<DescriptionListGroup> | ||
<DescriptionListTerm>Pending Restart</DescriptionListTerm> | ||
<DescriptionListDescription> | ||
{workspace.status.pendingRestart ? 'Yes' : 'No'} | ||
</DescriptionListDescription> | ||
</DescriptionListGroup> | ||
</DescriptionList> | ||
); |