Skip to content

Commit f95cd70

Browse files
Tolga MizrakciTolga Mizrakci
Tolga Mizrakci
authored and
Tolga Mizrakci
committed
bottom props panel first iteration
1 parent 1dba2e5 commit f95cd70

File tree

8 files changed

+628
-420
lines changed

8 files changed

+628
-420
lines changed

src/actions/components.js

Lines changed: 75 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -26,70 +26,84 @@ import {
2626
DELETE_PROP,
2727
ADD_PROP,
2828
DELETE_ALL_DATA,
29-
CHANGE_IMAGE_PATH,
30-
} from '../actionTypes/index';
29+
CHANGE_IMAGE_PATH
30+
} from "../actionTypes/index";
3131

32-
import { loadState } from '../localStorage';
32+
import { loadState } from "../localStorage";
3333

3434
// import createFiles from '../utils/createFiles.util';
3535
// import createApplicationUtil from '../utils/createApplication.util';
3636

37-
export const loadInitData = () => (dispatch) => {
38-
loadState().then(data => dispatch({
39-
type: LOAD_INIT_DATA,
40-
payload: {
41-
data: data ? data.workspace : {},
42-
},
43-
}));
37+
export const loadInitData = () => dispatch => {
38+
loadState().then(data =>
39+
dispatch({
40+
type: LOAD_INIT_DATA,
41+
payload: {
42+
data: data ? data.workspace : {}
43+
}
44+
})
45+
);
4446
};
4547

4648
export const updateChildren = ({ parentIds, childIndex, childId }) => ({
4749
type: UPDATE_CHILDREN,
4850
payload: {
4951
parentIds,
5052
childIndex,
51-
childId,
52-
},
53+
childId
54+
}
5355
});
5456

5557
export const parentReassignment = ({ index, id, parentIds }) => ({
5658
type: REASSIGN_PARENT,
5759
payload: {
5860
index,
5961
id,
60-
parentIds,
61-
},
62+
parentIds
63+
}
6264
});
6365

