Skip to content

Commit d12ce9a

Browse files
ikreymerSuaYoo
andauthored
sidebar setup guide fixes: (#2105)
- ensure user-guide iframe is always visible if not fading in when 'Setup Guide' button is clicked - Clicking 'Setup Guide' scrolls to relevant section of guide (scope, limits, browser settings, scheduling, metadata) based on current workflow editor tab via hashtag --------- Co-authored-by: sua yoo <sua@webrecorder.org>
1 parent dde5056 commit d12ce9a

File tree

3 files changed

+43
-4
lines changed

3 files changed

+43
-4
lines changed

docs/user-guide/workflow-setup.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,3 +276,7 @@ Apply tags to the workflow. Tags applied to the workflow will propagate to every
276276
### Collection Auto-Add
277277

278278
Search for and specify [collections](collections.md) that this crawl workflow should automatically add archived items to as soon as crawling finishes. Canceled and Failed crawls will not be added to collections.
279+
280+
## Review Settings
281+
282+
This section lists all the previously entered settings for final review. If there are any errors from the previous form sections, they will be listed at the top. The errors need to be corrected before the crawl workflow can be created.

frontend/src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -850,14 +850,14 @@ export class App extends LiteElement {
850850
iframe.removeEventListener("load", oneLoad);
851851
};
852852

853-
iframe.classList.add(tw`opacity-0`);
854-
855853
if (pathName) {
856854
if (iframe.src.slice(this.docsUrl.length) !== pathName) {
855+
iframe.classList.add(tw`opacity-0`);
857856
iframe.addEventListener("load", oneLoad);
858857
iframe.src = `${this.docsUrl}${pathName}`;
859858
}
860859
} else {
860+
iframe.classList.add(tw`opacity-0`);
861861
iframe.addEventListener("load", oneLoad);
862862
iframe.src = this.docsUrl;
863863
}

frontend/src/pages/org/workflows-new.ts

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { localized, msg } from "@lit/localize";
22
import { mergeDeep } from "immutable";
3-
import { customElement, property } from "lit/decorators.js";
3+
import { customElement, property, state } from "lit/decorators.js";
44
import { ifDefined } from "lit/directives/if-defined.js";
55
import { when } from "lit/directives/when.js";
66

@@ -12,6 +12,23 @@ import { WorkflowScopeType } from "@/types/workflow";
1212
import LiteElement, { html } from "@/utils/LiteElement";
1313
import type { FormState as WorkflowFormState } from "@/utils/workflow";
1414

15+
type GuideHash =
16+
| "scope"
17+
| "limits"
18+
| "browser-settings"
19+
| "scheduling"
20+
| "metadata"
21+
| "review-settings";
22+
23+
const workflowTabToGuideHash: Record<string, GuideHash> = {
24+
crawlSetup: "scope",
25+
crawlLimits: "limits",
26+
browserSettings: "browser-settings",
27+
crawlScheduling: "scheduling",
28+
crawlMetadata: "metadata",
29+
confirmSettings: "review-settings",
30+
};
31+
1532
/**
1633
* Usage:
1734
* ```ts
@@ -33,6 +50,24 @@ export class WorkflowsNew extends LiteElement {
3350
@property({ type: Object })
3451
initialWorkflow?: WorkflowParams;
3552

53+
@state()
54+
private userGuideHashLink: GuideHash = "scope";
55+
56+
connectedCallback(): void {
57+
super.connectedCallback();
58+
59+
this.userGuideHashLink =
60+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
61+
workflowTabToGuideHash[window.location.hash.slice(1) as GuideHash] ||
62+
"scope";
63+
64+
window.addEventListener("hashchange", () => {
65+
const hashValue = window.location.hash.slice(1) as GuideHash;
66+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
67+
this.userGuideHashLink = workflowTabToGuideHash[hashValue] || "scope";
68+
});
69+
}
70+
3671
private get defaultNewWorkflow(): WorkflowParams {
3772
return {
3873
name: "",
@@ -93,7 +128,7 @@ export class WorkflowsNew extends LiteElement {
93128
UserGuideEventMap["btrix-user-guide-show"]["detail"]
94129
>("btrix-user-guide-show", {
95130
detail: {
96-
path: "/user-guide/workflow-setup/#scope",
131+
path: `/user-guide/workflow-setup/#${this.userGuideHashLink}`,
97132
},
98133
bubbles: true,
99134
}),

0 commit comments

Comments
 (0)