chore: tidy
This commit is contained in:
parent
69ec9ef50f
commit
5b06b3a139
|
@ -25,12 +25,11 @@ const EntityComponent = (props) => {
|
|||
return null;
|
||||
}
|
||||
const entity = new Entity(json);
|
||||
const {traits} = json;
|
||||
return (
|
||||
<div className="entity">
|
||||
<div className="document-pane" />
|
||||
<div className="settings-pane">
|
||||
<Traits context={entity.context} entity={entity} target={json.uuid} traits={traits} />
|
||||
<Traits entity={entity} traits={json.traits} />
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
|
|
@ -11,18 +11,14 @@ import Value from '~/client/value';
|
|||
|
||||
import {setTraitProperty} from './state';
|
||||
|
||||
const traitComponents = memoize(() => {
|
||||
return Object.values(allTraitComponents()).reduce((r, M) => {
|
||||
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) => {
|
|||
</span>
|
||||
<div className="invisible-separator" />
|
||||
<Value.Component
|
||||
context={context}
|
||||
context={entity.context}
|
||||
onChange={(value) => 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();
|
||||
}
|
||||
|
|
|
@ -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]) => (
|
||||
<TabPanel key={type}>
|
||||
<TraitPane
|
||||
context={context}
|
||||
entity={entity}
|
||||
key={type}
|
||||
target={target}
|
||||
trait={trait}
|
||||
type={type}
|
||||
/>
|
||||
|
@ -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,
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user