Skip to content

Commit 6b05f95

Browse files
authored
consistent empty state
1 parent 0b402e5 commit 6b05f95

5 files changed

Lines changed: 202 additions & 58 deletions

File tree

frontend/src/pages/org/archived-items.ts

Lines changed: 55 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,11 @@ import orgUploadsContext from "@/context/org-uploads";
2828
import { ClipboardController } from "@/controllers/clipboard";
2929
import PollTask from "@/controllers/poll";
3030
import { SearchParamsValue } from "@/controllers/searchParamsValue";
31+
import { type BtrixUserGuideShowEvent } from "@/events/btrix-user-guide-show";
3132
import { type BtrixChangeArchivedItemStateFilterEvent } from "@/features/archived-items/archived-item-state-filter";
3233
import { CrawlStatus } from "@/features/archived-items/crawl-status";
3334
import { type BtrixChangeQARatingFilterEvent } from "@/features/archived-items/qa-rating-filter";
35+
import { emptyMessage } from "@/layouts/emptyMessage";
3436
import { pageHeader } from "@/layouts/pageHeader";
3537
import type { APIPaginatedList, APIPaginationQuery } from "@/types/api";
3638
import { UPLOAD_STATES, type CrawlState } from "@/types/crawlState";
@@ -1005,13 +1007,59 @@ export class CrawlsList extends BtrixElement {
10051007
`;
10061008
}
10071009

1008-
return html`
1009-
<div class="border-b border-t py-5">
1010-
<p class="text-center text-neutral-500">
1011-
${msg("No archived items yet.")}
1012-
</p>
1013-
</div>
1014-
`;
1010+
if (this.itemType === "crawl") {
1011+
return html`
1012+
<div class="border-b border-t py-5">
1013+
<p class="text-center text-neutral-500">
1014+
${msg("No crawled items yet.")}
1015+
</p>
1016+
</div>
1017+
`;
1018+
}
1019+
1020+
const message = msg("Your org doesn’t have any archived items yet.");
1021+
const guideButton = html`<sl-button
1022+
variant="text"
1023+
@click=${() => {
1024+
this.dispatchEvent(
1025+
new CustomEvent<BtrixUserGuideShowEvent["detail"]>(
1026+
"btrix-user-guide-show",
1027+
{
1028+
detail: { path: "archived-items" },
1029+
bubbles: true,
1030+
composed: true,
1031+
},
1032+
),
1033+
);
1034+
}}
1035+
>
1036+
<sl-icon slot="prefix" name="book"></sl-icon>
1037+
${msg("Read Guide")}
1038+
</sl-button>`;
1039+
1040+
if (this.isCrawler) {
1041+
return emptyMessage({
1042+
classNames: tw`border-y`,
1043+
message,
1044+
detail: msg(
1045+
"Archived items are the result of a web archiving process, like crawl workflows.",
1046+
),
1047+
actions: html`<sl-button
1048+
@click=${() => (this.isUploadingArchive = true)}
1049+
?disabled=${isArchivingDisabled(this.org)}
1050+
>
1051+
<sl-icon slot="prefix" name="plus-lg"></sl-icon>
1052+
${msg("Import Archived Item")}
1053+
</sl-button>
1054+
${guideButton}`,
1055+
});
1056+
}
1057+
1058+
return emptyMessage({
1059+
classNames: tw`border-y`,
1060+
message,
1061+
actions: guideButton,
1062+
});
10151063
}
10161064

10171065
private async getArchivedItems(

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

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import { parsePage, type PageChangeEvent } from "@/components/ui/pagination";
2020
import type { BtrixChangeTagFilterEvent } from "@/components/ui/tag-filter/types";
2121
import { ClipboardController } from "@/controllers/clipboard";
2222
import { SearchParamsValue } from "@/controllers/searchParamsValue";
23+
import { type BtrixUserGuideShowEvent } from "@/events/btrix-user-guide-show";
2324
import { originsWithRemainder } from "@/features/browser-profiles/templates/origins-with-remainder";
2425
import { emptyMessage } from "@/layouts/emptyMessage";
2526
import { pageHeader } from "@/layouts/pageHeader";
@@ -33,6 +34,7 @@ import { SortDirection as SortDirectionEnum } from "@/types/utils";
3334
import { isApiError } from "@/utils/api";
3435
import { isArchivingDisabled } from "@/utils/orgs";
3536
import { toSearchItem, type SearchValues } from "@/utils/searchValues";
37+
import { tw } from "@/utils/tailwind";
3638

3739
const SORT_DIRECTIONS = ["asc", "desc"] as const;
3840
type SortDirection = (typeof SORT_DIRECTIONS)[number];
@@ -316,11 +318,17 @@ export class BrowserProfilesList extends BtrixElement {
316318
`
317319
: this.renderEmpty()}
318320
`,
321+
this.renderLoading,
319322
)}
320323
${when(this.selectedProfile, this.renderDuplicateDialog)}
321324
`;
322325
};
323326

