/**************************************************************************** * Copyright 2017 EPAM Systems * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. ***************************************************************************/ import { h } from 'preact'; import { connect } from 'preact-redux'; /** @jsx h */ import Dialog from '../component/dialog'; import Tabs from '../component/tabs'; import { Form, Field } from '../component/form'; import { check } from '../state/server'; const checkSchema = { title: 'Check', type: 'object', properties: { checkOptions: { type: 'array', items: { type: "string", enum: ['valence', 'radicals', 'pseudoatoms', 'stereo', 'query', 'overlapping_atoms', 'overlapping_bonds', 'rgroups', 'chiral', '3d'], enumNames: ['Valence', 'Radical', 'Pseudoatom', 'Stereochemistry', 'Query', 'Overlapping Atoms', 'Overlapping Bonds', 'R-Groups', 'Chirality', '3D Structure'] } } } }; function getOptionName(opt) { const d = checkSchema.properties.checkOptions.items; return d.enumNames[d.enum.indexOf(opt)]; } function Check(props) { const tabs = ['Check', 'Settings']; const { formState, onCheck, ...prop } = props; const { result, moleculeErrors } = formState; return ( result} params={prop}>
i === 0 ? onCheck(result.checkOptions) : null}>
); } function ErrorsCheck(props) { const { moleculeErrors } = props; const moleculeErrorsTypes = Object.keys(moleculeErrors); return (
{moleculeErrorsTypes.length === 0 ?
No errors found
: moleculeErrorsTypes.map(type => (
{getOptionName(type)} error :
{moleculeErrors[type]}
))}
); } export default connect( store => ({ formState: store.modal.form }), dispatch => ({ onCheck: (opts) => dispatch(check(opts)) }) )(Check);