Skip to content

Commit b73bea1

Browse files
committed
allows opening in new tab
1 parent b8c622c commit b73bea1

File tree

1 file changed

+69
-31
lines changed

1 file changed

+69
-31
lines changed

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

Lines changed: 69 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import { ShareableNotice } from "./templates/shareable-notice";
2525

2626
import { BtrixElement } from "@/classes/BtrixElement";
2727
import type { OverflowDropdown } from "@/components/ui/overflow-dropdown";
28-
import { WorkflowTab } from "@/routes";
28+
import { OrgTab, WorkflowTab } from "@/routes";
2929
import { noData } from "@/strings/ui";
3030
import type { ListWorkflow } from "@/types/crawler";
3131
import { humanizeSchedule } from "@/utils/cron";
@@ -40,15 +40,15 @@ export type WorkflowColumnName =
4040
| "actions";
4141

4242
const columnWidths = {
43-
name: "minmax(18rem, 1fr)",
43+
// TODO Consolidate with table.stylesheet.css
44+
// https://github.com/webrecorder/browsertrix/issues/3001
45+
name: "[clickable-start] minmax(18rem, 1fr)",
4446
"latest-crawl": "minmax(15rem, 18rem)",
4547
"total-crawls": "minmax(6rem, 9rem)",
4648
modified: "minmax(12rem, 15rem)",
47-
actions: "3rem",
49+
actions: "[clickable-end] 3rem",
4850
} as const satisfies Record<WorkflowColumnName, string>;
4951

50-
// postcss-lit-disable-next-line
51-
const mediumBreakpointCss = css`30rem`;
5252
// postcss-lit-disable-next-line
5353
const largeBreakpointCss = css`60rem`;
5454
// postcss-lit-disable-next-line
@@ -65,11 +65,6 @@ const rowCss = css`
6565
right: 0;
6666
}
6767
68-
@media only screen and (min-width: ${mediumBreakpointCss}) {
69-
.row {
70-
grid-template-columns: repeat(2, 1fr);
71-
}
72-
}
7368
@media only screen and (min-width: ${largeBreakpointCss}) {
7469
.row {
7570
grid-template-columns: var(--btrix-workflow-list-columns);
@@ -252,6 +247,43 @@ export class WorkflowListItem extends BtrixElement {
252247
border-left: 1px solid var(--sl-panel-border-color);
253248
}
254249
}
250+
251+
/*
252+
* TODO Consolidate with table.stylesheet.css
253+
* https://github.com/webrecorder/browsertrix/issues/3001
254+
*/
255+
.rowClickTarget--cell {
256+
display: grid;
257+
grid-template-columns: subgrid;
258+
white-space: nowrap;
259+
overflow: hidden;
260+
}
261+
262+
.rowClickTarget {
263+
max-width: 100%;
264+
}
265+
266+
.col sl-tooltip > *,
267+
.col btrix-popover > *,
268+
.col btrix-overflow-dropdown {
269+
/* Place above .rowClickTarget::after overlay */
270+
z-index: 10;
271+
position: relative;
272+
}
273+
274+
.rowClickTarget::after {
275+
content: "";
276+
display: block;
277+
position: absolute;
278+
inset: 0;
279+
grid-column: clickable-start / clickable-end;
280+
}
281+
282+
.rowClickTarget:focus-visible {
283+
outline: var(--sl-focus-ring);
284+
outline-offset: -0.25rem;
285+
border-radius: 0.5rem;
286+
}
255287
`,
256288
];
257289

@@ -271,13 +303,18 @@ export class WorkflowListItem extends BtrixElement {
271303
@query("btrix-overflow-dropdown")
272304
dropdownMenu!: OverflowDropdown;
273305

306+
@query("a")
307+
private readonly anchor?: HTMLAnchorElement | null;
308+
274309
private readonly columnTemplate = {
275-
name: () =>
276-
html`<div class="col">
277-
<div class="detail url items-center truncate">
310+
name: () => {
311+
const href = `/orgs/${this.orgSlugState}/${OrgTab.Workflows}/${this.workflow?.id}/${this.workflow?.lastCrawlState?.startsWith("failed") ? WorkflowTab.Logs : WorkflowTab.LatestCrawl}`;
312+
313+
return html`<div class="col rowClickTarget--cell">
314+
<a class="detail url rowClickTarget items-center truncate" href=${href}>
278315
${when(this.workflow?.shareable, ShareableNotice)}
279316
${this.safeRender(this.renderName)}
280-
</div>
317+
</a>
281318
<div class="desc truncate">
282319
${this.safeRender((workflow) => {
283320
if (workflow.schedule) {
@@ -291,7 +328,8 @@ export class WorkflowListItem extends BtrixElement {
291328
return msg("---");
292329
})}
293330
</div>
294-
</div>`,
331+
</div>`;
332+
},
295333
"latest-crawl": () =>
296334
html`<div class="col">${this.safeRender(this.renderLatestCrawl)}</div>`,
297335
"total-crawls": () =>
@@ -358,20 +396,7 @@ export class WorkflowListItem extends BtrixElement {
358396
} satisfies Record<WorkflowColumnName, () => TemplateResult>;
359397

360398
render() {
361-
return html`<div
362-
class="item row"
363-
role="button"
364-
@click=${async (e: MouseEvent) => {
365-
if (e.target === this.dropdownMenu) {
366-
return;
367-
}
368-
e.preventDefault();
369-
await this.updateComplete;
370-
const failedStates = ["failed", "failed_not_logged_in"];
371-
const href = `/orgs/${this.orgSlugState}/workflows/${this.workflow?.id}/${failedStates.includes(this.workflow?.lastCrawlState || "") ? WorkflowTab.Logs : WorkflowTab.LatestCrawl}`;
372-
this.navigate.to(href);
373-
}}
374-
>
399+
return html`<div class="item row">
375400
${this.columns
376401
? this.columns.map((col) => this.columnTemplate[col]())
377402
: Object.values(this.columnTemplate).map((render) => render())}
@@ -480,7 +505,7 @@ export class WorkflowListItem extends BtrixElement {
480505

481506
return html`
482507
<sl-tooltip hoist placement="bottom" ?disabled=${!tooltipContent}>
483-
<div>
508+
<div class="w-max" @click=${this.redirectEventToAnchor}>
484509
<div class="detail">${status}</div>
485510
<div class="desc duration">${duration}</div>
486511
</div>
@@ -495,7 +520,7 @@ export class WorkflowListItem extends BtrixElement {
495520

496521
return html`
497522
<sl-tooltip hoist placement="bottom">
498-
<div>
523+
<div class="w-max" @click=${this.redirectEventToAnchor}>
499524
<div class="detail truncate">
500525
${workflow.modifiedByName
501526
? html`<btrix-user-chip
@@ -548,6 +573,19 @@ export class WorkflowListItem extends BtrixElement {
548573
>${nameSuffix}
549574
`;
550575
};
576+
577+
/*
578+
* TODO Remove when refactored to `btrix-table`
579+
* https://github.com/webrecorder/browsertrix/issues/3001
580+
*/
581+
private readonly redirectEventToAnchor = (e: MouseEvent) => {
582+
if (!e.defaultPrevented) {
583+
const newEvent = new MouseEvent(e.type, e);
584+
e.stopPropagation();
585+
586+
this.anchor?.dispatchEvent(newEvent);
587+
}
588+
};
551589
}
552590

553591
@customElement("btrix-workflow-list")

0 commit comments

Comments
 (0)