mirror of
https://github.com/xodio/xod.git
synced 2026-03-25 10:06:55 +01:00
refactor(constants): add ENTITIES constant and replace magic strings in editor reducer and inspector
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import R from 'ramda';
|
||||
import React from 'react';
|
||||
import Widgets from './InspectorWidgets';
|
||||
import * as ENTITIES from '../constants/entities';
|
||||
|
||||
const styles = {
|
||||
container: {
|
||||
@@ -48,21 +48,23 @@ class Inspector extends React.Component {
|
||||
} else if (selection.length === 1) {
|
||||
const entity = (selection[0].entity);
|
||||
switch (entity) {
|
||||
default:
|
||||
case 'Node':
|
||||
case ENTITIES.NODE:
|
||||
this.widgets = [
|
||||
new Widgets.HintWidget({
|
||||
text: 'There are no properties for the selected node.',
|
||||
}),
|
||||
];
|
||||
break;
|
||||
case 'Link':
|
||||
case ENTITIES.LINK:
|
||||
this.widgets = [
|
||||
new Widgets.HintWidget({
|
||||
text: 'Links have not any properties.',
|
||||
}),
|
||||
];
|
||||
break;
|
||||
default:
|
||||
this.widgets = [];
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
this.widgets = [
|
||||
|
||||
3
app/constants/entities.js
Normal file
3
app/constants/entities.js
Normal file
@@ -0,0 +1,3 @@
|
||||
export const NODE = 'Node';
|
||||
export const LINK = 'Link';
|
||||
export const PIN = 'Pin';
|
||||
@@ -7,6 +7,7 @@ import {
|
||||
EDITOR_SET_MODE,
|
||||
EDITOR_SET_SELECTED_NODETYPE,
|
||||
} from '../actionTypes';
|
||||
import * as ENTITIES from '../constants/entities';
|
||||
|
||||
const addSelection = (entityName, action, state) => {
|
||||
const select = {
|
||||
@@ -25,9 +26,9 @@ export const editor = (state = {}, action) => {
|
||||
linkingPin: null,
|
||||
});
|
||||
case EDITOR_SELECT_NODE:
|
||||
return addSelection('Node', action, state);
|
||||
return addSelection(ENTITIES.NODE, action, state);
|
||||
case EDITOR_SELECT_LINK:
|
||||
return addSelection('Link', action, state);
|
||||
return addSelection(ENTITIES.LINK, action, state);
|
||||
case EDITOR_SELECT_PIN:
|
||||
return R.set(R.lensProp('linkingPin'), action.payload.id, state);
|
||||
case EDITOR_SET_MODE:
|
||||
|
||||
Reference in New Issue
Block a user