Skip to content

Commit 5e493a0

Browse files
authored
Merge pull request #3024 from webrecorder/frontend-browser-profile-ui-enhancements
Resolves #2936
2 parents fba1e46 + c7eb835 commit 5e493a0

File tree

80 files changed

+4716
-2844
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+4716
-2844
lines changed
Lines changed: 7 additions & 0 deletions
Loading

frontend/src/components/ui/badge.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ export type BadgeVariant =
1313
| "primary"
1414
| "cyan"
1515
| "blue"
16-
| "high-contrast";
16+
| "high-contrast"
17+
| "text"
18+
| "text-neutral";
1719

1820
/**
1921
* Show numeric value in a label
@@ -64,6 +66,8 @@ export class Badge extends TailwindElement {
6466
primary: tw`bg-white text-primary ring-primary`,
6567
cyan: tw`bg-cyan-50 text-cyan-600 ring-cyan-600`,
6668
blue: tw`bg-blue-50 text-blue-600 ring-blue-600`,
69+
text: tw`text-blue-500 ring-blue-600`,
70+
"text-neutral": tw`text-neutral-500 ring-neutral-600`,
6771
}[this.variant],
6872
]
6973
: {
@@ -75,6 +79,8 @@ export class Badge extends TailwindElement {
7579
primary: tw`bg-primary text-neutral-0`,
7680
cyan: tw`bg-cyan-50 text-cyan-600`,
7781
blue: tw`bg-blue-50 text-blue-600`,
82+
text: tw`text-blue-500`,
83+
"text-neutral": tw`text-neutral-500`,
7884
}[this.variant],
7985
this.pill
8086
? [

frontend/src/components/ui/code/index.ts

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import type { LanguageFn } from "highlight.js";
33
import hljs from "highlight.js/lib/core";
44
import { css, html } from "lit";
55
import { customElement, property } from "lit/decorators.js";
6+
import { ifDefined } from "lit/directives/if-defined.js";
67
import { html as staticHtml, unsafeStatic } from "lit/static-html.js";
78

89
import { TailwindElement } from "@/classes/TailwindElement";
@@ -52,11 +53,11 @@ export class Code extends TailwindElement {
5253
}
5354
5455
.hljs-path {
55-
color: var(--sl-color-blue-900);
56+
color: var(--sl-color-sky-600);
5657
}
5758
5859
.hljs-domain {
59-
color: var(--sl-color-blue-600);
60+
color: var(--sl-color-sky-700);
6061
}
6162
6263
.hljs-string {
@@ -71,7 +72,10 @@ export class Code extends TailwindElement {
7172
language: Language = Language.XML;
7273

7374
@property({ type: Boolean })
74-
wrap = true;
75+
noWrap = false;
76+
77+
@property({ type: Boolean })
78+
truncate = false;
7579

7680
async connectedCallback() {
7781
const languageFn = (await langaugeFiles[this.language]).default;
@@ -94,8 +98,11 @@ export class Code extends TailwindElement {
9498
part="base"
9599
class=${clsx(
96100
tw`font-monospace m-0 text-neutral-600`,
97-
this.wrap ? tw`whitespace-pre-wrap` : tw`whitespace-nowrap`,
101+
this.noWrap ? tw`whitespace-nowrap` : tw`whitespace-pre-wrap`,
102+
this.truncate && tw`truncate`,
98103
)}
99-
><code>${staticHtml`${unsafeStatic(htmlStr)}`}</code></pre>`;
104+
><code title=${ifDefined(
105+
this.truncate ? this.value : undefined,
106+
)}>${staticHtml`${unsafeStatic(htmlStr)}`}</code></pre>`;
100107
}
101108
}

frontend/src/components/ui/config-details.ts

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { consume } from "@lit/context";
12
import { localized, msg, str } from "@lit/localize";
23
import ISO6391 from "iso-639-1";
34
import { html, nothing, type TemplateResult } from "lit";
@@ -6,6 +7,10 @@ import { when } from "lit/directives/when.js";
67
import capitalize from "lodash/fp/capitalize";
78

89
import { BtrixElement } from "@/classes/BtrixElement";
10+
import {
11+
orgProxiesContext,
12+
type OrgProxiesContext,
13+
} from "@/context/org-proxies";
914
import { none, notSpecified } from "@/layouts/empty";
1015
import {
1116
Behavior,
@@ -36,6 +41,9 @@ import { getServerDefaults } from "@/utils/workflow";
3641
@customElement("btrix-config-details")
3742
@localized()
3843
export class ConfigDetails extends BtrixElement {
44+
@consume({ context: orgProxiesContext, subscribe: true })
45+
private readonly orgProxies?: OrgProxiesContext;
46+
3947
@property({ type: Object })
4048
crawlConfig?: CrawlConfig;
4149

@@ -235,29 +243,37 @@ export class ConfigDetails extends BtrixElement {
235243
msg("Browser Profile"),
236244
when(
237245
crawlConfig?.profileid,
238-
() =>
239-
html`<a
240-
class="text-blue-500 hover:text-blue-600"
246+
() => html`
247+
<btrix-link
241248
href=${`${this.navigate.orgBasePath}/browser-profiles/profile/${
242249
crawlConfig!.profileid
243250
}`}
244-
@click=${this.navigate.link}
251+
hideIcon
245252
>
246253
${crawlConfig?.profileName}
247-
</a>`,
254+
</btrix-link>
255+
`,
248256
() =>
249257
crawlConfig?.profileName ||
250258
html`<span class="text-neutral-400"
251259
>${msg("No custom profile")}</span
252260
>`,
253261
),
254262
)}
263+
${crawlConfig?.proxyId
264+
? this.renderSetting(
265+
msg("Crawler Proxy Server"),
266+
this.orgProxies?.servers.find(
267+
({ id }) => id === crawlConfig.proxyId,
268+
)?.label || capitalize(crawlConfig.proxyId),
269+
)
270+
: nothing}
255271
${this.renderSetting(
256272
msg("Browser Windows"),
257273
crawlConfig?.browserWindows ? `${crawlConfig.browserWindows}` : "",
258274
)}
259275
${this.renderSetting(
260-
msg("Crawler Channel (Exact Crawler Version)"),
276+
`${msg("Crawler Channel")} ${crawlConfig?.image ? msg("(Exact Crawler Version)") : ""}`.trim(),
261277
capitalize(
262278
crawlConfig?.crawlerChannel || CrawlerChannelImage.Default,
263279
) + (crawlConfig?.image ? ` (${crawlConfig.image})` : ""),
@@ -284,9 +300,6 @@ export class ConfigDetails extends BtrixElement {
284300
ISO6391.getName(seedsConfig.lang),
285301
)
286302
: nothing}
287-
${crawlConfig?.proxyId
288-
? this.renderSetting(msg("Proxy"), capitalize(crawlConfig.proxyId))
289-
: nothing}
290303
`,
291304
})}
292305
${this.renderSection({

frontend/src/components/ui/desc-list.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ export class DescList extends LitElement {
127127
vertical: !this.horizontal,
128128
horizontal: this.horizontal,
129129
})}
130+
part="base"
130131
>
131132
<slot></slot>
132133
</dl>`;

frontend/src/components/ui/dialog.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ import {
1010
* <sl-dialog> with custom CSS
1111
*
1212
* Usage: see https://shoelace.style/components/dialog
13+
*
14+
* @attr label
15+
* @attr open
16+
* @attr noHeader
1317
*/
1418
@customElement("btrix-dialog")
1519
export class Dialog extends SlDialog {
@@ -27,8 +31,7 @@ export class Dialog extends SlDialog {
2731
}
2832
2933
.dialog__header {
30-
background-color: var(--sl-color-neutral-50);
31-
border-bottom: 1px solid var(--sl-color-neutral-100);
34+
border-bottom: 1px solid var(--sl-panel-border-color);
3235
}
3336
3437
.dialog__title {
@@ -50,7 +53,7 @@ export class Dialog extends SlDialog {
5053
.dialog__footer {
5154
padding-top: var(--sl-spacing-small);
5255
padding-bottom: var(--sl-spacing-small);
53-
border-top: 1px solid var(--sl-color-neutral-100);
56+
border-top: 1px solid var(--sl-panel-border-color);
5457
}
5558
`,
5659
];

frontend/src/components/ui/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import("./combobox");
1616
import("./config-details");
1717
import("./copy-button");
1818
import("./copy-field");
19+
import("./tag-container");
1920
import("./data-grid");
2021
import("./details");
2122
import("./file-input");
@@ -41,7 +42,8 @@ import("./select-crawler-proxy");
4142
import("./select-crawler");
4243
import("./syntax-input");
4344
import("./table");
44-
import("./tag-input");
4545
import("./tag");
46+
import("./tag-filter");
47+
import("./tag-input");
4648
import("./time-input");
4749
import("./user-language-select");

frontend/src/components/ui/link.ts

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import clsx from "clsx";
2-
import { html } from "lit";
2+
import { html, nothing } from "lit";
33
import { customElement, property } from "lit/decorators.js";
44
import { ifDefined } from "lit/directives/if-defined.js";
55

@@ -19,13 +19,16 @@ export class Link extends BtrixElement {
1919
@property({ type: String })
2020
variant: "primary" | "neutral" = "neutral";
2121

22+
@property({ type: Boolean })
23+
hideIcon = false;
24+
2225
render() {
2326
if (!this.href) return;
2427

2528
return html`
2629
<a
2730
class=${clsx(
28-
"group inline-flex items-center gap-1 transition-colors",
31+
"group inline-flex items-center gap-1 transition-colors duration-fast",
2932
{
3033
primary: "text-primary-500 hover:text-primary-600",
3134
neutral: "text-blue-500 hover:text-blue-600",
@@ -39,12 +42,16 @@ export class Link extends BtrixElement {
3942
: this.navigate.link}
4043
>
4144
<slot></slot>
42-
<sl-icon
43-
slot="suffix"
44-
name="arrow-right"
45-
class="size-4 transition-transform group-hover:translate-x-1"
46-
></sl-icon
47-
></a>
45+
${this.hideIcon
46+
? nothing
47+
: html`
48+
<sl-icon
49+
slot="suffix"
50+
name="arrow-right"
51+
class="size-4 transition-transform duration-fast group-hover:translate-x-1"
52+
></sl-icon>
53+
`}
54+
</a>
4855
`;
4956
}
5057
}

frontend/src/components/ui/select-crawler-proxy.ts

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { localized, msg } from "@lit/localize";
22
import type { SlSelect } from "@shoelace-style/shoelace";
3-
import { html } from "lit";
3+
import { html, type PropertyValues } from "lit";
44
import { customElement, property, state } from "lit/decorators.js";
55
import { ifDefined } from "lit/directives/if-defined.js";
66

@@ -40,15 +40,30 @@ export class SelectCrawlerProxy extends BtrixElement {
4040
@property({ type: String })
4141
defaultProxyId: string | null = null;
4242

43+
@property({ type: String })
44+
profileProxyId?: string | null = null;
45+
4346
@property({ type: Array })
4447
proxyServers: Proxy[] = [];
4548

4649
@property({ type: String })
4750
proxyId: string | null = null;
4851

52+
@property({ type: String })
53+
label?: string;
54+
4955
@property({ type: String })
5056
size?: SlSelect["size"];
5157

58+
@property({ type: String })
59+
placeholder?: string;
60+
61+
@property({ type: String })
62+
helpText?: string;
63+
64+
@property({ type: Boolean })
65+
disabled?: boolean;
66+
5267
@state()
5368
private selectedProxy?: Proxy;
5469

@@ -59,6 +74,18 @@ export class SelectCrawlerProxy extends BtrixElement {
5974
return this.selectedProxy?.id || "";
6075
}
6176

77+
protected willUpdate(changedProperties: PropertyValues): void {
78+
if (changedProperties.has("proxyId")) {
79+
if (this.proxyId) {
80+
this.selectedProxy = this.proxyServers.find(
81+
({ id }) => id === this.proxyId,
82+
);
83+
} else if (changedProperties.get("proxyId")) {
84+
this.selectedProxy = undefined;
85+
}
86+
}
87+
}
88+
6289
protected firstUpdated() {
6390
void this.initProxies();
6491
}
@@ -75,18 +102,21 @@ export class SelectCrawlerProxy extends BtrixElement {
75102
return html`
76103
<sl-select
77104
name="proxyId"
78-
label=${msg("Crawler Proxy Server")}
105+
label=${this.label || msg("Crawler Proxy Server")}
79106
value=${this.selectedProxy?.id || ""}
80107
placeholder=${this.defaultProxy
81108
? `${msg(`Default Proxy:`)} ${this.defaultProxy.label}`
82109
: msg("No Proxy")}
83110
hoist
84111
clearable
112+
?disabled=${this.disabled ?? Boolean(this.profileProxyId)}
85113
size=${ifDefined(this.size)}
86114
@sl-change=${this.onChange}
87115
@sl-hide=${this.stopProp}
88116
@sl-after-hide=${this.stopProp}
89117
>
118+
<slot name="prefix" slot="prefix"></slot>
119+
<slot name="suffix" slot="suffix"></slot>
90120
${this.proxyServers.map(
91121
(server) =>
92122
html` <sl-option value=${server.id}>
@@ -102,7 +132,7 @@ export class SelectCrawlerProxy extends BtrixElement {
102132
? html`
103133
<div slot="help-text">
104134
${msg("Description:")}
105-
<span class="font-monospace"
135+
<span class="font-monospace leading-tight"
106136
>${this.selectedProxy.description || ""}</span
107137
>
108138
</div>
@@ -112,12 +142,13 @@ export class SelectCrawlerProxy extends BtrixElement {
112142
? html`
113143
<div slot="help-text">
114144
${msg("Description:")}
115-
<span class="font-monospace"
145+
<span class="font-monospace leading-tight"
116146
>${this.defaultProxy.description || ""}</span
117147
>
118148
</div>
119149
`
120150
: ``}
151+
<slot name="help-text" slot="help-text"></slot>
121152
</sl-select>
122153
`;
123154
}

0 commit comments

Comments
 (0)