Skip to content

Commit 8530c68

Browse files
committed
run analysis from review
1 parent 83b3327 commit 8530c68

File tree

7 files changed

+271
-133
lines changed

7 files changed

+271
-133
lines changed

frontend/src/components/ui/badge.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export class Badge extends TailwindElement {
4646
return html`
4747
<span
4848
class=${clsx(
49-
tw`inline-flex h-[1.125rem] items-center justify-center align-[1px] text-xs`,
49+
tw`inline-flex h-[1rem] items-center justify-center align-[1px] text-xs`,
5050
this.outline
5151
? [
5252
tw`ring-1`,

frontend/src/features/qa/page-list/helpers/page.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ import type { ArchivedItemQAPage } from "@/types/qa";
44
export type Page = ArchivedItemPage | ArchivedItemQAPage;
55

66
export const isQaPage = (page: Page): page is ArchivedItemQAPage => {
7-
if ("qa" in page) return true;
7+
if ("qa" in page) return !!page.qa;
88
return false;
99
};

frontend/src/features/qa/page-list/page-list.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,9 @@ export class PageList extends BtrixElement {
8484
@property({ type: String })
8585
qaRunId?: string;
8686

87+
@property({ type: Boolean })
88+
analyzed?: boolean;
89+
8790
@property({ type: String })
8891
itemPageId?: string;
8992

@@ -131,7 +134,7 @@ export class PageList extends BtrixElement {
131134
<div
132135
class="z-40 mb-1 flex flex-wrap items-center gap-2 rounded-lg border bg-neutral-50 p-2"
133136
>
134-
${when(this.qaRunId, () => this.renderSortControl())}
137+
${when(this.qaRunId && this.analyzed, () => this.renderSortControl())}
135138
${this.renderFilterControl()}
136139
</div>
137140
<div

frontend/src/features/qa/qa-run-dropdown.ts

Lines changed: 87 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { localized, msg } from "@lit/localize";
1+
import { localized, msg, str } from "@lit/localize";
22
import type { SlSelectEvent } from "@shoelace-style/shoelace";
33
import { html } from "lit";
44
import { customElement, property } from "lit/decorators.js";
@@ -8,6 +8,8 @@ import { type QARun } from "@/types/qa";
88

99
export type SelectDetail = { item: { id: string } };
1010

11+
const inProgressLabel = msg("Analysis in progress");
12+
1113
/**
1214
* @fires btrix-select
1315
*/
@@ -17,45 +19,112 @@ export class QaRunDropdown extends BtrixElement {
1719
@property({ type: Array })
1820
items: QARun[] = [];
1921

22+
@property({ type: String })
23+
crawlId?: string;
24+
2025
@property({ type: String })
2126
selectedId?: string;
2227

2328
render() {
2429
if (!this.items.length) return;
2530

31+
if (this.items.length === 1) {
32+
const run = this.items[0];
33+
34+
if (!run.finished) {
35+
const startedDate =
36+
run.started &&
37+
this.localize.date(run.started, {
38+
year: "numeric",
39+
month: "long",
40+
day: "numeric",
41+
hour: "2-digit",
42+
minute: "2-digit",
43+
timeZoneName: "short",
44+
});
45+
46+
return html`<btrix-popover
47+
content=${msg(str`Analysis started on ${startedDate}`)}
48+
>
49+
<span class="inline-flex items-center gap-1.5">
50+
<btrix-crawl-status
51+
type="qa"
52+
hideLabel
53+
state=${run.state}
54+
slot="prefix"
55+
hoist
56+
></btrix-crawl-status>
57+
<span class="text-neutral-600">${inProgressLabel}</span>
58+
</span>
59+
</btrix-popover>`;
60+
}
61+
}
62+
2663
const selectedRun = this.selectedId
2764
? this.items.find(({ id }) => id === this.selectedId)
2865
: null;
2966

67+
const finishedDate =
68+
selectedRun?.finished &&
69+
this.localize.date(selectedRun.finished, {
70+
year: "numeric",
71+
month: "long",
72+
day: "numeric",
73+
hour: "2-digit",
74+
minute: "2-digit",
75+
timeZoneName: "short",
76+
});
77+
78+
const startedDate =
79+
selectedRun?.started &&
80+
this.localize.date(selectedRun.started, {
81+
year: "numeric",
82+
month: "long",
83+
day: "numeric",
84+
hour: "2-digit",
85+
minute: "2-digit",
86+
timeZoneName: "short",
87+
});
88+
3089
return html`
31-
<sl-dropdown @sl-select=${this.onSelect} distance="-2">
32-
<sl-button slot="trigger" variant="text" size="small" caret>
33-
${selectedRun
34-
? html`<btrix-crawl-status
35-
type="qa"
36-
hideLabel
37-
state=${selectedRun.state}
38-
slot="prefix"
39-
hoist
40-
></btrix-crawl-status>
41-
${selectedRun.finished
42-
? this.localize.date(selectedRun.finished)
43-
: msg("In progress")}`
44-
: msg("Select a QA run")}
45-
</sl-button>
90+
<sl-dropdown @sl-select=${this.onSelect} distance="-2" hoist>
91+
<div slot="trigger">
92+
<btrix-popover
93+
placement="top"
94+
content=${finishedDate
95+
? msg(str`Analysis finished on ${finishedDate}`)
96+
: msg(str`Analysis started on ${startedDate}`)}
97+
?disabled=${!startedDate && !finishedDate}
98+
>
99+
<sl-button variant="text" size="small" caret>
100+
${selectedRun
101+
? html`<btrix-crawl-status
102+
type="qa"
103+
hideLabel
104+
state=${selectedRun.state}
105+
slot="prefix"
106+
hoist
107+
></btrix-crawl-status>
108+
${selectedRun.finished
109+
? this.localize.date(selectedRun.finished)
110+
: inProgressLabel}`
111+
: msg("Select Analysis Run")}
112+
</sl-button>
113+
</btrix-popover>
114+
</div>
46115
<sl-menu>
47116
${this.items.map((run) => {
48117
const isSelected = selectedRun && run.id === selectedRun.id;
49118
return html`
50119
<sl-menu-item
51120
value=${run.id}
52121
type="checkbox"
53-
?disabled=${isSelected}
122+
?disabled=${!run.finished}
54123
?checked=${isSelected}
55124
>
56125
${run.finished
57126
? this.localize.date(run.finished)
58-
: msg("In progress")}
127+
: inProgressLabel}
59128
<btrix-crawl-status
60129
type="qa"
61130
hideLabel

frontend/src/pages/org/archived-item-detail/archived-item-detail.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,9 @@ export class ArchivedItemDetail extends BtrixElement {
104104
@state()
105105
mostRecentNonFailedQARun?: QARun;
106106

107+
@state()
108+
private mostRecentSuccessQARun?: QARun;
109+
107110
@query("#stopQARunDialog")
108111
private readonly stopQARunDialog?: Dialog | null;
109112

@@ -137,7 +140,7 @@ export class ArchivedItemDetail extends BtrixElement {
137140
}
138141

139142
private get reviewUrl(): string {
140-
return `${new URL(window.location.href).pathname}/review/screenshots?qaRunId=${this.qaRunId || ""}`;
143+
return `${new URL(window.location.href).pathname}/review/screenshots${this.mostRecentSuccessQARun ? `?qaRunId=${this.mostRecentSuccessQARun.id}` : ""}`;
141144
}
142145

143146
private timerId?: number;
@@ -186,15 +189,19 @@ export class ArchivedItemDetail extends BtrixElement {
186189
this.mostRecentNonFailedQARun = this.qaRuns?.find((run) =>
187190
isNotFailed(run),
188191
);
192+
this.mostRecentSuccessQARun = this.qaRuns?.find((run) =>
193+
isSuccessfullyFinished(run),
194+
);
189195
}
190196
if (
191197
(changedProperties.has("qaRuns") ||
192198
changedProperties.has("mostRecentNonFailedQARun")) &&
193-
this.qaRuns &&
194-
this.mostRecentNonFailedQARun?.id
199+
this.qaRuns
195200
) {
196201
if (!this.qaRunId) {
197-
this.qaRunId = this.mostRecentNonFailedQARun.id;
202+
this.qaRunId = this.qaRuns.find((run) =>
203+
isSuccessfullyFinished(run),
204+
)?.id;
198205
}
199206
}
200207

@@ -304,6 +311,7 @@ export class ArchivedItemDetail extends BtrixElement {
304311
.qaRuns=${this.qaRuns}
305312
.qaRunId=${this.qaRunId}
306313
.mostRecentNonFailedQARun=${this.mostRecentNonFailedQARun}
314+
.mostRecentSuccessQARun=${this.mostRecentSuccessQARun}
307315
@btrix-qa-runs-update=${() => void this.fetchQARuns()}
308316
></btrix-archived-item-detail-qa>
309317
`,

frontend/src/pages/org/archived-item-detail/ui/qa.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,9 @@ export class ArchivedItemDetailQA extends BtrixElement {
101101
@property({ attribute: false })
102102
mostRecentNonFailedQARun?: QARun;
103103

104+
@property({ attribute: false })
105+
mostRecentSuccessQARun?: QARun;
106+
104107
@state()
105108
private pages?: APIPaginatedList<ArchivedItemPage>;
106109

@@ -643,7 +646,6 @@ export class ArchivedItemDetailQA extends BtrixElement {
643646
const remainingPageCount = pageCount - analyzedPageCount;
644647
const remainderBarLabel = qaIsRunning ? msg("Pending") : msg("Incomplete");
645648

646-
console.log({ pageCount, barData, analyzedPageCount });
647649
return html`
648650
<btrix-meter class="flex-1" value=${analyzedPageCount} max=${pageCount}>
649651
${barData.map((bar) => {
@@ -782,7 +784,7 @@ export class ArchivedItemDetailQA extends BtrixElement {
782784
rowClickTarget="a"
783785
>
784786
<a
785-
href=${`${this.navigate.orgBasePath}/workflows/${this.workflowId}/crawls/${this.crawlId}/review/screenshots?qaRunId=${this.qaRunId || ""}&itemPageId=${page.id}`}
787+
href=${`${this.navigate.orgBasePath}/workflows/${this.workflowId}/crawls/${this.crawlId}/review/screenshots?qaRunId=${this.mostRecentSuccessQARun?.id || ""}&itemPageId=${page.id}`}
786788
title=${msg(str`Review "${page.title ?? page.url}"`)}
787789
@click=${this.navigate.link}
788790
>

0 commit comments

Comments
 (0)