Skip to content

Commit f216c26

Browse files
committed
clean up crawl list display
1 parent 7d533cd commit f216c26

File tree

10 files changed

+224
-163
lines changed

10 files changed

+224
-163
lines changed

frontend/src/components/ui/badge.ts

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ export class Badge extends TailwindElement {
2828
@property({ type: String })
2929
variant: BadgeVariant = "neutral";
3030

31+
@property({ type: String })
32+
size?: "medium" | "large" = "medium";
33+
3134
@property({ type: Boolean })
3235
outline = false;
3336

@@ -47,15 +50,16 @@ export class Badge extends TailwindElement {
4750
return html`
4851
<span
4952
class=${clsx(
50-
tw`inline-flex min-h-4 items-center justify-center align-[1px] text-xs leading-none`,
53+
tw`inline-flex min-h-4 items-center justify-center align-[1px] leading-none`,
54+
this.size === "medium" && tw`text-xs`,
5155
this.outline
5256
? [
53-
tw`ring-1`,
57+
tw`mx-px ring-1`,
5458
{
55-
success: tw`bg-success-500 text-success-500 ring-success-500`,
59+
success: tw`bg-success-50 text-success-700 ring-success-400`,
5660
warning: tw`bg-warning-600 text-warning-600 ring-warning-600`,
5761
danger: tw`bg-danger-500 text-danger-500 ring-danger-500`,
58-
neutral: tw`bg-neutral-100 text-neutral-600 ring-neutral-600`,
62+
neutral: tw`bg-neutral-100 text-neutral-600 ring-neutral-300`,
5963
"high-contrast": tw`bg-neutral-600 text-neutral-0 ring-neutral-0`,
6064
primary: tw`bg-white text-primary ring-primary`,
6165
cyan: tw`bg-cyan-50 text-cyan-600 ring-cyan-600`,
@@ -72,7 +76,12 @@ export class Badge extends TailwindElement {
7276
cyan: tw`bg-cyan-50 text-cyan-600`,
7377
blue: tw`bg-blue-50 text-blue-600`,
7478
}[this.variant],
75-
this.pill ? tw`min-w-[1.125rem] rounded-full px-1` : tw`rounded px-2`,
79+
this.pill
80+
? [
81+
tw`min-w-[1.125rem] rounded-full`,
82+
this.size === "large" ? tw`px-1.5 py-0.5` : tw`px-1`,
83+
]
84+
: [tw`rounded`, this.size === "large" ? tw`px-2.5 py-1` : tw`px-2`],
7685
)}
7786
part="base"
7887
>

frontend/src/features/archived-items/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import("./archived-item-list");
22
import("./archived-item-state-filter");
33
import("./archived-item-tag-filter");
4-
import("./crawl-list");
54
import("./crawl-log-table");
65
import("./crawl-logs");
76
import("./delete-item-dialog");

frontend/src/features/crawl-workflows/workflow-list.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,12 @@ export class WorkflowListItem extends BtrixElement {
452452
<sl-tooltip hoist placement="bottom">
453453
<div>
454454
<div class="detail truncate">
455-
<span class="userName">${workflow.modifiedByName}</span>
455+
${workflow.modifiedByName
456+
? html`<btrix-user-chip
457+
userId=${workflow.modifiedBy}
458+
userName=${workflow.modifiedByName}
459+
></btrix-user-chip>`
460+
: notSpecified}
456461
</div>
457462
<div class="desc">${shortDate(workflow.modified)}</div>
458463
</div>
Lines changed: 47 additions & 156 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,12 @@
1-
/**
2-
* Display list of crawls
3-
*
4-
* Usage example:
5-
* ```ts
6-
* <btrix-crawl-list>
7-
* <btrix-crawl-list-item .crawl=${crawl1}>
8-
* </btrix-crawl-list-item>
9-
* <btrix-crawl-list-item .crawl=${crawl2}>
10-
* </btrix-crawl-list-item>
11-
* </btrix-crawl-list>
12-
* ```
13-
*/
141
import { localized, msg } from "@lit/localize";
152
import { css, html, nothing, type TemplateResult } from "lit";
16-
import {
17-
customElement,
18-
property,
19-
query,
20-
queryAssignedElements,
21-
} from "lit/decorators.js";
3+
import { customElement, property, query } from "lit/decorators.js";
224
import { ifDefined } from "lit/directives/if-defined.js";
235

246
import { BtrixElement } from "@/classes/BtrixElement";
25-
import { TailwindElement } from "@/classes/TailwindElement";
267
import type { OverflowDropdown } from "@/components/ui/overflow-dropdown";
278
import type { Crawl } from "@/types/crawler";
28-
import { renderName } from "@/utils/crawler";
9+
import { isSkipped, renderName } from "@/utils/crawler";
2910
import { humanizeExecutionSeconds } from "@/utils/executionTimeFormatter";
3011

3112
/**
@@ -99,7 +80,7 @@ export class CrawlListItem extends BtrixElement {
9980
`;
10081
} else {
10182
const label = html`
102-
<btrix-table-cell class="clickLabel" role="generic">
83+
<btrix-table-cell class="clickLabel pl-0" role="generic">
10384
${this.safeRender((workflow) => renderName(workflow))}
10485
</btrix-table-cell>
10586
`;
@@ -114,6 +95,12 @@ export class CrawlListItem extends BtrixElement {
11495
`;
11596
}
11697

98+
const skipped = isSkipped(this.crawl);
99+
const hasExec = Boolean(this.crawl.crawlExecSeconds);
100+
const notApplicable = html`<sl-tooltip content=${msg("Not applicable")}>
101+
<sl-icon name="slash" class="text-base text-neutral-400"></sl-icon>
102+
</sl-tooltip>`;
103+
117104
return html`
118105
<btrix-table-row
119106
class=${this.href
@@ -171,51 +158,62 @@ export class CrawlListItem extends BtrixElement {
171158
minute="2-digit"
172159
></btrix-format-date>
173160
`
174-
: html`<span class="text-neutral-400" role="presentation"
175-
>---</span
176-
>`,
161+
: notApplicable,
177162
)}
178163
</btrix-table-cell>
179164
<btrix-table-cell>
180165
${this.safeRender((crawl) =>
181-
this.localize.humanizeDuration(
182-
(crawl.finished
183-
? new Date(crawl.finished)
184-
: new Date()
185-
).valueOf() - new Date(crawl.started).valueOf(),
186-
),
187-
)}
188-
</btrix-table-cell>
189-
<btrix-table-cell>
190-
${this.safeRender((crawl) =>
191-
humanizeExecutionSeconds(crawl.crawlExecSeconds),
166+
!skipped
167+
? html`<sl-tooltip>
168+
${humanizeExecutionSeconds(crawl.crawlExecSeconds, {
169+
style: "short",
170+
})}
171+
<span slot="content">
172+
${humanizeExecutionSeconds(crawl.crawlExecSeconds, {
173+
style: "long",
174+
})}
175+
</span>
176+
</sl-tooltip>`
177+
: notApplicable,
192178
)}
193179
</btrix-table-cell>
194180
<btrix-table-cell>
195181
${this.safeRender((crawl) => {
196-
const pagesFound = +(crawl.stats?.found || 0);
197-
if (crawl.finished) {
198-
const pagesComplete = crawl.pageCount ? +crawl.pageCount : 0;
199-
return `${this.localize.number(pagesComplete, { notation: "compact" })}`;
182+
if (hasExec) {
183+
const pagesComplete = crawl.finished
184+
? crawl.pageCount
185+
? +crawl.pageCount
186+
: 0
187+
: +(crawl.stats?.done || 0);
188+
189+
return this.localize.number(pagesComplete, {
190+
notation: "compact",
191+
});
200192
}
201193
202-
const pagesComplete = +(crawl.stats?.done || 0);
203-
return `${this.localize.number(pagesComplete, { notation: "compact" })} / ${this.localize.number(pagesFound, { notation: "compact" })}`;
194+
return notApplicable;
204195
})}
205196
</btrix-table-cell>
206197
<btrix-table-cell>
207198
${this.safeRender((crawl) =>
208-
this.localize.bytes(
209-
crawl.finished ? crawl.fileSize || 0 : +(crawl.stats?.size || 0),
210-
{
211-
unitDisplay: "narrow",
212-
},
213-
),
199+
hasExec
200+
? this.localize.bytes(
201+
crawl.finished
202+
? crawl.fileSize || 0
203+
: +(crawl.stats?.size || 0),
204+
)
205+
: notApplicable,
214206
)}
215207
</btrix-table-cell>
216208
<btrix-table-cell>
217209
<div class="max-w-sm truncate">
218-
${this.safeRender((crawl) => crawl.userName)}
210+
${this.safeRender(
211+
(crawl) =>
212+
html`<btrix-user-chip
213+
userId=${crawl.userid}
214+
userName=${crawl.userName}
215+
></btrix-user-chip>`,
216+
)}
219217
</div>
220218
</btrix-table-cell>
221219
<btrix-table-cell class="pl-1 pr-1">
@@ -248,110 +246,3 @@ export class CrawlListItem extends BtrixElement {
248246
</div>`;
249247
}
250248
}
251-
252-
/**
253-
* @slot
254-
*/
255-
@customElement("btrix-crawl-list")
256-
@localized()
257-
export class CrawlList extends TailwindElement {
258-
static styles = css`
259-
btrix-table {
260-
--btrix-table-cell-gap: var(--sl-spacing-x-small);
261-
--btrix-table-cell-padding-x: var(--sl-spacing-small);
262-
}
263-
264-
btrix-table-body {
265-
--btrix-table-cell-padding-y: var(--sl-spacing-2x-small);
266-
}
267-
268-
btrix-table-body ::slotted(*:nth-of-type(n + 2)) {
269-
--btrix-border-top: 1px solid var(--sl-panel-border-color);
270-
}
271-
272-
btrix-table-body ::slotted(*:first-of-type) {
273-
--btrix-border-radius-top: var(--sl-border-radius-medium);
274-
}
275-
276-
btrix-table-body ::slotted(*:last-of-type) {
277-
--btrix-border-radius-bottom: var(--sl-border-radius-medium);
278-
}
279-
`;
280-
281-
@property({ type: String })
282-
collectionId?: string;
283-
284-
@property({ type: String })
285-
workflowId?: string;
286-
287-
@queryAssignedElements({ selector: "btrix-crawl-list-item" })
288-
listItems!: HTMLElement[];
289-
290-
render() {
291-
return html` <style>
292-
btrix-table {
293-
--btrix-table-grid-template-columns: min-content [clickable-start]
294-
${this.workflowId ? "" : `30ch `}repeat(7, auto) [clickable-end]
295-
min-content;
296-
}
297-
</style>
298-
<btrix-overflow-scroll class="-mx-3 part-[content]:px-3">
299-
<btrix-table>
300-
<btrix-table-head class="mb-2">
301-
<btrix-table-header-cell class="pr-0">
302-
<span class="sr-only">${msg("Status")}</span>
303-
</btrix-table-header-cell>
304-
${this.workflowId
305-
? nothing
306-
: html`
307-
<btrix-table-header-cell>
308-
${msg("Name")}
309-
</btrix-table-header-cell>
310-
`}
311-
<btrix-table-header-cell>
312-
${msg("Started")}
313-
</btrix-table-header-cell>
314-
<btrix-table-header-cell>
315-
${msg("Finished")}
316-
</btrix-table-header-cell>
317-
<btrix-table-header-cell
318-
>${msg("Run Duration")}</btrix-table-header-cell
319-
>
320-
<btrix-table-header-cell
321-
>${msg("Execution Time")}</btrix-table-header-cell
322-
>
323-
<btrix-table-header-cell>${msg("Pages")}</btrix-table-header-cell>
324-
<btrix-table-header-cell>${msg("Size")}</btrix-table-header-cell>
325-
<btrix-table-header-cell>
326-
${msg("Run By")}
327-
</btrix-table-header-cell>
328-
<btrix-table-header-cell class="pl-1 pr-1">
329-
<span class="sr-only">${msg("Row actions")}</span>
330-
</btrix-table-header-cell>
331-
</btrix-table-head>
332-
<btrix-table-body class="rounded border">
333-
<slot @slotchange=${this.handleSlotchange}></slot>
334-
</btrix-table-body>
335-
</btrix-table>
336-
</btrix-overflow-scroll>`;
337-
}
338-
339-
private handleSlotchange() {
340-
const assignProp = (
341-
el: HTMLElement,
342-
attr: { name: string; value: string },
343-
) => {
344-
if (!el.attributes.getNamedItem(attr.name)) {
345-
el.setAttribute(attr.name, attr.value);
346-
}
347-
};
348-
349-
this.listItems.forEach((item) => {
350-
assignProp(item, {
351-
name: "collectionId",
352-
value: this.collectionId || "",
353-
});
354-
assignProp(item, { name: "workflowId", value: this.workflowId || "" });
355-
});
356-
}
357-
}

0 commit comments

Comments
 (0)