Skip to content

Commit 31e2635

Browse files
authored
[DT-2772] Add Other Data Location option and update URL handling (#3289)
1 parent ca34683 commit 31e2635

File tree

6 files changed

+46
-49
lines changed

6 files changed

+46
-49
lines changed

cypress/component/StudyAssets/consent_group_list.spec.tsx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,15 @@ import ConsentGroupList from 'src/components/consent_group_list/ConsentGroupList
55
import ConsentGroupSummary from 'src/components/consent_group_list/ConsentGroupSummary'
66
import ConsentGroupRow from 'src/components/consent_group_list/ConsentGroupRow'
77
import {
8-
testDeleteViaModal,
9-
testViewModeFlow,
108
testCloseViewMode,
9+
testDeleteViaModal,
1110
testEditModeRender,
12-
testViewModeRender,
13-
testViewActionTrigger,
1411
testSummaryViewActionTrigger,
12+
testViewActionTrigger,
13+
testViewModeFlow,
14+
testViewModeRender,
1515
} from './testUtils'
16+
import { DataLocationType } from 'src/pages/data_submission/v2/v2-models'
1617

1718
const sampleConsentGroup: ConsentGroup2 = {
1819
consentGroupId: 'cg1',
@@ -22,7 +23,7 @@ const sampleConsentGroup: ConsentGroup2 = {
2223
generalResearchUse: true,
2324
irb: false,
2425
accessManagement: 'open',
25-
dataLocation: 'Not Determined',
26+
dataLocation: DataLocationType.NotDetermined,
2627
}
2728

2829
const ConsentGroupListHarness: React.FC<{ initial: ConsentGroup2[] }> = ({ initial }) => {

package-lock.json

Lines changed: 5 additions & 25 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
"@types/react-dom": "18.3.1",
5555
"@types/react-modal": "3.16.3",
5656
"@vitejs/plugin-react": "5.1.2",
57-
"cypress": "15.8.2",
57+
"cypress": "15.9.0",
5858
"cypress-vite": "1.8.0",
5959
"eslint": "9.39.2",
6060
"eslint-plugin-cypress": "5.2.0",

src/components/consent_group_list/ConsentGroupAddEdit.tsx

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { AccessManagementType, ConsentGroup, ConsentGroup2, selectedPrimaryGroup
77
import { DacPicker } from 'src/components/forms/DacPicker'
88
import { FileInput } from 'src/components/forms/FileInput'
99
import { DataSet } from 'src/libs/ajax/DataSet'
10+
import { DataLocationType } from 'src/pages/data_submission/v2/v2-models'
1011

1112
interface ConsentGroupAddEditProps {
1213
readonly id: number
@@ -22,7 +23,6 @@ interface Validation {
2223
accessManagement?: ValidationError
2324
numberOfParticipants?: ValidationError
2425
dataAccessCommitteeId?: ValidationError
25-
dataLocation?: ValidationError
2626
primaryConsent?: ValidationError
2727
gs?: ValidationError
2828
mor?: ValidationError
@@ -166,7 +166,6 @@ export default function ConsentGroupAddEdit(props: ConsentGroupAddEditProps): Re
166166
if (showOtherPrimaryText && (!cg.otherPrimary?.trim())) {
167167
v.otherPrimary = makeError('required')
168168
}
169-
if (!cg.dataLocation?.trim()) v.dataLocation = makeError('required')
170169
if (showGSText && (!cg.gs?.trim())) {
171170
v.gs = makeError('required')
172171
}
@@ -585,7 +584,6 @@ export default function ConsentGroupAddEdit(props: ConsentGroupAddEditProps): Re
585584
{/* location */}
586585
<div style={{ display: 'flex', flexDirection: 'row', justifyContent: 'space-between' }}>
587586
<FormFieldTitle
588-
required={true}
589587
title="Data Location"
590588
description="Please provide the location of your data resource for this consent group"
591589
disabled={readOnly}
@@ -598,14 +596,14 @@ export default function ConsentGroupAddEdit(props: ConsentGroupAddEditProps): Re
598596
name="dataLocation"
599597
type={FormFieldTypes.SELECT}
600598
selectOptions={[
601-
'AnVIL Workspace',
602-
'Terra Workspace',
603-
'TDR Location',
604-
'Not Determined',
599+
DataLocationType.AnVILWorkspace,
600+
DataLocationType.TerraWorkspace,
601+
DataLocationType.TDRLocation,
602+
DataLocationType.NotDetermined,
603+
DataLocationType.Other,
605604
]}
606605
placeholder="Data Location(s)"
607606
defaultValue={current?.dataLocation}
608-
validation={validation.dataLocation}
609607
onChange={({ key, value }: { key: string, value: string }) => {
610608
if (value === 'Not Determined') {
611609
const next = structuredClone(current)

src/components/data_search/DatasetSearchTableConstants.tsx

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import DatasetExportButton from 'src/components/data_search/DatasetExportButton'
88
import { dataUseCellData } from 'src/components/dac_dataset_table/DACDatasetTableCellData'
99
import 'src/components/data_search/DatasetSearch.css'
1010
import { muiCheckboxFix } from 'src/libs/muiThemeFix'
11+
import { DataLocationType } from 'src/pages/data_submission/v2/v2-models'
1112

1213
export interface DatasetSearchTableTab<T> {
1314
key: string
@@ -420,16 +421,20 @@ export const makeDatasetTableHeader = (datasets: DatasetTerm[], selected: number
420421
cellStyle: makeHeaderStyle(cellWidths.dataLocation),
421422
cellDataFn: (dataset: DatasetTerm) => {
422423
let dataLocation
423-
if (dataset.dataLocation === 'TDR Location') {
424-
dataLocation = 'Terra Data Repo'
424+
const TERRA_DATA_REPO = 'Terra Data Repo'
425+
if (dataset.dataLocation === DataLocationType.TDRLocation) {
426+
dataLocation = TERRA_DATA_REPO
425427
}
426-
else if (dataset.dataLocation === 'Terra Workspace') {
428+
else if (dataset.dataLocation === DataLocationType.TerraWorkspace) {
427429
dataLocation = dataset.url
428-
? <Link href={dataset.url}>Terra Workspace</Link>
429-
: 'Terra Data Repo'
430+
? <Link href={dataset.url}>{DataLocationType.TerraWorkspace}</Link>
431+
: TERRA_DATA_REPO
430432
}
431-
else if (dataset.dataLocation === 'Not Determined') {
432-
dataLocation = 'Not Determined'
433+
else if (dataset.dataLocation === DataLocationType.NotDetermined) {
434+
dataLocation = DataLocationType.NotDetermined
435+
}
436+
else if (dataset.dataLocation === DataLocationType.Other) {
437+
dataLocation = dataset.url ? new URL(dataset.url).hostname : ''
433438
}
434439
else {
435440
dataLocation = dataset.url

src/pages/data_submission/v2/v2-models.tsx

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -541,17 +541,30 @@ export class AccessManagement extends StringDatasetProperty {
541541
}
542542
}
543543

544+
export enum DataLocationType {
545+
AnVILWorkspace = 'AnVIL Workspace',
546+
TerraWorkspace = 'Terra Workspace',
547+
TDRLocation = 'TDR Location',
548+
NotDetermined = 'Not Determined',
549+
Other = 'Other',
550+
}
551+
544552
export class DataLocation extends StringDatasetProperty {
545553
static readonly schemaProperty = 'dataLocation'
546554
static readonly propertyName = 'Data Location'
547-
static readonly VALUES = ['AnVIL Workspace', 'Terra Workspace', 'TDR Location', 'Not Determined']
555+
static readonly VALUES = [
556+
DataLocationType.AnVILWorkspace,
557+
DataLocationType.TerraWorkspace,
558+
DataLocationType.TDRLocation,
559+
DataLocationType.NotDetermined,
560+
DataLocationType.Other,
561+
]
562+
548563
constructor(value?: string, datasetId?: number, propertyId?: number) {
549564
super('Data Location', '', DataLocation.propertyName, DataLocation.schemaProperty, value, datasetId, propertyId)
550565
}
551566
}
552567

553-
export type DataLocationType = 'AnVIL Workspace' | 'Terra Workspace' | 'TDR Location' | 'Not Determined'
554-
555568
export class DataURL extends StringDatasetProperty {
556569
static readonly schemaProperty = 'url'
557570
static readonly propertyName = 'URL'

0 commit comments

Comments
 (0)