Skip to content

Commit 54cf4c8

Browse files
authored
Merge pull request #53 from oslabs-beta/alex/cleanup
Alex/cleanup
2 parents 965224d + 3ba26c6 commit 54cf4c8

File tree

6 files changed

+519
-480
lines changed

6 files changed

+519
-480
lines changed

src/client/components-v2/App.tsx

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,36 @@
1-
import React, { useState, useEffect, JSXElementConstructor } from 'react';
2-
import { HashRouter, Routes, Route } from 'react-router-dom';
3-
import ContentsContainer from '../components/containers/ContentsContainer';
4-
import SidebarContainer from '../components/containers/SidebarContainer';
5-
import ResponsePaneContainer from '../components/containers/ResponsePaneContainer';
6-
import RightSideContainer from '../components/containers/RightSideContainer';
1+
import React, { useState, useEffect } from 'react';
2+
import { HashRouter } from 'react-router-dom';
3+
// Import controllers
74
import historyController from '../controllers/historyController';
85
import collectionsController from '../controllers/collectionsController';
9-
import UpdatePopUpContainer from '../components/containers/UpdatePopUpContainer';
10-
import { WindowExt } from '../../types'
11-
import '../../assets/style/App.scss';
6+
// Import local components
7+
import UpdatePopUpContainer from './legacy-components/UpdatePopUpContainer';
8+
import HistoryOrWorkspaceContainer from './workspace/HistoryOrWorkspaceContainer';
129
import NavBarContainer from './navbar/NavBarContainer';
13-
import WorkspaceContainer from './workspace/WorkspaceContainer';
1410
import MainContainer from './main/MainContainer';
15-
import HistoryOrWorkspaceContainer from './history-workspace-display/HistoryOrWorkspaceContainer';
16-
11+
import { WindowExt } from '../../types'
12+
// Import MUI components
1713
import { Box, Divider } from '@mui/material';
14+
// Import styling
15+
/**
16+
* Note to future devs:
17+
* Our team is finishing our work on this app, and part of our stretch goals were to migrate
18+
* all of the existing components to use Material UI. We made this decision for a few reasons:
19+
* (1) There are a toooon of people who work on this application. It needs consistent styling,
20+
* and making changes to the SASS files can really complicate development of the app.
21+
* (2) Material UI is very easy to use and very supported. If you know React and a touch of CSS, you'll be able
22+
* to quickly make visually-compatible components without touching CSS files, which will speed up
23+
* development.
24+
* - AA 18 May, 2022
25+
*/
26+
import '../../assets/style/App.scss';
1827

1928

2029
const { api } = window as unknown as WindowExt;
2130

2231
const App = () => {
32+
{/* */}
2333
const [message, setMessage] = useState(null);
24-
2534
// currentWorkspace is the current Workspace's UUID. It is only altered in WorkspaceSelect.tsx, which is rendered by CurrentWorskpaceDisplay.tsx
2635
const [currentWorkspaceId, setWorkspace] = React.useState('');
2736

@@ -32,7 +41,7 @@ const App = () => {
3241
}, []);
3342

