Skip to content

Commit fa731e6

Browse files
committed
accepted incoming changes (small merge conflict)
2 parents ee5f484 + 2a26d99 commit fa731e6

18 files changed

+1229
-691
lines changed

index.js

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
#!/usr/bin/env node
2-
const util = require('util');
3-
const program = require('commander');
4-
const execFile = util.promisify(require('child_process').execFile);
5-
const { Spinner } = require('cli-spinner');
2+
// const util = require('util');
3+
// const program = require('commander');
4+
// const execFile = util.promisify(require('child_process').execFile);
5+
// const { Spinner } = require('cli-spinner');
66

7-
const spinner = new Spinner('running app... %s');
8-
spinner.setSpinnerString('|/-\\');
7+
// const spinner = new Spinner('running app... %s');
8+
// spinner.setSpinnerString('|/-\\');
99

10-
program
11-
.version('1.0.0', '-v, --version, -V')
12-
.description('An application for prototyping React application.');
10+
// program
11+
// .version('1.0.0', '-v, --version, -V')
12+
// .description('An application for prototyping React application.');
1313

14-
program
15-
.command('start')
16-
.description('Start-up reactype app')
17-
.action(() => {
18-
spinner.start();
19-
execFile('npm', ['start']).catch(err => console.log(err));
20-
});
14+
// program
15+
// .command('start')
16+
// .description('Start-up reactype app')
17+
// .action(() => {
18+
// spinner.start();
19+
// execFile('npm', ['start']).catch(err => console.log(err));
20+
// });
2121

2222
program.parse(process.argv);

main.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ const {
77
ipcMain,
88
} = require('electron');
99

10+
1011
require('electron-reload')(__dirname);
1112

1213
// const isDev = true;
@@ -34,6 +35,11 @@ function openFile() {
3435
mainWindow.webContents.send('new-file', file);
3536
}
3637

