@@ -18,7 +18,7 @@ import type { AuthState } from "../../utils/AuthService";
18
18
import LiteElement , { html } from "../../utils/LiteElement" ;
19
19
import type { Crawl , CrawlState , Workflow , WorkflowParams } from "./types" ;
20
20
import type { APIPaginatedList , APIPaginationQuery } from "../../types/api" ;
21
- import { isActive } from "../../utils/crawler" ;
21
+ import { isActive , activeCrawlStates } from "../../utils/crawler" ;
22
22
23
23
type Crawls = APIPaginatedList & {
24
24
items : Crawl [ ] ;
@@ -78,6 +78,7 @@ export class CrawlsList extends LiteElement {
78
78
firstSeed : msg ( "Crawl Start URL" ) ,
79
79
cid : msg ( "Workflow ID" ) ,
80
80
} ;
81
+
81
82
@property ( { type : Object } )
82
83
authState ! : AuthState ;
83
84
@@ -87,6 +88,11 @@ export class CrawlsList extends LiteElement {
87
88
@property ( { type : Boolean } )
88
89
isCrawler ! : boolean ;
89
90
91
+ // TODO better handling of using same crawls-list
92
+ // component between superadmin view and regular view
93
+ @property ( { type : Boolean } )
94
+ isAdminView = false ;
95
+
90
96
// e.g. `/org/${this.orgId}/crawls`
91
97
@property ( { type : String } )
92
98
crawlsBaseUrl ! : string ;
@@ -103,7 +109,7 @@ export class CrawlsList extends LiteElement {
103
109
shouldFetch ?: boolean ;
104
110
105
111
@state ( )
106
- private lastFetched ?: number ;
112
+ private crawlStates : CrawlState [ ] = finishedCrawlStates ;
107
113
108
114
@state ( )
109
115
private crawls ?: Crawls ;
@@ -166,6 +172,15 @@ export class CrawlsList extends LiteElement {
166
172
}
167
173
168
174
protected willUpdate ( changedProperties : Map < string , any > ) {
175
+ if ( changedProperties . has ( "isAdminView" ) && this . isAdminView === true ) {
176
+ // TODO better handling of using same crawls-list
177
+ // component between superadmin view and regular view
178
+ this . crawlStates = activeCrawlStates ;
179
+ this . orderBy = {
180
+ field : "started" ,
181
+ direction : sortableFields [ "started" ] . defaultDirection ! ,
182
+ } ;
183
+ }
169
184
if (
170
185
changedProperties . has ( "shouldFetch" ) ||
171
186
changedProperties . get ( "crawlsBaseUrl" ) ||
@@ -199,7 +214,10 @@ export class CrawlsList extends LiteElement {
199
214
changedProperties . has ( "crawlsBaseUrl" ) ||
200
215
changedProperties . has ( "crawlsAPIBaseUrl" )
201
216
) {
202
- this . fetchConfigSearchValues ( ) ;
217
+ // TODO add back when API supports `orgs/all/crawlconfigs`
218
+ if ( ! this . isAdminView ) {
219
+ this . fetchConfigSearchValues ( ) ;
220
+ }
203
221
}
204
222
}
205
223
@@ -223,7 +241,11 @@ export class CrawlsList extends LiteElement {
223
241
<main>
224
242
<header class="contents">
225
243
<div class="flex w-full h-8 mb-4">
226
- <h1 class="text-xl font-semibold">${ msg ( "Finished Crawls" ) } </h1>
244
+ <h1 class="text-xl font-semibold">
245
+ ${ this . isAdminView
246
+ ? msg ( "Running Crawls" )
247
+ : msg ( "Finished Crawls" ) }
248
+ </h1>
227
249
</div>
228
250
<div
229
251
class="sticky z-10 mb-3 top-2 p-4 bg-neutral-50 border rounded-lg"
@@ -266,7 +288,7 @@ export class CrawlsList extends LiteElement {
266
288
class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-[minmax(0,100%)_fit-content(100%)_fit-content(100%)] gap-x-2 gap-y-2 items-center"
267
289
>
268
290
<div class="col-span-1 md:col-span-2 lg:col-span-1">
269
- ${ this . renderSearch ( ) }
291
+ ${ when ( ! this . isAdminView , ( ) => this . renderSearch ( ) ) }
270
292
</div>
271
293
<div class="flex items-center">
272
294
<div class="text-neutral-500 mx-2">${ msg ( "View:" ) } </div>
@@ -277,7 +299,9 @@ export class CrawlsList extends LiteElement {
277
299
pill
278
300
multiple
279
301
max-tags-visible="1"
280
- placeholder=${ msg ( "Finished Crawls" ) }
302
+ placeholder=${ this . isAdminView
303
+ ? msg ( "All Active Crawls" )
304
+ : msg ( "Finished Crawls" ) }
281
305
@sl-change=${ async ( e : CustomEvent ) => {
282
306
const value = ( e . target as SlSelect ) . value as CrawlState [ ] ;
283
307
await this . updateComplete ;
@@ -287,7 +311,7 @@ export class CrawlsList extends LiteElement {
287
311
} ;
288
312
} }
289
313
>
290
- ${ finishedCrawlStates . map ( this . renderStatusMenuItem ) }
314
+ ${ this . crawlStates . map ( this . renderStatusMenuItem ) }
291
315
</sl-select>
292
316
</div>
293
317
@@ -448,7 +472,7 @@ export class CrawlsList extends LiteElement {
448
472
if ( ! this . crawls ) return ;
449
473
450
474
return html `
451
- <btrix-crawl-list>
475
+ <btrix-crawl-list baseUrl= ${ this . isAdminView ? "/crawls/crawl" : "" } >
452
476
${ this . crawls . items . map ( this . renderCrawlItem ) }
453
477
</btrix-crawl-list>
454
478
@@ -515,6 +539,10 @@ export class CrawlsList extends LiteElement {
515
539
<sl-icon name="copy-code" library="app" slot="prefix"></sl-icon>
516
540
${ msg ( "Copy Workflow ID" ) }
517
541
</sl-menu-item>
542
+ <sl-menu-item @click=${ ( ) => CopyButton . copyToClipboard ( crawl . id ) } >
543
+ <sl-icon name="copy-code" library="app" slot="prefix"></sl-icon>
544
+ ${ msg ( "Copy Crawl ID" ) }
545
+ </sl-menu-item>
518
546
<sl-menu-item
519
547
@click=${ ( ) => CopyButton . copyToClipboard ( crawl . tags . join ( "," ) ) }
520
548
?disabled=${ ! crawl . tags . length }
@@ -639,7 +667,7 @@ export class CrawlsList extends LiteElement {
639
667
}
640
668
641
669
private async getCrawls ( queryParams ?: APIPaginationQuery ) : Promise < Crawls > {
642
- const state = this . filterBy . state || finishedCrawlStates ;
670
+ const state = this . filterBy . state || this . crawlStates ;
643
671
const query = queryString . stringify (
644
672
{
645
673
...this . filterBy ,
@@ -666,7 +694,6 @@ export class CrawlsList extends LiteElement {
666
694
) ;
667
695
668
696
this . getCrawlsController = null ;
669
- this . lastFetched = Date . now ( ) ;
670
697
671
698
return data ;
672
699
}
0 commit comments