@@ -5,7 +5,7 @@ import React, {
5
5
import * as JsSearch from 'js-search' ;
6
6
import jsonpath from 'jsonpath' ;
7
7
import {
8
- Tag , Popover , Space , Collapse , Button , Dropdown , Pagination , Tooltip , Spin ,
8
+ Tag , Space , Collapse , Button , Dropdown , Pagination , Tooltip , Spin ,
9
9
} from 'antd' ;
10
10
import {
11
11
LockOutlined ,
@@ -35,6 +35,7 @@ import DiscoveryMDSSearch from './DiscoveryMDSSearch';
35
35
import DiscoveryAccessibilityLinks from './DiscoveryAccessibilityLinks' ;
36
36
import doSearchFilterSort from './Utils/Search/doSearchFilterSort' ;
37
37
import './Discovery.css' ;
38
+ import DiscoveryDataAvailabilityTooltips from './DiscoveryDataAvailabilityTooltips' ;
38
39
39
40
export const accessibleFieldName = '__accessible' ;
40
41
@@ -44,6 +45,7 @@ export enum AccessLevel {
44
45
WAITING = 3 ,
45
46
NOT_AVAILABLE = 4 ,
46
47
OTHER = 5 ,
48
+ MIXED = 6 ,
47
49
}
48
50
49
51
export enum AccessSortDirection {
@@ -52,8 +54,6 @@ export enum AccessSortDirection {
52
54
53
55
const { Panel } = Collapse ;
54
56
55
- const ARBORIST_READ_PRIV = 'read' ;
56
-
57
57
const setUpMenuItemInfo = ( menuItemInfo , supportedValues ) => {
58
58
if ( supportedValues ?. waiting ?. enabled === true ) {
59
59
menuItemInfo . push (
@@ -483,10 +483,20 @@ const Discovery: React.FunctionComponent<Props> = (props: Props) => {
483
483
checked = { props . accessFilters [ accessLevel ] }
484
484
onChange = {
485
485
( ) => {
486
- props . onAccessFilterSet ( {
486
+ const updatedAccessFilter = {
487
487
...props . accessFilters ,
488
488
[ accessLevel ] : ! props . accessFilters [ accessLevel ] ,
489
- } ) ;
489
+ } ;
490
+ // If "mixed availability" is enabled, set its value so it would show when either "accessible" or "unaccessible" is set
491
+ const isMixedAvailabilityEnabled = config . features ?. authorization ?. supportedValues ?. mixed ?. enabled === true ;
492
+ const setMixedAvailabilityToShowWhenAccessibleOrUnaccessibleIsSet = ( ) => {
493
+ updatedAccessFilter [ AccessLevel . MIXED ] = Boolean ( updatedAccessFilter [ AccessLevel . ACCESSIBLE ] )
494
+ || Boolean ( updatedAccessFilter [ AccessLevel . UNACCESSIBLE ] ) ;
495
+ } ;
496
+ if ( isMixedAvailabilityEnabled ) {
497
+ setMixedAvailabilityToShowWhenAccessibleOrUnaccessibleIsSet ( ) ;
498
+ }
499
+ props . onAccessFilterSet ( updatedAccessFilter ) ;
490
500
}
491
501
}
492
502
>
@@ -513,6 +523,7 @@ const Discovery: React.FunctionComponent<Props> = (props: Props) => {
513
523
[ AccessLevel . NOT_AVAILABLE ] : true ,
514
524
[ AccessLevel . WAITING ] : true ,
515
525
[ AccessLevel . UNACCESSIBLE ] : true ,
526
+ [ AccessLevel . MIXED ] : true ,
516
527
} ,
517
528
) }
518
529
> Reset
@@ -578,78 +589,12 @@ const Discovery: React.FunctionComponent<Props> = (props: Props) => {
578
589
ellipsis : false ,
579
590
width : '200px' ,
580
591
textWrap : 'word-break' ,
581
- render : ( _ , record ) => {
582
- if ( record [ accessibleFieldName ] === AccessLevel . WAITING ) {
583
- return (
584
- < Popover
585
- overlayClassName = 'discovery-popover'
586
- placement = 'topRight'
587
- arrowPointAtCenter
588
- content = { (
589
- < div className = 'discovery-popover__text' >
590
- Data are not yet available for this study
591
- </ div >
592
- ) }
593
- >
594
- < ClockCircleOutlined className = 'discovery-table__access-icon' />
595
- </ Popover >
596
- ) ;
597
- }
598
- if ( record [ accessibleFieldName ] === AccessLevel . NOT_AVAILABLE ) {
599
- return (
600
- < Popover
601
- overlayClassName = 'discovery-popover'
602
- placement = 'topRight'
603
- arrowPointAtCenter
604
- content = { (
605
- < div className = 'discovery-popover__text' >
606
- No data will be shared by this study
607
- </ div >
608
- ) }
609
- >
610
- < DashOutlined className = 'discovery-table__access-icon' />
611
- </ Popover >
612
- ) ;
613
- }
614
- if ( record [ accessibleFieldName ] === AccessLevel . ACCESSIBLE ) {
615
- return (
616
- < Popover
617
- overlayClassName = 'discovery-popover'
618
- placement = 'topRight'
619
- arrowPointAtCenter
620
- title = { 'You have access to these data.' }
621
- content = { (
622
- < div className = 'discovery-popover__text' >
623
- < React . Fragment > You have < code > { ARBORIST_READ_PRIV } </ code > access to </ React . Fragment >
624
- < React . Fragment > < code > { record [ config . minimalFieldMapping . authzField ] } </ code > .</ React . Fragment >
625
- </ div >
626
- ) }
627
- >
628
- < UnlockOutlined className = 'discovery-table__access-icon' />
629
- </ Popover >
630
- ) ;
631
- }
632
- if ( record [ accessibleFieldName ] === AccessLevel . UNACCESSIBLE ) {
633
- return (
634
- < Popover
635
- overlayClassName = 'discovery-popover'
636
- placement = 'topRight'
637
- arrowPointAtCenter
638
- title = { 'You do not currently have access to these data.' }
639
- content = { (
640
- < div className = 'discovery-popover__text' >
641
- < React . Fragment > You don't have < code > { ARBORIST_READ_PRIV } </ code > access to </ React . Fragment >
642
- < React . Fragment > < code > { record [ config . minimalFieldMapping . authzField ] } </ code > . </ React . Fragment >
643
- < React . Fragment > Visit the repository to request access to these data</ React . Fragment >
644
- </ div >
645
- ) }
646
- >
647
- < LockOutlined className = 'discovery-table__access-icon' />
648
- </ Popover >
649
- ) ;
650
- }
651
- return < React . Fragment /> ;
652
- } ,
592
+ render : ( _ , record ) => (
593
+ < DiscoveryDataAvailabilityTooltips
594
+ dataAvailabilityLevel = { record [ accessibleFieldName ] }
595
+ authzFieldName = { record [ config . minimalFieldMapping . authzField ] }
596
+ />
597
+ ) ,
653
598
} ) ;
654
599
}
655
600
// -----
0 commit comments