Skip to content

Commit b84c850

Browse files
committed
removed all annotations variables, changed component to DeleteButton from Annotation
1 parent fdd6c20 commit b84c850

File tree

7 files changed

+55
-41
lines changed

7 files changed

+55
-41
lines changed

app/src/components/main/DirectChildComponent.tsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { Component, ChildElement } from '../../interfaces/Interfaces';
33
import { useDrag } from 'react-dnd';
44
import { ItemTypes } from '../../constants/ItemTypes';
55
import StateContext from '../../context/context';
6-
import DeleteButton from './Annotation';
6+
import DeleteButton from './DeleteButton';
77
import { combineStyles } from '../../helperFunctions/combineStyles';
88
import globalDefaultStyle from '../../public/styles/globalDefaultStyles';
99

@@ -67,11 +67,7 @@ function DirectChildComponent({
6767
return (
6868
<div onClick={onClickHandler} style={combinedStyle} ref={drag}>
6969
<strong>{name}</strong>
70-
<DeleteButton
71-
id={childId}
72-
name={name}
73-
// annotations={annotations}
74-
/>
70+
<DeleteButton id={childId} name={name} />
7571
</div>
7672
);
7773
}

app/src/components/main/DirectChildHTML.tsx

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,11 @@ import { ItemTypes } from '../../constants/ItemTypes';
55
import StateContext from '../../context/context';
66
import { combineStyles } from '../../helperFunctions/combineStyles';
77
import globalDefaultStyle from '../../public/styles/globalDefaultStyles';
8-
import DeleteButton from './Annotation';
8+
import DeleteButton from './DeleteButton';
99

1010
import { styleContext } from '../../containers/AppContainer';
1111

12-
function DirectChildHTML({
13-
childId,
14-
name,
15-
type,
16-
typeId,
17-
style,
18-
annotations
19-
}: ChildElement) {
12+
function DirectChildHTML({ childId, name, type, typeId, style }: ChildElement) {
2013
const [state, dispatch] = useContext(StateContext);
2114
const { isThemeLight } = useContext(styleContext);
2215

@@ -98,7 +91,6 @@ function DirectChildHTML({
9891
<DeleteButton
9992
id={childId}
10093
name={name[0].toLowerCase() + name.slice(1)}
101-
annotations={annotations}
10294
/>
10395
</span>
10496
</div>

app/src/components/main/DirectChildHTMLNestable.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { combineStyles } from '../../helperFunctions/combineStyles';
77
import globalDefaultStyle from '../../public/styles/globalDefaultStyles';
88
import renderChildren from '../../helperFunctions/renderChildren';
99
import adjustComponentColor from '../../helperFunctions/adjustComponentColor';
10-
import DeleteButton from './Annotation';
10+
import DeleteButton from './DeleteButton';
1111
import validateNewParent from '../../helperFunctions/changePositionValidation';
1212
import componentNest from '../../helperFunctions/componentNestValidation';
1313
import AddRoute from './AddRoute';
@@ -22,7 +22,6 @@ function DirectChildHTMLNestable({
2222
style,
2323
children,
2424
name,
25-
annotations,
2625
attributes
2726
}: ChildElement) {
2827
const [state, dispatch] = useContext(StateContext);
@@ -224,7 +223,7 @@ function DirectChildHTMLNestable({
224223
{attributes && attributes.compLink ? ` ${attributes.compLink}` : ''}
225224
</strong>
226225
{routeButton}
227-
<DeleteButton id={childId} name={name} annotations={annotations} />
226+
<DeleteButton id={childId} name={name} />
228227
</span>
229228
{renderChildren(children)}
230229
</div>

app/src/components/main/IndirectChild.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,15 @@ import { combineStyles } from '../../helperFunctions/combineStyles';
33
import globalDefaultStyle from '../../public/styles/globalDefaultStyles';
44
import StateContext from '../../context/context';
55
import { Component } from '../../interfaces/Interfaces';
6-
import DeleteButton from './Annotation';
6+
import DeleteButton from './DeleteButton';
77

88
function IndirectChild({
99
style,
1010
children,
1111
placeHolder,
1212
linkId,
1313
childId,
14-
name,
15-
annotations
14+
name
1615
}) {
1716
const [state, dispatch] = useContext(StateContext);
1817
let combinedStyle = combineStyles(globalDefaultStyle, style);
@@ -37,7 +36,7 @@ function IndirectChild({
3736
return (
3837
<div style={combinedStyle}>
3938
{` ( ${childId} )`}
40-
<DeleteButton id={childId} name={name} annotations={annotations} />
39+
<DeleteButton id={childId} name={name} />
4140
{linkId ? (
4241
<div onClick={onClickHandlerRoute}>{linkName}</div>
4342
) : (

app/src/helperFunctions/renderChildren.tsx

Lines changed: 46 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ const renderChildren = (children: ChildElement[]) => {
1515
const [state, dispatch] = useContext(StateContext);
1616

1717
return children.map((child: ChildElement, i: number) => {
18-
const { type, style, childId, children, attributes, name, annotations} = child;
19-
let {typeId} = child;
18+
const { type, style, childId, children, attributes, name } = child;
19+
let { typeId } = child;
2020
if (name === '') child.name = state.components[typeId - 1].name;
2121
// A DirectChildComponent is an instance of a top level component
2222
// This component will render IndirectChild components (div/components rendered inside a child component)
@@ -30,28 +30,57 @@ const renderChildren = (children: ChildElement[]) => {
3030
typeId={typeId}
3131
key={'DirChildComp' + childId.toString() + name}
3232
name={name}
33-
annotations={annotations}
3433
/>
3534
);
3635
}
3736
// child is a non-nestable type of HTML element (aka NOT divs, forms, OrderedLists, UnorderedLists, menus)
38-
else if (type === 'HTML Element' && typeId !== 11 && typeId !== 1000 && typeId !== 2 && typeId !== 3 && typeId !== 14 && typeId !== 15 && typeId !== 16 && typeId !== 17 && typeId !== 18 && typeId !== -1 && typeId !== 19) {
37+
else if (
38+
type === 'HTML Element' &&
39+
typeId !== 11 &&
40+
typeId !== 1000 &&
41+
typeId !== 2 &&
42+
typeId !== 3 &&
43+
typeId !== 14 &&
44+
typeId !== 15 &&
45+
typeId !== 16 &&
46+
typeId !== 17 &&
47+
typeId !== 18 &&
48+
typeId !== -1 &&
49+
typeId !== 19
50+
) {
3951
return (
4052
<DirectChildHTML
4153
childId={childId}
4254
type={type}
4355
typeId={typeId}
44-
key={'DirChildHTML' + childId.toString() + name }
56+
key={'DirChildHTML' + childId.toString() + name}
4557
name={name}
46-
annotations={annotations}
4758
/>
4859
);
4960
}
5061
// child is a nestable type of HTML element (divs, forms, OrderedLists, UnorderedLists, menus)
51-
else if (type === 'HTML Element' && (typeId === 11 || typeId === 2 || typeId === 3 || typeId === 14 || typeId === 15 || typeId === 16 || typeId === 17 || typeId === 18 || typeId === -1 || typeId === 19)) {
52-
if((typeId === 18 || typeId === 19) && state.projectType === 'Classic React') typeId = 18;
53-
if((typeId === 17 || typeId === -1) && state.projectType === 'Next.js') return renderChildren(children);
54-
if((typeId === 18 || typeId === 19) && state.projectType === 'Next.js') typeId = 19;
62+
else if (
63+
type === 'HTML Element' &&
64+
(typeId === 11 ||
65+
typeId === 2 ||
66+
typeId === 3 ||
67+
typeId === 14 ||
68+
typeId === 15 ||
69+
typeId === 16 ||
70+
typeId === 17 ||
71+
typeId === 18 ||
72+
typeId === -1 ||
73+
typeId === 19)
74+
) {
75+
if (
76+
(typeId === 18 || typeId === 19) &&
77+
state.projectType === 'Classic React'
78+
)
79+
typeId = 18;
80+
if ((typeId === 17 || typeId === -1) && state.projectType === 'Next.js')
81+
return renderChildren(children);
82+
if ((typeId === 18 || typeId === 19) && state.projectType === 'Next.js')
83+
typeId = 19;
5584
return (
5685
<DirectChildHTMLNestable
5786
childId={childId}
@@ -60,19 +89,22 @@ const renderChildren = (children: ChildElement[]) => {
6089
children={children}
6190
key={'DirChildHTMLNest' + childId.toString() + name}
6291
name={name}
63-
annotations={annotations}
6492
attributes={attributes}
6593
/>
6694
);
67-
}
68-
else if (type === 'HTML Element' && typeId === 1000 ) {
95+
} else if (type === 'HTML Element' && typeId === 1000) {
6996
return (
7097
<SeparatorChild
7198
childId={childId}
7299
type={type}
73100
typeId={typeId}
74101
children={children}
75-
key={'SeparatorChild' + childId.toString() + name + (Math.random()*1000).toString()}
102+
key={
103+
'SeparatorChild' +
104+
childId.toString() +
105+
name +
106+
(Math.random() * 1000).toString()
107+
}
76108
name={name}
77109
/>
78110
);

app/src/interfaces/Interfaces.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ export interface ChildElement {
2626
events: object;
2727
children?: ChildElement[];
2828
stateProps: StateProp[]; // state: [ { id, key, value, type }, ...]
29-
annotations?: string;
3029
stateUsed?: object;
3130
passedInProps: StateProp[];
3231
}
@@ -43,7 +42,6 @@ export interface Component {
4342
past: any[];
4443
future: any[];
4544
stateProps: StateProp[]; // state: [ { id, key, value, type }, ...]
46-
annotations?: string;
4745
useStateCodes: string[];
4846
useContext?: object;
4947
passedInProps: StateProp[];
@@ -92,11 +90,9 @@ export interface DragItemType {
9290
export interface LoginInt {
9391
isLoggedIn: boolean;
9492
}
95-
// Annotations TO BE REMOVED
9693
export interface DeleteButtons {
9794
id: number;
9895
name: string;
99-
annotations?: string;
10096
}
10197
export interface StatePropsPanelProps {
10298
selectHandler: (table: any) => void;

0 commit comments

Comments
 (0)