From a79783a6349a1157c1c82f005a8ca165d8fb0c6a Mon Sep 17 00:00:00 2001 From: "Cornelius A. Ludmann" Date: Mon, 7 Jun 2021 14:15:20 +0000 Subject: [PATCH] [dashboard] Add workspace status indicator color red for failed status --- .../src/workspaces/WorkspaceEntry.tsx | 22 ++++++++++++++----- .../gitpod-protocol/src/workspace-instance.ts | 14 ++++++------ 2 files changed, 24 insertions(+), 12 deletions(-) diff --git a/components/dashboard/src/workspaces/WorkspaceEntry.tsx b/components/dashboard/src/workspaces/WorkspaceEntry.tsx index 89faa69d7855fb..c69476265e6926 100644 --- a/components/dashboard/src/workspaces/WorkspaceEntry.tsx +++ b/components/dashboard/src/workspaces/WorkspaceEntry.tsx @@ -4,7 +4,7 @@ * See License-AGPL.txt in the project root for license information. */ -import { CommitContext, Workspace, WorkspaceInfo, WorkspaceInstance, WorkspaceInstancePhase } from '@gitpod/gitpod-protocol'; +import { CommitContext, Workspace, WorkspaceInfo, WorkspaceInstance, WorkspaceInstanceConditions, WorkspaceInstancePhase } from '@gitpod/gitpod-protocol'; import { GitpodHostUrl } from '@gitpod/gitpod-protocol/lib/util/gitpod-host-url'; import moment from 'moment'; import React, { useState } from 'react'; @@ -15,8 +15,11 @@ import PendingChangesDropdown from '../components/PendingChangesDropdown'; import Tooltip from '../components/Tooltip'; import { WorkspaceModel } from './workspace-model'; -function getLabel(state: WorkspaceInstancePhase) { - return state.substr(0,1).toLocaleUpperCase() + state.substr(1); +function getLabel(state: WorkspaceInstancePhase, conditions?: WorkspaceInstanceConditions) { + if (conditions?.failed) { + return "Failed"; + } + return state.substr(0, 1).toLocaleUpperCase() + state.substr(1); } interface Props { @@ -131,6 +134,7 @@ export function getProject(ws: Workspace) { export function WorkspaceStatusIndicator({instance}: {instance?: WorkspaceInstance}) { const state: WorkspaceInstancePhase = instance?.status?.phase || 'stopped'; + const conditions = instance?.status?.conditions; let stateClassName = 'rounded-full w-3 h-3 text-sm align-middle'; switch (state) { case 'running': { @@ -138,20 +142,28 @@ export function WorkspaceStatusIndicator({instance}: {instance?: WorkspaceInstan break; } case 'stopped': { - stateClassName += ' bg-gray-400' + if (conditions?.failed) { + stateClassName += ' bg-red-400' + } else { + stateClassName += ' bg-gray-400' + } break; } case 'interrupted': { stateClassName += ' bg-red-400' break; } + case 'unknown': { + stateClassName += ' bg-red-400' + break; + } default: { stateClassName += ' bg-gitpod-kumquat animate-pulse' break; } } return
- +
; diff --git a/components/gitpod-protocol/src/workspace-instance.ts b/components/gitpod-protocol/src/workspace-instance.ts index af53ed3184184a..7d965dd034ecbb 100644 --- a/components/gitpod-protocol/src/workspace-instance.ts +++ b/components/gitpod-protocol/src/workspace-instance.ts @@ -83,7 +83,7 @@ export interface WorkspaceInstanceStatus { // WorkspaceInstancePhase describes a high-level state of a workspace instance export type WorkspaceInstancePhase = // unknown indicates an issue within the system in that it cannot determine the actual phase of - // a workspace. This phase is usually accompanied by an error. + // a workspace. This phase is usually accompanied by an error. "unknown" | // Preparing means that we haven't actually started the workspace instance just yet, but rather @@ -91,21 +91,21 @@ export type WorkspaceInstancePhase = "preparing" | // Pending means the workspace does not yet consume resources in the cluster, but rather is looking for - // some space within the cluster. If for example the cluster needs to scale up to accomodate the - // workspace, the workspace will be in Pending state until that happened. + // some space within the cluster. If for example the cluster needs to scale up to accomodate the + // workspace, the workspace will be in Pending state until that happened. "pending" | // Creating means the workspace is currently being created. Thati includes downloading the images required - // to run the workspace over the network. The time spent in this phase varies widely and depends on the current - // network speed, image size and cache states. + // to run the workspace over the network. The time spent in this phase varies widely and depends on the current + // network speed, image size and cache states. "creating" | // Initializing is the phase in which the workspace is executing the appropriate workspace initializer (e.g. Git - // clone or backup download). After this phase one can expect the workspace to either be Running or Failed. + // clone or backup download). After this phase one can expect the workspace to either be Running or Failed. "initializing" | // Running means the workspace is able to actively perform work, either by serving a user through Theia, - // or as a headless workspace. + // or as a headless workspace. "running" | // Interrupted is an exceptional state where the container should be running but is temporarily unavailable.