feat(operator): command palette, impersonation, incident, tweaks (O.8)

- CommandPalette + useCommandPalette: ⌘K opens a search-and-jump panel over
  real tenants/partners + fixture flags + nav + actions. Arrow keys + Enter
  navigate, Escape/backdrop close. Recents are intentionally omitted for now;
  add when there's something to recent over.
- Impersonation stub: useImpersonation + ImpersonationModal + ImpersonationBanner.
  Modal opens from tenant detail and from the palette. Banner stays at the top
  of the shell until exited. No real OBO token is minted — wiring OAuth Token
  Exchange is tracked as a follow-up.
- IncidentModal + useIncidentModal: opened from the Overview and Infrastructure
  incident banners, renders the mock INCIDENT data with metrics, timeline and
  draft composer.
- TweaksPanel + useTweaks: floating bottom-right panel for theme (dark/light),
  density (comfy/compact), env badge (prod/staging/dev). Saved to localStorage.
- Theme/density apply via [data-theme] + [data-density] overrides in
  tokens.css. Topbar env badge now reads from useTweaks instead of a prop.
- Layout wires ⌘K + ⌘[ at the document level and mounts the palette + modals
  + banner + tweaks panel once for all pages.
This commit is contained in:
Ronni Baslund
2026-05-24 08:34:34 +02:00
parent e0ac643e80
commit c71e782dc0
16 changed files with 1162 additions and 30 deletions
@@ -0,0 +1,158 @@
<script setup lang="ts">
const { candidate, cancel, confirm } = useImpersonation()
const reason = ref('Customer reported issue — investigating')
const asUser = ref('first-user@example.com · Owner')
watch(candidate, (v) => {
if (v) {
reason.value = 'Customer reported issue — investigating'
}
})
function onConfirm() {
if (!reason.value.trim()) return
confirm(reason.value.trim(), asUser.value)
}
</script>
<template>
<Teleport to="body">
<div v-if="candidate" class="backdrop" @click="cancel">
<div class="modal" role="dialog" :aria-label="`Impersonate inside ${candidate.name}`" @click.stop>
<header>
<div>
<Eyebrow>Operator action · logged</Eyebrow>
<h2>Impersonate inside {{ candidate.name }}</h2>
</div>
<button class="x" type="button" aria-label="Close" @click="cancel">
<UiIcon name="x" :size="12" />
</button>
</header>
<div class="body">
<div class="warn">
<UiIcon name="shield" :size="15" />
<p>
You'll see <strong>{{ candidate.name }}</strong>'s workspace exactly as one of their users sees it.
Any state-changing action will be flagged in their audit log as an operator action with your name
attached. <Mono dim>// stub — no real session is created</Mono>
</p>
</div>
<label class="field">
<span>Impersonate as</span>
<input v-model="asUser" type="text" />
</label>
<label class="field">
<span>Reason (required)</span>
<input v-model="reason" type="text" />
</label>
<Mono dim class="note">// logged as op.impersonate · session expires after 30 min idle</Mono>
</div>
<footer>
<UiButton variant="ghost" @click="cancel">Cancel</UiButton>
<UiButton variant="danger" :disabled="!reason.trim()" @click="onConfirm">
<template #leading><UiIcon name="key" :size="13" /></template>
Enter impersonation mode
</UiButton>
</footer>
</div>
</div>
</Teleport>
</template>
<style scoped>
.backdrop {
position: fixed;
inset: 0;
background: rgba(0, 0, 0, 0.55);
display: flex;
align-items: center;
justify-content: center;
padding: 24px;
z-index: 180;
}
.modal {
width: 100%;
max-width: 520px;
background: var(--elevated);
border: 1px solid var(--border);
border-radius: 10px;
box-shadow: 0 24px 80px rgba(0, 0, 0, 0.5);
display: flex;
flex-direction: column;
overflow: hidden;
}
header {
padding: 16px 20px;
display: flex;
justify-content: space-between;
align-items: flex-start;
border-bottom: 1px solid var(--border);
}
h2 { margin: 4px 0 0 0; font-family: var(--font-display); font-weight: 600; font-size: 17px; }
.x {
width: 26px; height: 26px;
border: 0; border-radius: 6px; background: transparent;
color: var(--text-mute); cursor: pointer;
display: inline-flex; align-items: center; justify-content: center;
}
.x:hover { background: var(--surface); color: var(--text); }
.body {
padding: 16px 20px;
display: flex;
flex-direction: column;
gap: 14px;
}
.warn {
display: flex;
align-items: flex-start;
gap: 10px;
padding: 12px 14px;
background: rgba(226, 48, 48, 0.06);
border: 1px solid rgba(226, 48, 48, 0.24);
border-left: 3px solid var(--bad);
border-radius: 6px;
color: var(--bad);
}
.warn p { margin: 0; font-size: 12px; color: var(--text-dim); line-height: 1.55; }
.warn strong { color: var(--text); }
.field { display: flex; flex-direction: column; gap: 6px; }
.field span {
font-family: var(--font-mono);
font-size: 10px;
letter-spacing: 0.12em;
text-transform: uppercase;
color: var(--text-mute);
font-weight: 500;
}
.field input {
height: 34px;
padding: 0 12px;
border: 1px solid var(--border);
background: var(--input-bg);
color: var(--text);
border-radius: 6px;
font-family: inherit;
font-size: 13px;
outline: 0;
}
.field input:focus { border-color: var(--border-hi); }
.note { padding-top: 2px; }
footer {
padding: 12px 20px;
display: flex;
justify-content: flex-end;
gap: 8px;
border-top: 1px solid var(--border);
background: var(--surface);
}
</style>