Skip to content

Commit cf62247

Browse files
committed
Merge branch 'dev' into sidebar
2 parents 5fa52b7 + 939d6ab commit cf62247

20 files changed

+351
-257
lines changed

Dockerfile

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,64 @@
11
# Stage 1: Build
2-
FROM node:21.2.0-alpine as build
2+
FROM node:21.2.0-alpine AS build
33

44
# python: required dependency for node alpine, shrinks image size from 2.17GB to 1.67GB
55
RUN apk add --no-cache --virtual .gyp \
66
python3 \
77
make \
88
g++
99

10+
RUN npm install -g [email protected]
11+
12+
1013
WORKDIR /app
1114

1215
COPY package*.json ./
1316

17+
1418
RUN npm install --no-install-recommends --fetch-retry-maxtimeout 500000
1519

20+
# install vite virst
21+
22+
1623
COPY . .
24+
ENV NODE_ENV='production'
25+
# i am hoping the above will make it so that the frontend files will know that it is production.
26+
RUN npm run prod-build
1727

1828
# Stage 2: Runtime
19-
FROM node:21.2.0-alpine as runtime
29+
FROM node:21.2.0-alpine AS runtime
2030

2131
WORKDIR /app
2232

2333
COPY --from=build /app/package*.json ./
2434

25-
RUN npm install --no-install-recommends --only=production --fetch-retry-maxtimeout 500000
35+
RUN npm install --no-install-recommends --fetch-retry-maxtimeout 500000
36+
37+
# RUN npm run dev-frontend # no, dont just run the app while building
38+
39+
# make a build file?
2640

41+
42+
# --only=prod
2743
# COPY --from=build /app/.env .env
2844
COPY --from=build /app/config.js ./config.js
2945
COPY --from=build /app/server ./server
30-
COPY --from=build /app/build /app
46+
COPY --from=build /app/build /app/build
47+
48+
COPY .env .env
49+
#just make the env file go into the docker image?
50+
3151

3252
EXPOSE 5656
3353

34-
ENV IS_DOCKER true
54+
ENV IS_DOCKER=true
55+
56+
57+
ENV VIDEOSDK='vidsdk'
58+
59+
# productino you dolt!, if we are using docker, its production!
60+
ENV PORT=5656
61+
62+
# no longer put the envs here cause we are not dumb.
3563

36-
CMD [ "npm", "start" ]
64+
CMD [ "npm", "start" ]

