@@ -39,7 +39,7 @@ import {
39
39
ChipProps as MChipProps ,
40
40
FadeProps as MFadeProps ,
41
41
} from "@mui/material" ;
42
- import React from "react" ;
42
+ import React , { ReactNode } from "react" ;
43
43
import {
44
44
ANVIL_CMG_CATEGORY_KEY ,
45
45
ANVIL_CMG_CATEGORY_LABEL ,
@@ -112,6 +112,7 @@ import { Unused, Void } from "../../../common/entities";
112
112
import { SUMMARY_DISPLAY_TEXT } from "./summaryMapper/constants" ;
113
113
import { mapExportSummary } from "./summaryMapper/summaryMapper" ;
114
114
import { ExportEntity } from "app/components/Export/components/AnVILExplorer/components/ExportEntity/exportEntity" ;
115
+ import { RequestAccess } from "../../../../components/Detail/components/AnVILCMG/components/RequestAccess/requestAccess" ;
115
116
116
117
/**
117
118
* Build props for activity type BasicCell component from the given activities response.
@@ -512,6 +513,7 @@ export const buildDatasetHero = (
512
513
datasetsResponse : DatasetsResponse
513
514
) : React . ComponentProps < typeof C . BackPageHero > => {
514
515
return {
516
+ actions : getDatasetRequestAccess ( datasetsResponse ) ,
515
517
breadcrumbs : getDatasetBreadcrumbs ( datasetsResponse ) ,
516
518
callToAction : getDatasetCallToAction ( datasetsResponse ) ,
517
519
title : getDatasetTitle ( datasetsResponse ) ,
@@ -1079,10 +1081,7 @@ function getDatasetCallToAction(
1079
1081
) : CallToAction | undefined {
1080
1082
const isReady = isResponseReady ( datasetsResponse ) ;
1081
1083
const isAccessGranted = isDatasetAccessible ( datasetsResponse ) ;
1082
- const registeredIdentifier = getDatasetRegisteredIdentifier ( datasetsResponse ) ;
1083
- if ( ! isReady ) {
1084
- return ;
1085
- }
1084
+ if ( ! isReady ) return ;
1086
1085
// Display export button if user is authorized to access the dataset.
1087
1086
if ( isAccessGranted ) {
1088
1087
return {
@@ -1091,14 +1090,6 @@ function getDatasetCallToAction(
1091
1090
url : `/datasets/${ getDatasetEntryId ( datasetsResponse ) } /export` ,
1092
1091
} ;
1093
1092
}
1094
- // Display request access button if user is not authorized to access the dataset.
1095
- if ( registeredIdentifier === LABEL . UNSPECIFIED ) {
1096
- return {
1097
- label : "Request Access" ,
1098
- target : ANCHOR_TARGET . BLANK ,
1099
- url : `https://dbgap.ncbi.nlm.nih.gov/aa/wga.cgi?adddataset=${ registeredIdentifier } ` ,
1100
- } ;
1101
- }
1102
1093
// Otherwise, display nothing.
1103
1094
}
1104
1095
@@ -1116,6 +1107,23 @@ export function getDatasetRegisteredIdentifier(
1116
1107
) ;
1117
1108
}
1118
1109
1110
+ /**
1111
+ * Returns the `actions` prop for the Hero component from the given datasets response.
1112
+ * @param datasetsResponse - Response model return from datasets API.
1113
+ * @returns react node to be used as the `actions` props for the Hero component.
1114
+ */
1115
+ function getDatasetRequestAccess (
1116
+ datasetsResponse : DatasetsResponse
1117
+ ) : ReactNode {
1118
+ const isReady = isResponseReady ( datasetsResponse ) ;
1119
+ const isAccessGranted = isDatasetAccessible ( datasetsResponse ) ;
1120
+ if ( ! isReady ) return null ;
1121
+ // Display nothing if user is authorized to access the dataset.
1122
+ if ( isAccessGranted ) return null ;
1123
+ // Display request access button if user is not authorized to access the dataset.
1124
+ return RequestAccess ( { datasetsResponse } ) ;
1125
+ }
1126
+
1119
1127
/**
1120
1128
* Returns StatusBadge component props from the given datasets response.
1121
1129
* @param datasetsResponse - Response model return from datasets API.
0 commit comments