Skip to content

Commit d8817e6

Browse files
emma-sgikreymer
andauthored
Disable "Fail crawl if not logged in" unless a browser profile is selected (#2832)
Closes #2829 ## Changes Disables the "Fail crawl if not logged in" checkbox in the workflow editor unless a browser profile is selected, as otherwise the crawl will always fail if it hits a website that the behavior exists (since there's no logins included in the default profile) --------- Co-authored-by: Ilya Kreymer <[email protected]>
1 parent 4373ff6 commit d8817e6

File tree

1 file changed

+65
-3
lines changed

1 file changed

+65
-3
lines changed

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

Lines changed: 65 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -943,6 +943,23 @@ export class WorkflowEditor extends BtrixElement {
943943
};
944944

945945
private readonly renderPageScope = () => {
946+
const linkToBrowserSettings = (label: string) =>
947+
html`<button
948+
type="button"
949+
class="text-blue-600 hover:text-blue-500"
950+
@click=${async () => {
951+
this.updateProgressState({ activeTab: "browserSettings" });
952+
953+
await this.updateComplete;
954+
955+
void this.scrollToActivePanel();
956+
}}
957+
>
958+
${label}
959+
</button>`;
960+
const link_to_browser_profile = linkToBrowserSettings(
961+
msg("Browser Profile"),
962+
);
946963
return html`
947964
${this.formState.scopeType === ScopeType.Page
948965
? html`
@@ -1016,8 +1033,18 @@ export class WorkflowEditor extends BtrixElement {
10161033
${inputCol(html`
10171034
<sl-checkbox
10181035
name="failOnContentCheck"
1019-
?checked=${this.formState.failOnContentCheck}
1036+
?checked=${this.formState.failOnContentCheck &&
1037+
this.formState.browserProfile !== null}
1038+
?disabled=${this.formState.browserProfile === null}
10201039
>
1040+
${this.formState.browserProfile === null
1041+
? html`<span slot="help-text">
1042+
${msg(
1043+
html`Custom logged in ${link_to_browser_profile} is required
1044+
to use this option.`,
1045+
)}
1046+
</span>`
1047+
: nothing}
10211048
${msg("Fail crawl if not logged in")}
10221049
</sl-checkbox>
10231050
`)}
@@ -1372,6 +1399,24 @@ https://replayweb.page/docs`}
13721399
const additionalUrlList = urlListToArray(this.formState.urlList);
13731400
const maxUrls = this.localize.number(URL_LIST_MAX_URLS);
13741401

1402+
const linkToBrowserSettings = (label: string) =>
1403+
html`<button
1404+
type="button"
1405+
class="text-blue-600 hover:text-blue-500"
1406+
@click=${async () => {
1407+
this.updateProgressState({ activeTab: "browserSettings" });
1408+
1409+
await this.updateComplete;
1410+
1411+
void this.scrollToActivePanel();
1412+
}}
1413+
>
1414+
${label}
1415+
</button>`;
1416+
const link_to_browser_profile = linkToBrowserSettings(
1417+
msg("Browser Profile"),
1418+
);
1419+
13751420
return html`
13761421
${inputCol(html`
13771422
<sl-input
@@ -1516,8 +1561,17 @@ https://example.net`}
15161561
${inputCol(html`
15171562
<sl-checkbox
15181563
name="failOnContentCheck"
1519-
?checked=${this.formState.failOnContentCheck}
1564+
?checked=${this.formState.failOnContentCheck &&
1565+
this.formState.browserProfile !== null}
1566+
?disabled=${this.formState.browserProfile === null}
15201567
>
1568+
${this.formState.browserProfile === null
1569+
? html`<span slot="help-text">
1570+
${msg(
1571+
html`Select a ${link_to_browser_profile} to use this option.`,
1572+
)}
1573+
</span>`
1574+
: nothing}
15211575
${msg("Fail crawl if not logged in")}
15221576
</sl-checkbox>
15231577
`)}
@@ -1911,7 +1965,7 @@ https://archiveweb.page/images/${"logo.svg"}`}
19111965
.profileId=${this.formState.browserProfile?.id}
19121966
@on-change=${(e: SelectBrowserProfileChangeEvent) =>
19131967
this.updateFormState({
1914-
browserProfile: e.detail.value,
1968+
browserProfile: e.detail.value ?? null,
19151969
})}
19161970
></btrix-select-browser-profile>
19171971
`)}
@@ -2844,6 +2898,14 @@ https://archiveweb.page/images/${"logo.svg"}`}
28442898
}
28452899
}
28462900

2901+
// Disable failOnContentCheck if no browser profile is selected
2902+
// This is done here rather than in `willChange` so that the state of the checkbox
2903+
// can be remembered if the switches from a browser profile to no browser profile,
2904+
// and then back to a browser profile
2905+
if (this.formState.browserProfile === null) {
2906+
this.formState.failOnContentCheck = false;
2907+
}
2908+
28472909
const isValid = await this.checkFormValidity(this.formElem);
28482910

28492911
if (!isValid || this.formHasError) {

0 commit comments

Comments
 (0)