Skip to content

Commit

Permalink
Implement changes
Browse files Browse the repository at this point in the history
  • Loading branch information
oplantalech committed Jul 19, 2019
1 parent eda0ed0 commit 91540c7
Showing 1 changed file with 18 additions and 16 deletions.
34 changes: 18 additions & 16 deletions src/shared/components/studyTagsTooltip/StudyTagsTooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,16 @@ export type StudyTagsTooltipProps = {
children: any;
};

export type BuildOverlayTooltipProps = {
export type StudyInfoOverlayTooltipProps = {
studyDescription: string;
studyId: string;
isVirtualStudy: boolean;
};

@observer
default class BuildOverlay extends React.Component<BuildOverlayTooltipProps, {}> {
default class StudyInfoOverlay extends React.Component<StudyInfoOverlayTooltipProps, {}> {
@observable readonly studyMetadata = remoteData({
invoke: async () => {
if (this.props.isVirtualStudy) {
return '';
}
return client.getTagsUsingGET({studyId: this.props.studyId});
},
onError: (error) => {
Expand All @@ -67,17 +64,22 @@ default class BuildOverlay extends React.Component<BuildOverlayTooltipProps, {}>

render() {
let overlay:any = '';
if (this.studyMetadata.isPending) {
overlay = <Loader isLoading={true}/>;
}
else if (this.studyMetadata.isComplete) {
const resultKeyLength = Object.keys(this.studyMetadata.result).length;
const description = <div dangerouslySetInnerHTML={this.addHTMLDescription(this.props.studyDescription)}/>;
overlay = resultKeyLength > 0 ? ([description, <br/>, <div className="studyTagsTooltip"> <JsonToTable json={this.studyMetadata.result}/></div>]) : description;
}
else if (this.studyMetadata.isError) {
overlay = 'error';
if (this.props.isVirtualStudy) {
overlay = <div dangerouslySetInnerHTML={this.addHTMLDescription(this.props.studyDescription)}/>;
} else {
if (this.studyMetadata.isPending) {
overlay = <Loader isLoading={true}/>;
}
else if (this.studyMetadata.isComplete) {
const resultKeyLength = Object.keys(this.studyMetadata.result).length;
const description = <div dangerouslySetInnerHTML={this.addHTMLDescription(this.props.studyDescription)}/>;
overlay = resultKeyLength > 0 ? ([description, <br/>, <div className="studyTagsTooltip"> <JsonToTable json={this.studyMetadata.result}/></div>]) : description;
}
else if (this.studyMetadata.isError) {
overlay = 'error';
}
}

return overlay;
}
}
Expand All @@ -90,7 +92,7 @@ export default class StudyTagsTooltip extends React.Component<StudyTagsTooltipPr
key={this.props.key}
mouseEnterDelay={this.props.mouseEnterDelay}
placement={this.props.placement}
overlay={<BuildOverlay
overlay={<StudyInfoOverlay
studyDescription={this.props.studyDescription}
studyId={this.props.studyId}
isVirtualStudy={this.props.isVirtualStudy}
Expand Down

0 comments on commit 91540c7

Please sign in to comment.