Skip to content

Commit 0ddeb5a

Browse files
committed
Project Filtering
1 parent 32f02ee commit 0ddeb5a

File tree

6 files changed

+59
-16
lines changed

6 files changed

+59
-16
lines changed

app/src/components/left/HTMLPanel.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ const useStyles = makeStyles({
339339
border: '1px solid #186BB4'
340340
},
341341
lightThemeFontColor: {
342-
color: '#155084',
342+
color: 'white',
343343
'& .MuiInputBase-root': {
344344
color: 'rgba (0, 0, 0, 0.54)'
345345
}

app/src/components/marketplace/MarketplaceCard.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ import { MoreVert } from '@mui/icons-material';
1717
import React from 'react';
1818
import imageSrc from '../../../../resources/marketplace_images/marketplace_image.png';
1919
import { red } from '@mui/material/colors';
20+
import {useDispatch, useSelector} from 'react-redux'
21+
import { RootState } from '../../redux/store';
22+
import { saveProject } from '../../helperFunctions/projectGetSaveDel';
2023

2124
interface Project {
2225
comments: string[]
@@ -34,12 +37,16 @@ const ITEM_HEIGHT = 48;
3437
const MarketplaceCard = ({proj} :{proj: Project}) => {
3538
const [anchorEl, setAnchorEl] = React.useState<null | HTMLElement>(null);
3639
const open = Boolean(anchorEl);
40+
const state = useSelector((store:RootState) => store.appState);
41+
console.log('HEY', state)
3742
const handleClick = (event: React.MouseEvent<HTMLElement>) => {
3843
setAnchorEl(event.currentTarget);
3944
};
4045
const handleClose = () => {
4146
setAnchorEl(null);
4247
};
48+
49+
4350
return (
4451
<>
4552
<Card

app/src/components/right/OpenProjects.tsx

Lines changed: 47 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ export interface ProjectDialogProps {
2424
function ProjectsDialog(props: ProjectDialogProps) {
2525
const classes = useStyles();
2626
const { onClose, open, projects } = props;
27+
console.log(projects)
2728
const state = useSelector((store:RootState) => store.appState);
2829
const dispatch = useDispatch();
2930
// If no projects selected, keep the name of the current displayed
@@ -40,6 +41,14 @@ function ProjectsDialog(props: ProjectDialogProps) {
4041
dispatch(openProject(selectedProject))
4142
onClose();
4243
};
44+
// these two filter between user projects and market projects
45+
// const userProjects = projects.filter((project: any) => {
46+
// project.forked === undefined
47+
// })
48+
// const marketProjects = projects.filter((project: any) => {
49+
// project.forked !== undefined
50+
// })
51+
4352
return (
4453
<Dialog
4554
onClose={handleClose}
@@ -48,20 +57,44 @@ function ProjectsDialog(props: ProjectDialogProps) {
4857
>
4958
<DialogTitle style={{ color: "#000" }} id="project-dialog-title">Open Project</DialogTitle>
5059
<List style={{ color: "#000" }}>
51-
{projects.map((project: any, index: number) => (
52-
<ListItem
53-
button
54-
onClick={() => handleListItemClick(project.name)}
55-
key={index}
56-
>
57-
<ListItemAvatar>
58-
<Avatar className={classes.avatar}>
59-
<FolderOpenIcon />
60-
</Avatar>
61-
</ListItemAvatar>
62-
<ListItemText primary={project.name} />
63-
</ListItem>
64-
))}
60+
{projects.filter((project: any) => project.forked === undefined).map((project: any, index: number) => {
61+
console.log("Logging something inside the map:", project.forked); // Add this line
62+
return (
63+
<ListItem
64+
button
65+
onClick={() => handleListItemClick(project.name)}
66+
key={index}
67+
>
68+
<ListItemAvatar>
69+
<Avatar className={classes.avatar}>
70+
<FolderOpenIcon />
71+
</Avatar>
72+
</ListItemAvatar>
73+
<ListItemText primary={project.name} />
74+
</ListItem>
75+
);
76+
})}
77+
</List>
78+
{/* this section handles the projects cloned from the marketplace */}
79+
<DialogTitle style={{ color: "#000" }} id="project-dialog-title">MP Projects</DialogTitle>
80+
<List style={{ color: "#000" }}>
81+
{projects.filter((project: any) => project.forked !== undefined).map((project: any, index: number) => {
82+
console.log("Logging something inside the second map:", project.forked); // Add this line
83+
return (
84+
<ListItem
85+
button
86+
onClick={() => handleListItemClick(project.name)}
87+
key={index}
88+
>
89+
<ListItemAvatar>
90+
<Avatar className={classes.avatar}>
91+
<FolderOpenIcon />
92+
</Avatar>
93+
</ListItemAvatar>
94+
<ListItemText primary={project.name} />
95+
</ListItem>
96+
);
97+
})}
6598
</List>
6699
</Dialog>
67100
);

app/src/interfaces/Interfaces.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { DragObjectWithType } from 'react-dnd';
22

33
export interface State {
44
name: string;
5+
forked: boolean;
56
isLoggedIn: boolean;
67
components: Component[];
78
rootComponents: number[];

app/src/redux/reducers/slice/appStateSlice.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import manageSeparators from '../../../helperFunctions/manageSeparators';
1313

1414
export const initialState: State = {
1515
name: '',
16+
forked: false,
1617
isLoggedIn: false,
1718
// config: { saveFlag: true, saveTimer: false },
1819
components: [

server/models/reactypeModels.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@ const sessionSchema = new Schema({
7878

7979
const projectSchema = new Schema(
8080
{
81-
name: String,
81+
name: {type: String, required: true},
82+
forked: {type: String},
8283
likes: { type: Number, default: 0 },
8384
published: { type: Boolean, default: false },
8485
project: { type: Object, required: true },

0 commit comments

Comments
 (0)