Deploy console
Move through services, menus and commands without leaving the keyboard. Promotions and rollbacks run on sample data.
Built with
Try it with the keyboard
- Press Tab until the Commands button has focus, then press Ctrl+K to open the command palette. The shortcut works anywhere inside the console; outside it, Ctrl+K still opens the docs search.
- Type
promote checkoutand press Enter. The rollout bar fills, and a status message says when the release is live. - Press Ctrl+K again, type
edge-gateway stagingand press Enter to jump to that service. Focus lands on its row in the service tree. - Press Shift+F10 to open the row’s context menu, move with ↓, and press Esc to close it. Focus returns to the row.
- Press Shift+Tab to reach the menubar, then use → and ↓ to open the View menu and choose Logs.
Deploy console
Northstar Studio · Promote, roll back and inspect services.
- checkout-api
- edge-gateway
- media-worker
checkout-api production · us-east
Livedep-3108- Release
- v2.14.0
8c41f2a - Serving
- v2.14.0
8c41f2a - Previous release
- v2.13.2
- Channel
- production
- Region
- us-east
- Started
- Nov 18, 09:42 by Maya Okafor
- Build command
pnpm build- Health check
/healthz- Rollback window
- 24 hours
Settings apply to every channel of checkout-api. This sample shows them read-only.
vue
<script setup lang="ts">
import {
computed,
nextTick,
onBeforeUnmount,
onMounted,
ref,
shallowRef,
useId,
useTemplateRef,
} from 'vue'
import {
GhostBadge,
GhostButton,
GhostCommandPalette,
GhostCommandPaletteContent,
GhostCommandPaletteEmpty,
GhostCommandPaletteGroup,
GhostCommandPaletteInput,
GhostCommandPaletteItem,
GhostCommandPaletteLabel,
GhostCommandPaletteList,
GhostCommandPaletteOverlay,
GhostCommandPaletteSeparator,
GhostCommandPaletteTitle,
GhostCommandPaletteTrigger,
GhostContextMenu,
GhostContextMenuContent,
GhostContextMenuItem,
GhostContextMenuLabel,
GhostContextMenuSeparator,
GhostContextMenuTrigger,
GhostKbd,
GhostMenubar,
GhostMenubarContent,
GhostMenubarItem,
GhostMenubarMenu,
GhostMenubarRadioGroup,
GhostMenubarRadioItem,
GhostMenubarSeparator,
GhostMenubarTrigger,
GhostTree,
GhostTreeGroup,
GhostTreeItem,
GhostTreeTrigger,
useGhostToast,
type GhostCommandPaletteCommandPayload,
type GhostTreeValue,
} from '@ghostvue/themes'
import DeploymentDetail from './DeploymentDetail.vue'
import {
canRun,
deploymentStatusTones,
initialDeployments,
nextDeploymentId,
productionFor,
projects,
slotLabel,
workspaceName,
type Deployment,
type DeploymentAction,
type DeploymentStatus,
type DetailTab,
} from './deployments'
import './deploy-console.css'
const { toast } = useGhostToast()
const prefix = useId()
const frame = useTemplateRef<HTMLElement>('frame')
const deployments = shallowRef<readonly Deployment[]>(initialDeployments)
const selectedSlot = ref('checkout-api/production/us-east')
const expanded = ref<string[]>([...projects])
const tab = ref<DetailTab>('overview')
/*
* Below the two-column width the service tree collapses behind the Services
* button. CSS decides the width (a container query on the console), so this
* flag only matters while the console is narrow.
*/
const treeOpen = ref(false)
const paletteOpen = ref(false)
const search = ref('')
const announcement = ref('')
const selected = computed(() =>
deployments.value.find((entry) => entry.slot === selectedSlot.value),
)
function deploymentsOf(project: string): Deployment[] {
return deployments.value.filter((entry) => entry.project === project)
}
const actionOrder = ['promote', 'rollback', 'redeploy'] as const
function actionsFor(entry: Deployment): DeploymentAction[] {
return actionOrder.filter((action) =>
canRun(deployments.value, entry, action),
)
}
const selectedActions = computed(() =>
selected.value ? actionsFor(selected.value) : [],
)
/** Visible action label for menus, which already name the deployment. */
const menuLabels = {
promote: 'Promote to production',
rollback: 'Roll back',
redeploy: 'Redeploy',
} as const satisfies Record<DeploymentAction, string>
/** Palette label: the palette lists every deployment, so it names one. */
function paletteLabel(entry: Deployment, action: DeploymentAction): string {
switch (action) {
case 'promote':
return `Promote ${entry.project} ${entry.release.version} to production`
case 'rollback':
return `Roll back ${entry.project} production to ${entry.previous?.version ?? ''}`
case 'redeploy':
return `Redeploy ${entry.project} ${entry.channel}`
}
}
// ---------------------------------------------------------------------------
// Rollouts
// ---------------------------------------------------------------------------
/** Percent rolled out per slot while it is Building. */
const rollouts = ref<Record<string, number>>({})
const timers = new Map<string, ReturnType<typeof setInterval>>()
const ROLLOUT_STEP_MS = 600
const ROLLOUT_STEP_PERCENT = 20
const rolloutSteps = [
'Build finished',
'Starting instances',
'Health check passed',
'Shifting traffic',
'Rollout complete',
] as const
function replace(slot: string, change: (entry: Deployment) => Deployment) {
deployments.value = deployments.value.map((entry) =>
entry.slot === slot ? change(entry) : entry,
)
}
/** Clears the region first so a repeated message is announced again. */
async function announce(message: string): Promise<void> {
announcement.value = ''
await nextTick()
announcement.value = message
}
/**
* Advances a slot that was just set to Building in fixed steps, appending a
* log line per step. `finish` gives the deployment its final status and
* fields, and the polite status region then says it is done.
*/
function startRollout(
slot: string,
finish: (entry: Deployment) => Deployment,
doneMessage: (entry: Deployment) => string,
): void {
rollouts.value = { ...rollouts.value, [slot]: 0 }
let step = 0
const timer = setInterval(() => {
const line = rolloutSteps[step] ?? 'Rollout complete'
step += 1
const percent = Math.min(100, step * ROLLOUT_STEP_PERCENT)
replace(slot, (entry) => ({ ...entry, logs: [...entry.logs, line] }))
if (percent < 100) {
rollouts.value = { ...rollouts.value, [slot]: percent }
return
}
clearInterval(timer)
timers.delete(slot)
rollouts.value = Object.fromEntries(
Object.entries(rollouts.value).filter(([key]) => key !== slot),
)
replace(slot, finish)
const done = deployments.value.find((entry) => entry.slot === slot)
if (done) void announce(doneMessage(done))
}, ROLLOUT_STEP_MS)
timers.set(slot, timer)
}
function run(entry: Deployment, action: DeploymentAction): void {
// Menus and the palette are built from the same rule, but the data can
// change between rendering a command and choosing it.
if (!canRun(deployments.value, entry, action)) return
const building: DeploymentStatus = 'Building'
if (action === 'promote') {
const target = productionFor(deployments.value, entry)
if (!target) return
const release = entry.release
replace(target.slot, (current) => ({
...current,
id: nextDeploymentId(deployments.value),
release,
previous: current.serving ?? current.release,
// The old release keeps serving until the rollout finishes.
serving: current.serving ?? current.release,
status: building,
author: 'You',
started: 'Just now',
logs: [`Promoting ${release.version} from staging`],
}))
void announce(
`Promoting ${entry.project} ${release.version} to ${slotLabel(target)}`,
)
startRollout(
target.slot,
(current) => ({ ...current, status: 'Live', serving: undefined }),
(done) =>
`${done.project} ${done.release.version} is live on ${slotLabel(done)}`,
)
return
}
if (action === 'rollback') {
const previous = entry.previous
if (!previous) return
replace(entry.slot, (current) => ({
...current,
status: building,
serving: current.release,
logs: [...current.logs, `Rolling back to ${previous.version}`],
}))
void announce(`Rolling back ${entry.project} to ${previous.version}`)
startRollout(
entry.slot,
(current) => ({
...current,
status: 'Rolled back',
serving: previous,
previous: undefined,
}),
(done) =>
`${done.project} rolled back. ${previous.version} is serving ${slotLabel(done)}`,
)
return
}
replace(entry.slot, (current) => ({
...current,
id: nextDeploymentId(deployments.value),
status: building,
author: 'You',
started: 'Just now',
logs: [`Redeploying ${current.release.version}`],
}))
void announce(`Redeploying ${entry.project} ${entry.channel}`)
startRollout(
entry.slot,
(current) => ({ ...current, status: 'Live' }),
(done) =>
`${done.project} ${done.release.version} is live on ${slotLabel(done)}`,
)
}
function runOnSelected(action: DeploymentAction): void {
if (selected.value) run(selected.value, action)
}
onBeforeUnmount(() => {
for (const timer of timers.values()) clearInterval(timer)
timers.clear()
})
async function copyId(entry: Deployment | undefined): Promise<void> {
if (!entry) return
try {
await navigator.clipboard.writeText(entry.id)
toast({ title: 'Deployment ID copied', description: entry.id })
} catch {
toast({
title: 'Could not copy',
description: `The browser blocked the clipboard. The ID is ${entry.id}.`,
})
}
}
// ---------------------------------------------------------------------------
// Tree
// ---------------------------------------------------------------------------
/**
* Only deployment rows hold a selection; a project row just groups them.
* The tree is controlled, so ignoring a project value keeps the current
* deployment selected.
*/
function selectSlot(value: GhostTreeValue): void {
if (typeof value !== 'string') return
if (deployments.value.some((entry) => entry.slot === value))
selectedSlot.value = value
}
function treeItemFor(slot: string): HTMLElement | null {
return (
frame.value?.querySelector<HTMLElement>(
`[role="treeitem"][data-ghost-tree-value="${CSS.escape(slot)}"]`,
) ?? null
)
}
/** Opens the tree (when narrow) with the slot's project expanded and in view. */
function revealSlot(slot: string): void {
const entry = deployments.value.find((item) => item.slot === slot)
if (!entry) return
selectedSlot.value = slot
treeOpen.value = true
if (!expanded.value.includes(entry.project))
expanded.value = [...expanded.value, entry.project]
}
async function focusServices(): Promise<void> {
revealSlot(selectedSlot.value)
await nextTick()
treeItemFor(selectedSlot.value)?.focus()
}
function setAllExpanded(open: boolean): void {
expanded.value = open ? [...projects] : []
}
// ---------------------------------------------------------------------------
// Command palette
// ---------------------------------------------------------------------------
interface PaletteCommand {
id: string
label: string
hint?: string
run: () => void
}
/** Slot to focus once the palette closes after a Go to command. */
let jumpTarget: string | undefined
/**
* Set when Go > Command palette opens the palette. The menu item that
* opened it is gone by then, so the palette would otherwise have nowhere to
* return focus; the Go button is where the reader came from.
*/
let openedFromMenu = false
async function openPaletteFromMenu(): Promise<void> {
// Let the menu close and hand focus back to the Go button first.
await nextTick()
openedFromMenu = true
paletteOpen.value = true
}
const commandGroups = computed(() => {
const goTo: PaletteCommand[] = deployments.value.map((entry) => ({
id: `go:${entry.slot}`,
label: `${entry.project} ${slotLabel(entry)}`,
hint: entry.status,
run: () => {
revealSlot(entry.slot)
jumpTarget = entry.slot
},
}))
const actions: PaletteCommand[] = deployments.value.flatMap((entry) =>
actionsFor(entry).map((action) => ({
id: `${action}:${entry.slot}`,
label: paletteLabel(entry, action),
run: () => {
run(entry, action)
},
})),
)
const view: PaletteCommand[] = (
[
['overview', 'Show overview'],
['logs', 'Show logs'],
['settings', 'Show settings'],
] as const
).map(([value, label]) => ({
id: `tab:${value}`,
label,
run: () => {
tab.value = value
},
}))
return [
{ id: 'actions', label: 'Actions', commands: actions },
{ id: 'go', label: 'Go to service', commands: goTo },
{ id: 'view', label: 'View', commands: view },
]
})
/** Every word of the query must appear in the label, in any order. */
const visibleGroups = computed(() => {
const words = search.value.trim().toLowerCase().split(/\s+/).filter(Boolean)
return commandGroups.value
.map((group) => ({
...group,
commands: group.commands.filter((command) => {
const label = command.label.toLowerCase()
return words.every((word) => label.includes(word))
}),
}))
.filter((group) => group.commands.length > 0)
})
function onCommand({ id }: GhostCommandPaletteCommandPayload): void {
jumpTarget = undefined
commandGroups.value
.flatMap((group) => group.commands)
.find((command) => command.id === id)
?.run()
}
/**
* After a Go to command, focus lands on that service's tree row instead of
* where the palette was opened, so Shift+F10 or the arrow keys act on it
* next. Other commands fall back to the opener.
*/
function paletteReturnFocus(): HTMLElement | null {
const slot = jumpTarget
const fromMenu = openedFromMenu
jumpTarget = undefined
openedFromMenu = false
if (slot) return treeItemFor(slot)
return fromMenu ? document.getElementById(`${prefix}-go`) : null
}
/*
* Ctrl/⌘+K opens the palette, but only while focus is inside this console.
* The docs site binds the same keys to its search on `window` and does not
* check `defaultPrevented`, so the console claims the press in the capture
* phase, before any bubbling listener runs, and stops it there. Presses
* outside the console reach the docs search unchanged.
*
* The palette and menus render in a layer on `<body>`, outside the console
* element, and carry `deploy-console-layer`. A press inside them is also
* the console's: it is swallowed so docs search never opens over the
* console's own overlay.
*/
function onShortcut(event: KeyboardEvent): void {
if (
event.defaultPrevented ||
event.isComposing ||
event.altKey ||
event.shiftKey ||
!(event.ctrlKey || event.metaKey) ||
event.key.toLowerCase() !== 'k'
)
return
const target = event.target
const root = frame.value
if (!root || !(target instanceof Element)) return
const inConsole = root.contains(target)
if (!inConsole && !target.closest('.deploy-console-layer')) return
event.preventDefault()
event.stopPropagation()
if (inConsole) paletteOpen.value = true
}
onMounted(() => {
window.addEventListener('keydown', onShortcut, { capture: true })
})
onBeforeUnmount(() => {
window.removeEventListener('keydown', onShortcut, { capture: true })
})
function tone(status: DeploymentStatus) {
return deploymentStatusTones[status]
}
function setTab(value: string): void {
if (value === 'overview' || value === 'logs' || value === 'settings')
tab.value = value
}
</script>
<template>
<section
ref="frame"
class="deploy-console"
aria-labelledby="deploy-console-title"
>
<header class="deploy-console__heading">
<div>
<h2 id="deploy-console-title">Deploy console</h2>
<p>{{ workspaceName }} · Promote, roll back and inspect services.</p>
</div>
<GhostCommandPalette
v-model:open="paletteOpen"
v-model:search="search"
@command="onCommand"
>
<GhostCommandPaletteTrigger
:as="GhostButton"
variant="outline"
size="sm"
aria-keyshortcuts="Control+K Meta+K"
>
Commands
<GhostKbd size="sm" :keys="['mod', 'k']" />
</GhostCommandPaletteTrigger>
<GhostCommandPaletteOverlay />
<GhostCommandPaletteContent
class="deploy-console-layer deploy-palette"
:return-focus="paletteReturnFocus"
>
<GhostCommandPaletteTitle>Deploy commands</GhostCommandPaletteTitle>
<GhostCommandPaletteInput placeholder="Search services and actions" />
<GhostCommandPaletteList class="deploy-palette__list">
<template v-for="(group, index) in visibleGroups" :key="group.id">
<GhostCommandPaletteSeparator v-if="index > 0" />
<GhostCommandPaletteGroup>
<GhostCommandPaletteLabel>{{
group.label
}}</GhostCommandPaletteLabel>
<GhostCommandPaletteItem
v-for="command in group.commands"
:id="command.id"
:key="command.id"
:text-value="command.label"
>
<span class="deploy-palette__label">{{ command.label }}</span>
<span v-if="command.hint" class="deploy-palette__hint">{{
command.hint
}}</span>
</GhostCommandPaletteItem>
</GhostCommandPaletteGroup>
</template>
<GhostCommandPaletteEmpty
>No services or actions match. Try a project name such as
checkout-api.</GhostCommandPaletteEmpty
>
</GhostCommandPaletteList>
<div class="deploy-palette__footer">
<span><GhostKbd keys="up" /> <GhostKbd keys="down" /> to move</span>
<span><GhostKbd keys="enter" /> to run</span>
<span><GhostKbd keys="esc" /> to close</span>
</div>
</GhostCommandPaletteContent>
</GhostCommandPalette>
</header>
<div class="deploy-console__bar">
<GhostMenubar class="deploy-menubar" aria-label="Console">
<GhostMenubarMenu>
<GhostMenubarTrigger :as="GhostButton" variant="ghost" size="sm"
>Deployment</GhostMenubarTrigger
>
<GhostMenubarContent
class="deploy-console-layer"
aria-label="Deployment"
:offset="6"
>
<GhostMenubarItem
:disabled="!selectedActions.includes('promote')"
@select="runOnSelected('promote')"
>Promote to production</GhostMenubarItem
>
<GhostMenubarItem
:disabled="!selectedActions.includes('rollback')"
@select="runOnSelected('rollback')"
>Roll back</GhostMenubarItem
>
<GhostMenubarItem
:disabled="!selectedActions.includes('redeploy')"
@select="runOnSelected('redeploy')"
>Redeploy</GhostMenubarItem
>
<GhostMenubarSeparator decorative />
<GhostMenubarItem @select="copyId(selected)"
>Copy deployment ID</GhostMenubarItem
>
</GhostMenubarContent>
</GhostMenubarMenu>
<GhostMenubarMenu>
<GhostMenubarTrigger :as="GhostButton" variant="ghost" size="sm"
>View</GhostMenubarTrigger
>
<GhostMenubarContent
class="deploy-console-layer"
aria-label="View"
:offset="6"
>
<GhostMenubarRadioGroup
:model-value="tab"
@update:model-value="setTab"
>
<GhostMenubarRadioItem value="overview">
<span class="deploy-menu__indicator" aria-hidden="true">{{
tab === 'overview' ? '●' : ''
}}</span>
Overview
</GhostMenubarRadioItem>
<GhostMenubarRadioItem value="logs">
<span class="deploy-menu__indicator" aria-hidden="true">{{
tab === 'logs' ? '●' : ''
}}</span>
Logs
</GhostMenubarRadioItem>
<GhostMenubarRadioItem value="settings">
<span class="deploy-menu__indicator" aria-hidden="true">{{
tab === 'settings' ? '●' : ''
}}</span>
Settings
</GhostMenubarRadioItem>
</GhostMenubarRadioGroup>
<GhostMenubarSeparator decorative />
<GhostMenubarItem @select="setAllExpanded(true)"
>Expand all services</GhostMenubarItem
>
<GhostMenubarItem @select="setAllExpanded(false)"
>Collapse all services</GhostMenubarItem
>
</GhostMenubarContent>
</GhostMenubarMenu>
<GhostMenubarMenu>
<GhostMenubarTrigger
:id="`${prefix}-go`"
:as="GhostButton"
variant="ghost"
size="sm"
>Go</GhostMenubarTrigger
>
<GhostMenubarContent
class="deploy-console-layer"
aria-label="Go"
:offset="6"
>
<GhostMenubarItem
aria-haspopup="dialog"
@select="openPaletteFromMenu"
>
<span class="deploy-menu__label">Command palette…</span>
<GhostKbd size="sm" :keys="['mod', 'k']" />
</GhostMenubarItem>
<GhostMenubarItem @select="focusServices"
>Services</GhostMenubarItem
>
</GhostMenubarContent>
</GhostMenubarMenu>
</GhostMenubar>
<GhostButton
class="deploy-console__services-toggle"
variant="outline"
tone="neutral"
size="sm"
:aria-expanded="treeOpen"
:aria-controls="`${prefix}-services`"
@click="treeOpen = !treeOpen"
>Services</GhostButton
>
</div>
<div class="deploy-console__body">
<div
:id="`${prefix}-services`"
class="deploy-console__services"
:data-open="treeOpen"
>
<!--
Each deployment row is its own context-menu target: the trigger
renders as the tree item, so the row keeps the tree's single roving
tab stop and Shift+F10 or the Menu key opens the menu on the
focused row, with focus returning to it on close.
-->
<GhostTree
v-model:expanded="expanded"
class="deploy-tree"
aria-label="Services"
:model-value="selectedSlot"
:expand-on-click="true"
@update:model-value="selectSlot"
>
<GhostTreeItem
v-for="project in projects"
:key="project"
:value="project"
>
<template #default="{ expanded: open }">
<GhostTreeTrigger>
<span
class="deploy-tree__chevron"
:data-open="open"
aria-hidden="true"
>›</span
>
<span class="deploy-tree__project">{{ project }}</span>
</GhostTreeTrigger>
<GhostTreeGroup>
<GhostContextMenu
v-for="entry in deploymentsOf(project)"
:key="entry.slot"
>
<GhostContextMenuTrigger
:as="GhostTreeItem"
:value="entry.slot"
class="deploy-tree__deployment"
>
<GhostTreeTrigger>
<span class="deploy-tree__slot">{{
slotLabel(entry)
}}</span>
<GhostBadge
:tone="tone(entry.status)"
variant="soft"
size="sm"
>{{ entry.status }}</GhostBadge
>
</GhostTreeTrigger>
</GhostContextMenuTrigger>
<GhostContextMenuContent
class="deploy-console-layer"
:aria-label="`Actions for ${entry.project} ${slotLabel(entry)}`"
>
<GhostContextMenuLabel
>{{ entry.project }}
{{ slotLabel(entry) }}</GhostContextMenuLabel
>
<GhostContextMenuSeparator decorative />
<GhostContextMenuItem
v-for="action in actionsFor(entry)"
:key="action"
@select="run(entry, action)"
>{{ menuLabels[action] }}</GhostContextMenuItem
>
<GhostContextMenuItem
@select="
() => {
selectedSlot = entry.slot
tab = 'logs'
}
"
>View logs</GhostContextMenuItem
>
<GhostContextMenuItem @select="copyId(entry)"
>Copy deployment ID</GhostContextMenuItem
>
</GhostContextMenuContent>
</GhostContextMenu>
</GhostTreeGroup>
</template>
</GhostTreeItem>
</GhostTree>
</div>
<DeploymentDetail
v-if="selected"
v-model:tab="tab"
class="deploy-console__detail"
:deployment="selected"
:progress="rollouts[selected.slot]"
:actions="selectedActions"
@run="runOnSelected"
@copy-id="copyId(selected)"
/>
</div>
<!-- Polite: rollout start and completion wait for the reader to pause. -->
<p class="deploy-visually-hidden" role="status">{{ announcement }}</p>
</section>
</template>vue
<script setup lang="ts">
import { computed, useId } from 'vue'
import {
GhostBadge,
GhostButton,
GhostProgress,
GhostScrollArea,
GhostTabs,
GhostTabsContent,
GhostTabsList,
GhostTabsTrigger,
GhostTooltip,
GhostTooltipContent,
GhostTooltipTrigger,
} from '@ghostvue/themes'
import {
deploymentStatusTones,
projectSettings,
slotLabel,
type Deployment,
type DeploymentAction,
type DetailTab,
} from './deployments'
const props = defineProps<{
deployment: Deployment
/** Rollout percentage while the deployment is Building. */
progress: number | undefined
/** Actions that apply now, in the order the buttons show them. */
actions: readonly DeploymentAction[]
}>()
const tab = defineModel<DetailTab>('tab', { required: true })
const emit = defineEmits<{
run: [action: DeploymentAction]
copyId: []
}>()
const headingId = useId()
const actionLabels = {
promote: 'Promote to production',
rollback: 'Roll back',
redeploy: 'Redeploy',
} as const satisfies Record<DeploymentAction, string>
const settings = computed(() => projectSettings[props.deployment.project])
/**
* What serves traffic on this slot: an explicit `serving` release (during a
* rollout or after a rollback), else the release itself once it is Live.
* A Queued or Failed deployment serves nothing yet.
*/
const serving = computed(
() =>
props.deployment.serving ??
(props.deployment.status === 'Live' ? props.deployment.release : undefined),
)
</script>
<template>
<section class="deploy-detail" :aria-labelledby="headingId">
<header class="deploy-detail__header">
<div class="deploy-detail__title">
<h3 :id="headingId">
{{ deployment.project }}
<span class="deploy-detail__slot">{{ slotLabel(deployment) }}</span>
</h3>
<GhostBadge
:tone="deploymentStatusTones[deployment.status]"
variant="soft"
size="sm"
>{{ deployment.status }}</GhostBadge
>
</div>
<div class="deploy-detail__id">
<code>{{ deployment.id }}</code>
<!--
Icon-only button: the name carries the action, and the tooltip
shows the same words to sighted pointer and keyboard users.
-->
<GhostTooltip>
<GhostTooltipTrigger
:as="GhostButton"
variant="ghost"
tone="neutral"
size="sm"
icon-only
aria-label="Copy deployment ID"
@click="emit('copyId')"
>
<svg
data-part="icon"
aria-hidden="true"
focusable="false"
viewBox="0 0 16 16"
fill="none"
stroke="currentColor"
stroke-width="1.5"
>
<rect x="5.5" y="5.5" width="8" height="8" rx="1.5" />
<path
d="M10.5 3.5v-1a1 1 0 0 0-1-1h-6a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h1"
/>
</svg>
</GhostTooltipTrigger>
<GhostTooltipContent placement="top" :offset="6"
>Copy deployment ID</GhostTooltipContent
>
</GhostTooltip>
</div>
</header>
<!--
While a rollout runs, the bar sits above the tabs so it stays in view
on every tab. Completion is announced by the console's polite status
region, not by the bar, so the reader hears one message.
-->
<div v-if="progress !== undefined" class="deploy-detail__progress">
<GhostProgress
:label="`Rolling out ${deployment.release.version} to ${slotLabel(deployment)}`"
:value="progress"
:max="100"
:value-text="`${String(progress)}% rolled out`"
/>
<span class="deploy-detail__progress-text" aria-hidden="true"
>{{ progress }}% rolled out</span
>
</div>
<GhostTabs v-model="tab">
<div class="deploy-detail__tabs">
<GhostTabsList aria-label="Deployment">
<GhostTabsTrigger value="overview">Overview</GhostTabsTrigger>
<GhostTabsTrigger value="logs">Logs</GhostTabsTrigger>
<GhostTabsTrigger value="settings">Settings</GhostTabsTrigger>
</GhostTabsList>
<GhostTabsContent value="overview" class="deploy-detail__panel">
<dl class="deploy-facts">
<div>
<dt>Release</dt>
<dd>
{{ deployment.release.version }}
<code>{{ deployment.release.commit }}</code>
</dd>
</div>
<div>
<dt>Serving</dt>
<dd v-if="serving">
{{ serving.version }}
<code>{{ serving.commit }}</code>
</dd>
<dd v-else>Nothing yet</dd>
</div>
<div>
<dt>Previous release</dt>
<dd>{{ deployment.previous?.version ?? 'None kept' }}</dd>
</div>
<div>
<dt>Channel</dt>
<dd>{{ deployment.channel }}</dd>
</div>
<div>
<dt>Region</dt>
<dd>{{ deployment.region }}</dd>
</div>
<div>
<dt>Started</dt>
<dd>{{ deployment.started }} by {{ deployment.author }}</dd>
</div>
</dl>
<div v-if="actions.length" class="deploy-detail__actions">
<GhostButton
v-for="action in actions"
:key="action"
:variant="action === 'promote' ? 'solid' : 'outline'"
size="sm"
@click="emit('run', action)"
>{{ actionLabels[action] }}</GhostButton
>
</div>
</GhostTabsContent>
<GhostTabsContent value="logs" class="deploy-detail__panel">
<!-- No focusable content inside, so the area is its own named tab stop. -->
<GhostScrollArea
:label="`Logs for ${deployment.id}`"
class="deploy-logs"
>
<ol class="deploy-logs__list">
<li v-for="(line, index) in deployment.logs" :key="index">
{{ line }}
</li>
</ol>
</GhostScrollArea>
</GhostTabsContent>
<GhostTabsContent value="settings" class="deploy-detail__panel">
<dl v-if="settings" class="deploy-facts">
<div>
<dt>Build command</dt>
<dd>
<code>{{ settings.buildCommand }}</code>
</dd>
</div>
<div>
<dt>Health check</dt>
<dd>
<code>{{ settings.healthCheck }}</code>
</dd>
</div>
<div>
<dt>Rollback window</dt>
<dd>{{ settings.rollbackWindow }}</dd>
</div>
</dl>
<p class="deploy-detail__note">
Settings apply to every channel of {{ deployment.project }}. This
sample shows them read-only.
</p>
</GhostTabsContent>
</div>
</GhostTabs>
</section>
</template>ts
/**
* Sample data for the Deploy console showcase. Names, channels, regions and
* status words come from the Tideline demo world
* (docs/contributing/demo-world.md). Nothing here talks to a network: every
* action replaces records in memory.
*/
export type DeploymentStatus =
'Queued' | 'Building' | 'Live' | 'Failed' | 'Rolled back'
export type Channel = 'production' | 'staging' | 'preview'
export type Region = 'us-east' | 'eu-west'
/** A release of a project: its version and the commit it was built from. */
export interface Release {
version: string
commit: string
}
/**
* The latest deployment to one channel in one region of a project. The tree
* shows one row per slot (`project/channel/region`), so a row keeps its place
* and selection when a promotion or rollback replaces its deployment.
*/
export interface Deployment {
/** Stable slot key, also the tree value: `checkout-api/production/us-east`. */
slot: string
/** Deployment id, counting up over time like invoice ids. */
id: string
project: string
channel: Channel
region: Region
release: Release
status: DeploymentStatus
/**
* The release serving traffic when it is not `release`: during a rollout
* the old release keeps serving, and after a rollback
* the previous live release serves while the rolled-back one stays on the
* record.
*/
serving?: Release | undefined
/** The release a rollback returns to. Only production keeps one. */
previous?: Release | undefined
/** Who started the deployment. */
author: string
/** Display time, such as `Nov 18, 09:42`. */
started: string
logs: readonly string[]
}
/**
* Badge tone for each status, from the demo world's deployment table. Each
* status keeps its own tone so Mono, where accent sits close to neutral, still
* separates Queued from Building by the word itself.
*/
export const deploymentStatusTones = {
Queued: 'neutral',
Building: 'accent',
Live: 'success',
Failed: 'danger',
'Rolled back': 'warning',
} as const satisfies Record<DeploymentStatus, string>
export const projects = [
'checkout-api',
'edge-gateway',
'media-worker',
] as const
/** The workspace this console belongs to (the first demo-world customer). */
export const workspaceName = 'Northstar Studio'
/** Static settings per project, shown read-only on the Settings tab. */
export const projectSettings: Record<
string,
{ buildCommand: string; healthCheck: string; rollbackWindow: string }
> = {
'checkout-api': {
buildCommand: 'pnpm build',
healthCheck: '/healthz',
rollbackWindow: '24 hours',
},
'edge-gateway': {
buildCommand: 'cargo build --release',
healthCheck: '/status',
rollbackWindow: '72 hours',
},
'media-worker': {
buildCommand: 'go build ./cmd/worker',
healthCheck: '/ready',
rollbackWindow: '24 hours',
},
}
function slotKey(project: string, channel: Channel, region: Region): string {
return `${project}/${channel}/${region}`
}
function deployment(
fields: Omit<Deployment, 'slot' | 'logs'> & { logs?: readonly string[] },
): Deployment {
return {
...fields,
slot: slotKey(fields.project, fields.channel, fields.region),
logs: fields.logs ?? [
`Cloning ${fields.project} at ${fields.release.commit}`,
`Building ${fields.release.version}`,
`Starting ${fields.region} instances`,
'Health check passed',
`Serving ${fields.channel} traffic`,
],
}
}
export const initialDeployments: readonly Deployment[] = [
deployment({
id: 'dep-3108',
project: 'checkout-api',
channel: 'production',
region: 'us-east',
release: { version: 'v2.14.0', commit: '8c41f2a' },
previous: { version: 'v2.13.2', commit: '51d0e9b' },
status: 'Live',
author: 'Maya Okafor',
started: 'Nov 18, 09:42',
}),
deployment({
id: 'dep-3114',
project: 'checkout-api',
channel: 'staging',
region: 'us-east',
release: { version: 'v2.15.0', commit: 'c7e2a90' },
status: 'Live',
author: 'Daniel Reyes',
started: 'Nov 18, 13:05',
}),
deployment({
id: 'dep-3117',
project: 'checkout-api',
channel: 'preview',
region: 'us-east',
release: { version: 'v2.16.0-rc.1', commit: 'e13f4c2' },
status: 'Failed',
author: 'Priya Natarajan',
started: 'Nov 18, 14:20',
logs: [
'Cloning checkout-api at e13f4c2',
'Building v2.16.0-rc.1',
'Starting us-east instances',
'Health check failed: /healthz returned 503',
'Deployment stopped',
],
}),
deployment({
id: 'dep-3099',
project: 'edge-gateway',
channel: 'production',
region: 'eu-west',
release: { version: 'v1.8.3', commit: '4b9d7e1' },
previous: { version: 'v1.8.2', commit: '2fa6c38' },
status: 'Live',
author: 'Tom Whitfield',
started: 'Nov 17, 16:18',
}),
deployment({
id: 'dep-3111',
project: 'edge-gateway',
channel: 'staging',
region: 'eu-west',
release: { version: 'v1.9.0', commit: '9e0b5d4' },
status: 'Live',
author: 'Elena Petrova',
started: 'Nov 18, 10:31',
}),
deployment({
id: 'dep-3102',
project: 'media-worker',
channel: 'production',
region: 'us-east',
release: { version: 'v0.9.4', commit: 'a1c8f05' },
serving: { version: 'v0.9.3', commit: '7d2e6b1' },
status: 'Rolled back',
author: 'Sam Lindqvist',
started: 'Nov 17, 18:02',
logs: [
'Cloning media-worker at a1c8f05',
'Building v0.9.4',
'Starting us-east instances',
'Error rate above 2% for 5 minutes',
'Rolled back to v0.9.3',
],
}),
deployment({
id: 'dep-3118',
project: 'media-worker',
channel: 'staging',
region: 'us-east',
release: { version: 'v0.10.0', commit: 'f6a3d29' },
status: 'Queued',
author: 'Grace Liu',
started: 'Nov 18, 14:35',
logs: ['Waiting for a build runner'],
}),
]
/** Next deployment id after the sample data, counting up like invoice ids. */
export function nextDeploymentId(deployments: readonly Deployment[]): string {
const highest = Math.max(
...deployments.map((entry) => Number(entry.id.slice('dep-'.length))),
)
return `dep-${String(highest + 1)}`
}
/** Row and palette label: `production · us-east`. */
export function slotLabel(entry: Pick<Deployment, 'channel' | 'region'>) {
return `${entry.channel} · ${entry.region}`
}
/** The staging slot a production slot is promoted from, in the same region. */
export function stagingFor(
deployments: readonly Deployment[],
target: Deployment,
): Deployment | undefined {
return deployments.find(
(entry) =>
entry.project === target.project &&
entry.channel === 'staging' &&
entry.region === target.region,
)
}
/** The production slot a staging slot promotes to, in the same region. */
export function productionFor(
deployments: readonly Deployment[],
source: Deployment,
): Deployment | undefined {
return deployments.find(
(entry) =>
entry.project === source.project &&
entry.channel === 'production' &&
entry.region === source.region,
)
}
/** The actions a deployment offers, shared by every menu and the palette. */
export type DeploymentAction = 'promote' | 'rollback' | 'redeploy'
/**
* Whether `action` applies to `entry` now. Promote runs from a Live staging
* slot whose release production does not already serve (a rolled-back
* release can be promoted again); Roll back needs a
* Live production slot with a previous release; Redeploy retries a Failed
* deployment. Nothing runs while the slot is Building.
*/
export function canRun(
deployments: readonly Deployment[],
entry: Deployment,
action: DeploymentAction,
): boolean {
if (entry.status === 'Building') return false
switch (action) {
case 'promote': {
if (entry.channel !== 'staging' || entry.status !== 'Live') return false
const target = productionFor(deployments, entry)
return (
target !== undefined &&
target.status !== 'Building' &&
// Compare with what production serves, not its latest record: after
// a rollback the rolled-back release is still on the record but no
// longer serving, so it can be promoted again.
(target.serving ?? target.release).version !== entry.release.version
)
}
case 'rollback':
return (
entry.channel === 'production' &&
entry.status === 'Live' &&
entry.previous !== undefined
)
case 'redeploy':
return entry.status === 'Failed'
}
}
/** The tabs of the deployment detail, shared with the View menu. */
export type DetailTab = 'overview' | 'logs' | 'settings'css
.deploy-gallery {
inline-size: min(100% - 2rem, 72rem);
margin-inline: auto;
padding-block: clamp(1.75rem, 5vw, 4rem) 4rem;
color: var(--ghost-surface-fg);
}
.deploy-gallery__header {
display: grid;
gap: var(--ghost-space-gap-sm);
margin-block-end: var(--ghost-space-inset-lg);
}
.deploy-gallery__header p,
.deploy-console__heading p {
color: var(--ghost-text-muted);
max-inline-size: 52ch;
}
/*
* The console is a size container so the two-column layout follows the
* space the example page gives it (narrower while the source panel is
* open), not the viewport.
*/
.deploy-console {
container: deploy-console / inline-size;
display: grid;
gap: var(--ghost-space-gap-md);
min-inline-size: 0;
padding: clamp(0.75rem, 3vw, 1.5rem);
background: var(--ghost-elevation-1-bg);
border: var(--ghost-border-hairline-width) solid
var(--ghost-elevation-1-border);
border-radius: var(--ghost-radius-lg);
box-shadow:
var(--ghost-elevation-1-shadow), var(--ghost-elevation-1-highlight);
}
.deploy-console__heading,
.deploy-console__bar {
display: flex;
align-items: center;
flex-wrap: wrap;
justify-content: space-between;
gap: var(--ghost-space-gap-sm);
}
.deploy-console__heading h2 {
font-size: 1.25rem;
font-weight: 650;
}
.deploy-console__bar {
padding-block-end: var(--ghost-space-inset-sm);
border-block-end: var(--ghost-border-hairline-width) solid
var(--ghost-border-default);
}
.deploy-menubar {
display: flex;
flex-wrap: wrap;
gap: var(--ghost-space-gap-xs);
}
.deploy-menu__indicator {
display: inline-block;
inline-size: 1em;
text-align: center;
}
.deploy-menu__label {
flex: 1;
}
.deploy-console__body {
display: grid;
grid-template-columns: minmax(14rem, 18rem) minmax(0, 1fr);
gap: var(--ghost-space-gap-lg);
align-items: start;
}
.deploy-console__services {
min-inline-size: 0;
padding-inline-end: var(--ghost-space-gap-md);
border-inline-end: var(--ghost-border-hairline-width) solid
var(--ghost-border-default);
}
/* The toggle only matters once the tree can collapse. */
.deploy-console__services-toggle {
display: none;
}
@container deploy-console (max-width: 40rem) {
.deploy-console__body {
grid-template-columns: minmax(0, 1fr);
}
.deploy-console__services-toggle {
display: inline-flex;
}
.deploy-console__services {
padding-inline-end: 0;
padding-block-end: var(--ghost-space-gap-md);
border-inline-end: 0;
border-block-end: var(--ghost-border-hairline-width) solid
var(--ghost-border-default);
}
.deploy-console__services[data-open='false'] {
display: none;
}
}
.deploy-tree {
inline-size: 100%;
}
.deploy-tree__chevron {
display: inline-block;
inline-size: 1rem;
text-align: center;
}
.deploy-tree__chevron[data-open='true'] {
rotate: 90deg;
}
.deploy-tree__project {
font-weight: var(--ghost-type-weight-semibold);
}
.deploy-tree__deployment [data-part='trigger'] {
display: flex;
align-items: center;
justify-content: space-between;
gap: var(--ghost-space-gap-sm);
}
.deploy-tree__slot {
min-inline-size: 0;
overflow-wrap: anywhere;
}
.deploy-detail {
display: grid;
gap: var(--ghost-space-gap-md);
min-inline-size: 0;
}
.deploy-detail__header,
.deploy-detail__title,
.deploy-detail__id {
display: flex;
align-items: center;
flex-wrap: wrap;
gap: var(--ghost-space-gap-sm);
}
.deploy-detail__header {
justify-content: space-between;
}
.deploy-detail__title h3 {
margin: 0;
font-size: 1.125rem;
font-weight: 650;
}
.deploy-detail__slot {
color: var(--ghost-text-muted);
font-weight: var(--ghost-type-weight-medium);
}
.deploy-detail__id code,
.deploy-facts code,
.deploy-logs__list {
font-family: var(--ghost-type-family-mono);
font-size: var(--ghost-type-size-sm);
}
.deploy-detail__progress {
display: grid;
gap: var(--ghost-space-gap-xs);
}
.deploy-detail__progress-text,
.deploy-detail__note,
.deploy-facts dt {
color: var(--ghost-text-muted);
font-size: var(--ghost-type-size-sm);
}
.deploy-detail__progress-text {
font-variant-numeric: tabular-nums;
}
/* GhostTabs renders no element; this keeps the strip above its panel. */
.deploy-detail__tabs {
display: grid;
min-inline-size: 0;
}
/* Inactive panels carry `hidden`; a display value here must not undo it. */
.deploy-detail__panel:not([hidden]) {
display: grid;
gap: var(--ghost-space-gap-md);
padding-block-start: var(--ghost-space-inset-md);
}
.deploy-facts {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr));
gap: var(--ghost-space-gap-md);
margin: 0;
}
.deploy-facts dd {
margin: 0;
overflow-wrap: anywhere;
}
.deploy-detail__actions {
display: flex;
flex-wrap: wrap;
gap: var(--ghost-space-gap-sm);
}
.deploy-detail__note {
margin: 0;
}
.deploy-logs {
max-block-size: 14rem;
padding: var(--ghost-space-inset-sm);
background: var(--ghost-surface-muted-bg);
border: var(--ghost-border-hairline-width) solid var(--ghost-border-default);
border-radius: var(--ghost-radius-md);
}
.deploy-logs__list {
display: grid;
gap: var(--ghost-space-gap-xs);
margin: 0;
padding-inline-start: 2.5em;
}
/* The palette is portaled to <body>, so it is styled by its own class. */
.deploy-palette__list {
max-block-size: min(50dvh, 22rem);
overflow: auto;
}
.deploy-palette__label {
flex: 1;
min-inline-size: 0;
}
.deploy-palette__hint {
/* Inherits, so it keeps contrast on the highlighted row too. */
color: inherit;
font-size: var(--ghost-type-size-xs);
}
.deploy-palette__footer {
display: flex;
flex-wrap: wrap;
gap: var(--ghost-space-gap-md);
padding-block-start: var(--ghost-space-inset-sm);
padding-inline: var(--ghost-space-inset-sm);
border-block-start: var(--ghost-border-hairline-width) solid
var(--ghost-border-default);
color: var(--ghost-text-muted);
font-size: var(--ghost-type-size-sm);
}
.deploy-visually-hidden {
position: absolute;
inline-size: 1px;
block-size: 1px;
margin: 0;
overflow: hidden;
clip-path: inset(50%);
white-space: nowrap;
}