Improve new config navigation UX (#508)

* add job type to url

* add back to choose crawl type

* update for duplicate

* enable jumping into section
This commit is contained in:
sua yoo 2023-01-19 09:39:45 -08:00 committed by GitHub
parent ccd87e0dff
commit f780cb534b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 60 additions and 23 deletions

View File

@ -578,6 +578,7 @@ export class App extends LiteElement {
case "browser": case "browser":
case "crawlTemplate": case "crawlTemplate":
case "crawlTemplateEdit": case "crawlTemplateEdit":
case "crawlTemplateNew":
return html`<btrix-org return html`<btrix-org
class="w-full" class="w-full"
@navigate=${this.onNavigateTo} @navigate=${this.onNavigateTo}
@ -593,7 +594,8 @@ export class App extends LiteElement {
crawlConfigId=${this.viewState.params.crawlConfigId} crawlConfigId=${this.viewState.params.crawlConfigId}
crawlId=${this.viewState.params.crawlId} crawlId=${this.viewState.params.crawlId}
?isAddingMember=${this.viewState.route === "orgAddMember"} ?isAddingMember=${this.viewState.route === "orgAddMember"}
?isNewResourceTab=${this.viewState.route === "orgNewResourceTab"} ?isNewResourceTab=${this.viewState.route === "orgNewResourceTab" ||
this.viewState.route === "crawlTemplateNew"}
?isEditing=${"edit" in this.viewState.params} ?isEditing=${"edit" in this.viewState.params}
></btrix-org>`; ></btrix-org>`;

View File

@ -100,7 +100,7 @@ type FormState = {
const getDefaultProgressState = (hasConfigId = false): ProgressState => { const getDefaultProgressState = (hasConfigId = false): ProgressState => {
let activeTab: StepName = "crawlSetup"; let activeTab: StepName = "crawlSetup";
if (hasConfigId && window.location.hash) { if (window.location.hash) {
const hashValue = window.location.hash.slice(1); const hashValue = window.location.hash.slice(1);
if (STEPS.includes(hashValue as any)) { if (STEPS.includes(hashValue as any)) {

View File

@ -459,9 +459,12 @@ export class CrawlTemplatesDetail extends LiteElement {
tags: this.crawlConfig.tags, tags: this.crawlConfig.tags,
}; };
this.navTo(`/orgs/${this.orgId}/crawl-configs/new`, { this.navTo(
`/orgs/${this.orgId}/crawl-configs/new?jobType=${crawlTemplate.jobType}`,
{
crawlTemplate, crawlTemplate,
}); }
);
this.notify({ this.notify({
message: msg(str`Copied crawl configuration to new template.`), message: msg(str`Copied crawl configuration to new template.`),

View File

@ -169,7 +169,7 @@ export class CrawlTemplatesList extends LiteElement {
<div class="grow-0 mb-4"> <div class="grow-0 mb-4">
<sl-button <sl-button
href=${`/orgs/${this.orgId}/crawl-configs/new`} href=${`/orgs/${this.orgId}/crawl-configs/new?jobType`}
variant="primary" variant="primary"
@click=${this.navLink} @click=${this.navLink}
> >
@ -611,9 +611,12 @@ export class CrawlTemplatesList extends LiteElement {
tags: template.tags, tags: template.tags,
}; };
this.navTo(`/orgs/${this.orgId}/crawl-configs/new`, { this.navTo(
`/orgs/${this.orgId}/crawl-configs/new?jobType=${crawlTemplate.jobType}`,
{
crawlTemplate, crawlTemplate,
}); }
);
this.notify({ this.notify({
message: msg(str`Copied crawl configuration to new template.`), message: msg(str`Copied crawl configuration to new template.`),

View File

@ -50,21 +50,38 @@ export class CrawlTemplatesNew extends LiteElement {
@state() @state()
private jobType?: JobType; private jobType?: JobType;
connectedCallback() {
super.connectedCallback();
if (!this.jobType) {
const url = new URL(window.location.href);
this.jobType = (url.searchParams.get("jobType") as JobType) || undefined;
}
}
private renderHeader() { private renderHeader() {
let href = `/orgs/${this.orgId}/crawl-configs`;
let label = msg("Back to Crawl Configs");
// Allow user to go back to choose crawl type if new (not duplicated) config
if (this.jobType && !this.initialCrawlTemplate.jobType) {
href = `/orgs/${this.orgId}/crawl-configs/new`;
label = msg("Choose Crawl Type");
}
return html` return html`
<nav class="mb-5"> <nav class="mb-5">
<a <a
class="text-gray-600 hover:text-gray-800 text-sm font-medium" class="text-gray-600 hover:text-gray-800 text-sm font-medium"
href=${`/orgs/${this.orgId}/crawl-configs`} href=${href}
@click=${this.navLink} @click=${(e: any) => {
this.navLink(e);
this.jobType = undefined;
}}
> >
<sl-icon <sl-icon
name="arrow-left" name="arrow-left"
class="inline-block align-middle" class="inline-block align-middle"
></sl-icon> ></sl-icon>
<span class="inline-block align-middle" <span class="inline-block align-middle">${label}</span>
>${msg("Back to Crawl Configs")}</span
>
</a> </a>
</nav> </nav>
`; `;
@ -116,10 +133,14 @@ export class CrawlTemplatesNew extends LiteElement {
<div <div
class="border rounded p-8 md:py-12 flex flex-col md:flex-row items-start justify-evenly" class="border rounded p-8 md:py-12 flex flex-col md:flex-row items-start justify-evenly"
> >
<div <a
role="button" role="button"
class="jobTypeButton" class="jobTypeButton"
@click=${() => (this.jobType = "url-list")} href=${`/orgs/${this.orgId}/crawl-configs/new?jobType=url-list`}
@click=${(e: any) => {
this.navLink(e);
this.jobType = "url-list";
}}
> >
<figure class="w-64 m-4"> <figure class="w-64 m-4">
<img class="transition-transform" src=${urlListSvg} /> <img class="transition-transform" src=${urlListSvg} />
@ -132,11 +153,15 @@ export class CrawlTemplatesNew extends LiteElement {
</p> </p>
</figcaption> </figcaption>
</figure> </figure>
</div> </a>
<div <a
role="button" role="button"
class="jobTypeButton" class="jobTypeButton"
@click=${() => (this.jobType = "seed-crawl")} href=${`/orgs/${this.orgId}/crawl-configs/new?jobType=seed-crawl`}
@click=${(e: any) => {
this.navLink(e);
this.jobType = "seed-crawl";
}}
> >
<figure class="w-64 m-4"> <figure class="w-64 m-4">
<img class="transition-transform" src=${seededCrawlSvg} /> <img class="transition-transform" src=${seededCrawlSvg} />
@ -149,7 +174,7 @@ export class CrawlTemplatesNew extends LiteElement {
</p> </p>
</figcaption> </figcaption>
</figure> </figure>
</div> </a>
</div> </div>
`; `;
} }

View File

@ -736,9 +736,12 @@ export class CrawlsList extends LiteElement {
tags: template.tags, tags: template.tags,
}; };
this.navTo(`/orgs/${crawl.oid}/crawl-configs/new`, { this.navTo(
`/orgs/${crawl.oid}/crawl-configs/new?jobType=${crawlTemplate.jobType}`,
{
crawlTemplate, crawlTemplate,
}); }
);
this.notify({ this.notify({
message: msg(str`Copied crawl configuration to new template.`), message: msg(str`Copied crawl configuration to new template.`),

View File

@ -19,6 +19,7 @@ export const ROUTES = {
"/orgs/:id/:tab/profile/browser/:browserId?name&description&profileId&navigateUrl", "/orgs/:id/:tab/profile/browser/:browserId?name&description&profileId&navigateUrl",
crawlTemplate: "/orgs/:id/:tab/config/:crawlConfigId", crawlTemplate: "/orgs/:id/:tab/config/:crawlConfigId",
crawlTemplateEdit: "/orgs/:id/:tab/config/:crawlConfigId?edit", crawlTemplateEdit: "/orgs/:id/:tab/config/:crawlConfigId?edit",
crawlTemplateNew: "/orgs/:id/:tab/new?jobType",
users: "/users", users: "/users",
usersInvite: "/users/invite", usersInvite: "/users/invite",
crawls: "/crawls", crawls: "/crawls",