Skip to content

Commit 223c04d

Browse files
committed
Fixed componentRoutingItem bug that caused app to crash when the workspace is cleared. Consolidated tests into a single folder.
1 parent 3389325 commit 223c04d

File tree

5 files changed

+16
-3
lines changed

5 files changed

+16
-3
lines changed
File renamed without changes.
File renamed without changes.

app/src/components/left/ComponentPanelRoutingItem.tsx

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ const ComponentPanelRoutingItem: React.FC<{}> = () => {
1414

1515
// find the root components that can be associated with a route
1616
// These will be the components that are displayed in the dropdown
17+
console.log('in the comp panel routing, state is ', state);
1718
let navigableComponents = state.components
1819
.filter(comp => state.rootComponents.includes(comp.id))
1920
.map(comp => comp.name);
@@ -22,12 +23,22 @@ const ComponentPanelRoutingItem: React.FC<{}> = () => {
2223
const [route, setRoute] = useState(navigableComponents[0]);
2324

2425
// TODO: Add a useMemo so that this isn't recalculated on every render
25-
const routeId = state.components.find(comp => comp.name === route).id;
26+
let routeId;
27+
// check if the component in the drop down still references an existing component
28+
const referencedComponent = state.components.find(
29+
comp => comp.name === route
30+
);
31+
// if so, set the route id for that component to the id of the referenced compnent
32+
if (referencedComponent) routeId = referencedComponent.id;
33+
// otherwise, set the component name and and id to the root component
34+
else {
35+
setRoute(state.components[0].name);
36+
routeId = 1;
37+
}
2638

2739
const handleRouteChange = event => {
2840
setRoute(event.target.value);
2941
};
30-
3142

3243
// useDrag hook allows components in left panel to be drag source
3344

app/src/components/right/ProjectManager.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ const ProjectManager = () => {
164164
) : null}
165165
{!state.name && state.isLoggedIn ? (
166166
<p style={{ color: 'white' }}>
167-
Project will not be saved until it is named!!!
167+
Select "Save project as" to create and save a project
168168
</p>
169169
) : null}
170170

app/src/helperFunctions/projectGetSaveDel.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ export const deleteProject = (project: any): Promise<Object> => {
5656
name: project.name,
5757
userId: window.localStorage.getItem('ssid')
5858
});
59+
console.log('body is ', body);
60+
console.log('url is ', `${serverURL}/deleteProject`);
5961
const deletedProject = fetch(`${serverURL}/deleteProject`, {
6062
method: 'DELETE',
6163
credentials: 'include',

0 commit comments

Comments
 (0)