Skip to content

Commit 3fdbaeb

Browse files
committed
disable proxy selection
1 parent 3582fcf commit 3fdbaeb

File tree

6 files changed

+57
-9
lines changed

6 files changed

+57
-9
lines changed

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

Lines changed: 20 additions & 1 deletion
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

@@ -49,6 +49,12 @@ export class SelectCrawlerProxy extends BtrixElement {
4949
@property({ type: String })
5050
size?: SlSelect["size"];
5151

52+
@property({ type: String })
53+
helpText?: string;
54+
55+
@property({ type: Boolean })
56+
disabled?: boolean;
57+
5258
@state()
5359
private selectedProxy?: Proxy;
5460

@@ -59,6 +65,18 @@ export class SelectCrawlerProxy extends BtrixElement {
5965
return this.selectedProxy?.id || "";
6066
}
6167

68+
protected willUpdate(changedProperties: PropertyValues): void {
69+
if (changedProperties.has("proxyId")) {
70+
if (this.proxyId) {
71+
this.selectedProxy = this.proxyServers.find(
72+
({ id }) => id === this.proxyId,
73+
);
74+
} else if (changedProperties.get("proxyId")) {
75+
this.selectedProxy = undefined;
76+
}
77+
}
78+
}
79+
6280
protected firstUpdated() {
6381
void this.initProxies();
6482
}
@@ -82,6 +100,7 @@ export class SelectCrawlerProxy extends BtrixElement {
82100
: msg("No Proxy")}
83101
hoist
84102
clearable
103+
?disabled=${this.disabled}
85104
size=${ifDefined(this.size)}
86105
@sl-change=${this.onChange}
87106
@sl-hide=${this.stopProp}

frontend/src/controllers/localize.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,11 @@ export class LocalizeController extends SlLocalizeController {
5555
})
5656
: seconds > 60
5757
? html`<sl-relative-time
58-
class=${ifDefined(capitalize ? tw`capitalize` : undefined)}
58+
class=${ifDefined(
59+
capitalize
60+
? tw`inline-block first-letter:capitalize`
61+
: undefined,
62+
)}
5963
sync
6064
date=${dateStr}
6165
></sl-relative-time>`

frontend/src/features/browser-profiles/select-browser-profile.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
import { localized, msg } from "@lit/localize";
2-
import type { SlDrawer, SlSelect } from "@shoelace-style/shoelace";
2+
import type {
3+
SlChangeEvent,
4+
SlDrawer,
5+
SlSelect,
6+
} from "@shoelace-style/shoelace";
37
import { html, nothing, type PropertyValues } from "lit";
48
import { customElement, property, query, state } from "lit/decorators.js";
59
import { ifDefined } from "lit/directives/if-defined.js";
@@ -119,6 +123,7 @@ export class SelectBrowserProfile extends BtrixElement {
119123
${this.localize.relativeDate(
120124
this.selectedProfile.modified ||
121125
this.selectedProfile.created,
126+
{ capitalize: true },
122127
)}
123128
</span>
124129
`
@@ -188,6 +193,7 @@ export class SelectBrowserProfile extends BtrixElement {
188193
<btrix-desc-list-item label=${msg("Last Modified")}>
189194
${this.localize.relativeDate(
190195
modifiedByAnyDate || profile.created,
196+
{ capitalize: true },
191197
)}
192198
</btrix-desc-list-item>
193199
</btrix-desc-list>
@@ -279,7 +285,7 @@ export class SelectBrowserProfile extends BtrixElement {
279285
`;
280286
}
281287

282-
private async onChange(e: Event) {
288+
private async onChange(e: SlChangeEvent) {
283289
this.selectedProfile = this.browserProfiles?.find(
284290
({ id }) => id === (e.target as SlSelect | null)?.value,
285291
);

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

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1987,10 +1987,14 @@ https://archiveweb.page/images/${"logo.svg"}`}
19871987
${inputCol(html`
19881988
<btrix-select-browser-profile
19891989
.profileId=${this.formState.browserProfile?.id}
1990-
@on-change=${(e: SelectBrowserProfileChangeEvent) =>
1990+
@on-change=${(e: SelectBrowserProfileChangeEvent) => {
1991+
const profile = e.detail.value;
1992+
19911993
this.updateFormState({
1992-
browserProfile: e.detail.value ?? null,
1993-
})}
1994+
browserProfile: profile ?? null,
1995+
proxyId: profile?.proxyId ?? null,
1996+
});
1997+
}}
19941998
></btrix-select-browser-profile>
19951999
`)}
19962000
${this.renderHelpTextCol(infoTextFor["browserProfile"])}
@@ -2003,11 +2007,24 @@ https://archiveweb.page/images/${"logo.svg"}`}
20032007
)}
20042008
.proxyServers=${proxies.servers}
20052009
.proxyId="${this.formState.proxyId || ""}"
2010+
?disabled=${!!this.formState.browserProfile}
20062011
@btrix-change=${(e: SelectCrawlerProxyChangeEvent) =>
20072012
this.updateFormState({
20082013
proxyId: e.detail.value,
20092014
})}
20102015
></btrix-select-crawler-proxy>
2016+
${when(
2017+
this.formState.browserProfile,
2018+
() => html`
2019+
<div class="form-help-text">
2020+
<sl-icon
2021+
class="mr-0.5 align-[-.175em]"
2022+
name="info-circle"
2023+
></sl-icon>
2024+
${msg("Using proxy from browser profile.")}
2025+
</div>
2026+
`,
2027+
)}
20112028
`),
20122029
this.renderHelpTextCol(infoTextFor["proxyId"]),
20132030
]

frontend/src/pages/org/browser-profiles-list.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -578,7 +578,7 @@ export class BrowserProfilesList extends BtrixElement {
578578
: nothing}
579579
</btrix-table-cell>
580580
<btrix-table-cell>
581-
${this.localize.relativeDate(modifiedByAnyDate)}
581+
${this.localize.relativeDate(modifiedByAnyDate, { capitalize: true })}
582582
</btrix-table-cell>
583583
<btrix-table-cell class="p-0">
584584
${this.renderActions(data)}

frontend/src/pages/org/browser-profiles/profile.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,9 @@ export class BrowserProfilesProfilePage extends BtrixElement {
468468
</btrix-desc-list-item>
469469
<btrix-desc-list-item label=${msg("Last Modified")}>
470470
${this.renderDetail((profile) =>
471-
this.localize.relativeDate(modifiedByAnyDate || profile.created),
471+
this.localize.relativeDate(modifiedByAnyDate || profile.created, {
472+
capitalize: true,
473+
}),
472474
)}
473475
</btrix-desc-list-item>
474476
<btrix-desc-list-item label=${msg("Last Modified By")}>

0 commit comments

Comments
 (0)