Skip to content

Commit 9f3bb92

Browse files
authored
Merge pull request #52 from oslabs-beta/ev/export-ui
Ev/export UI
2 parents dfbd765 + 0630224 commit 9f3bb92

File tree

18 files changed

+666
-224
lines changed

18 files changed

+666
-224
lines changed

src/client/components-v2/main/http2-composer/Http2Composer.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ export default function Http2Composer(props) {
6262
warningMessage,
6363
} = props;
6464

65-
console.log(newRequestBody)
65+
// console.log(newRequestBody)
6666

6767
const {
6868
gRPC,

src/client/components-v2/navbar/LoginStatus.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,12 @@ export default function LoginContainer(props) {
7272
flexDirection: 'row',
7373
alignItems: 'center',
7474
}}>
75-
<MoreVertRoundedIcon fontSize='small' onClick={handleSignOut}/>
75+
<Button
76+
sx={{ maxWidth: '24px', maxHeight: '24px', minWidth: '24px', minHeight: '24px' }}
77+
onClick={handleSignOut}
78+
>
79+
<LogoutRoundedIcon fontSize='small' />
80+
</Button>
7681
<StyledBadge
7782
sx={{
7883
m: 1,
@@ -82,7 +87,7 @@ export default function LoginContainer(props) {
8287
variant="dot">
8388
<Avatar alt={session.username} src={session.avatar}/>
8489
</StyledBadge>
85-
<Button variant="outlined">Invite +</Button>
90+
{/* <Button variant="outlined">Invite +</Button> */}
8691
</Box>
8792
:
8893
<Box sx={{

src/client/components-v2/workspace/CurrentWorkspaceDisplay.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { connect } from "react-redux";
33
import { Box } from '@mui/material';
44
import WorkspaceSelect from './WorkspaceSelect';
55
import DeleteWorkspaceButton from "./buttons/DeleteWorkspaceButton"
6-
import ExportWorkspaceButton from "./buttons/ExportWorkspaceButton";
6+
import ImportExportWorkspaceButton from "./buttons/ImportExportWorkspaceButton";
77
import InviteToWorkspaceButton from "./buttons/InviteToWorkspaceButton";
88

99
const mapStateToProps = (store) => {
@@ -19,7 +19,7 @@ function CurrentWorkspaceDisplay(props) {
1919
<WorkspaceSelect {...props} />
2020
{/* <SaveWorkspaceButton /> */}
2121
<DeleteWorkspaceButton id={props.currentWorkspaceId} currentWorkspace={props.currentWorkspace} />
22-
<ExportWorkspaceButton />
22+
<ImportExportWorkspaceButton />
2323
<InviteToWorkspaceButton />
2424
</Box>
2525
)

src/client/components-v2/workspace/WorkspaceSelect.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export default function WorkspaceSelect({ currentWorkspaceId, handleWorkspaceCha
5151
</Select>
5252
<FormHelperText>Current Workspace</FormHelperText>
5353
</FormControl>
54-
<ImportWorkspaceModal open={open} handleClose={handleClose}/>
54+
{/* <ImportWorkspaceModal open={open} handleClose={handleClose}/> */}
5555
</Box>
5656
)
5757
}
Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
1-
import React from "react";
2-
import { Button } from '@mui/material';
3-
import { IosShareRounded } from "@mui/icons-material";
4-
import ExportWorkspaceModal from "../modals/export-workspace/ExportWorkspaceModal";
1+
// import React from "react";
2+
// import { Button } from '@mui/material';
3+
// import { IosShareRounded } from "@mui/icons-material";
4+
// import ExportWorkspaceModal from "../modals/export-workspace/ExportWorkspaceModal";
55

6-
export default function ExportWorkspaceButton() {
7-
const [open, setOpen] = React.useState(false);
8-
const handleOpen = () => setOpen(true);
9-
const handleClose = () => setOpen(false);
6+
// export default function ExportWorkspaceButton() {
7+
// const [open, setOpen] = React.useState(false);
8+
// const handleOpen = () => setOpen(true);
9+
// const handleClose = () => setOpen(false);
1010

11-
return(
12-
<div>
13-
<Button
14-
variant="text"
15-
sx={{ maxWidth: '24px', maxHeight: '24px', minWidth: '24px', minHeight: '24px' }}
16-
onClick={handleOpen}>
17-
<IosShareRounded fontSize="small"/>
18-
</Button>
19-
<ExportWorkspaceModal open={open} handleClose={handleClose}/>
20-
</div>
21-
)
22-
}
11+
// return(
12+
// <div>
13+
// <Button
14+
// variant="text"
15+
// sx={{ maxWidth: '24px', maxHeight: '24px', minWidth: '24px', minHeight: '24px' }}
16+
// onClick={handleOpen}>
17+
// <IosShareRounded fontSize="small"/>
18+
// </Button>
19+
// <ExportWorkspaceModal open={open} handleClose={handleClose}/>
20+
// </div>
21+
// )
22+
// }
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import React from "react";
2+
import { Button } from '@mui/material';
3+
import ImportExportIcon from '@mui/icons-material/ImportExport';
4+
import ImportExportWorkspaceModal from "../modals/import-export-workspace/ImportExportWorkspaceModal";
5+
import { styled } from '@mui/material/styles';
6+
import Tooltip, { TooltipProps, tooltipClasses } from '@mui/material/Tooltip';
7+
8+
9+
//creates the formatting for the little button that appears when you hover over the import/export icon
10+
const LightTooltip = styled(({ className, ...props }: TooltipProps) => (
11+
<Tooltip {...props} classes={{ popper: className }} />
12+
))(({ theme }) => ({
13+
[`& .${tooltipClasses.tooltip}`]: {
14+
backgroundColor: theme.palette.common.white,
15+
color: 'rgba(0, 0, 0, 0.87)',
16+
boxShadow: theme.shadows[1],
17+
fontSize: 11,
18+
fontWeight: 'bold',
19+
},
20+
}));
21+
22+
23+
export default function ImportExportWorkspaceButton() {
24+
const [open, setOpen] = React.useState(false);
25+
const handleOpen = () => setOpen(true);
26+
const handleClose = () => setOpen(false);
27+
28+
return(
29+
<div>
30+
<LightTooltip title="Import/Export">
31+
<Button
32+
variant="text"
33+
sx={{ maxWidth: '24px', maxHeight: '24px', minWidth: '24px', minHeight: '24px' }}
34+
onClick={handleOpen}>
35+
<ImportExportIcon fontSize="small"/>
36+
</Button>
37+
</LightTooltip>
38+
<ImportExportWorkspaceModal open={open} handleClose={handleClose}/>
39+
</div>
40+
)
41+
}

src/client/components-v2/workspace/modals/export-workspace/ExportWorkspaceModal.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import collectionsController from '../../../../controllers/collectionsController
1010
import githubController from '../../../../controllers/githubController';
1111
import db from '../../../../db';
1212
import { useLiveQuery } from 'dexie-react-hooks';
13+
import * as actions from '../../../../features/business/businessSlice';
14+
import * as uiactions from '../../../../features/ui/uiSlice';
1315

1416
const style = {
1517
display: 'flex',
@@ -61,6 +63,9 @@ export default function ExportWorkspaceModal({ open, handleClose }) {
6163
{/* <Box id="import-workspace-modal-description" sx={{ m: 1, webkitJustifyContent: 'space-around', minWidth: 200 }}> */}
6264
<Button
6365
variant="contained" size="small"
66+
onClick={() =>
67+
collectionsController.exportCollection(localWorkspaces)
68+
}
6469
>Files
6570
</Button>
6671
<Button
@@ -72,4 +77,4 @@ export default function ExportWorkspaceModal({ open, handleClose }) {
7277
</Fade>
7378
</Modal>
7479
);
75-
}
80+
};
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,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+
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+
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import React, { useState } from 'react';
2+
// Import MUI components
3+
import Box from '@mui/material/Box';
4+
import List from '@mui/material/ListItem';
5+
import ListItem from '@mui/material/ListItem';
6+
import ListItemButton from '@mui/material/ListItemButton';
7+
import Collapse from '@mui/material/Collapse';
8+
import ListItemText from '@mui/material/ListItemText';
9+
import ExpandLess from '@mui/icons-material/ExpandLess';
10+
import ExpandMore from '@mui/icons-material/ExpandMore';
11+
12+
export default function ExportToGithubList({ workspaces }) {
13+
const [expand, setExpand] = useState(false);
14+
const handleListButtonClick = () => {
15+
setExpand(!expand);
16+
}
17+
18+
console.log('workspaces', workspaces)
19+
const workspacesList = [];
20+
for (let workspace of workspaces) {
21+
workspacesList.push(
22+
<ListItem disablePadding>
23+
<ListItemButton onClick={handleListButtonClick}>
24+
<ListItemText primary={workspace.name}/>
25+
{expand ? <ExpandLess /> : <ExpandMore />}
26+
</ListItemButton>
27+
<Collapse in={expand} timeout="auto" unmountOnExit>
28+
hello
29+
</Collapse>
30+
</ListItem>
31+
)
32+
}
33+
34+
return(
35+
{workspacesList}
36+
)
37+
38+
}
39+
40+
{/* <ListItem disablePadding>
41+
<ListItemButton onClick={handleExportToGithubListClick}>
42+
<ListItemIcon>
43+
<GitHubIcon/>
44+
</ListItemIcon>
45+
<ListItemText primary="Export to GitHub"/>
46+
{exportToGithubList ? <ExpandLess /> : <ExpandMore />}
47+
</ListItemButton>
48+
</ListItem>
49+
<Collapse in={exportToLocalFilesList} timeout="auto" unmountOnExit>
50+
{dbWorkspaces}
51+
</Collapse> */}

0 commit comments

Comments
 (0)