Skip to content

Commit 143d0fd

Browse files
authored
Merge pull request #3 from oslabs-beta/ahsan-ben-branch
Merging MVP features into dev
2 parents 55bf5c2 + 34b180a commit 143d0fd

28 files changed

+1680
-127
lines changed

app/electron/main.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ async function createWindow() {
6666
// enable devtools when in development mode
6767
devTools: true,
6868
// crucial security feature - blocks rendering process from having access to node modules
69-
nodeIntegration: false,
69+
nodeIntegration: true,
7070
// web workers will not have access to node
7171
nodeIntegrationInWorker: false,
7272
// disallow experimental feature to allow node.js support in sub-frames (i-frames/child windows)
@@ -76,10 +76,10 @@ async function createWindow() {
7676
// Electron API only available from preload, not loaded page
7777
contextIsolation: true,
7878
// disables remote module. critical for ensuring that rendering process doesn't have access to node functionality
79-
enableRemoteModule: false,
79+
enableRemoteModule: true,
8080
// path of preload script. preload is how the renderer page will have access to electron functionality
8181
preload: path.join(__dirname, 'preload.js'),
82-
nativeWindowOpen: true
82+
nativeWindowOpen: true,
8383
}
8484
});
8585

@@ -391,11 +391,11 @@ ipcMain.on('github', event => {
391391
height: 600,
392392
title: 'Github Oauth',
393393
webPreferences: {
394-
nodeIntegration: false,
394+
nodeIntegration: true,
395395
nodeIntegrationInWorker: false,
396396
nodeIntegrationInSubFrames: false,
397397
contextIsolation: true,
398-
enableRemoteModule: false,
398+
enableRemoteModule: true,
399399
zoomFactor: 1.0
400400
}
401401
});
@@ -470,11 +470,11 @@ ipcMain.on('tutorial', event => {
470470
minWidth: 661,
471471
title: 'Tutorial',
472472
webPreferences: {
473-
nodeIntegration: false,
473+
nodeIntegration: true,
474474
nodeIntegrationInWorker: false,
475475
nodeIntegrationInSubFrames: false,
476476
contextIsolation: true,
477-
enableRemoteModule: false,
477+
enableRemoteModule: true,
478478
zoomFactor: 1.0
479479
}
480480
});

