Skip to content

Commit

Permalink
Merge pull request #2548 from thehyve/fix_tags_in_virtual_studies
Browse files Browse the repository at this point in the history
Do not retrieve tags for virtual studies
  • Loading branch information
alisman authored Jul 23, 2019
2 parents dc7a813 + 91540c7 commit 92ff432
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 13 deletions.
1 change: 1 addition & 0 deletions src/shared/components/query/studyList/StudyList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,7 @@ export default class StudyList extends QueryStoreComponent<IStudyListProps, {}>
key={i}
studyDescription={this.store.isVirtualStudy(study.studyId) ? study.description.replace(/\r?\n/g, '<br />') : study.description}
studyId={study.studyId}
isVirtualStudy={this.store.isVirtualStudy(study.studyId)}
mouseEnterDelay={0}
placement="top"
>
Expand Down
34 changes: 21 additions & 13 deletions src/shared/components/studyTagsTooltip/StudyTagsTooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,21 @@ import Loader from '../loadingIndicator/LoadingIndicator';
export type StudyTagsTooltipProps = {
studyDescription: string;
studyId: string;
isVirtualStudy: boolean;
key: number;
mouseEnterDelay: number;
placement: string;
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 () => {
return client.getTagsUsingGET({studyId: this.props.studyId});
Expand All @@ -62,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 @@ -85,9 +92,10 @@ 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}
/>}
children={this.props.children}
/>);
Expand Down

0 comments on commit 92ff432

Please sign in to comment.