Skip to content

Commit 70d8164

Browse files
Merge pull request #133 from ChristianEdwardPadilla/master
added types to bottom tab, removed dead imports, refactored D3 tree t…
2 parents 79c838d + 49132dc commit 70d8164

20 files changed

+279
-585
lines changed

src/actions/components.js

Lines changed: 0 additions & 247 deletions
This file was deleted.

src/actions/components.ts

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
import { ComponentInt, ComponentsInt, PropInt } from '../utils/Interfaces.ts';
1+
import {
2+
ComponentInt, ComponentsInt, PropInt, ChildInt,
3+
} from '../utils/Interfaces.ts';
24

35
import {
46
LOAD_INIT_DATA,
@@ -66,21 +68,23 @@ export const deleteComponent = ({
6668
componentId: number;
6769
stateComponents: ComponentsInt;
6870
}) => (dispatch: any) => {
69-
// find all places where the "to be delted" is a child and do what u gotta do
70-
stateComponents.forEach((parent) => {
71-
parent.childrenArray.filter(child => child.childComponentId === componentId).forEach((child) => {
72-
dispatch({
73-
type: DELETE_CHILD,
74-
payload: {
75-
parentId: parent.id,
76-
childId: child.childId,
77-
calledFromDeleteComponent: true,
78-
},
71+
// find all places where the "to be deleted" is a child and do what u gotta do
72+
stateComponents.forEach((parent: ComponentInt) => {
73+
parent.childrenArray
74+
.filter((child: ChildInt) => child.childComponentId === componentId)
75+
.forEach((child: ChildInt) => {
76+
dispatch({
77+
type: DELETE_CHILD,
78+
payload: {
79+
parentId: parent.id,
80+
childId: child.childId,
81+
calledFromDeleteComponent: true,
82+
},
83+
});
7984
});
80-
});
8185
});
8286

83-
// change focus to APp
87+
// change focus to app
8488
dispatch({ type: CHANGE_FOCUS_COMPONENT, payload: { title: 'App' } });
8589
// after taking care of the children delete the component
8690
dispatch({ type: DELETE_COMPONENT, payload: { componentId } });

src/components/App.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { Component } from 'react';
1+
import React from 'react';
22
import '../public/styles/style.css';
33
import AppContainer from '../containers/AppContainer.tsx';
44

src/components/BottomTabs.tsx

Lines changed: 2 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -96,31 +96,6 @@ class BottomTabs extends Component<PropsInt> {
9696
this.setState({ value });
9797
};
9898

99-
findChildren(component: ComponentInt, components: ComponentsInt, tree: any) {
100-
if (!component.childrenArray.length) {
101-
return tree;
102-
}
103-
const newChildrenArray = [];
104-
105-
for (let i = 0; i < component.childrenArray.length; i++) {
106-
const name = component.childrenArray[i].componentName;
107-
const newTree: TreeInt = {
108-
name,
109-
attributes: {},
110-
children: [],
111-
};
112-
newChildrenArray.push(newTree);
113-
tree.children = newChildrenArray;
114-
if (component.childrenArray[i].childType === 'COMP') {
115-
const newFocusComp = components.find(
116-
comp => comp.title === component.childrenArray[i].componentName,
117-
);
118-
this.findChildren(newFocusComp, components, newTree);
119-
}
120-
}
121-
return tree;
122-
}
123-
12499
generateComponentTree(componentId: number, components: ComponentsInt) {
125100
const component = components.find(comp => comp.id === componentId);
126101
const tree = { name: component.title, attributes: {}, children: [] };
@@ -141,13 +116,7 @@ class BottomTabs extends Component<PropsInt> {
141116

142117
render() {
143118
const {
144-
classes,
145-
components,
146-
focusComponent,
147-
deleteProp,
148-
addProp,
149-
focusChild,
150-
// rightColumnOpen
119+
classes, components, focusComponent, deleteProp, addProp, focusChild,
151120
} = this.props;
152121
const { value } = this.state;
153122

@@ -156,13 +125,6 @@ class BottomTabs extends Component<PropsInt> {
156125
const htmlAttribCount = focusComponent.childrenArray.filter(child => child.childType === 'HTML')
157126
.length;
158127

159-
// const counters = focusComponent.ch
160-
const tree = {
161-
name: focusComponent.title,
162-
attributes: {},
163-
children: [],
164-
};
165-
166128
return (
167129
<div className={classes.root}>
168130
<Tabs
@@ -207,8 +169,7 @@ class BottomTabs extends Component<PropsInt> {
207169
ref={node => (this.treeWrapper = node)}
208170
>
209171
<Tree
210-
data={[this.findChildren(focusComponent, components, tree)]}
211-
// data={[this.generateComponentTree(focusComponent.id, components)]}
172+
data={[this.generateComponentTree(focusComponent.id, components)]}
212173
separation={{ siblings: 0.3, nonSiblings: 0.3 }}
213174
transitionDuration={0}
214175
translate={this.state.translate}

0 commit comments

Comments
 (0)