38+
// export files
39+
function exportComponents() {
40+
console.log('hi from exportComponents');
41+
}
42+
3743
// Choose directory
3844
ipcMain.on('choose_app_dir', (event) => {
3945
const directory = dialog.showOpenDialog(mainWindow, {
@@ -60,10 +66,15 @@ const createWindow = () => {
6066
mainWindow = new BrowserWindow({
6167
width,
6268
height,
69+
show: false,
6370
});
6471

6572
// and load the index.html of the app.
6673
mainWindow.loadURL(`file://${__dirname}/build/index.html`);
74+
// load page once window is loaded
75+
mainWindow.once('ready-to-show', () => {
76+
mainWindow.show();
77+
});
6778

6879
const template = [{
6980
label: 'File',
@@ -73,6 +84,13 @@ const createWindow = () => {
7384
click() {
7485
openFile();
7586
},
87+
},
88+
{
89+
label: 'Export Components',
90+
accelerator: process.platform === 'darwin' ? 'Cmd+E' : 'Ctrl+Shift+E',
91+
click() {
92+
exportComponents();
93+
},
7694
}],
7795
},
7896
{

src/actions/components.js

Lines changed: 100 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -25,21 +25,23 @@ import {
2525
DELETE_PROP,
2626
ADD_PROP,
2727
DELETE_ALL_DATA,
28-
CHANGE_IMAGE_PATH,
29-
} from '../actionTypes/index';
30-
31-
import { loadState } from '../localStorage';
32-
33-
// import createFiles from '../utils/createFiles.util';
34-
// import createApplicationUtil from '../utils/createApplication.util';
35-
36-
export const loadInitData = () => (dispatch) => {
37-
loadState().then(data => dispatch({
38-
type: LOAD_INIT_DATA,
39-
payload: {
40-
data: data ? data.workspace : {},
41-
},
42-
}));
28+
CHANGE_IMAGE_PATH
29+
} from "../actionTypes/index";
30+
31+
import { loadState } from "../localStorage";
32+
33+
import createFiles from '../utils/createFiles.util';
34+
import createApplicationUtil from '../utils/createApplication.util'
35+
36+
export const loadInitData = () => dispatch => {
37+
loadState().then(data =>
38+
dispatch({
39+
type: LOAD_INIT_DATA,
40+
payload: {
41+
data: data ? data.workspace : {}
42+
}
43+
})
44+
);
4345
};
4446

4547
// export const updateChildren = ({ parentIds, childIndex, childId }) => ({
@@ -60,39 +62,47 @@ export const loadInitData = () => (dispatch) => {
6062
// },
6163
// });
6264

63-
export const addComponent = ({ title }) => (dispatch) => {
65+
export const addComponent = ({ title }) => dispatch => {
6466
dispatch({ type: ADD_COMPONENT, payload: { title } });
6567
};
6668

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

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

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

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

94104
// change focus to APp
95-
dispatch({ type: CHANGE_FOCUS_COMPONENT, payload: { title: 'App' } });
105+
dispatch({ type: CHANGE_FOCUS_COMPONENT, payload: { title: "App" } });
96106
// after taking care of the children delete the component
97107
dispatch({ type: DELETE_COMPONENT, payload: { componentId } });
98108
};
@@ -128,98 +138,101 @@ export const deleteComponent = ({ componentId, stateComponents }) => (dispatch)
128138
// dispatch({ type: SET_SELECTABLE_PARENTS });
129139
// };
130140

131-
export const changeFocusComponent = ({ title }) => (dispatch) => {
141+
export const changeFocusComponent = ({ title }) => dispatch => {
132142
dispatch({ type: CHANGE_FOCUS_COMPONENT, payload: { title } });
133143
};
134144

135145
// make sure childId is being sent in
136-
export const changeFocusChild = ({ title, childId }) => (dispatch) => {
146+
export const changeFocusChild = ({ title, childId }) => dispatch => {
137147
dispatch({ type: CHANGE_FOCUS_CHILD, payload: { title, childId } });
138148
};
139149

140-
export const changeComponentFocusChild = ({ componentId, childId }) => (dispatch) => {
150+
export const changeComponentFocusChild = ({
151+
componentId,
152+
childId
153+
}) => dispatch => {
141154
dispatch({
142155
type: CHANGE_COMPONENT_FOCUS_CHILD,
143-
payload: { componentId, childId },
156+
payload: { componentId, childId }
144157
});
145158
};
146159

147-
// export const exportFiles = ({ components, path }) => (dispatch) => {
148-
// dispatch({
149-
// type: EXPORT_FILES,
150-
// });
160+
export const exportFiles = ({ components, path }) => (dispatch) => {
161+
dispatch({
162+
type: EXPORT_FILES,
163+
});
151164

152-
// createFiles(components, path)
153-
// .then(dir => dispatch({
154-
// type: EXPORT_FILES_SUCCESS,
155-
// payload: { status: true, dir: dir[0] },
156-
// }))
157-
// .catch(err => dispatch({
158-
// type: EXPORT_FILES_ERROR,
159-
// payload: { status: true, err },
160-
// }));
161-
// };
165+
createFiles(components, path)
166+
.then(dir => dispatch({
167+
type: EXPORT_FILES_SUCCESS,
168+
payload: { status: true, dir: dir[0] },
169+
}))
170+
.catch(err => dispatch({
171+
type: EXPORT_FILES_ERROR,
172+
payload: { status: true, err },
173+
}));
174+
};
162175

163176
export const handleClose = () => ({
164177
type: HANDLE_CLOSE,
165-
payload: false,
178+
payload: false
166179
});
167180

168-
export const handleTransform = (componentId, childId, {
169-
x, y, width, height,
170-
}) => ({
181+
export const handleTransform = (
182+
componentId,
183+
childId,
184+
{ x, y, width, height }
185+
) => ({
171186
type: HANDLE_TRANSFORM,
172187
payload: {
173188
componentId,
174189
childId,
175190
x,
176191
y,
177192
width,
178-
height,
179-
},
193+
height
194+
}
180195
});
181196

182-
// export const createApplication = ({
183-
// path, components = [], genOption, appName = 'proto_app', repoUrl,
184-
// }) => (dispatch) => {
185-
// if (genOption === 0) {
186-
// dispatch(exportFiles({ path, components }));
187-
// } else if (genOption) {
188-
// dispatch({
189-
// type: CREATE_APPLICATION,
190-
// });
191-
// createApplicationUtil({
192-
// path, appName, genOption, repoUrl,
193-
// })
194-
// .then(() => {
195-
// dispatch({
196-
// type: CREATE_APPLICATION_SUCCESS,
197-
// });
198-
// dispatch(exportFiles({ path: `${path}/${appName}`, components }));
199-
// })
200-
// .catch(err => dispatch({
201-
// type: CREATE_APPLICATION_ERROR,
202-
// payload: { status: true, err },
203-
// }));
204-
// }
205-
// };
197+
export const createApplication = ({
198+
path, components = [], genOption, appName = 'proto_app', repoUrl,
199+
}) => (dispatch) => {
200+
if (genOption === 0) {
201+
dispatch(exportFiles({ path, components }));
202+
} else if (genOption) {
203+
dispatch({
204+
type: CREATE_APPLICATION,
205+
});
206+
createApplicationUtil({
207+
path, appName, genOption, repoUrl,
208+
})
209+
.then(() => {
210+
dispatch({
211+
type: CREATE_APPLICATION_SUCCESS,
212+
});
213+
dispatch(exportFiles({ path: `${path}/${appName}`, components }));
214+
})
215+
.catch(err => dispatch({
216+
type: CREATE_APPLICATION_ERROR,
217+
payload: { status: true, err },
218+
}));
219+
}
220+
};
206221

207222
export const openExpansionPanel = component => ({
208223
type: OPEN_EXPANSION_PANEL,
209-
payload: { component },
224+
payload: { component }
210225
});
211226

212227
// export const deleteAllData = () => ({
213228
// type: DELETE_ALL_DATA,
214229
// });
215230

216-
217-
218-
export const deleteProp = ( propId ) => (dispatch) => {
219-
; dispatch({ type: DELETE_PROP, payload: propId });
231+
export const deleteProp = propId => dispatch => {
232+
dispatch({ type: DELETE_PROP, payload: propId });
220233
};
221234

222235
export const addProp = prop => ({
223236
type: ADD_PROP,
224-
payload: { ...prop },
237+
payload: { ...prop }
225238
});

0 commit comments

Comments
 (0)