__tests__/componentBuilder.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ describe('componentBuilder', () => {
124124
name: 'p',
125125
childId: 4,
126126
style: {},
127-
attributes: { compText: 'Hello, world!' },
127+
attributes: { comptext: 'Hello, world!' },
128128
events: {},
129129
stateProps: [],
130130
passedInProps: [],

app/src/components/App.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import { toggleLoggedIn } from '../redux/reducers/slice/appStateSlice';
66
import { useDispatch } from 'react-redux';
77

88
import AppContainer from '../containers/AppContainer';
9-
109
/**
1110
* The `App` component is the root component of the React application. It performs an initial check
1211
* to determine if a user is logged in (not a 'guest') by inspecting local storage, and updates the

app/src/components/right/ExportButton.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ import createModal from './createModal';
1111
import { RootState } from '../../redux/store';
1212
import zipFiles from '../../helperFunctions/zipFiles';
1313

14+
// NOTE: from the v22 team, this file is unused, if you are editing this and nothing is changing.
15+
// dont say I did not warn you.
16+
1417
/**
1518
* Renders an export button that triggers a modal for selecting export options.
1619
* The button and modal allow users to export project components in various formats.

app/src/components/top/NavBar.tsx

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@ import logo from '../../public/icons/win/logo.png';
1313
import { useSelector, useDispatch } from 'react-redux';
1414
import {
1515
publishProject,
16-
unpublishProject,
16+
unpublishProject
1717
} from '../../helperFunctions/projectGetSaveDel';
1818
import PublishModal from './PublishModal';
1919
import {
2020
updateProjectId,
2121
updateProjectName,
2222
updateProjectPublished,
23-
toggleScreenshotTrigger,
23+
toggleScreenshotTrigger
2424
} from '../../redux/reducers/slice/appStateSlice';
2525
import { State } from '../../interfaces/Interfaces';
2626

@@ -49,7 +49,8 @@ const NavBar: React.FC = (): JSX.Element => {
4949
const [publishModalOpen, setPublishModalOpen] = useState(false);
5050
const [projectName, setProjectName] = useState(state.name || '');
5151
const [invalidProjectName, setInvalidProjectName] = useState(false);
52-
const [invalidProjectNameMessage, setInvalidProjectNameMessage] = useState('');
52+
const [invalidProjectNameMessage, setInvalidProjectNameMessage] =
53+
useState('');
5354
const urlAdd = useHistory();
5455
const isMarketplace = urlAdd.location.pathname === '/marketplace';
5556

@@ -76,19 +77,19 @@ const NavBar: React.FC = (): JSX.Element => {
7677
const buttonContainerStyle = {
7778
display: 'flex',
7879
alignItems: 'center',
79-
justifyContent: 'flex-start',
80+
justifyContent: 'flex-start'
8081
};
8182

8283
const buttonStyle = {
83-
backgroundColor: '#0671E3',
84+
backgroundColor: '#2D313A',
8485
border: 'none',
8586
color: 'white',
8687
fontSize: '12px',
8788
padding: '8px 15px',
8889
cursor: 'pointer',
8990
marginRight: '10px',
9091
marginLeft: '5px',
91-
borderRadius: '10px',
92+
borderRadius: '10px'
9293
};
9394

9495
const moreVertButtonStyle = {
@@ -103,7 +104,7 @@ const NavBar: React.FC = (): JSX.Element => {
103104
minWidth: '20px',
104105
marginLeft: '0px',
105106
marginRight: '10px',
106-
boxShadow: 'none',
107+
boxShadow: 'none'
107108
};
108109

109110
const handlePublish = () => {
@@ -142,7 +143,7 @@ const NavBar: React.FC = (): JSX.Element => {
142143

143144
const handleAlertClose = (
144145
event: React.SyntheticEvent | Event,
145-
reason?: string,
146+
reason?: string
146147
) => {
147148
if (reason === 'clickaway') {
148149
return;
@@ -156,7 +157,7 @@ const NavBar: React.FC = (): JSX.Element => {
156157

157158
const Alert = React.forwardRef<HTMLDivElement, AlertProps>(function Alert(
158159
props,
159-
ref,
160+
ref
160161
) {
161162
return <MuiAlert elevation={6} ref={ref} variant="filled" {...props} />;
162163
});
@@ -178,7 +179,7 @@ const NavBar: React.FC = (): JSX.Element => {
178179
</button>
179180
) : (
180181
<button style={buttonStyle} onClick={handlePublish}>
181-
Publish
182+
Import
182183
</button>
183184
)}
184185
<NewExportButton />

app/src/components/top/NavBarButtons.tsx

Lines changed: 88 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,15 @@ import { resetAllState } from '../../redux/reducers/slice/appStateSlice';
2323
import { setStyle } from '../../redux/reducers/slice/styleSlice';
2424
import { emitEvent } from '../../helperFunctions/socket';
2525

26+
// added imports for publish logic
27+
import { publishProject } from '../../helperFunctions/projectGetSaveDel';
28+
import {
29+
updateProjectId,
30+
updateProjectName,
31+
updateProjectPublished,
32+
toggleScreenshotTrigger,
33+
} from '../../redux/reducers/slice/appStateSlice';
34+
2635
const { API_BASE_URL } = serverConfig;
2736

2837
const useStyles = makeStyles((theme) => createStyles({
@@ -121,50 +130,71 @@ const navbarDropDown = (props): JSX.Element => {
121130
props.setDropDownMenu(true);
122131
};
123132

124-
const clearWorkspace = () => {
125-
// Reset state for project to initial state
126-
const resetState = () => {
127-
if (roomCode) emitEvent('clearCanvasAction', roomCode, userName);
128-
else dispatch(resetAllState());
129-
};
130-
// Set modal options
131-
const children = (
132-
<List className="export-preference" style={{ zIndex: '12' }}>
133-
<ListItem
134-
key={'clear'}
135-
button
136-
onClick={resetState}
137-
style={{
138-
backgroundColor: '#E12D39',
139-
borderRadius: '50px',
140-
marginBottom: '2%',
141-
marginTop: '5%',
142-
}}
143-
>
144-
<ListItemText
145-
primary={'Yes, delete all project data'}
146-
style={{ textAlign: 'center' }}
147-
onClick={closeModal}
148-
/>
149-
</ListItem>
150-
</List>
151-
);
133+
// const clearWorkspace = () => {
134+
// // Reset state for project to initial state
135+
// const resetState = () => {
136+
// if (roomCode) emitEvent('clearCanvasAction', roomCode, userName);
137+
// else dispatch(resetAllState());
138+
// };
139+
// // Set modal options
140+
// const children = (
141+
// <List className="export-preference" style={{ zIndex: '12' }}>
142+
// <ListItem
143+
// key={'clear'}
144+
// button
145+
// onClick={resetState}
146+
// style={{
147+
// backgroundColor: '#E12D39',
148+
// borderRadius: '50px',
149+
// marginBottom: '2%',
150+
// marginTop: '5%',
151+
// }}
152+
// >
153+
// <ListItemText
154+
// primary={'Yes, delete all project data'}
155+
// style={{ textAlign: 'center' }}
156+
// onClick={closeModal}
157+
// />
158+
// </ListItem>
159+
// </List>
160+
// );
152161

153-
// Create modal
154-
setModal(
155-
createModal({
156-
closeModal,
157-
children,
158-
message: 'Are you sure you want to delete all data?',
159-
primBtnLabel: null,
160-
primBtnAction: null,
161-
secBtnAction: null,
162-
secBtnLabel: null,
163-
open: true,
164-
}),
165-
);
166-
};
162+
// // Create modal
163+
// setModal(
164+
// createModal({
165+
// closeModal,
166+
// children,
167+
// message: 'Are you sure you want to delete all data?',
168+
// primBtnLabel: null,
169+
// primBtnAction: null,
170+
// secBtnAction: null,
171+
// secBtnLabel: null,
172+
// open: true,
173+
// }),
174+
// );
175+
// };
167176

177+
// handlePublish logic
178+
const handlePublish = () => {
179+
if (!state.name) {
180+
console.log({state});
181+
console.error('Project name cannot be empty');
182+
return;
183+
}
184+
if (!state.isLoggedIn) {
185+
console.error('User must be logged in to publish');
186+
return;
187+
}
188+
publishProject(state.name, state)
189+
.then((newProject) => {
190+
dispatch(updateProjectId(newProject._id));
191+
dispatch(updateProjectName(newProject.name));
192+
dispatch(updateProjectPublished(newProject.published));
193+
dispatch(toggleScreenshotTrigger());
194+
console.log('Project published successfully!');
195+
})
196+
.catch((error) => console.error('Error publishing project:', error));
197+
};
168198
const handleClose = () => {
169199
setAnchorEl(null);
170200
props.setDropMenu(false);
@@ -217,7 +247,21 @@ const navbarDropDown = (props): JSX.Element => {
217247
<span>Tutorial</span>
218248
</button>
219249
</Link>
220-
<button onClick={() => clearWorkspace()}>
250+
<button onClick={handlePublish} style={{ backgroundColor: '#0671E3', color: 'white' }}>
251+
<svg
252+
xmlns="http://www.w3.org/2000/svg"
253+
width="16"
254+
height="16"
255+
fill="currentColor"
256+
className="bi bi-upload"
257+
viewBox="0 0 16 16"
258+
>
259+
<path d="M.5 9.5a.5.5 0 0 0 .5.5h3v5a1 1 0 0 0 1 1h6a1 1 0 0 0 1-1v-5h3a.5.5 0 0 0 .5-.5v-4a.5.5 0 0 0-.5-.5H10V1.5a.5.5 0 0 0-1 0v3H7V1.5a.5.5 0 0 0-1 0v3H.5a.5.5 0 0 0-.5.5v4z" />
260+
<path d="M7 6v6h2V6H7z" />
261+
</svg>
262+
<span>Publish</span>
263+
</button>
264+
{/* <button onClick={() => clearWorkspace()}>
221265
<svg
222266
xmlns="http://www.w3.org/2000/svg"
223267
width="16"
@@ -229,7 +273,7 @@ const navbarDropDown = (props): JSX.Element => {
229273
<path d="M6.5 1h3a.5.5 0 0 1 .5.5v1H6v-1a.5.5 0 0 1 .5-.5ZM11 2.5v-1A1.5 1.5 0 0 0 9.5 0h-3A1.5 1.5 0 0 0 5 1.5v1H2.506a.58.58 0 0 0-.01 0H1.5a.5.5 0 0 0 0 1h.538l.853 10.66A2 2 0 0 0 4.885 16h6.23a2 2 0 0 0 1.994-1.84l.853-10.66h.538a.5.5 0 0 0 0-1h-.995a.59.59 0 0 0-.01 0H11Zm1.958 1-.846 10.58a1 1 0 0 1-.997.92h-6.23a1 1 0 0 1-.997-.92L3.042 3.5h9.916Zm-7.487 1a.5.5 0 0 1 .528.47l.5 8.5a.5.5 0 0 1-.998.06L5 5.03a.5.5 0 0 1 .47-.53Zm5.058 0a.5.5 0 0 1 .47.53l-.5 8.5a.5.5 0 1 1-.998-.06l.5-8.5a.5.5 0 0 1 .528-.47ZM8 4.5a.5.5 0 0 1 .5.5v8.5a.5.5 0 0 1-1 0V5a.5.5 0 0 1 .5-.5Z" />
230274
</svg>
231275
<span>Clear Canvas</span>
232-
</button>
276+
</button> */}
233277
{state.isLoggedIn && (
234278
<button onClick={handleClick}>
235279
<svg

app/src/components/top/NewExportButton.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export default function NewExportButton(): JSX.Element {
3333
const closeModal = () => setModal('');
3434

3535
const buttonStyle = {
36-
backgroundColor: '#2D313A',
36+
backgroundColor: '#0671E3',
3737
border: 'none',
3838
color: 'white',
3939
fontSize: '12px',

app/src/components/top/PublishModal.tsx

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,8 @@ const PublishModal = ({
3535
projectName,
3636
onChange,
3737
invalidProjectName,
38-
invalidProjectNameMessage,
39-
}): JSX.Element => {
40-
return (
38+
invalidProjectNameMessage
39+
}): JSX.Element => (
4140
<Dialog
4241
style={{ color: '#000' }}
4342
open={open}
@@ -68,11 +67,10 @@ const PublishModal = ({
6867
Cancel
6968
</Button>
7069
<Button onClick={onSave} color="primary">
71-
Publish
70+
Import
7271
</Button>
7372
</DialogActions>
7473
</Dialog>
75-
);
76-
};
74+
);
7775

7876
export default PublishModal;

0 commit comments

Comments
 (0)