327+
private readonly renderLoading = () =>
328+
html`<div class="my-24 flex w-full items-center justify-center text-2xl">
329+
<sl-spinner></sl-spinner>
330+
</div>`;
331+
324332
private readonly renderDuplicateDialog = (profile: Profile) => {
325333
return html`<btrix-profile-browser-dialog
326334
.profile=${profile}
@@ -353,9 +361,28 @@ export class BrowserProfilesList extends BtrixElement {
353361
}
354362

355363
const message = msg("Your org doesn’t have any browser profiles yet.");
364+
const guideButton = html`<sl-button
365+
variant="text"
366+
@click=${() => {
367+
this.dispatchEvent(
368+
new CustomEvent<BtrixUserGuideShowEvent["detail"]>(
369+
"btrix-user-guide-show",
370+
{
371+
detail: { path: "browser-profiles" },
372+
bubbles: true,
373+
composed: true,
374+
},
375+
),
376+
);
377+
}}
378+
>
379+
<sl-icon slot="prefix" name="book"></sl-icon>
380+
${msg("Read Guide")}
381+
</sl-button>`;
356382

357383
if (this.isCrawler) {
358384
return emptyMessage({
385+
classNames: tw`border-y`,
359386
message,
360387
detail: msg(
361388
"Browser profiles let you crawl pages behind paywalls and logins.",
@@ -376,11 +403,16 @@ export class BrowserProfilesList extends BtrixElement {
376403
<sl-icon slot="prefix" name="plus-lg"></sl-icon>
377404
${msg("Create Browser Profile")}
378405
</sl-button>
406+
${guideButton}
379407
`,
380408
});
381409
}
382410

383-
return emptyMessage({ message });
411+
return emptyMessage({
412+
classNames: tw`border-y`,
413+
message,
414+
actions: guideButton,
415+
});
384416
}
385417

386418
private renderControls() {

frontend/src/pages/org/collections-list.ts

Lines changed: 46 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,12 @@ import { when } from "lit/directives/when.js";
1313
import debounce from "lodash/fp/debounce";
1414
import queryString from "query-string";
1515

16-
import type { SelectNewDialogEvent } from ".";
17-
1816
import { BtrixElement } from "@/classes/BtrixElement";
1917
import { parsePage, type PageChangeEvent } from "@/components/ui/pagination";
2018
import { WithSearchOrgContext } from "@/context/search-org/WithSearchOrgContext";
2119
import { ClipboardController } from "@/controllers/clipboard";
2220
import type { BtrixRequestOrgUpdate } from "@/events/btrix-request-org-update";
21+
import { type BtrixUserGuideShowEvent } from "@/events/btrix-user-guide-show";
2322
import { SelectCollectionAccess } from "@/features/collections/select-collection-access";
2423
import { emptyMessage } from "@/layouts/emptyMessage";
2524
import { pageHeader } from "@/layouts/pageHeader";
@@ -299,7 +298,7 @@ export class CollectionsList extends WithSearchOrgContext(BtrixElement) {
299298
}
300299

301300
private readonly renderLoading = () =>
302-
html`<div class="my-24 flex w-full items-center justify-center text-3xl">
301+
html`<div class="my-24 flex w-full items-center justify-center text-2xl">
303302
<sl-spinner></sl-spinner>
304303
</div>`;
305304

@@ -535,39 +534,51 @@ export class CollectionsList extends WithSearchOrgContext(BtrixElement) {
535534
}
536535

537536
const message = msg("Your org doesn’t have any collections yet.");
537+
const guideButton = html`<sl-button
538+
variant="text"
539+
@click=${() => {
540+
this.dispatchEvent(
541+
new CustomEvent<BtrixUserGuideShowEvent["detail"]>(
542+
"btrix-user-guide-show",
543+
{
544+
detail: { path: "collection" },
545+
bubbles: true,
546+
composed: true,
547+
},
548+
),
549+
);
550+
}}
551+
>
552+
<sl-icon slot="prefix" name="book"></sl-icon>
553+
${msg("Read Guide")}
554+
</sl-button>`;
538555

539-
return html`
540-
${when(
541-
this.isCrawler,
542-
() =>
543-
emptyMessage({
544-
classNames: tw`border-y`,
545-
message,
546-
detail: msg(
547-
"Collections let you easily organize, replay, and share multiple crawls.",
548-
),
549-
actions: html`
550-
<sl-button
551-
@click=${() => {
552-
this.dispatchEvent(
553-
new CustomEvent("select-new-dialog", {
554-
detail: "collection",
555-
}) as SelectNewDialogEvent,
556-
);
557-
}}
558-
>
559-
<sl-icon slot="prefix" name="plus-lg"></sl-icon>
560-
${msg("Create Collection")}
561-
</sl-button>
562-
`,
563-
}),
564-
() =>
565-
emptyMessage({
566-
classNames: tw`border-y`,
567-
message,
568-
}),
569-
)}
570-
`;
556+
if (this.isCrawler) {
557+
return emptyMessage({
558+
classNames: tw`border-y`,
559+
message,
560+
detail: msg(
561+
"Collections let you easily organize, replay, and share multiple crawls.",
562+
),
563+
actions: html`
564+
<sl-button
565+
@click=${() => {
566+
this.openDialogName = "create";
567+
}}
568+
>
569+
<sl-icon slot="prefix" name="plus-lg"></sl-icon>
570+
${msg("Create New Collection")}
571+
</sl-button>
572+
${guideButton}
573+
`,
574+
});
575+
}
576+
577+
return emptyMessage({
578+
classNames: tw`border-y`,
579+
message,
580+
actions: guideButton,
581+
});
571582
};
572583

573584
private readonly renderItem = (col: Collection) => {

frontend/src/pages/org/crawling.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,18 @@ export class OrgCrawling extends BtrixElement {
4545
variant="primary"
4646
size="small"
4747
?disabled=${this.org?.readOnly}
48-
@click=${() =>
49-
this.navigate.to(
50-
`${this.navigate.orgBasePath}/workflows/new`,
51-
{
52-
scopeType:
53-
this.appState.userPreferences?.newWorkflowScopeType,
54-
},
55-
)}
48+
href=${`${this.navigate.orgBasePath}/workflows/new`}
49+
@click=${(e: MouseEvent) => {
50+
if (e.metaKey) {
51+
return;
52+
}
53+
e.preventDefault();
54+
55+
this.navigate.to((e.target as HTMLAnchorElement).href, {
56+
scopeType:
57+
this.appState.userPreferences?.newWorkflowScopeType,
58+
});
59+
}}
5660
>
5761
<sl-icon slot="prefix" name="plus-lg"></sl-icon>
5862
${msg("New Workflow")}</sl-button

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

Lines changed: 56 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import activeCrawlsCountContext, {
2929
} from "@/context/active-crawls-count";
3030
import { makeUpdateActiveCrawlsCountEvent } from "@/context/active-crawls-count/events";
3131
import { SearchParamsValue } from "@/controllers/searchParamsValue";
32+
import { type BtrixUserGuideShowEvent } from "@/events/btrix-user-guide-show";
3233
import {
3334
Action,
3435
type BtrixSelectActionEvent,
@@ -40,6 +41,7 @@ import {
4041
WorkflowSearch,
4142
type SearchFields,
4243
} from "@/features/crawl-workflows/workflow-search";
44+
import { emptyMessage } from "@/layouts/emptyMessage";
4345
import { WorkflowTab } from "@/routes";
4446
import { deleteConfirmation } from "@/strings/ui";
4547
import type { APIPaginatedList, APIPaginationQuery } from "@/types/api";
@@ -754,7 +756,7 @@ export class WorkflowsList extends BtrixElement {
754756
<div class="rounded-lg border bg-neutral-50 p-4">
755757
<p class="text-center">
756758
<span class="text-neutral-400"
757-
>${msg("No matching Workflows found.")}</span
759+
>${msg("No matching workflows found.")}</span
758760
>
759761
<button
760762
class="font-medium text-neutral-500 underline hover:no-underline"
@@ -777,16 +779,63 @@ export class WorkflowsList extends BtrixElement {
777779
`;
778780
}
779781

