diff --git a/frontend/src/features/archived-items/archived-item-tag-filter.ts b/frontend/src/features/archived-items/archived-item-tag-filter.ts index 1cb1b2afba..0f2652b989 100644 --- a/frontend/src/features/archived-items/archived-item-tag-filter.ts +++ b/frontend/src/features/archived-items/archived-item-tag-filter.ts @@ -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"; @@ -44,6 +46,9 @@ export class ArchivedItemTagFilter extends BtrixElement { @property({ type: Array }) tags?: string[]; + @property({ type: String }) + itemType?: ArchivedItem["type"]; + @state() private searchString = ""; @@ -93,9 +98,15 @@ 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( - `/orgs/${this.orgId}/all-crawls/tagCounts`, + `/orgs/${this.orgId}/all-crawls/tagCounts?${query}`, + { signal }, ); this.fuse.setCollection(tags); @@ -103,7 +114,7 @@ export class ArchivedItemTagFilter extends BtrixElement { // Match fuse shape return tags.map((item) => ({ item })); }, - args: () => [] as const, + args: () => [this.itemType] as const, }); render() { diff --git a/frontend/src/pages/org/archived-items.ts b/frontend/src/pages/org/archived-items.ts index c273895958..de7efd49bc 100644 --- a/frontend/src/pages/org/archived-items.ts +++ b/frontend/src/pages/org/archived-items.ts @@ -641,6 +641,7 @@ export class CrawlsList extends BtrixElement { { this.filterByTags.setValue(e.detail.value?.tags); this.filterByTagsType.setValue(e.detail.value?.type || "or");