Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions frontend/src/features/archived-items/archived-item-tag-filter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@ import {
state,
} from "lit/decorators.js";
import { repeat } from "lit/directives/repeat.js";
import queryString from "query-string";
import { isFocusable } from "tabbable";

import { BtrixElement } from "@/classes/BtrixElement";
import type { BtrixChangeEvent } from "@/events/btrix-change";
import type { ArchivedItem } from "@/types/crawler";
import { type WorkflowTag, type WorkflowTags } from "@/types/workflow";
import { stopProp } from "@/utils/events";
import { isNotEqual } from "@/utils/is-not-equal";
Expand All @@ -44,6 +46,9 @@ export class ArchivedItemTagFilter extends BtrixElement {
@property({ type: Array })
tags?: string[];

@property({ type: String })
itemType?: ArchivedItem["type"];

@state()
private searchString = "";

Expand Down Expand Up @@ -93,17 +98,23 @@ export class ArchivedItemTagFilter extends BtrixElement {
}

private readonly orgTagsTask = new Task(this, {
task: async () => {
task: async ([itemType], { signal }) => {
const query = queryString.stringify({
onlySuccessful: true,
crawlType: itemType,
});

const { tags } = await this.api.fetch<WorkflowTags>(
`/orgs/${this.orgId}/all-crawls/tagCounts`,
`/orgs/${this.orgId}/all-crawls/tagCounts?${query}`,
{ signal },
);

this.fuse.setCollection(tags);

// Match fuse shape
return tags.map((item) => ({ item }));
},
args: () => [] as const,
args: () => [this.itemType] as const,
});

render() {
Expand Down
1 change: 1 addition & 0 deletions frontend/src/pages/org/archived-items.ts
Original file line number Diff line number Diff line change
Expand Up @@ -641,6 +641,7 @@ export class CrawlsList extends BtrixElement {

<btrix-archived-item-tag-filter
.tags=${this.filterByTags.value}
itemType=${ifDefined(this.itemType || undefined)}
@btrix-change=${(e: BtrixChangeArchivedItemTagFilterEvent) => {
this.filterByTags.setValue(e.detail.value?.tags);
this.filterByTagsType.setValue(e.detail.value?.type || "or");
Expand Down
Loading