Commit f3d453d0 authored by Jaden DIEFENBAUGH's avatar Jaden DIEFENBAUGH
Browse files

check for splittable key not results, DRY default entityDetail obj, fixes #8

parent 157c80fc
......@@ -28,6 +28,7 @@ import CacheInput from './CacheInput.jsx';
import ValidSchemaBadge from './ValidSchemaBadge.jsx';
import DeleteInputBtn from './DeleteInputBtn.jsx';
import TypedField from './TypedField.jsx';
import { getDefaultEntityObject } from './EntityDetail.jsx';
type Props = {
data: BeatObject,
......@@ -64,7 +65,7 @@ const getValidObj = (data = {}) => {
},
};
if(obj.contents.results === undefined && obj.contents.splittable === undefined)
if(JSON.stringify(data.contents) === JSON.stringify(getDefaultEntityObject().contents))
obj.contents.splittable = false;
return obj;
......@@ -105,7 +106,7 @@ export class AlgorithmEditor extends React.Component<Props, State> {
tabTo = (tab: string) => { if(this.activeTab !== tab) this.setState({ activeTab: tab }); }
isAnalyzer = (): boolean => { return this.state.cache.contents.results ? true : false; }
isAnalyzer = (): boolean => { return !Object.keys(this.state.cache.contents).includes('splittable'); }
changeContentsVal = (field: string, val: any) => {
const newCache = {
......
......@@ -174,11 +174,13 @@ export class EntityDetail extends React.Component<Props, State> {
}
}
export const getDefaultEntityObject = () => ({name: '', contents: {}});
const mapStateToProps: MapStateToProps<*,*,*> = (state, ownProps) => {
const entity = ownProps.match.params.entity;
const name = ownProps.match.params.name;
const obj = {
getEntityObject: (): BeatObject => Selectors[`${ entity }Get`](state).find(o => o.name === name) || {name: '', contents: {}},
getEntityObject: (): BeatObject => Selectors[`${ entity }Get`](state).find(o => o.name === name) || getDefaultEntityObject(),
};
return obj;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment