Servers dialog (write-only keychain secret, test connection, unknown and changed host key), status-bar progress with Cancel, Deployment log tool window, Upload/Download in the project tree menu and Tools › Deployment. docs/deployment.md, architecture section, G17 row. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
217 lines
4.9 KiB
Vue
217 lines
4.9 KiB
Vue
<script setup lang="ts">
|
|
/**
|
|
* The Deployment log tool window (G17), shown in the bottom panel: every
|
|
* line of the deployment log (newest at the bottom), with its time, the
|
|
* server and a severity icon; the running job's progress above the list
|
|
* with Cancel; and Clear. The log follows new lines while it is scrolled
|
|
* to the bottom. State lives in the Deployment store (`deploy.ts`).
|
|
*/
|
|
import { CircleAlert, Info, TriangleAlert } from "@lucide/vue";
|
|
import { computed, nextTick, ref, watch } from "vue";
|
|
import { t } from "../../i18n";
|
|
import { useDeployStore, type LogEntry } from "./deploy";
|
|
|
|
const deploy = useDeployStore();
|
|
|
|
/** The list element. */
|
|
const list = ref<HTMLElement | null>(null);
|
|
|
|
/** Icons by severity. */
|
|
const ICONS = { error: CircleAlert, warning: TriangleAlert, info: Info } as const;
|
|
|
|
/**
|
|
* The time of a line, `HH:MM:SS` in local time.
|
|
*
|
|
* @param entry - the line.
|
|
*/
|
|
function timeOf(entry: LogEntry): string {
|
|
const d = new Date(entry.time);
|
|
const two = (n: number) => String(n).padStart(2, "0");
|
|
return `${two(d.getHours())}:${two(d.getMinutes())}:${two(d.getSeconds())}`;
|
|
}
|
|
|
|
/**
|
|
* The accessible name of a severity.
|
|
*
|
|
* @param level - the severity.
|
|
*/
|
|
function levelLabel(level: LogEntry["level"]): string {
|
|
return level === "error"
|
|
? t("deploy.log.error")
|
|
: level === "warning"
|
|
? t("deploy.log.warning")
|
|
: t("deploy.log.info");
|
|
}
|
|
|
|
/** The running job's line, or null. */
|
|
const running = computed(() => {
|
|
const p = deploy.progress;
|
|
if (p === null) {
|
|
return null;
|
|
}
|
|
return t("deploy.log.running", {
|
|
server: p.server,
|
|
done: p.filesDone,
|
|
total: p.filesTotal,
|
|
file: p.file,
|
|
});
|
|
});
|
|
|
|
watch(
|
|
() => deploy.entries.length,
|
|
async () => {
|
|
const el = list.value;
|
|
const atBottom = el === null || el.scrollTop + el.clientHeight >= el.scrollHeight - 24;
|
|
await nextTick();
|
|
if (atBottom && list.value) {
|
|
list.value.scrollTop = list.value.scrollHeight;
|
|
}
|
|
},
|
|
);
|
|
</script>
|
|
|
|
<template>
|
|
<section
|
|
class="deploy-log"
|
|
:aria-label="t('deploy.log.title')"
|
|
data-test="deploy-log"
|
|
>
|
|
<header class="deploy-log__header">
|
|
<span
|
|
v-if="running !== null"
|
|
class="deploy-log__running"
|
|
role="status"
|
|
>{{ running }}</span>
|
|
<span
|
|
v-else
|
|
class="deploy-log__idle"
|
|
>{{ deploy.entries.length === 0 ? t("deploy.log.empty") : "" }}</span>
|
|
<button
|
|
v-if="running !== null"
|
|
type="button"
|
|
class="deploy-log__button"
|
|
data-test="deploy-log-cancel"
|
|
@click="deploy.cancel()"
|
|
>
|
|
{{ t("deploy.cancel") }}
|
|
</button>
|
|
<button
|
|
type="button"
|
|
class="deploy-log__button"
|
|
:disabled="deploy.entries.length === 0"
|
|
data-test="deploy-log-clear"
|
|
@click="deploy.clearLog()"
|
|
>
|
|
{{ t("deploy.log.clear") }}
|
|
</button>
|
|
</header>
|
|
<ol
|
|
ref="list"
|
|
class="deploy-log__list"
|
|
>
|
|
<li
|
|
v-for="entry in deploy.entries"
|
|
:key="entry.id"
|
|
class="deploy-log__line"
|
|
:class="`deploy-log__line--${entry.level}`"
|
|
data-test="deploy-log-line"
|
|
>
|
|
<component
|
|
:is="ICONS[entry.level]"
|
|
class="deploy-log__icon"
|
|
:size="12"
|
|
:aria-label="levelLabel(entry.level)"
|
|
/>
|
|
<time class="deploy-log__time">{{ timeOf(entry) }}</time>
|
|
<span class="deploy-log__server">{{ entry.server }}</span>
|
|
<span class="deploy-log__message">{{ entry.message }}</span>
|
|
</li>
|
|
</ol>
|
|
</section>
|
|
</template>
|
|
|
|
<style scoped>
|
|
.deploy-log {
|
|
display: flex;
|
|
flex-direction: column;
|
|
height: 100%;
|
|
min-height: 0;
|
|
}
|
|
|
|
.deploy-log__header {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 8px;
|
|
flex: none;
|
|
padding: 2px 8px;
|
|
border-bottom: 1px solid var(--lt-border);
|
|
}
|
|
|
|
.deploy-log__running,
|
|
.deploy-log__idle {
|
|
flex: 1;
|
|
min-width: 0;
|
|
overflow: hidden;
|
|
text-overflow: ellipsis;
|
|
white-space: nowrap;
|
|
color: var(--lt-fg-muted);
|
|
}
|
|
|
|
.deploy-log__button {
|
|
padding: 1px 8px;
|
|
font: inherit;
|
|
color: var(--lt-fg);
|
|
background: transparent;
|
|
border: 1px solid var(--lt-border);
|
|
border-radius: 4px;
|
|
}
|
|
|
|
.deploy-log__button:disabled {
|
|
color: var(--lt-fg-muted);
|
|
}
|
|
|
|
.deploy-log__button:focus-visible {
|
|
outline: 1px solid var(--lt-accent);
|
|
}
|
|
|
|
.deploy-log__list {
|
|
flex: 1;
|
|
margin: 0;
|
|
padding: 2px 0;
|
|
list-style: none;
|
|
overflow-y: auto;
|
|
font-family: var(--lt-font-mono);
|
|
font-size: var(--lt-font-size-small);
|
|
}
|
|
|
|
.deploy-log__line {
|
|
display: flex;
|
|
align-items: baseline;
|
|
gap: 8px;
|
|
padding: 1px 8px;
|
|
}
|
|
|
|
.deploy-log__icon {
|
|
flex: none;
|
|
align-self: center;
|
|
}
|
|
|
|
.deploy-log__line--error {
|
|
color: var(--lt-error);
|
|
}
|
|
|
|
.deploy-log__line--warning {
|
|
color: var(--lt-diag-warning);
|
|
}
|
|
|
|
.deploy-log__time,
|
|
.deploy-log__server {
|
|
flex: none;
|
|
color: var(--lt-fg-muted);
|
|
}
|
|
|
|
.deploy-log__message {
|
|
white-space: pre-wrap;
|
|
overflow-wrap: anywhere;
|
|
}
|
|
</style>
|