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 table // Workspace …
…redirect status column kubeflow#147 Signed-off-by: Asaad <[email protected]>
- Loading branch information
1 parent
2c05c38
commit 33af0bc
Showing
3 changed files
with
154 additions
and
13 deletions.
There are no files selected for viewing
53 changes: 53 additions & 0 deletions
53
workspaces/frontend/src/app/actions/WorkspaceKindsActions.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,53 @@ | ||
import { WorkspaceKind } from '~/shared/types'; | ||
|
||
type KindLogoDict = Record<string, string>; | ||
|
||
/** | ||
* Builds a dictionary of kind names to logos, and returns it. | ||
* @param {WorkspaceKind[]} workspaceKinds - The list of workspace kinds. | ||
* @returns {KindLogoDict} A dictionary with kind names as keys and logo URLs as values. | ||
*/ | ||
export function buildKindLogoDictionary(workspaceKinds: WorkspaceKind[] | []): KindLogoDict { | ||
const kindLogoDict: KindLogoDict = {}; | ||
|
||
for (const workspaceKind of workspaceKinds) { | ||
try { | ||
kindLogoDict[workspaceKind.name] = workspaceKind.logo.url; | ||
} catch { | ||
kindLogoDict[workspaceKind.name] = ''; | ||
} | ||
} | ||
return kindLogoDict; | ||
} | ||
|
||
type WorkspaceRedirectStatus = Record< | ||
string, | ||
{ to: string; message: string; level: string } | null | ||
>; | ||
|
||
|
||
/** | ||
* Builds a dictionary of workspace kinds to redirect statuses. | ||
* @param {WorkspaceKind[]} workspaceKinds - The list of workspace kinds. | ||
* @returns {WorkspaceRedirectStatus} A dictionary with kind names as keys and redirect status objects as values. | ||
*/ | ||
export function buildWorkspaceRedirectStatus( | ||
workspaceKinds: WorkspaceKind[] | [] | ||
): WorkspaceRedirectStatus { | ||
const workspaceRedirectStatus: WorkspaceRedirectStatus = {}; | ||
for (const workspaceKind of workspaceKinds) { | ||
// Loop through the `values` array inside `imageConfig` | ||
const redirect = workspaceKind.podTemplate?.options?.imageConfig?.values?.find( | ||
(value) => value.redirect | ||
)?.redirect; | ||
// If redirect exists, extract the necessary properties | ||
workspaceRedirectStatus[workspaceKind.name] = redirect | ||
? { | ||
to: redirect.to, | ||
message: redirect.message.text, | ||
level: redirect.message.level, | ||
} | ||
: null; | ||
} | ||
return workspaceRedirectStatus; | ||
} |
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
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