app/electron/menu.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,11 @@ var MenuBuilder = function(mainWindow, appName) {
3939
minWidth: 665,
4040
title: 'Tutorial',
4141
webPreferences: {
42-
nodeIntegration: false,
42+
nodeIntegration: true,
4343
nodeIntegrationInWorker: false,
4444
nodeIntegrationInSubFrames: false,
4545
contextIsolation: true,
46-
enableRemoteModule: false,
46+
enableRemoteModule: true,
4747
zoomFactor: 1.0,
4848
devTools: false
4949
}

app/src/Dashboard/Project.tsx

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -105,17 +105,17 @@ const Project = ({
105105
setCommentVal(commentValue);
106106
}
107107
const recentComments = [];
108-
if (comments.length > 0) {
109-
const reversedCommentArray = comments.slice(0).reverse();
110-
const min = Math.min(6, reversedCommentArray.length)
111-
for (let i = 0; i < min ; i++) {
112-
recentComments.push(
113-
<p className='comment'>
114-
<b>{ reversedCommentArray[i].username }</b>:
115-
{ reversedCommentArray[i].text }
116-
</p>
117-
)}
118-
}
108+
// if (comments?.length > 0) {
109+
// const reversedCommentArray = comments.slice(0).reverse();
110+
// const min = Math.min(6, reversedCommentArray.length)
111+
// for (let i = 0; i < min ; i++) {
112+
// recentComments.push(
113+
// <p className='comment'>
114+
// <b>{ reversedCommentArray[i].username }</b>:
115+
// { reversedCommentArray[i].text }
116+
// </p>
117+
// )}
118+
// }
119119
// Closes out the open modal
120120
const closeModal = () => setModal('');
121121
// Creates modal that asks if user wants to delete project

app/src/Dashboard/ProjectContainer.tsx

Lines changed: 42 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -103,21 +103,21 @@ const ProjectContainer = (): JSX.Element => {
103103
const [style, setStyle] = useState(initialStyle);
104104
// hook for sorting menu
105105
const [selectedOption, setSelectedOption] = useState('RATING');
106-
const sortByRating = projects => {
107-
// generate a sorted array of public projects based on likes
108-
const sortedRatings = projects.sort((a, b) => b.likes - a.likes);
109-
return sortedRatings;
110-
};
111-
const sortByDate = projects => {
112-
// generate a sorted array of public projects based on date
113-
const sortedRatings = projects.sort((a, b) => b.createdAt - a.createdAt);
114-
return sortedRatings;
115-
};
116-
const sortByUser = projects => {
117-
// generate a sorted array of public projects based on username
118-
const sortedRatings = projects.sort((a, b) => b.username - a.username);
119-
return sortedRatings;
120-
};
106+
// const sortByRating = projects => {
107+
// // generate a sorted array of public projects based on likes
108+
// const sortedRatings = projects.sort((a, b) => b.likes - a.likes);
109+
// return sortedRatings;
110+
// };
111+
// const sortByDate = projects => {
112+
// // generate a sorted array of public projects based on date
113+
// const sortedRatings = projects.sort((a, b) => b.createdAt - a.createdAt);
114+
// return sortedRatings;
115+
// };
116+
// const sortByUser = projects => {
117+
// // generate a sorted array of public projects based on username
118+
// const sortedRatings = projects.sort((a, b) => b.username - a.username);
119+
// return sortedRatings;
120+
// };
121121
// function for selecting drop down sorting menu
122122
const optionClicked = value => {
123123
setSelectedOption(value);
@@ -128,22 +128,36 @@ const ProjectContainer = (): JSX.Element => {
128128
variables: myVar
129129
});
130130
if (loading) return <p>Loading...</p>;
131-
if (error) return <p>Error :{error}</p>;
131+
// if (error) return <p>Error :{error}</p>;
132132
// based on resolver(getAllProject) for this query, the data is stored in the data object with the key 'getAllProjects'
133-
const projects = data.getAllProjects;
133+
//const projects = data.getAllProjects;
134+
const projects = [
135+
{key: 1},
136+
{name: 'testproject'},
137+
{likes: 10},
138+
{published: true},
139+
{id: 10},
140+
{userId: 10},
141+
{username: 'arao7'},
142+
{createdAt: 'testDate'},
143+
{comments: []}
144+
]
134145
// create array to hold the data recieved in the public dashboard the will be conditionally rendered
135-
let sortedProjects = projects.filter(proj => {
136-
return proj.published;
137-
});
138-
const userProjects = projects.filter(proj => {
139-
return proj.username === username;
140-
});
146+
// let sortedProjects = projects.filter(proj => {
147+
// return proj.published;
148+
// });
149+
// const userProjects = projects.filter(proj => {
150+
// return proj.username === username;
151+
// });
152+
153+
let sortedProjects = projects;
154+
const userProjects = projects;
141155
// checking which sorting method was selected from drop down menu and invoking correct sorting function
142-
if (selectedOption === 'DATE') sortedProjects = sortByDate(sortedProjects);
143-
else if (selectedOption === 'USER')
144-
sortedProjects = sortByUser(sortedProjects);
145-
else if (selectedOption === 'RATING')
146-
sortedProjects = sortByRating(sortedProjects);
156+
// if (selectedOption === 'DATE') sortedProjects = sortByDate(sortedProjects);
157+
// else if (selectedOption === 'USER')
158+
// sortedProjects = sortByUser(sortedProjects);
159+
// else if (selectedOption === 'RATING')
160+
// sortedProjects = sortByRating(sortedProjects);
147161
// create array to hold the components Project of loggin-in users
148162
// generate an array of Project components based on queried data
149163
const userDisplay = arrToComponent(userProjects);
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
import React, { useEffect, useState, useContext } from 'react';
2+
import { useStore } from 'react-redux';
3+
import { useDispatch } from 'react-redux';
4+
import Divider from '@mui/material/Divider';
5+
import Grid from '@mui/material/Grid';
6+
import DataTable from './components/DataTable';
7+
import * as actions from '../../../redux/actions/actions';
8+
import { Typography } from '@mui/material';
9+
import StateContext from '../../../context/context';
10+
import StatePropsPanel from './components/StatePropsPanel';
11+
import TableStateProps from './components/TableStateProps';
12+
13+
//LegacyPD added this in here
14+
//import StatePropsPanel from '../../right/StatePropsPanel';
15+
16+
const CreateContainer = ({isThemeLight, data}) => {
17+
const defaultTableData = [{ key: 'Enter Key', value: 'Enter value' }];
18+
const store = useStore();
19+
const [state, setState] = useState([]);
20+
const [tableState, setTableState] = useState(defaultTableData);
21+
const [contextInput, setContextInput] = useState(null);
22+
const [stateContext, dispatchContext] = useContext(StateContext);
23+
24+
//pass down stateprops and parent props from state management
25+
26+
//pulling data from redux store
27+
useEffect(() => {
28+
setState(store.getState().contextSlice);
29+
}, []);
30+
31+
const dispatch = useDispatch();
32+
33+
//update data store when user adds a new context
34+
const handleClickSelectContext = () => {
35+
//prevent user from adding duplicate context
36+
for (let i = 0; i < state.allContext.length; i += 1) {
37+
if (state.allContext[i].name === contextInput.name) {
38+
return;
39+
}
40+
}
41+
setContextInput('');
42+
dispatch(actions.addContextActionCreator(contextInput));
43+
setState(store.getState().contextSlice);
44+
};
45+
46+
//update data store when user add new key-value pair to context
47+
const handleClickInputData = ({ name }, { inputKey, inputValue }) => {
48+
dispatch(
49+
actions.addContextValuesActionCreator({ name, inputKey, inputValue })
50+
);
51+
setState(store.getState().contextSlice);
52+
};
53+
54+
//update data store when user deletes context
55+
const handleDeleteContextClick = () => {
56+
dispatch(actions.deleteContext(contextInput));
57+
setContextInput('');
58+
setState(store.getState().contextSlice);
59+
setTableState(defaultTableData);
60+
dispatchContext({
61+
type: 'DELETE ELEMENT',
62+
payload: 'FAKE_ID'
63+
});
64+
};
65+
66+
//re-render data table when there's new changes
67+
const renderTable = targetContext => {
68+
if (
69+
targetContext === null ||
70+
targetContext === undefined ||
71+
!targetContext.values
72+
) {
73+
// if (targetContext === null || targetContext === undefined) {
74+
setTableState(defaultTableData);
75+
} else {
76+
setTableState(targetContext.values);
77+
}
78+
};
79+
return (
80+
<Grid container display="flex" justifyContent="stretch" flexDirection="column">
81+
<StatePropsPanel isThemeLight={isThemeLight} data={data}/>
82+
</Grid>
83+
);
84+
};
85+
86+
export default CreateContainer;

0 commit comments

Comments
 (0)