import { action, computed, makeObservable, observable } from "mobx"; import { observer } from "mobx-react"; import React from "react"; import { Button, Modal } from "react-bootstrap"; import EditorActionsManager from "../managers/EditorActionsManager"; import { EModalType, IProfileMetaData } from "../ui/react-pathway-mapper"; interface IProfilesModalProps { profiles: IProfileMetaData[]; editor: EditorActionsManager; show: boolean; handleClose: Function; handleProfileLabelClicked: (index: number) => void; enabledProfileCountLimit: number; } @observer export default class ProfilesModal extends React.Component< IProfilesModalProps, {} > { @observable showEnabledProfileWarningModal: boolean = false; constructor(props: IProfilesModalProps) { super(props); makeObservable(this); } @action setShowEnabledProfileWarningModal(val: boolean) { this.showEnabledProfileWarningModal = val; } @computed get profileEnabledMap() { const enabledProfiles: IProfileMetaData[] = []; this.props.profiles.forEach(profile => { if (profile.enabled && enabledProfiles.length < this.props.enabledProfileCountLimit) { enabledProfiles.push(profile); } }); const profileEnabledMap = {}; this.props.profiles.forEach((profile: IProfileMetaData) => { const enabled = enabledProfiles.indexOf(profile) > -1; profileEnabledMap[profile.profileId] = enabled; }); return profileEnabledMap; } handleProfileLabelClicked(index: number) { this.props.handleProfileLabelClicked(index); } render() { const profileLabels = this.props.profiles.map( (profile: IProfileMetaData, i: number) => ( ) ); return ( { this.props.handleClose(EModalType.PROFILES); }} > Genomic Data Set(s) to Show {profileLabels.length > 0 ? ( profileLabels ) : (

There is currently no data to show

)} this.setShowEnabledProfileWarningModal(false)}> Warning

At most 6 data sets can be displayed at the same time, please disable some other data set before enabling this.

); } }