64-
export const addComponent = ({ title }) => (dispatch) => {
66+
export const addComponent = ({ title }) => dispatch => {
6567
dispatch({ type: ADD_COMPONENT, payload: { title } });
6668
};
6769

68-
export const addChild = ({ title }) => (dispatch) => {
70+
export const addChild = ({ title }) => dispatch => {
6971
dispatch({ type: ADD_CHILD, payload: { title } });
7072
};
7173

72-
export const deleteChild = ({}) => (dispatch) => {
74+
export const deleteChild = ({}) => dispatch => {
7375
// with no payload, it will delete focusd child
7476
dispatch({ type: DELETE_CHILD, payload: {} });
7577
};
7678

77-
export const deleteComponent = ({ componentId, stateComponents }) => (dispatch) => {
78-
console.log('Hello from component.js delete component.componentId= ', componentId);
79+
export const deleteComponent = ({
80+
componentId,
81+
stateComponents
82+
}) => dispatch => {
83+
console.log(
84+
"Hello from component.js delete component.componentId= ",
85+
componentId
86+
);
7987

8088
// find all places where the "to be delted" is a child and do what u gotta do
81-
stateComponents.forEach((parent) => {
82-
parent.childrenArray.filter(child => child.childComponentId == componentId).forEach((child) => {
83-
// console.log(`Should delete ${child.childId} from component id:${parent.id} ${parent.title}`)
84-
dispatch({
85-
type: DELETE_CHILD,
86-
payload: { parentId: parent.id, childId: child.childId, calledFromDeleteComponent: true },
89+
stateComponents.forEach(parent => {
90+
parent.childrenArray
91+
.filter(child => child.childComponentId == componentId)
92+
.forEach(child => {
93+
// console.log(`Should delete ${child.childId} from component id:${parent.id} ${parent.title}`)
94+
dispatch({
95+
type: DELETE_CHILD,
96+
payload: {
97+
parentId: parent.id,
98+
childId: child.childId,
99+
calledFromDeleteComponent: true
100+
}
101+
});
87102
});
88-
});
89103
});
90104

91105
// change focus to APp
92-
dispatch({ type: CHANGE_FOCUS_COMPONENT, payload: { title: 'App' } });
106+
dispatch({ type: CHANGE_FOCUS_COMPONENT, payload: { title: "App" } });
93107
// after taking care of the children delete the component
94108
dispatch({ type: DELETE_COMPONENT, payload: { componentId } });
95109
};
@@ -99,43 +113,49 @@ export const updateComponent = ({
99113
index,
100114
newParentId = null,
101115
color = null,
102-
stateful = null,
103-
}) => (dispatch) => {
116+
stateful = null
117+
}) => dispatch => {
104118
dispatch({
105119
type: UPDATE_COMPONENT,
106120
payload: {
107121
id,
108122
index,
109123
newParentId,
110124
color,
111-
stateful,
112-
},
125+
stateful
126+
}
113127
});
114128

115129
if (newParentId) {
116130
dispatch(
117131
updateChildren({
118132
parentIds: [newParentId],
119133
childId: id,
120-
childIndex: index,
121-
}),
134+
childIndex: index
135+
})
122136
);
123137
}
124138

125139
dispatch({ type: SET_SELECTABLE_PARENTS });
126140
};
127141

128-
export const changeFocusComponent = ({ title }) => (dispatch) => {
142+
export const changeFocusComponent = ({ title }) => dispatch => {
129143
dispatch({ type: CHANGE_FOCUS_COMPONENT, payload: { title } });
130144
};
131145

132146
// make sure childId is being sent in
133-
export const changeFocusChild = ({ title, childId }) => (dispatch) => {
147+
export const changeFocusChild = ({ title, childId }) => dispatch => {
134148
dispatch({ type: CHANGE_FOCUS_CHILD, payload: { title, childId } });
135149
};
136150

137-
export const changeComponentFocusChild = ({ componentId, childId }) => (dispatch) => {
138-
dispatch({ type: CHANGE_COMPONENT_FOCUS_CHILD, payload: { componentId, childId } });
151+
export const changeComponentFocusChild = ({
152+
componentId,
153+
childId
154+
}) => dispatch => {
155+
dispatch({
156+
type: CHANGE_COMPONENT_FOCUS_CHILD,
157+
payload: { componentId, childId }
158+
});
139159
};
140160

141161
// export const exportFiles = ({ components, path }) => (dispatch) => {
@@ -156,21 +176,23 @@ export const changeComponentFocusChild = ({ componentId, childId }) => (dispatch
156176

157177
export const handleClose = () => ({
158178
type: HANDLE_CLOSE,
159-
payload: false,
179+
payload: false
160180
});
161181

162-
export const handleTransform = (componentId, childId, {
163-
x, y, width, height,
164-
}) => ({
182+
export const handleTransform = (
183+
componentId,
184+
childId,
185+
{ x, y, width, height }
186+
) => ({
165187
type: HANDLE_TRANSFORM,
166188
payload: {
167189
componentId,
168190
childId,
169191
x,
170192
y,
171193
width,
172-
height,
173-
},
194+
height
195+
}
174196
});
175197

176198
// export const createApplication = ({
@@ -200,7 +222,7 @@ export const handleTransform = (componentId, childId, {
200222

201223
export const toggleDragging = status => ({
202224
type: TOGGLE_DRAGGING,
203-
payload: status,
225+
payload: status
204226
});
205227

206228
// export const moveToBottom = componentId => ({
@@ -215,7 +237,7 @@ export const toggleDragging = status => ({
215237

216238
export const openExpansionPanel = component => ({
217239
type: OPEN_EXPANSION_PANEL,
218-
payload: { component },
240+
payload: { component }
219241
});
220242

221243
// export const deleteAllData = () => ({
@@ -227,12 +249,12 @@ export const openExpansionPanel = component => ({
227249
// payload: path,
228250
// });
229251

230-
// export const deleteCompProp = ({ id, index }) => ({
231-
// type: DELETE_PROP,
232-
// payload: { id, index },
233-
// });
252+
export const deleteProp = ({ id, index }) => ({
253+
type: DELETE_PROP,
254+
payload: { id, index }
255+
});
234256

235-
// export const addCompProp = prop => ({
236-
// type: ADD_PROP,
237-
// payload: { ...prop },
238-
// });
257+
export const addProp = prop => ({
258+
type: ADD_PROP,
259+
payload: { ...prop }
260+
});

src/components/BottomPanel.jsx

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
import React, { Component } from "react";
2+
import { connect } from "react-redux";
3+
// import PropTypes from 'prop-types';
4+
import {
5+
handleClose,
6+
deleteCompProp,
7+
addCompProp
8+
} from "../actions/components";
9+
// import Snackbars from '../components/Snackbars.jsx';
10+
import RightTabs from "./RightTabs.jsx";
11+
12+
const IPC = require("electron").ipcRenderer;
13+
14+
const mapDispatchToProps = dispatch => ({
15+
handleNotificationClose: () => dispatch(handleClose()),
16+
deleteProp: ({ id, index }) => dispatch(deleteCompProp({ id, index })),
17+
addProp: prop => dispatch(addCompProp(prop))
18+
});
19+
20+
const mapStateToProps = store => ({
21+
successOpen: store.workspace.successOpen,
22+
errorOpen: store.workspace.errorOpen,
23+
appDir: store.workspace.appDir
24+
});
25+
26+
class BottomPanel extends Component {
27+
state = {
28+
successOpen: false,
29+
errorOpen: false
30+
};
31+
32+
viewAppDir = () => {
33+
IPC.send("view_app_dir", this.props.appDir);
34+
};
35+
36+
render() {
37+
const {
38+
components,
39+
successOpen,
40+
errorOpen,
41+
handleNotificationClose,
42+
appDir,
43+
focusComponent,
44+
deleteProp,
45+
addProp
46+
// rightColumnOpen
47+
} = this.props;
48+
49+
return (
50+
<div className="bottom-panel" style={{ width: "100%" }}>
51+
<RightTabs
52+
components={components}
53+
focusComponent={focusComponent}
54+
deleteProp={deleteProp}
55+
addProp={addProp}
56+
// rightColumnOpen={rightColumnOpen}
57+
/>
58+
{/* <Snackbars
59+
successOpen={successOpen}
60+
errorOpen={errorOpen}
61+
handleNotificationClose={handleNotificationClose}
62+
msg={appDir}
63+
viewAppDir={this.viewAppDir}
64+
/> */}
65+
</div>
66+
);
67+
}
68+
}
69+
70+
// RightContainer.propTypes = {
71+
// components: PropTypes.array.isRequired,
72+
// successOpen: PropTypes.bool.isRequired,
73+
// appDir: PropTypes.string,
74+
// errorOpen: PropTypes.bool.isRequired,
75+
// focusComponent: PropTypes.object.isRequired,
76+
// handleNotificationClose: PropTypes.func.isRequired,
77+
// deleteProp: PropTypes.func.isRequired,
78+
// addProp: PropTypes.func.isRequired,
79+
// width: PropTypes.number.isRequired,
80+
// rightColumnOpen: PropTypes.bool.isRequired,
81+
// };
82+
83+
export default connect(
84+
mapStateToProps,
85+
mapDispatchToProps
86+
)(BottomPanel);

0 commit comments

Comments
 (0)