chore: tidy
This commit is contained in:
parent
69ec9ef50f
commit
5b06b3a139
|
@ -25,12 +25,11 @@ const EntityComponent = (props) => {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
const entity = new Entity(json);
|
const entity = new Entity(json);
|
||||||
const {traits} = json;
|
|
||||||
return (
|
return (
|
||||||
<div className="entity">
|
<div className="entity">
|
||||||
<div className="document-pane" />
|
<div className="document-pane" />
|
||||||
<div className="settings-pane">
|
<div className="settings-pane">
|
||||||
<Traits context={entity.context} entity={entity} target={json.uuid} traits={traits} />
|
<Traits entity={entity} traits={json.traits} />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
|
@ -11,18 +11,14 @@ import Value from '~/client/value';
|
||||||
|
|
||||||
import {setTraitProperty} from './state';
|
import {setTraitProperty} from './state';
|
||||||
|
|
||||||
const traitComponents = memoize(() => {
|
const traitComponents = memoize(() => Object.values(allTraitComponents()).reduce((r, M) => {
|
||||||
return Object.values(allTraitComponents()).reduce((r, M) => {
|
|
||||||
const {default: TraitComponent} = M;
|
const {default: TraitComponent} = M;
|
||||||
return {...r, [TraitComponent.type]: TraitComponent};
|
return {...r, [TraitComponent.type]: TraitComponent};
|
||||||
}, {});
|
}, {}));
|
||||||
});
|
|
||||||
|
|
||||||
const TraitPane = (props) => {
|
const TraitPane = (props) => {
|
||||||
const {
|
const {
|
||||||
context,
|
|
||||||
entity,
|
entity,
|
||||||
target,
|
|
||||||
trait,
|
trait,
|
||||||
type: traitType,
|
type: traitType,
|
||||||
} = props;
|
} = props;
|
||||||
|
@ -41,7 +37,7 @@ const TraitPane = (props) => {
|
||||||
Object.values(mapObject(description, (description, key) => {
|
Object.values(mapObject(description, (description, key) => {
|
||||||
const {label, options, type} = description;
|
const {label, options, type} = description;
|
||||||
const payload = {
|
const payload = {
|
||||||
target,
|
target: entity.uuid,
|
||||||
trait: traitType,
|
trait: traitType,
|
||||||
half,
|
half,
|
||||||
key,
|
key,
|
||||||
|
@ -54,7 +50,7 @@ const TraitPane = (props) => {
|
||||||
</span>
|
</span>
|
||||||
<div className="invisible-separator" />
|
<div className="invisible-separator" />
|
||||||
<Value.Component
|
<Value.Component
|
||||||
context={context}
|
context={entity.context}
|
||||||
onChange={(value) => dispatch(setTraitProperty({...payload, value}))}
|
onChange={(value) => dispatch(setTraitProperty({...payload, value}))}
|
||||||
options={'function' === typeof options ? options(entity) : options}
|
options={'function' === typeof options ? options(entity) : options}
|
||||||
type={type}
|
type={type}
|
||||||
|
@ -73,9 +69,14 @@ const TraitPane = (props) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
TraitPane.propTypes = {
|
TraitPane.propTypes = {
|
||||||
context: PropTypes.shape({}).isRequired,
|
entity: PropTypes.shape({
|
||||||
target: PropTypes.string.isRequired,
|
context: PropTypes.shape({}),
|
||||||
trait: PropTypes.shape({}).isRequired,
|
uuid: PropTypes.string,
|
||||||
|
}).isRequired,
|
||||||
|
trait: PropTypes.shape({
|
||||||
|
params: PropTypes.shape({}),
|
||||||
|
state: PropTypes.shape({}),
|
||||||
|
}).isRequired,
|
||||||
type: PropTypes.string.isRequired,
|
type: PropTypes.string.isRequired,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -83,7 +84,7 @@ export default TraitPane;
|
||||||
|
|
||||||
if (module.hot) {
|
if (module.hot) {
|
||||||
registerHooks({
|
registerHooks({
|
||||||
autoreg$accept: (type, M) => {
|
autoreg$accept: (type) => {
|
||||||
if ('trait-component' === type) {
|
if ('trait-component' === type) {
|
||||||
traitComponents.cache.clear();
|
traitComponents.cache.clear();
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,7 @@ const decorate = compose(
|
||||||
// );
|
// );
|
||||||
|
|
||||||
const Traits = (props) => {
|
const Traits = (props) => {
|
||||||
const {context, entity, target, traits} = props;
|
const {entity, traits} = props;
|
||||||
const [tabIndex, setTabIndex] = useState(0);
|
const [tabIndex, setTabIndex] = useState(0);
|
||||||
let listRef;
|
let listRef;
|
||||||
const entries = Object.entries(traits);
|
const entries = Object.entries(traits);
|
||||||
|
@ -61,10 +61,8 @@ const Traits = (props) => {
|
||||||
{entries.map(([type, trait]) => (
|
{entries.map(([type, trait]) => (
|
||||||
<TabPanel key={type}>
|
<TabPanel key={type}>
|
||||||
<TraitPane
|
<TraitPane
|
||||||
context={context}
|
|
||||||
entity={entity}
|
entity={entity}
|
||||||
key={type}
|
key={type}
|
||||||
target={target}
|
|
||||||
trait={trait}
|
trait={trait}
|
||||||
type={type}
|
type={type}
|
||||||
/>
|
/>
|
||||||
|
@ -76,8 +74,7 @@ const Traits = (props) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
Traits.propTypes = {
|
Traits.propTypes = {
|
||||||
context: PropTypes.shape({}).isRequired,
|
entity: PropTypes.shape({}).isRequired,
|
||||||
target: PropTypes.string.isRequired,
|
|
||||||
traits: PropTypes.shape({}).isRequired,
|
traits: PropTypes.shape({}).isRequired,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user