Skip to content

Commit 250bed4

Browse files
committed
fix unlink dataset if not cgds, and fixs
1 parent 9349e91 commit 250bed4

File tree

2 files changed

+25
-12
lines changed

2 files changed

+25
-12
lines changed

src/frontend/static/frontend/src/components/pipeline/all-experiments-view/ClinicalSourcePopup.tsx

+6-5
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ interface ClinicalSourceState {
7272
/** Alert interface */
7373
alert: CustomAlert,
7474
/** Posibles values for survival tuple */
75-
survivalTuplesPossiblesValues: string[],
75+
survivalTuplesPossiblesValues: string[] | undefined,
7676
}
7777

7878
/**
@@ -137,8 +137,9 @@ export class ClinicalSourcePopup extends React.Component<PopupClinicalSourceProp
137137
clinicalSource.selectedExistingFile = null
138138
clinicalSource.CGDSStudy = null
139139
cleanRef(clinicalSource.newUploadedFileRef)
140+
const survivalColumns = []
140141

141-
this.setState({ clinicalSource }, this.updateSourceFilenames)
142+
this.setState({ clinicalSource, survivalColumns }, this.updateSourceFilenames)
142143
}
143144

144145
/**
@@ -238,9 +239,9 @@ export class ClinicalSourcePopup extends React.Component<PopupClinicalSourceProp
238239
if (jsonResponse.data.number_samples_in_common > 0) {
239240
clinicalSource.type = SourceType.UPLOADED_DATASETS
240241
clinicalSource.selectedExistingFile = selectedFile
241-
242-
const survivalColumns = selectedFile.survival_columns ?? []
243-
this.setState({ clinicalSource, survivalColumns }, this.updateSourceFilenames)
242+
const survivalColumns = selectedFile.survival_columns || []
243+
const survivalTuplesPossiblesValues = undefined
244+
this.setState({ clinicalSource, survivalColumns, survivalTuplesPossiblesValues }, this.updateSourceFilenames)
244245
} else {
245246
this.clinicalSourceVoid()
246247
}

src/frontend/static/frontend/src/components/pipeline/experiment-result/gene-gem-details/survival-analysis/KaplanMeier.tsx

+19-7
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ interface KaplanMeierChartState {
6565
selectedSurvivalColumnId: Nullable<number>,
6666
/** Flag of survival data request */
6767
gettingSurvivalData: boolean,
68+
/** Flag to check if source is being unlink */
69+
unlinkingSource: boolean,
6870
}
6971

7072
/**
@@ -83,7 +85,8 @@ class KaplanMeierChart extends React.Component<KaplanMeierChartProps, KaplanMeie
8385
couldInferFieldsOfInterest: false,
8486
survivalColumns: [],
8587
selectedSurvivalColumnId: null,
86-
gettingSurvivalData: false
88+
gettingSurvivalData: false,
89+
unlinkingSource: false
8790
}
8891
}
8992

@@ -207,14 +210,24 @@ class KaplanMeierChart extends React.Component<KaplanMeierChartProps, KaplanMeie
207210
})
208211
}
209212

213+
/**
214+
* Unlink dataset if experiment is not created by cBioportal datasets
215+
*/
210216
handleUnlinkClinicalSource () {
211-
const myHeaders = getDjangoHeader()
217+
// validate if is dataset from cBioportal
218+
if (this.props.gem_source.cgds_dataset || this.props.mRNA_source.cgds_dataset) {
219+
return
220+
}
212221

222+
const myHeaders = getDjangoHeader()
223+
let unlinkingSource = true
224+
this.setState({ unlinkingSource })
213225
const url = `${urlUnlinkClinicalSourceUserFile}/${this.props.experimentId}/`
214226
ky.patch(url, { headers: myHeaders }).then((response) => {
215227
response.json().then((response: DjangoCommonResponse) => {
216228
if (response.status.code === DjangoResponseCode.SUCCESS) {
217-
// Todo: callback para success
229+
unlinkingSource = false
230+
this.setState({ unlinkingSource })
218231
} else {
219232
alertGeneralError()
220233
}
@@ -324,15 +337,14 @@ class KaplanMeierChart extends React.Component<KaplanMeierChartProps, KaplanMeie
324337
</Label>
325338
</Grid.Column>
326339
<Grid.Column style={{ display: 'flex', justifyContent: 'flex-end' }}>
327-
<div style={{ margin: '0 2rem 0 0' }}>
340+
<div style={{ margin: '0 2rem 0 0', display: this.props.gem_source.cgds_dataset || this.props.mRNA_source.cgds_dataset ? 'none' : 'normal' }}>
328341
<Button
329342
color='orange'
330343
fluid
331344
title='Unlink clinical dataset from this experiment'
332345
onClick={() => this.handleUnlinkClinicalSource()}
333-
/* loading={this.state.unlinkingSource}
334-
onClick={this.unlinkClinicalSource}
335-
disabled={isProcessing} */
346+
loading={this.state.unlinkingSource}
347+
disabled={this.state.unlinkingSource}
336348
>
337349
Unlink DataSet
338350
</Button>

0 commit comments

Comments
 (0)