Add QA tab to archived item detail (#1590)

Adds tab with placeholders as a starting point to work off of. The badge and button is not currently linked up to any data or actions.
This commit is contained in:
sua yoo 2024-03-12 14:05:16 -07:00 committed by GitHub
parent 16e8b761c0
commit eb7036bf87
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 53 additions and 32 deletions

View File

@ -1,7 +1,7 @@
import { TailwindElement } from "@/classes/TailwindElement"; import { css } from "lit";
import { tw } from "@/utils/tailwind";
import { html } from "lit";
import { customElement, property } from "lit/decorators.js"; import { customElement, property } from "lit/decorators.js";
import SlBadge from "@shoelace-style/shoelace/dist/components/badge/badge.component.js";
import badgeStyles from "@shoelace-style/shoelace/dist/components/badge/badge.styles.js";
/** /**
* Show numeric value in a label * Show numeric value in a label
@ -12,35 +12,18 @@ import { customElement, property } from "lit/decorators.js";
* ``` * ```
*/ */
@customElement("btrix-badge") @customElement("btrix-badge")
export class Badge extends TailwindElement { export class Badge extends SlBadge {
@property({ type: String }) static styles = [
variant: badgeStyles,
| "success" css`
| "warning" .badge {
| "danger" border-color: rgba(255, 255, 255, 0.5);
| "neutral" line-height: 1rem;
| "primary" padding: 0 1ch;
| "high-contrast" = "neutral"; }
`,
];
@property({ type: String, reflect: true }) @property({ type: String, reflect: true })
role: string | null = "status"; role: string | null = "status";
render() {
return html`
<span
class="h-4.5 ${{
success: tw`bg-success-500 text-neutral-0`,
warning: tw`bg-warning-600 text-neutral-0`,
danger: tw`bg-danger-500 text-neutral-0`,
neutral: tw`bg-neutral-100 text-neutral-600`,
"high-contrast": tw`bg-neutral-600 text-neutral-0`,
primary: tw`bg-primary text-neutral-0`,
}[
this.variant
]} inline-flex items-center justify-center rounded-sm px-2 align-[1px] text-xs"
>
<slot></slot>
</span>
`;
}
} }

View File

@ -21,6 +21,7 @@ import { isApiError } from "@/utils/api";
const SECTIONS = [ const SECTIONS = [
"overview", "overview",
"qa",
"watch", "watch",
"replay", "replay",
"files", "files",
@ -142,6 +143,15 @@ export class CrawlDetail extends LiteElement {
let sectionContent: string | TemplateResult = ""; let sectionContent: string | TemplateResult = "";
switch (this.sectionName) { switch (this.sectionName) {
case "qa":
sectionContent = this.renderPanel(
html`${this.renderTitle(msg("Crawl Analysis"))}
<sl-button size="small" @click=${() => console.log("TODO")}>
${msg("Reanalyze Crawl")}
</sl-button>`,
this.renderQA(),
);
break;
case "replay": case "replay":
sectionContent = this.renderPanel(msg("Replay"), this.renderReplay(), { sectionContent = this.renderPanel(msg("Replay"), this.renderReplay(), {
"overflow-hidden": true, "overflow-hidden": true,
@ -314,11 +324,13 @@ export class CrawlDetail extends LiteElement {
label, label,
iconLibrary, iconLibrary,
icon, icon,
detail,
}: { }: {
section: SectionName; section: SectionName;
label: string; label: string;
iconLibrary: "app" | "default"; iconLibrary: "app" | "default";
icon: string; icon: string;
detail?: TemplateResult<1>;
}) => { }) => {
const isActive = section === this.sectionName; const isActive = section === this.sectionName;
const baseUrl = window.location.pathname.split("#")[0]; const baseUrl = window.location.pathname.split("#")[0];
@ -336,7 +348,7 @@ export class CrawlDetail extends LiteElement {
aria-hidden="true" aria-hidden="true"
library=${iconLibrary} library=${iconLibrary}
></sl-icon> ></sl-icon>
${label}</btrix-navigation-button ${label}${detail}</btrix-navigation-button
> >
`; `;
}; };
@ -351,6 +363,20 @@ export class CrawlDetail extends LiteElement {
icon: "info-circle-fill", icon: "info-circle-fill",
label: msg("Overview"), label: msg("Overview"),
})} })}
${when(
this.itemType === "crawl",
() => html`
${renderNavItem({
section: "qa",
iconLibrary: "default",
icon: "clipboard2-data-fill",
label: msg("QA"),
detail: html`
<btrix-badge variant="primary">${msg("Ready")}</btrix-badge>
`,
})}
`,
)}
${renderNavItem({ ${renderNavItem({
section: "replay", section: "replay",
iconLibrary: "app", iconLibrary: "app",
@ -526,6 +552,15 @@ export class CrawlDetail extends LiteElement {
`; `;
} }
private renderQA() {
return html`
<section class="mb-5 rounded-lg border p-4">[summary]</section>
<section class="mb-7 rounded-lg border p-4">[stats]</section>
<h4 class="text-lg font-semibold">${msg("Pages")}</h4>
<section>[pages]</section>
`;
}
private renderReplay() { private renderReplay() {
if (!this.crawl) return; if (!this.crawl) return;
const replaySource = `/api/orgs/${this.crawl.oid}/${ const replaySource = `/api/orgs/${this.crawl.oid}/${

View File

@ -75,6 +75,9 @@ import(
import( import(
/* webpackChunkName: "shoelace" */ "@shoelace-style/shoelace/dist/components/tree-item/tree-item" /* webpackChunkName: "shoelace" */ "@shoelace-style/shoelace/dist/components/tree-item/tree-item"
); );
import(
/* webpackChunkName: "shoelace" */ "@shoelace-style/shoelace/dist/components/badge/badge"
);
setBasePath("/shoelace"); setBasePath("/shoelace");
registerIconLibrary("app", { registerIconLibrary("app", {