3443
return (
35-
<div id="app" className="is-tall">
44+
<div id="app" className="git brais-tall">
3645
<HashRouter>
3746
<NavBarContainer />
3847
<Divider orientation="horizontal"/>

src/client/components/containers/UpdatePopUpContainer.jsx renamed to src/client/components-v2/legacy-components/UpdatePopUpContainer.jsx

File renamed without changes.

src/client/components-v2/history-workspace-display/HistoryOrWorkspaceContainer.tsx renamed to src/client/components-v2/workspace/HistoryOrWorkspaceContainer.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import Button from '@mui/material/Button';
77
import Box from '@mui/material/Box';
88
import BarGraph from '../../components/display/BarGraph';
99
import ScheduleContainer from '../../components/containers/ScheduleContainer';
10-
import WorkspaceContainer from "../workspace/WorkspaceContainer";
10+
import WorkspaceContainer from "./WorkspaceContainer";
1111
import HistoryContainer from '../../components/containers/HistoryContainer';
1212
import AccessTimeIcon from '@mui/icons-material/AccessTime';
1313
import WorkIcon from '@mui/icons-material/Work';
Lines changed: 95 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,95 @@
1-
import React from 'react';
2-
// Import controllers
3-
import collectionsController from '../../../../controllers/collectionsController'
4-
// Import MUI components
5-
import DialogTitle from '@mui/material/DialogTitle';
6-
import Dialog from '@mui/material/Dialog';
7-
import List from '@mui/material/List';
8-
import ListItem from '@mui/material/ListItem';
9-
import ListItemText from '@mui/material/ListItemText';
10-
import ListItemButton from '@mui/material/ListItemButton';
11-
12-
13-
// export interface SimpleDialogProps {
14-
// open: boolean;
15-
// selectedValue: string;
16-
// onClose: (value: string) => void;
17-
// }
18-
19-
export default function ExportToGithubDialog({ allUserRepos, workspace, selectedRepo, open, onClose}) {
20-
// const { onClose, selectedValue, open } = props;
21-
22-
const handleClose = () => {
23-
onClose(selectedRepo);
24-
};
25-
26-
const handleListItemClick = (value: string) => {
27-
onClose(value);
28-
};
29-
30-
const handleExportToRepo = (repo) => {
31-
console.log('need to export this specific file to this clicked-on repo.')
32-
console.log('workspace to export:', workspace)
33-
console.log('repo metadata:', repo.repository)
34-
collectionsController.exportToGithub(workspace.id, repo.repository.name, repo.sha)
35-
//
36-
}
37-
38-
console.log(
39-
'all user repos:', allUserRepos
40-
)
41-
const repoListItems = []
42-
for (let repo of allUserRepos) {
43-
// console.log('sha', repo.sha);
44-
repoListItems.push(
45-
<ListItemButton
46-
key={repo.repository.id}
47-
onClick={() => handleExportToRepo(repo)}
48-
>
49-
<ListItem>
50-
<ListItemText primary={repo.repository.full_name} />
51-
</ListItem>
52-
</ListItemButton>
53-
)
54-
}
55-
56-
57-
return (
58-
<Dialog onClose={handleClose} open={open}>
59-
<DialogTitle>Select a repository to export to.</DialogTitle>
60-
<List sx={{ pt: 0 }}>
61-
{repoListItems}
62-
{/* <ListItem autoFocus button onClick={() => handleListItemClick}>
63-
<ListItemText primary="repo" />
64-
</ListItem > */}
65-
</List>
66-
</Dialog>
67-
);
68-
}
1+
import React from 'react';
2+
// Import controllers
3+
import collectionsController from '../../../../controllers/collectionsController'
4+
// Import MUI components
5+
import DialogTitle from '@mui/material/DialogTitle';
6+
import Dialog from '@mui/material/Dialog';
7+
import List from '@mui/material/List';
8+
import ListItem from '@mui/material/ListItem';
9+
import ListItemText from '@mui/material/ListItemText';
10+
import ListItemButton from '@mui/material/ListItemButton';
11+
// Database handling
12+
import db from '../../../../db';
13+
import { useLiveQuery } from 'dexie-react-hooks';
14+
15+
16+
// export interface SimpleDialogProps {
17+
// open: boolean;
18+
// selectedValue: string;
19+
// onClose: (value: string) => void;
20+
// }
21+
22+
export default function ExportToGithubDialog({ allUserRepos, workspace, selectedRepo, open, onClose}) {
23+
let files = useLiveQuery(() => db.files.toArray());
24+
let repos = useLiveQuery(() => db.repos.toArray());
25+
26+
// db.table('repo')
27+
// .where('name')
28+
// .equalsIgnoreCase(name)
29+
// .first((foundCollection: boolean) => !!foundCollection)
30+
// .then((found: boolean) => resolve(found))
31+
// .catch((error: Record<string, undefined>) => {
32+
// console.error(error.stack || error);
33+
// reject(error);
34+
// });
35+
36+
const handleClose = () => {
37+
onClose(selectedRepo);
38+
};
39+
40+
const handleListItemClick = (value: string) => {
41+
onClose(value);
42+
};
43+
44+
const handleExportToRepo = (repo) => {
45+
console.log('need to export this specific file to this clicked-on repo.')
46+
console.log('workspace to export:', workspace)
47+
console.log('repo metadata:', repo.repository)
48+
// grab sha off of current workspace
49+
let sha = '';
50+
for(let file of files) {
51+
if (file.repository.full_name === repo.full_name) {
52+
sha = file.sha;
53+
}
54+
}
55+
// db.table('files')
56+
// .where((workspace) => {
57+
58+
// })
59+
60+
61+
62+
collectionsController.exportToGithub(workspace.id, repo.name, sha)
63+
}
64+
65+
const repoListItems = []
66+
67+
if(repos !== undefined) {
68+
console.log(repos)
69+
for (let repo of repos) {
70+
repoListItems.push(
71+
<ListItemButton
72+
key={repo.id}
73+
onClick={() => handleExportToRepo(repo)}
74+
>
75+
<ListItem>
76+
<ListItemText primary={repo.full_name} />
77+
</ListItem>
78+
</ListItemButton>
79+
)
80+
}
81+
}
82+
83+
84+
return (
85+
<Dialog onClose={handleClose} open={open}>
86+
<DialogTitle>Select a repository to export to.</DialogTitle>
87+
<List sx={{ pt: 0 }}>
88+
{repoListItems}
89+
{/* <ListItem autoFocus button onClick={() => handleListItemClick}>
90+
<ListItemText primary="repo" />
91+
</ListItem > */}
92+
</List>
93+
</Dialog>
94+
);
95+
}

0 commit comments

Comments
 (0)