1
1
import { t } from '@lingui/macro' ;
2
- import { Button , DataList , Switch } from '@patternfly/react-core' ;
3
- import React , { Component , type ReactNode } from 'react' ;
2
+ import { Button , DataList } from '@patternfly/react-core' ;
3
+ import React , { Component } from 'react' ;
4
4
import { Navigate } from 'react-router-dom' ;
5
5
import {
6
6
CollectionAPI ,
7
7
CollectionVersionAPI ,
8
8
type CollectionVersionSearch ,
9
9
MyNamespaceAPI ,
10
- MySyncListAPI ,
11
- type SyncListType ,
12
10
} from 'src/api' ;
13
11
import {
14
12
AlertList ,
@@ -55,7 +53,6 @@ interface IState {
55
53
namespace ?: string ;
56
54
} ;
57
55
loading : boolean ;
58
- synclist : SyncListType ;
59
56
alerts : AlertType [ ] ;
60
57
updateCollection : CollectionVersionSearch ;
61
58
showImportModal : boolean ;
@@ -99,7 +96,6 @@ class Search extends Component<RouteProps, IState> {
99
96
params,
100
97
count : 0 ,
101
98
loading : true ,
102
- synclist : undefined ,
103
99
alerts : [ ] ,
104
100
updateCollection : null ,
105
101
showImportModal : false ,
@@ -118,10 +114,6 @@ class Search extends Component<RouteProps, IState> {
118
114
119
115
private load ( ) {
120
116
this . queryCollections ( ) ;
121
-
122
- if ( IS_INSIGHTS ) {
123
- this . getSynclist ( ) ;
124
- }
125
117
}
126
118
127
119
private addAlert ( alert : AlertType ) {
@@ -306,10 +298,6 @@ class Search extends Component<RouteProps, IState> {
306
298
< CollectionCard
307
299
key = { i }
308
300
{ ...c }
309
- footer = { this . renderSyncToogle (
310
- c . collection_version . name ,
311
- c . collection_version . namespace ,
312
- ) }
313
301
menu = { this . renderMenu ( false , c ) }
314
302
displaySignatures = {
315
303
( this . context as IAppContextType ) . featureFlags
@@ -422,24 +410,6 @@ class Search extends Component<RouteProps, IState> {
422
410
return dropdownMenu ;
423
411
}
424
412
425
- private renderSyncToogle ( name : string , namespace : string ) : ReactNode {
426
- const { synclist } = this . state ;
427
-
428
- if ( ! synclist ) {
429
- return null ;
430
- }
431
-
432
- return (
433
- < Switch
434
- id = { namespace + '.' + name }
435
- className = 'sync-toggle'
436
- label = { t `Sync` }
437
- isChecked = { this . isCollectionSynced ( name , namespace ) }
438
- onChange = { ( ) => this . toggleCollectionSync ( name , namespace ) }
439
- />
440
- ) ;
441
- }
442
-
443
413
private checkUploadPrivilleges ( collection ) {
444
414
const addAlert = ( ) => {
445
415
this . setState ( {
@@ -475,34 +445,6 @@ class Search extends Component<RouteProps, IState> {
475
445
} ) ;
476
446
}
477
447
478
- private toggleCollectionSync ( name : string , namespace : string ) {
479
- const synclist = { ...this . state . synclist } ;
480
-
481
- const colIndex = synclist . collections . findIndex (
482
- ( el ) => el . name === name && el . namespace === namespace ,
483
- ) ;
484
-
485
- if ( colIndex < 0 ) {
486
- synclist . collections . push ( { name : name , namespace : namespace } ) ;
487
- } else {
488
- synclist . collections . splice ( colIndex , 1 ) ;
489
- }
490
-
491
- MySyncListAPI . update ( synclist . id , synclist ) . then ( ( response ) => {
492
- this . setState ( { synclist : response . data } ) ;
493
- MySyncListAPI . curate ( synclist . id ) . then ( ( ) => null ) ;
494
- } ) ;
495
- }
496
-
497
- private isCollectionSynced ( name : string , namespace : string ) : boolean {
498
- const { synclist } = this . state ;
499
- const found = synclist . collections . find (
500
- ( el ) => el . name === name && el . namespace === namespace ,
501
- ) ;
502
-
503
- return synclist . policy === 'include' ? ! ! found : ! found ;
504
- }
505
-
506
448
private renderList ( collections ) {
507
449
return (
508
450
< div className = 'list-container' >
@@ -517,10 +459,6 @@ class Search extends Component<RouteProps, IState> {
517
459
. display_signatures
518
460
}
519
461
showNamespace
520
- synclistSwitch = { this . renderSyncToogle (
521
- c . collection_version . name ,
522
- c . collection_version . namespace ,
523
- ) }
524
462
{ ...this . renderMenu ( true , c ) }
525
463
/>
526
464
) ) }
@@ -530,20 +468,6 @@ class Search extends Component<RouteProps, IState> {
530
468
) ;
531
469
}
532
470
533
- private getSynclist ( ) {
534
- MySyncListAPI . list ( ) . then ( ( result ) => {
535
- // ignore results if more than 1 is returned
536
- // TODO: should we throw an error for this or just ignore it?
537
- if ( result . data . meta . count === 1 ) {
538
- this . setState ( { synclist : result . data . data [ 0 ] } ) ;
539
- } else {
540
- console . error (
541
- `my-synclist returned ${ result . data . meta . count } synclists` ,
542
- ) ;
543
- }
544
- } ) ;
545
- }
546
-
547
471
private queryCollections ( ) {
548
472
this . setState ( { loading : true } , ( ) => {
549
473
CollectionVersionAPI . list ( {
0 commit comments