780-
return html`
781-
<div class="border-b border-t py-5">
782-
<p class="text-center text-neutral-500">${msg("No Workflows yet.")}</p>
783-
</div>
784-
`;
782+
const message = msg("Your org doesn’t have any crawl workflows yet.");
783+
const guideButton = html`<sl-button
784+
variant="text"
785+
@click=${() => {
786+
this.dispatchEvent(
787+
new CustomEvent<BtrixUserGuideShowEvent["detail"]>(
788+
"btrix-user-guide-show",
789+
{
790+
detail: { path: "crawl-workflows" },
791+
bubbles: true,
792+
composed: true,
793+
},
794+
),
795+
);
796+
}}
797+
>
798+
<sl-icon slot="prefix" name="book"></sl-icon>
799+
${msg("Read Guide")}
800+
</sl-button>`;
801+
802+
if (this.appState.isCrawler) {
803+
return emptyMessage({
804+
classNames: tw`border-y`,
805+
message,
806+
detail: msg("Schedule, run, and manage crawls with crawl workflows."),
807+
actions: html`
808+
<sl-button
809+
href=${`${this.navigate.orgBasePath}/workflows/new`}
810+
@click=${(e: MouseEvent) => {
811+
if (e.metaKey) {
812+
return;
813+
}
814+
e.preventDefault();
815+
816+
this.navigate.to((e.target as HTMLAnchorElement).href, {
817+
scopeType: this.appState.userPreferences?.newWorkflowScopeType,
818+
});
819+
}}
820+
>
821+
<sl-icon slot="prefix" name="plus-lg"></sl-icon>
822+
${msg("Create New Workflow")}
823+
</sl-button>
824+
${guideButton}
825+
`,
826+
});
827+
}
828+
829+
return emptyMessage({
830+
classNames: tw`border-y`,
831+
message,
832+
actions: guideButton,
833+
});
785834
}
786835

787836
private renderLoading() {
788837
return html`<div
789-
class="my-24 flex w-full items-center justify-center text-3xl"
838+
class="my-24 flex w-full items-center justify-center text-2xl"
790839
>
791840
<sl-spinner></sl-spinner>
792841
</div>`;

0 commit comments

Comments
 (0)