Skip to content
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
66 changes: 45 additions & 21 deletions ui/src/App.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script setup lang="ts">
import { computed, onMounted, ref } from 'vue';
import { computed, onBeforeUnmount, onMounted, ref, watch } from 'vue';
import { useHub } from '@/stores/hub';
import { ago, useNow } from '@/lib/format';
import TopBar from '@/components/TopBar.vue';
Expand All @@ -16,6 +16,20 @@ const now = useNow();

onMounted(() => void hub.init());

// The banners below the top bar stay with it; the sidebar and other sticky
// parts start below them and are as much shorter (`--banners-h`), so a
// banner never makes the page scroll.
const banners = ref<HTMLElement | null>(null);
const bannersObserver = new ResizeObserver(([e]) => {
document.documentElement.style.setProperty('--banners-h', `${Math.round(e?.borderBoxSize?.[0]?.blockSize ?? 0)}px`);
});
watch(banners, (el, old) => {
if (old) bannersObserver.unobserve(old);
if (el) bannersObserver.observe(el);
else document.documentElement.style.setProperty('--banners-h', '0px');
});
onBeforeUnmount(() => bannersObserver.disconnect());

const hubDown = computed(() => hub.status === 'unreachable' || (hub.status === 'ok' && hub.stream === 'error'));
const booting = computed(() => hub.status === 'loading' && !hub.stacks.length);

Expand Down Expand Up @@ -45,27 +59,29 @@ async function startHub() {
<template v-else>
<a class="skip" href="#main">Skip to content</a>
<TopBar />
<div v-if="hubDown" class="hub-banner" role="alert" data-testid="hub-unreachable">
<div class="hub-banner-inner">
<Icon name="wifiOff" :size="18" />
<div class="grow">
<strong>devstack hub is not reachable.</strong> Start it here, or run <code>devstack ui</code> in a project.
<span class="last">Showing the last known state<template v-if="hub.lastContact"> from {{ ago(hub.lastContact, now) }}</template>.</span>
<div ref="banners" class="banners">
<div v-if="hubDown" class="hub-banner" role="alert" data-testid="hub-unreachable">
<div class="hub-banner-inner">
<Icon name="wifiOff" :size="18" />
<div class="grow">
<strong>devstack hub is not reachable.</strong> Start it here, or run <code>devstack ui</code> in a project.
<span class="last">Showing the last known state<template v-if="hub.lastContact"> from {{ ago(hub.lastContact, now) }}</template>.</span>
</div>
<a
class="btn btn-primary btn-sm"
href="devstack://hub/start"
title="Needs the devstack:// link (`devstack hub install`, done by `devstack up`)"
data-testid="action-start-hub"
@click="startHub()"
>
<span v-if="startingHub" class="spinner" /><Icon v-else name="play" :size="14" />
{{ startingHub ? 'Starting…' : 'Start hub' }}
</a>
<span class="retry"><span class="spinner" aria-hidden="true" /> retrying</span>
</div>
<a
class="btn btn-primary btn-sm"
href="devstack://hub/start"
title="Needs the devstack:// link (`devstack hub install`, done by `devstack up`)"
data-testid="action-start-hub"
@click="startHub()"
>
<span v-if="startingHub" class="spinner" /><Icon v-else name="play" :size="14" />
{{ startingHub ? 'Starting…' : 'Start hub' }}
</a>
<span class="retry"><span class="spinner" aria-hidden="true" /> retrying</span>
</div>
<GuestBanner v-if="!hubDown" />
</div>
<GuestBanner v-if="!hubDown" />
<div class="shell">
<Sidebar v-if="!booting" class="side" />
<main id="main" tabindex="-1">
Expand Down Expand Up @@ -115,10 +131,18 @@ main {
.side {
display: flex;
position: sticky;
top: var(--topbar-h);
height: calc(100vh - var(--topbar-h));
top: calc(var(--topbar-h) + var(--banners-h));
height: calc(100vh - var(--topbar-h) - var(--banners-h));
}
}
.banners {
position: sticky;
top: var(--topbar-h);
z-index: 29;
}
.banners:empty {
display: none;
}
.hub-banner {
background: var(--danger-soft);
border-bottom: 1px solid color-mix(in srgb, var(--danger) 30%, transparent);
Expand Down
2 changes: 2 additions & 0 deletions ui/src/styles/tokens.css
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
--space-5: 24px;
--space-6: 32px;
--topbar-h: 56px;
/* The banners below the top bar (App.vue measures them). */
--banners-h: 0px;
--ease: cubic-bezier(0.2, 0.7, 0.2, 1);

color-scheme: light;
Expand Down
4 changes: 2 additions & 2 deletions ui/src/views/OverviewView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -427,8 +427,8 @@ const starting = computed(() => !!(stack.id && hub.starting[stack.id]));
flex-direction: column;
gap: var(--space-3);
position: sticky;
top: calc(var(--topbar-h) + 12px);
max-height: calc(100vh - var(--topbar-h) - 24px);
top: calc(var(--topbar-h) + var(--banners-h) + 12px);
max-height: calc(100vh - var(--topbar-h) - var(--banners-h) - 24px);
overflow-y: auto;
padding-right: 2px;
}
Expand Down