From f699dcec21d74d547f72ba624529d7e4d1d5babf Mon Sep 17 00:00:00 2001 From: Christian Vogt Date: Fri, 28 Jul 2023 13:08:23 -0400 Subject: [PATCH] show event details without last activity timestamp --- frontend/src/pages/projects/notebook/utils.ts | 6 +++++- frontend/src/types.ts | 1 + frontend/src/utilities/notebookControllerUtils.ts | 13 +++++++++---- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/frontend/src/pages/projects/notebook/utils.ts b/frontend/src/pages/projects/notebook/utils.ts index 4619b959f7..5a361cbe20 100644 --- a/frontend/src/pages/projects/notebook/utils.ts +++ b/frontend/src/pages/projects/notebook/utils.ts @@ -124,7 +124,11 @@ export const useNotebookStatus = ( const events = useWatchNotebookEvents(notebook.metadata.namespace, podUid, spawnInProgress); const annotationTime = notebook?.metadata.annotations?.['notebooks.kubeflow.org/last-activity']; - const lastActivity = annotationTime ? new Date(annotationTime) : null; + const lastActivity = annotationTime + ? new Date(annotationTime) + : spawnInProgress || podUid + ? new Date(notebook.metadata.creationTimestamp ?? 0) + : null; if (!lastActivity) { // Notebook not started, we don't have a filter time, ignore diff --git a/frontend/src/types.ts b/frontend/src/types.ts index 75e6d1177a..4781bc9072 100644 --- a/frontend/src/types.ts +++ b/frontend/src/types.ts @@ -284,6 +284,7 @@ type K8sMetadata = { uid?: string; labels?: { [key: string]: string }; annotations?: { [key: string]: string }; + creationTimestamp?: string; }; /** diff --git a/frontend/src/utilities/notebookControllerUtils.ts b/frontend/src/utilities/notebookControllerUtils.ts index e643421dd0..1ae210e8f2 100644 --- a/frontend/src/utilities/notebookControllerUtils.ts +++ b/frontend/src/utilities/notebookControllerUtils.ts @@ -330,10 +330,15 @@ export const useNotebookStatus = ( evt.involvedObject.uid === currentUserNotebookPodUID, ); - const lastActivity = useLastActivity( - open, - notebook?.metadata.annotations?.['notebooks.kubeflow.org/last-activity'], - ); + const lastActivity = + useLastActivity( + open, + notebook?.metadata.annotations?.['notebooks.kubeflow.org/last-activity'], + ) || + (notebook && (spawnInProgress || isNotebookRunning) + ? new Date(notebook.metadata.creationTimestamp ?? 0) + : null); + if (!lastActivity) { // Notebook not started, we don't have a filter time, ignore return [null, []];