From 5b06b3a1395807cb749612b73323d13f1ef0147b Mon Sep 17 00:00:00 2001 From: cha0s Date: Fri, 26 Jun 2020 05:59:15 -0500 Subject: [PATCH] chore: tidy --- src/common/resources/entity/entity.jsx | 3 +-- src/common/resources/entity/trait-pane.jsx | 29 +++++++++++----------- src/common/resources/entity/traits.jsx | 7 ++---- 3 files changed, 18 insertions(+), 21 deletions(-) diff --git a/src/common/resources/entity/entity.jsx b/src/common/resources/entity/entity.jsx index 3ba88de..8b6e6cf 100644 --- a/src/common/resources/entity/entity.jsx +++ b/src/common/resources/entity/entity.jsx @@ -25,12 +25,11 @@ const EntityComponent = (props) => { return null; } const entity = new Entity(json); - const {traits} = json; return (
- +
); diff --git a/src/common/resources/entity/trait-pane.jsx b/src/common/resources/entity/trait-pane.jsx index 4980d28..22de4f5 100644 --- a/src/common/resources/entity/trait-pane.jsx +++ b/src/common/resources/entity/trait-pane.jsx @@ -11,18 +11,14 @@ import Value from '~/client/value'; import {setTraitProperty} from './state'; -const traitComponents = memoize(() => { - return Object.values(allTraitComponents()).reduce((r, M) => { - const {default: TraitComponent} = M; - return {...r, [TraitComponent.type]: TraitComponent}; - }, {}); -}); +const traitComponents = memoize(() => Object.values(allTraitComponents()).reduce((r, M) => { + const {default: TraitComponent} = M; + return {...r, [TraitComponent.type]: TraitComponent}; +}, {})); const TraitPane = (props) => { const { - context, entity, - target, trait, type: traitType, } = props; @@ -41,7 +37,7 @@ const TraitPane = (props) => { Object.values(mapObject(description, (description, key) => { const {label, options, type} = description; const payload = { - target, + target: entity.uuid, trait: traitType, half, key, @@ -54,7 +50,7 @@ const TraitPane = (props) => {
dispatch(setTraitProperty({...payload, value}))} options={'function' === typeof options ? options(entity) : options} type={type} @@ -73,9 +69,14 @@ const TraitPane = (props) => { }; TraitPane.propTypes = { - context: PropTypes.shape({}).isRequired, - target: PropTypes.string.isRequired, - trait: PropTypes.shape({}).isRequired, + entity: PropTypes.shape({ + context: PropTypes.shape({}), + uuid: PropTypes.string, + }).isRequired, + trait: PropTypes.shape({ + params: PropTypes.shape({}), + state: PropTypes.shape({}), + }).isRequired, type: PropTypes.string.isRequired, }; @@ -83,7 +84,7 @@ export default TraitPane; if (module.hot) { registerHooks({ - autoreg$accept: (type, M) => { + autoreg$accept: (type) => { if ('trait-component' === type) { traitComponents.cache.clear(); } diff --git a/src/common/resources/entity/traits.jsx b/src/common/resources/entity/traits.jsx index 75cf195..ce49f10 100644 --- a/src/common/resources/entity/traits.jsx +++ b/src/common/resources/entity/traits.jsx @@ -30,7 +30,7 @@ const decorate = compose( // ); const Traits = (props) => { - const {context, entity, target, traits} = props; + const {entity, traits} = props; const [tabIndex, setTabIndex] = useState(0); let listRef; const entries = Object.entries(traits); @@ -61,10 +61,8 @@ const Traits = (props) => { {entries.map(([type, trait]) => ( @@ -76,8 +74,7 @@ const Traits = (props) => { }; Traits.propTypes = { - context: PropTypes.shape({}).isRequired, - target: PropTypes.string.isRequired, + entity: PropTypes.shape({}).isRequired, traits: PropTypes.shape({}).isRequired, };