@@ -16,9 +16,7 @@ import {
1616import { labelFor } from "@/strings/crawl-workflows/labels" ;
1717import scopeTypeLabel from "@/strings/crawl-workflows/scopeType" ;
1818import sectionStrings from "@/strings/crawl-workflows/section" ;
19- import type { Collection } from "@/types/collection" ;
2019import { WorkflowScopeType , type StorageSeedFile } from "@/types/workflow" ;
21- import { isApiError } from "@/utils/api" ;
2220import { unescapeCustomPrefix } from "@/utils/crawl-workflows/unescapeCustomPrefix" ;
2321import { DEPTH_SUPPORTED_SCOPES , isPageScopeType } from "@/utils/crawler" ;
2422import { humanizeSchedule } from "@/utils/cron" ;
@@ -60,13 +58,9 @@ export class ConfigDetails extends BtrixElement {
6058 maxPagesPerCrawl ?: number ;
6159 } ;
6260
63- @state ( )
64- private collections : Collection [ ] = [ ] ;
65-
6661 async connectedCallback ( ) {
6762 super . connectedCallback ( ) ;
6863 void this . fetchOrgDefaults ( ) ;
69- await this . fetchCollections ( ) ;
7064 }
7165
7266 render ( ) {
@@ -313,6 +307,22 @@ export class ConfigDetails extends BtrixElement {
313307 ) }
314308 ` ,
315309 } ) }
310+ ${ when ( ! this . hideMetadata , ( ) =>
311+ this . renderSection ( {
312+ id : "collection" ,
313+ heading : sectionStrings . collection ,
314+ renderDescItems : ( ) => html `
315+ ${ this . renderSetting (
316+ html `< span class ="mb-1 inline-block "> ${ msg ( "Auto-Add" ) } </ span > ` ,
317+ crawlConfig ?. autoAddCollections . length
318+ ? html `< btrix-linked-collections-list
319+ .collectionIds =${ crawlConfig . autoAddCollections }
320+ > </ btrix-linked-collections-list > `
321+ : undefined ,
322+ ) }
323+ ` ,
324+ } ) ,
325+ ) }
316326 ${ when ( ! this . hideMetadata , ( ) =>
317327 this . renderSection ( {
318328 id : "crawl-metadata" ,
@@ -338,21 +348,6 @@ export class ConfigDetails extends BtrixElement {
338348 )
339349 : [ ] ,
340350 ) }
341- ${ this . renderSetting (
342- msg ( "Collections" ) ,
343- this . collections . length
344- ? this . collections . map (
345- ( coll ) =>
346- html `< sl-tag class ="mr-2 mt-1 " variant ="neutral ">
347- ${ coll . name }
348- < span class ="font-monostyle pl-1 text-xs ">
349- (${ this . localize . number ( coll . crawlCount ) }
350- ${ pluralOf ( "items" , coll . crawlCount ) } )
351- </ span >
352- </ sl-tag > ` ,
353- )
354- : undefined ,
355- ) }
356351 ` ,
357352 } ) ,
358353 ) }
@@ -633,44 +628,6 @@ export class ConfigDetails extends BtrixElement {
633628 ` ;
634629 }
635630
636- private async fetchCollections ( ) {
637- if ( this . crawlConfig ?. autoAddCollections ) {
638- try {
639- await this . getCollections ( ) ;
640- } catch ( e ) {
641- this . notify . toast ( {
642- message :
643- isApiError ( e ) && e . statusCode === 404
644- ? msg ( "Collections not found." )
645- : msg (
646- "Sorry, couldn't retrieve Collection details at this time." ,
647- ) ,
648- variant : "danger" ,
649- icon : "exclamation-octagon" ,
650- id : "collection-fetch-status" ,
651- } ) ;
652- }
653- }
654- }
655-
656- private async getCollections ( ) {
657- const collections : Collection [ ] = [ ] ;
658- const orgId = this . crawlConfig ?. oid ;
659-
660- if ( this . crawlConfig ?. autoAddCollections && orgId ) {
661- for ( const collectionId of this . crawlConfig . autoAddCollections ) {
662- const data = await this . api . fetch < Collection | undefined > (
663- `/orgs/${ orgId } /collections/${ collectionId } ` ,
664- ) ;
665- if ( data ) {
666- collections . push ( data ) ;
667- }
668- }
669- }
670- this . collections = collections ;
671- this . requestUpdate ( ) ;
672- }
673-
674631 // TODO Consolidate with workflow-editor
675632 private async fetchOrgDefaults ( ) {
676633 try {
0 commit comments