Skip to content

Commit 18b1fb8

Browse files
committed
staging for pulling upstream for merging of team code
2 parents 103b505 + 2ca943c commit 18b1fb8

File tree

7 files changed

+100
-24
lines changed

7 files changed

+100
-24
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@
7373
"build-bin": "electron-builder -mwl",
7474
"test": "cross-env NODE_ENV=test jest --verbose",
7575
"test:clear": "cross-env NODE_ENV=test jest --clearCache",
76+
"test:update-snap": "cross-env NODE_ENV=test jest --updateSnapshot",
7677
"linter": "eslint src",
7778
"develop": "concurrently \"npm run dev\" \"npm run electron\""
7879
},
@@ -92,7 +93,7 @@
9293
"js"
9394
],
9495
"transform": {
95-
"\\.(ts|tsx)$": "<rootDir>/node_modules/ts-jest/preprocessor.js"
96+
"\\.(ts|tsx)$": "<rootDir>/node_modules/ts-jest"
9697
},
9798
"testRegex": "/__tests__/.*\\.(ts|tsx|js)$",
9899
"globals": {
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import * as actions from '../actionCreators';
2+
import * as types from '../../actionTypes/index';
3+
4+
describe('Testing All of The Action Creators', () => {
5+
it('addComponent returns a proper action', () => {
6+
const payld = { title: 'Test' };
7+
const expectedAction = {
8+
type: types.ADD_COMPONENT,
9+
payload: payld
10+
};
11+
expect(actions.addComponent(payld)).toEqual(expectedAction);
12+
});
13+
14+
it('addChild returns a proper action', () => {
15+
const payld = { title: 'Test', childType: 'COMP', HTMLInfo: {} };
16+
const expectedAction = {
17+
type: types.ADD_CHILD,
18+
payload: payld
19+
};
20+
expect(actions.addChild(payld)).toEqual(expectedAction);
21+
});
22+
23+
it('addProp returns a proper action', () => {
24+
const payld = { key: 'Test', type: 'string' };
25+
const expectedAction = {
26+
type: types.ADD_PROP,
27+
payload: payld
28+
};
29+
expect(actions.addProp(payld)).toEqual(expectedAction);
30+
});
31+
32+
it('changeTutorial returns a proper action', () => {
33+
const payld = 1;
34+
const expectedAction = {
35+
type: types.CHANGE_TUTORIAL,
36+
payload: { tutorial: payld }
37+
};
38+
expect(actions.changeTutorial(payld)).toEqual(expectedAction);
39+
});
40+
41+
it('changeImagePath returns a proper action', () => {
42+
const payld = 'test/path';
43+
const expectedAction = {
44+
type: types.CHANGE_IMAGE_SOURCE,
45+
payload: { imageSource: payld }
46+
};
47+
expect(actions.changeImagePath(payld)).toEqual(expectedAction);
48+
});
49+
});

src/actions/actionCreators.ts

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -52,16 +52,22 @@ export const addChild = ({
5252
title: string;
5353
childType: string;
5454
HTMLInfo: object;
55-
}) => (dispatch: (arg: Action) => void) => {
56-
dispatch({ type: ADD_CHILD, payload: { title, childType, HTMLInfo } });
57-
};
58-
59-
export const addComponent = ({ title }: { title: string }) => (
60-
dispatch: (arg: Action) => void
61-
) => {
62-
dispatch({ type: ADD_COMPONENT, payload: { title } });
63-
};
55+
}): {
56+
type: string;
57+
payload: { title: string; childType: string; HTMLInfo: object };
58+
} => ({ type: ADD_CHILD, payload: { title, childType, HTMLInfo } });
6459

