Skip to content

Commit 96b21b0

Browse files
pseudochild totally removed from state, transformer working
2 parents 72cfffd + 2d70dfa commit 96b21b0

20 files changed

+989
-404
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: 94 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ import {
3030

3131
import { loadState } from '../localStorage';
3232

33-
// import createFiles from '../utils/createFiles.util';
34-
// import createApplicationUtil from '../utils/createApplication.util';
33+
import createFiles from '../utils/createFiles.util';
34+
import createApplicationUtil from '../utils/createApplication.util';
3535

3636
export const loadInitData = () => (dispatch) => {
3737
loadState().then(data => dispatch({
@@ -42,30 +42,30 @@ export const loadInitData = () => (dispatch) => {
4242
}));
4343
};
4444

45-
export const updateChildren = ({ parentIds, childIndex, childId }) => ({
46-
type: UPDATE_CHILDREN,
47-
payload: {
48-
parentIds,
49-
childIndex,
50-
childId,
51-
},
52-
});
45+
// export const updateChildren = ({ parentIds, childIndex, childId }) => ({
46+
// type: UPDATE_CHILDREN,
47+
// payload: {
48+
// parentIds,
49+
// childIndex,
50+
// childId,
51+
// },
52+
// });
5353

54-
export const parentReassignment = ({ index, id, parentIds }) => ({
55-
type: REASSIGN_PARENT,
56-
payload: {
57-
index,
58-
id,
59-
parentIds,
60-
},
61-
});
54+
// export const parentReassignment = ({ index, id, parentIds }) => ({
55+
// type: REASSIGN_PARENT,
56+
// payload: {
57+
// index,
58+
// id,
59+
// parentIds,
60+
// },
61+
// });
6262

6363
export const addComponent = ({ title }) => (dispatch) => {
6464
dispatch({ type: ADD_COMPONENT, payload: { title } });
6565
};
6666

67-
export const addChild = ({ title }) => (dispatch) => {
68-
dispatch({ type: ADD_CHILD, payload: { title } });
67+
export const addChild = ({ title, childType, HTMLInfo }) => (dispatch) => {
68+
dispatch({ type: ADD_CHILD, payload: { title, childType, HTMLInfo } });
6969
};
7070

7171
export const deleteChild = ({}) => (dispatch) => {
@@ -79,6 +79,7 @@ export const deleteComponent = ({ componentId, stateComponents }) => (dispatch)
7979
// find all places where the "to be delted" is a child and do what u gotta do
8080
stateComponents.forEach((parent) => {
8181
parent.childrenArray.filter(child => child.childComponentId == componentId).forEach((child) => {
82+
// console.log(`Should delete ${child.childId} from component id:${parent.id} ${parent.title}`)
8283
dispatch({
8384
type: DELETE_CHILD,
8485
payload: {
@@ -96,36 +97,36 @@ export const deleteComponent = ({ componentId, stateComponents }) => (dispatch)
9697
dispatch({ type: DELETE_COMPONENT, payload: { componentId } });
9798
};
9899

99-
export const updateComponent = ({
100-
id,
101-
index,
102-
newParentId = null,
103-
color = null,
104-
stateful = null,
105-
}) => (dispatch) => {
106-
dispatch({
107-
type: UPDATE_COMPONENT,
108-
payload: {
109-
id,
110-
index,
111-
newParentId,
112-
color,
113-
stateful,
114-
},
115-
});
100+
// export const updateComponent = ({
101+
// id,
102+
// index,
103+
// newParentId = null,
104+
// color = null,
105+
// stateful = null,
106+
// }) => (dispatch) => {
107+
// dispatch({
108+
// type: UPDATE_COMPONENT,
109+
// payload: {
110+
// id,
111+
// index,
112+
// newParentId,
113+
// color,
114+
// stateful,
115+
// },
116+
// });
116117

117-
if (newParentId) {
118-
dispatch(
119-
updateChildren({
120-
parentIds: [newParentId],
121-
childId: id,
122-
childIndex: index,
123-
}),
124-
);
125-
}
118+
// if (newParentId) {
119+
// dispatch(
120+
// updateChildren({
121+
// parentIds: [newParentId],
122+
// childId: id,
123+
// childIndex: index,
124+
// }),
125+
// );
126+
// }
126127

127-
dispatch({ type: SET_SELECTABLE_PARENTS });
128-
};
128+
// dispatch({ type: SET_SELECTABLE_PARENTS });
129+
// };
129130

130131
export const changeFocusComponent = ({ title }) => (dispatch) => {
131132
dispatch({ type: CHANGE_FOCUS_COMPONENT, payload: { title } });
@@ -143,21 +144,21 @@ export const changeComponentFocusChild = ({ componentId, childId }) => (dispatch
143144
});
144145
};
145146

146-
// export const exportFiles = ({ components, path }) => (dispatch) => {
147-
// dispatch({
148-
// type: EXPORT_FILES,
149-
// });
147+
export const exportFiles = ({ components, path }) => (dispatch) => {
148+
dispatch({
149+
type: EXPORT_FILES,
150+
});
150151

151-
// createFiles(components, path)
152-
// .then(dir => dispatch({
153-
// type: EXPORT_FILES_SUCCESS,
154-
// payload: { status: true, dir: dir[0] },
155-
// }))
156-
// .catch(err => dispatch({
157-
// type: EXPORT_FILES_ERROR,
158-
// payload: { status: true, err },
159-
// }));
160-
// };
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+
};
161162

162163
export const handleClose = () => ({
163164
type: HANDLE_CLOSE,
@@ -178,30 +179,37 @@ export const handleTransform = (componentId, childId, {
178179
},
179180
});
180181

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

206214
export const openExpansionPanel = component => ({
207215
type: OPEN_EXPANSION_PANEL,

0 commit comments

Comments
 (0)