Skip to content

[dashboard] Add workspace status indicator color red for failed status #4378

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

Merged
merged 1 commit into from
Jun 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 17 additions & 5 deletions components/dashboard/src/workspaces/WorkspaceEntry.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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 {
Expand Down Expand Up @@ -131,27 +134,36 @@ 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': {
stateClassName += ' bg-green-500'
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 <div className="m-auto">
<Tooltip content={getLabel(state)}>
<Tooltip content={getLabel(state, conditions)}>
<div className={stateClassName} />
</Tooltip>
</div>;
Expand Down
14 changes: 7 additions & 7 deletions components/gitpod-protocol/src/workspace-instance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,29 +83,29 @@ 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
// are still preparing for launch. This means we're building the Docker image for the workspace.
"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.
Expand Down