60+
export const addComponent = ({
61+
title
62+
}: {
63+
title: string;
64+
}): {
65+
type: string;
66+
payload: { title: string };
67+
} => ({
68+
type: ADD_COMPONENT,
69+
payload: { title }
70+
});
6571
export const addProp = ({ key, type }: { key: string; type: string }) => ({
6672
type: ADD_PROP,
6773
payload: { key, type }
@@ -102,7 +108,6 @@ export const changeFocusChild = ({ childId }: { childId: number }) => (
102108
dispatch({ type: CHANGE_FOCUS_CHILD, payload: { childId } });
103109
};
104110

105-
106111
export const changeFocusComponent = ({ title }: { title: string }) => (
107112
dispatch: (arg: Action) => void
108113
) => {
@@ -168,7 +173,6 @@ export const deleteAllData = () => ({
168173
type: DELETE_ALL_DATA
169174
});
170175

171-
172176
export const deleteComponent = ({
173177
componentId,
174178
stateComponents
@@ -306,7 +310,7 @@ export const toggleEditMode = ({ id }: { id: number }) => (
306310
};
307311

308312
export const toggleNative = () => ({
309-
type: TOGGLE_NATIVE,
313+
type: TOGGLE_NATIVE
310314
});
311315

312316
export const undo = () => ({

src/components/bottom/BottomTabs.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,13 @@ class BottomTabs extends Component<BottomTabsPropsInt, StateInt> {
137137
tree.children.push(
138138
this.generateComponentTree(child.childComponentId, components)
139139
);
140+
} else if (child.componentName.slice(0, 2) == 'RN') {
141+
let str = { Type: 'React Native Component' };
142+
tree.children.push({
143+
name: child.componentName,
144+
attributes: str,
145+
children: []
146+
});
140147
} else {
141148
let str = { Type: 'HTML Element' };
142149
tree.children.push({

src/components/left/SimpleModal.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,20 @@ const styles = (theme: any): any => ({
1212
width: 'auto',
1313
maxWidth: '500px',
1414
height: 'auto',
15-
maxHeight: '300px',
15+
maxHeight: '500px',
1616
backgroundColor: theme.palette.background.paper,
1717
boxShadow: theme.shadows[5],
1818
padding: '4%',
1919
minWidth: '500px',
20-
minHeight: '300px',
20+
minHeight: '300px'
2121
},
2222
button: {
2323
marginTop: '0%',
2424
height: 'auto',
2525
marginLeft: '3%',
2626
borderRadius: '4px',
27-
float: 'right',
28-
},
27+
float: 'right'
28+
}
2929
});
3030

3131
const SimpleModal = (props: any) => {
@@ -38,7 +38,7 @@ const SimpleModal = (props: any) => {
3838
primBtnAction,
3939
secBtnAction,
4040
closeModal,
41-
children = null,
41+
children = null
4242
} = props;
4343

4444
return (
@@ -53,7 +53,7 @@ const SimpleModal = (props: any) => {
5353
style={{
5454
top: '50%',
5555
left: '50%',
56-
transform: 'translate(-50%, -50%)',
56+
transform: 'translate(-50%, -50%)'
5757
}}
5858
className={classes.paper}
5959
>
@@ -65,7 +65,7 @@ const SimpleModal = (props: any) => {
6565
top: '2%',
6666
right: '1%',
6767
fontSize: '17px',
68-
fontWeight: 'bold',
68+
fontWeight: 'bold'
6969
}}
7070
>
7171
<CloseIcon />

src/reducers/bottomReducers.ts

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
PropInt
88
} from '../interfaces/Interfaces';
99
import { createHistory } from '../helperFunctions/createHistory';
10+
import { initialApplicationState } from './initialState';
1011

1112
export const addProp = (
1213
state: ApplicationStateInt,
@@ -112,13 +113,23 @@ export const toggleCodeEdit = (state: ApplicationStateInt) => ({
112113
});
113114

114115
export const toggleNative = (state: ApplicationStateInt) => {
115-
const components = cloneDeep(state.components);
116-
const app = components.find(e => e.id === 1);
116+
let check = window.confirm(
117+
`Are you sure you want to switch to ${
118+
state.native ? 'React Mode' : 'React Native Mode'
119+
}?\n\nSwitching to ${
120+
state.native ? 'React Mode' : 'React Native Mode'
121+
} will clear the workspace!\n\nMake sure to export your current code before changing modes!`
122+
);
123+
if (!check) {
124+
return { ...state };
125+
}
126+
const components = cloneDeep(initialApplicationState.components);
127+
const app = components.find((e: ComponentInt) => e.id === 1);
117128
app.position.width = !state.native ? 500 : 1200;
118129
app.position.height = !state.native ? 850 : 800;
119130

120131
return {
121-
...state,
132+
...initialApplicationState,
122133
native: !state.native,
123134
components
124135
};

src/reducers/leftReducers.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,11 @@ export const exportFilesError = (
502502
loading: false
503503
});
504504

505-
//Reducer that toggles the component class
505+
/*
506+
Reducer that toggles the component class
507+
lets the user choose whether the current
508+
component is a class components or not
509+
*/
506510
export const toggleComponentClass = (
507511
state: ApplicationStateInt,
508512
{ id }: { id: number }

0 commit comments

Comments
 (0)