Skip to content

Commit 69e301c

Browse files
authored
Merge pull request #13 from oslabs-beta/cleanUp
Clean up
2 parents db048ff + b2f6f0f commit 69e301c

File tree

19 files changed

+184
-369
lines changed

19 files changed

+184
-369
lines changed

app/electron/main.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,6 @@ ipcMain.on('github', event => {
387387
const githubURL = isDev
388388
? `http://localhost:${DEV_PORT}/auth/github`
389389
: `https://reactype-caret.herokuapp.com/auth/github`;
390-
console.log(githubURL);
391390
const options = {
392391
client_id: process.env.GITHUB_ID,
393392
client_secret: process.env.GITHUB_SECRET,

app/src/components/ContextAPIManager/AssignTab/components/ComponentDropDrown.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ const ComponentDropDown = ({
2222
});
2323
} else if (newValue && newValue.inputValue) {
2424
// Create a new contextInput from the user input
25-
//console.log(newValue,newValue.inputValue)
2625
setComponentInput({
2726
name: newValue.inputValue,
2827
values: []

app/src/components/ContextAPIManager/AssignTab/components/ContextDropDown.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ const ContextDropDown = ({
2222
});
2323
} else if (newValue && newValue.inputValue) {
2424
// Create a new contextInput from the user input
25-
//console.log(newValue,newValue.inputValue)
2625
setContextInput({
2726
name: newValue.inputValue,
2827
values: []

app/src/components/ContextAPIManager/CreateTab/components/AddContextForm.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ const AddContextForm = ({
3838
});
3939
} else if (newValue && newValue.inputValue) {
4040
// Create a new contextInput from the user input
41-
//console.log(newValue,newValue.inputValue)
4241
setContextInput({
4342
name: newValue.inputValue,
4443
values: []

app/src/components/StateManagement/CreateTab/CreateContainer.tsx

Lines changed: 1 addition & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,77 +1,17 @@
1-
import React, { useEffect, useState, useContext } from 'react';
1+
import React, { useEffect, useState } from 'react';
22
import { useStore } from 'react-redux';
3-
import { useDispatch } from 'react-redux';
43
import Grid from '@mui/material/Grid';
5-
import * as actions from '../../../redux/actions/actions';
6-
import StateContext from '../../../context/context';
74
import StatePropsPanel from './components/StatePropsPanel';
85

9-
//LegacyPD added this in here
10-
//import StatePropsPanel from '../../right/StatePropsPanel';
11-
126
const CreateContainer = ({isThemeLight, data}) => {
13-
const defaultTableData = [{ key: 'Enter Key', value: 'Enter value' }];
147
const store = useStore();
158
const [state, setState] = useState([]);
16-
const [tableState, setTableState] = useState(defaultTableData);
17-
const [contextInput, setContextInput] = useState(null);
18-
const [stateContext, dispatchContext] = useContext(StateContext);
19-
20-
//pass down stateprops and parent props from state management
219

2210
//pulling data from redux store
2311
useEffect(() => {
2412
setState(store.getState().contextSlice);
2513
}, []);
2614

27-
const dispatch = useDispatch();
28-
29-
//update data store when user adds a new context
30-
const handleClickSelectContext = () => {
31-
//prevent user from adding duplicate context
32-
for (let i = 0; i < state.allContext.length; i += 1) {
33-
if (state.allContext[i].name === contextInput.name) {
34-
return;
35-
}
36-
}
37-
setContextInput('');
38-
dispatch(actions.addContextActionCreator(contextInput));
39-
setState(store.getState().contextSlice);
40-
};
41-
42-
//update data store when user add new key-value pair to context
43-
const handleClickInputData = ({ name }, { inputKey, inputValue }) => {
44-
dispatch(
45-
actions.addContextValuesActionCreator({ name, inputKey, inputValue })
46-
);
47-
setState(store.getState().contextSlice);
48-
};
49-
50-
//update data store when user deletes context
51-
const handleDeleteContextClick = () => {
52-
dispatch(actions.deleteContext(contextInput));
53-
setContextInput('');
54-
setState(store.getState().contextSlice);
55-
setTableState(defaultTableData);
56-
dispatchContext({
57-
type: 'DELETE ELEMENT',
58-
payload: 'FAKE_ID'
59-
});
60-
};
61-
62-
//re-render data table when there's new changes
63-
const renderTable = targetContext => {
64-
if (
65-
targetContext === null ||
66-
targetContext === undefined ||
67-
!targetContext.values
68-
) {
69-
// if (targetContext === null || targetContext === undefined) {
70-
setTableState(defaultTableData);
71-
} else {
72-
setTableState(targetContext.values);
73-
}
74-
};
7515
return (
7616
<Grid container display="flex" justifyContent="stretch" flexDirection="column">
7717
<StatePropsPanel isThemeLight={isThemeLight} data={data}/>

app/src/components/StateManagement/CreateTab/components/StatePropsPanel.tsx

Lines changed: 6 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,17 @@
1-
2-
import React, { useState, useContext, useCallback, useEffect } from "react";
1+
import React, { useState, useContext, useEffect } from "react";
32
import {
4-
createStyles,
53
makeStyles,
64
styled,
7-
Theme,
8-
createTheme,
9-
ThemeProvider,
10-
withStyles
5+
Theme
116
} from "@material-ui/core/styles";
127
import Button from "@material-ui/core/Button";
138
import {
14-
Checkbox,
159
FormControl,
16-
FormControlLabel,
1710
FormHelperText,
18-
FormLabel,
19-
Grid,
2011
MenuItem,
21-
Input,
2212
InputLabel,
2313
Select,
24-
TextField,
14+
TextField
2515
} from "@material-ui/core";
2616
import StateContext from "../../../../context/context";
2717
import TableStateProps from "./TableStateProps";
@@ -74,8 +64,8 @@ const StatePropsPanel = ({ isThemeLight, data}): JSX.Element => {
7464
const resetError = () => {
7565
setErrorStatus(false);
7666
};
67+
7768
// submit new stateProps entries to state context
78-
let currKey;
7969
const submitNewState = (e) => {
8070
e.preventDefault();
8171

@@ -95,14 +85,9 @@ const StatePropsPanel = ({ isThemeLight, data}): JSX.Element => {
9585
return;
9686
}
9787

98-
// carly LegacyPD
9988
// check here to see if state has already been created with the submitted key
100-
// iterate through all the state keys in all of the components in the app
101-
// outer for loop: iterating through all of the components in the app
10289
for (let i = 0; i < state.components.length; i++) {
103-
// inner for loop iterating through the stateProps array for each component
10490
for (let j = 0; j < state.components[i].stateProps.length; j++) {
105-
// if find piece of state with the same key as inputKey, create an error
10691
if (inputKey === state.components[i].stateProps[j]["key"]) {
10792
setErrorStatus(true);
10893
setErrorMsg('Key name already in use.');
@@ -127,8 +112,6 @@ const StatePropsPanel = ({ isThemeLight, data}): JSX.Element => {
127112
type: 'func',
128113
};
129114

130-
131-
132115
dispatch({
133116
type: 'ADD STATE',
134117
payload: {newState: newState, setNewState: setNewState}
@@ -137,6 +120,7 @@ const StatePropsPanel = ({ isThemeLight, data}): JSX.Element => {
137120
resetError();
138121
clearForm();
139122
};
123+
140124
// find table row using its id and if it exists, populate form with its details
141125
const handlerRowSelect = (table) => {
142126
let exists = false;
@@ -170,10 +154,7 @@ const StatePropsPanel = ({ isThemeLight, data}): JSX.Element => {
170154
let currChild = currComponent.children[j];
171155
if (currChild.typeId === childId) {
172156
const currComponentCopy = JSON.parse(JSON.stringify(currComponent));
173-
// currComponentCopy.stateProps.map((el) => {
174-
// console.log(el)
175-
// el['id'] = el['id'] + 0.01;
176-
// })
157+
177158
return {parentProps: currComponentCopy.stateProps,
178159
parentName: currComponentCopy.name,
179160
parentComponent: currComponentCopy,

app/src/components/StateManagement/CreateTab/components/TableParentProps.tsx

Lines changed: 4 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,18 @@ import {
44
GridEditRowsModel,
55
} from '@mui/x-data-grid';
66
import Button from '@material-ui/core/Button';
7-
import ClearIcon from '@material-ui/icons/Clear';
87
import StateContext from "../../../../context/context";
98
import { makeStyles } from '@material-ui/core/styles';
109
import { StatePropsPanelProps } from '../../../../interfaces/Interfaces';
1110
import AddIcon from '@mui/icons-material/Add';
1211

1312
const TableParentProps = props => {
14-
// console.log('props from table state props', props)
1513
const [state, dispatch] = useContext(StateContext);
1614
const classes = useStyles();
1715
const currentId = state.canvasFocus.componentId;
1816
const currentComponent = state.components[currentId - 1];
1917
const [editRowsModel] = useState<GridEditRowsModel>({});
2018
const [gridColumns, setGridColumns] = useState([]);
21-
const [checked, setChecked] = useState(false);
2219
const parentProps = props.parentProps;
2320
const parentPassedInProps = props.parentPassedInProps;
2421
const parentComponent = props.parentComponent;
@@ -77,16 +74,11 @@ const TableParentProps = props => {
7774
});
7875
};
7976

80-
81-
8277
useEffect(() => {
8378
setGridColumns(columnTabs);
8479
}, [props.isThemeLight]);
8580

86-
const { selectHandler }: StatePropsPanelProps = props;
87-
// the delete button needs to be updated to remove
88-
// the states from the current focused component
89-
81+
// determine whether or not to include delete column in data grid
9082
useEffect(() => {
9183
if (props.canDeleteState) {
9284
setGridColumns(columnTabs);
@@ -95,11 +87,11 @@ const TableParentProps = props => {
9587
}
9688

9789
}, [state.canvasFocus.componentId]);
98-
// rows to show are either from current component or from a given provider
99-
// legacy pd convert parent props into a row array
100-
//let rows = parentProps;
90+
91+
10192
let rows;
10293

94+
// check if current component is a root component-- if yes, it shouldn't have any parent props
10395
if (currentComponent.name === 'App' || currentComponent.name === 'index') {rows = []}
10496
else {
10597
if (parentProps) {
@@ -110,29 +102,6 @@ const TableParentProps = props => {
110102
}
111103
}
112104

113-
// if (!props.providerId) {
114-
// const currentId = state.canvasFocus.componentId;
115-
// const currentComponent = state.components[currentId - 1];
116-
// rows = currentComponent.stateProps.slice();
117-
// } else {
118-
// const providerComponent = state.components[props.providerId - 1];
119-
// // changed to get whole object
120-
// if (props.displayObject){
121-
// const displayObject = props.displayObject;
122-
// // format for DataGrid
123-
// let id=1;
124-
// for (const key in displayObject) {
125-
// // if key is a number make it a string with brackets aroung number
126-
// const newKey = isNaN(key) ? key : '[' + key + ']';
127-
// const type = Array.isArray(displayObject[key]) ? 'array' : typeof (displayObject[key]);
128-
// rows.push({ id: id++, key: newKey, value: displayObject[key], type: type});
129-
// }
130-
// } else {
131-
// rows = providerComponent.stateProps.slice();
132-
// }
133-
// }
134-
135-
136105
return (
137106
<div className={'state-prop-grid'}>
138107
<DataGrid

app/src/components/StateManagement/CreateTab/components/TablePassedInProps.tsx

Lines changed: 4 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ import ClearIcon from '@material-ui/icons/Clear';
88
import StateContext from "../../../../context/context";
99
import { makeStyles } from '@material-ui/core/styles';
1010
import { StatePropsPanelProps } from '../../../../interfaces/Interfaces';
11-
import AddIcon from '@mui/icons-material/Add';
12-
import { borderLeft } from '@mui/system';
1311

1412
const TablePassedInProps = props => {
1513
const [state, dispatch] = useContext(StateContext);
@@ -20,6 +18,7 @@ const TablePassedInProps = props => {
2018
const currentComponent = state.components[currentId - 1];
2119
const passedInProps = (currentComponent.name !== 'App' && currentComponent.name !== 'index')? currentComponent.passedInProps : '';
2220

21+
//formatting for data grid columns
2322
const columnTabs = [
2423
{
2524
field: 'id',
@@ -66,6 +65,7 @@ const TablePassedInProps = props => {
6665
}
6766
}
6867
];
68+
6969
const deletePassedInProps = (rowId) => {
7070
// get the current focused component
7171
// remove the state that the button is clicked
@@ -80,10 +80,6 @@ const TablePassedInProps = props => {
8080
setGridColumns(columnTabs);
8181
}, [props.isThemeLight]);
8282

83-
const { selectHandler }: StatePropsPanelProps = props;
84-
// the delete button needs to be updated to remove
85-
// the states from the current focused component
86-
8783
useEffect(() => {
8884
if (props.canDeleteState) {
8985
setGridColumns(columnTabs);
@@ -93,41 +89,17 @@ const TablePassedInProps = props => {
9389

9490
}, [state.canvasFocus.componentId]);
9591

92+
// fill data grid rows with all of the passed in props from parent component (if there are any)
9693
let rows = passedInProps?.slice();
97-
// rows to show are either from current component or from a given provider
98-
// legacy pd convert parent props into a row array
99-
// if (!props.providerId) {
100-
// const currentId = state.canvasFocus.componentId;
101-
// const currentComponent = state.components[currentId - 1];
102-
// rows = currentComponent.stateProps.slice();
103-
// } else {
104-
// const providerComponent = state.components[props.providerId - 1];
105-
// // changed to get whole object
106-
// if (props.displayObject){
107-
// const displayObject = props.displayObject;
108-
// // format for DataGrid
109-
// let id=1;
110-
// for (const key in displayObject) {
111-
// // if key is a number make it a string with brackets aroung number
112-
// const newKey = isNaN(key) ? key : '[' + key + ']';
113-
// const type = Array.isArray(displayObject[key]) ? 'array' : typeof (displayObject[key]);
114-
// rows.push({ id: id++, key: newKey, value: displayObject[key], type: type});
115-
// }
116-
// } else {
117-
// rows = providerComponent.stateProps.slice();
118-
// }
119-
// }
120-
94+
12195
return (
12296
<div className={'state-prop-grid'}>
12397
<DataGrid
12498
rows={rows}
12599
columns={gridColumns}
126100
pageSize={5}
127101
editRowsModel={editRowsModel}
128-
// onRowClick={deleteParentProps}
129102
className={props.isThemeLight ? classes.themeLight : classes.themeDark}
130-
// checkboxSelection
131103
/>
132104
</div>
133105
);

app/src/components/StateManagement/CreateTab/components/TableStateProps.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,8 @@ const TableStateProps = props => {
1616
const [gridColumns, setGridColumns] = useState([]);
1717
const currentId = state.canvasFocus.componentId;
1818
const currentComponent = state.components[currentId - 1];
19-
const rows1 = props.rows1;
20-
const setRows1 = props.setRows1;
2119

20+
// formatting for data grid columns
2221
const columnTabs = [
2322
{
2423
field: 'id',
@@ -63,6 +62,7 @@ const TableStateProps = props => {
6362
}
6463
}
6564
];
65+
6666
const deleteState = (selectedId, stateName) => {
6767
// get the current focused component
6868
// send a dispatch to rerender the table
@@ -104,6 +104,7 @@ const TableStateProps = props => {
104104
}
105105

106106
}, [state.canvasFocus.componentId]);
107+
107108
// rows to show are either from current component or from a given provider
108109
let rows = [];
109110
currentComponent.stateProps?.forEach((prop) => rows.push(prop));
@@ -119,7 +120,6 @@ const TableStateProps = props => {
119120
onRowClick={selectHandler}
120121
className={props.isThemeLight ? classes.themeLight : classes.themeDark}
121122
/>
122-
123123
</div>
124124
);
125125
};

0 commit comments

Comments
 (0)