diff --git a/app/packs/src/apps/mydb/elements/details/reactions/analysesTab/ReactionDetailsContainers.js b/app/packs/src/apps/mydb/elements/details/reactions/analysesTab/ReactionDetailsContainers.js index fc2e53119c..a74d34cb04 100644 --- a/app/packs/src/apps/mydb/elements/details/reactions/analysesTab/ReactionDetailsContainers.js +++ b/app/packs/src/apps/mydb/elements/details/reactions/analysesTab/ReactionDetailsContainers.js @@ -15,11 +15,12 @@ import { hNmrCount, cNmrCount, instrumentText } from 'src/utilities/ElementUtils import { contentToText } from 'src/utilities/quillFormat'; import { chmoConversions } from 'src/components/OlsComponent'; import { previewContainerImage } from 'src/utilities/imageHelper'; -import { JcampIds, BuildSpcInfos } from 'src/utilities/SpectraHelper'; +import { JcampIds, BuildSpcInfos, BuildSpcInfosForNMRDisplayer, isNMRKind } from 'src/utilities/SpectraHelper'; import UIStore from 'src/stores/alt/stores/UIStore'; import SpectraActions from 'src/stores/alt/actions/SpectraActions'; import LoadingActions from 'src/stores/alt/actions/LoadingActions'; import ViewSpectra from 'src/apps/mydb/elements/details/ViewSpectra'; +import NMRiumDisplayer from 'src/components/nmriumWrapper/NMRiumDisplayer'; import TextTemplateActions from 'src/stores/alt/actions/TextTemplateActions'; @@ -42,48 +43,74 @@ const nmrMsg = (reaction, container) => { const SpectraEditorBtn = ({ element, spcInfo, hasJcamp, hasChemSpectra, toggleSpectraModal, confirmRegenerate, + toggleNMRDisplayerModal, hasNMRium, }) => ( - Spectra Editor {!spcInfo ? ': Reprocess' : ''}} - >{spcInfo ? ( - - + Spectra Editor {!spcInfo ? ': Reprocess' : ''}} + >{spcInfo ? ( + + } + onToggle={(open, event) => { if (event) { event.stopPropagation(); } }} + onClick={toggleSpectraModal} + disabled={!spcInfo || !hasChemSpectra} + > + { + event.stopPropagation(); + confirmRegenerate(event); + }} + disabled={!hasJcamp || !element.can_update} + > + Reprocess + + + + ) : ( + + )} + + { + hasNMRium ? ( + Process with NMRium} > - Reprocess - - - - ) : ( - - )} - + + + + + ) : null + } + ); SpectraEditorBtn.propTypes = { @@ -96,6 +123,8 @@ SpectraEditorBtn.propTypes = { hasChemSpectra: PropTypes.bool, toggleSpectraModal: PropTypes.func.isRequired, confirmRegenerate: PropTypes.func.isRequired, + toggleNMRDisplayerModal: PropTypes.func.isRequired, + hasNMRium: PropTypes.bool, }; SpectraEditorBtn.defaultProps = { @@ -103,6 +132,8 @@ SpectraEditorBtn.defaultProps = { spcInfo: false, element: {}, hasChemSpectra: false, + hasEditedJcamp: false, + hasNMRium: false, }; export default class ReactionDetailsContainers extends Component { @@ -192,13 +223,22 @@ export default class ReactionDetailsContainers extends Component { } }; const spcInfo = BuildSpcInfos(reaction, container); - const { hasChemSpectra } = UIStore.getState(); + const { hasChemSpectra, hasNmriumWrapper } = UIStore.getState(); const toggleSpectraModal = (e) => { e.stopPropagation(); SpectraActions.ToggleModal(); SpectraActions.LoadSpectra.defer(spcInfo); }; + //process open NMRium + const toggleNMRDisplayerModal = (e) => { + const spcInfosForNMRDisplayer = BuildSpcInfosForNMRDisplayer(reaction, container); + e.stopPropagation(); + SpectraActions.ToggleModalNMRDisplayer(); + SpectraActions.LoadSpectraForNMRDisplayer.defer(spcInfosForNMRDisplayer); // going to fetch files base on spcInfos + } + + const hasNMRium = isNMRKind(container) && hasNmriumWrapper; return (
@@ -219,6 +259,8 @@ export default class ReactionDetailsContainers extends Component { hasChemSpectra={hasChemSpectra} toggleSpectraModal={toggleSpectraModal} confirmRegenerate={confirmRegenerate} + toggleNMRDisplayerModal={toggleNMRDisplayerModal} + hasNMRium={hasNMRium} />
); @@ -388,6 +430,11 @@ export default class ReactionDetailsContainers extends Component { handleSampleChanged={this.handleSpChange} handleSubmit={this.props.handleSubmit} /> + ); diff --git a/spec/javascripts/packs/src/apps/mydb/elements/details/reactions/analysesTab/ReactionDetailsContainers.spec.js b/spec/javascripts/packs/src/apps/mydb/elements/details/reactions/analysesTab/ReactionDetailsContainers.spec.js index c40df56297..48876bded4 100644 --- a/spec/javascripts/packs/src/apps/mydb/elements/details/reactions/analysesTab/ReactionDetailsContainers.spec.js +++ b/spec/javascripts/packs/src/apps/mydb/elements/details/reactions/analysesTab/ReactionDetailsContainers.spec.js @@ -18,6 +18,9 @@ import Reaction from 'src/models/Reaction'; import Container from 'src/models/Container'; import { DndProvider } from 'react-dnd'; import { HTML5Backend } from 'react-dnd-html5-backend'; +import ImageModal from 'src/components/common/ImageModal'; +import PrintCodeButton from 'src/components/common/PrintCodeButton'; +import ContainerComponent from 'src/components/container/ContainerComponent'; Enzyme.configure({ adapter: new Adapter() }); @@ -62,6 +65,18 @@ describe('ReactionDetailsContainers', () => { describe('It has analyses', () => { let reaction = null; + const btnAdd = ( +
+   +
+ ); + beforeEach(() => { reaction = Reaction.buildEmpty(); }); @@ -82,15 +97,7 @@ describe('ReactionDetailsContainers', () => { ); const expectedValue = shallow(
-
-   -
+ {btnAdd} { ); expect(wrapper.html()).toEqual(expectedValue.html()); }); + + // it('Render with normal analysis', () => { + // const analysis = Container.buildAnalysis(); + // reaction.container.children[0].children.push(analysis); + + // const wrapper = shallow( + // + // + // + // ); + + // const SpectraEditorBtn = ( + //
+ // + //
+ // ); + + // const headerBtnGroup = ( + //
+ // + // + // { + // SpectraEditorBtn + // } + // {/* */} + //
+ // ); + + // const headerPanel = ( + //
+ //
+ // + //
+ //
+ // { + // headerBtnGroup + // } + //
+ //
{analysis.name}
+ //
Type: {analysis.extended_metadata.kind}
+ //
Status: {analysis.extended_metadata.status} {''}        {''}
+ //
+ // + // Content: + // + // {/* */} + // + //
+ + //
+ //
+ //
+ // ); + + // const expectedValue = shallow( + // + //
+ // {btnAdd} + // + // + // + // + // {headerPanel} + // + // + // + // + //
+ //
+ //
+ //
+ //
+ // ); + + // expect(wrapper.html()).toEqual(expectedValue.html()); + // }); }); });