Skip to content

Commit dc5b7e8

Browse files
Merge pull request #9 from oslabs-beta/devContext
Finished OSP for Context Manager
2 parents 32887be + 00ea81e commit dc5b7e8

31 files changed

+1645
-715
lines changed

CHANGE_LOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,17 @@
33
<h1 align="center">ReacType Change Log</h1>
44
</p>
55

6+
**Version 12.0.0 Changes**
7+
8+
-Context Visualizer: You can now visually see what component is consuming which context. As you click on the interactive tree, the component assigned to the context will be revealed.
9+
-React 18: Updated to React 18
10+
-Export Feature: Created an exportable context file, integrated with original codebase.
11+
Ready to go code: Added boilerplate codes to components based on which contexts they are consuming.
12+
13+
**A note to future contributors**
14+
15+
Attempted to implement Facebook and Google OAuth via passport but as of Electron’s current version, neither of them not compatible with electron.
16+
617
**Version 11.0.0 Changes:**
718

819
- Added Next.js functionality

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ How to use
3030
- **Start a project (only after registration)**: Registered users can create a new project and select whether they want their project to be a Next.js, Gatsby.js, or classic React project. Also, registered users can save projects to return to them at a later time.
3131
- **Add Components**: Create components on the right panel. Components can be associated with a route, or they can be used within other components.
3232
- **Delete Components**: Delete components after focusing on them in the right panel. Be careful when deleting components: Upon deletion, all instances of the component will be removed within the application/project.
33+
- **Context Visualizer**: You can now visually see what component is consuming which context. As you click on the interactive tree, the component assigned to the context will be revealed.
34+
- **Context Code Preview**: Once contexts have been assigned to the desired components, click ‘Export’ to incorporate context into your existing codebase so you can save it as a file.
35+
- **Ready to go code**: Added boilerplate codes to components based on which contexts they are consuming.
3336
- **Add Custom Elements**: Create custom elements or add provided HTML elements into the application. Once the project is exported, the HTML tags generated in the code preview will function as expected. You can specify functionality for custom elements in the code preview. The tutorial on HTML Elements explains more on how to do this.
3437
- **Delete Custom HTML Elements**: Delete custom HTML elements by clicking on the ‘X’ button adjacent to the element. Be careful when deleting custom elements: All instances of the element will be deleted within the application/project.
3538
- **Create Instances on the Canvas**: Each component has its own canvas. Add an element to a component by dragging it onto the canvas. Div components are arbitrarily nestable and useful for complex layouts. Next.js and Gatsby.js projects have Link components to enable client-side navigation to other routes.
@@ -107,6 +110,8 @@ How to use
107110

108111
[Anthony Torrero](https://www.linkedin.com/in/anthony-torrero-4b8798159/) [@Anthonytorrero](https://github.com/Anthonytorrero)
109112

113+
[Bianca Picasso](linkedin.com/in/bianca-picasso) [@BiancaPicasso](https://github.com/BiancaPicasso)
114+
110115
[Brian Han](https://www.linkedin.com/in/brianjisoohan/) [@brianjshan](https://github.com/brianjshan)
111116

112117
[Bryan Chau](https://www.linkedin.com/in/chaubryan1/) [@bchauu](https://github.com/bchauu)
@@ -139,6 +144,8 @@ How to use
139144

140145
[Fredo Chen](https://www.linkedin.com/in/fredochen/) [@fredosauce](https://github.com/fredosauce)
141146

147+
[Huy Pham](linkedin.com/in/huypham048) [@huypham048](https://github.com/huypham048)
148+
142149
[Jonathan Calvo Ramirez](https://www.linkedin.com/in/jonathan-calvo/) [@jonocr](https://github.com/jonocr)
143150

144151
[Jesse Zuniga](https://linkedin.com/in/jesse-zuniga) [@jzuniga206](https://github.com/jzuniga206)
@@ -149,6 +156,8 @@ How to use
149156

150157
[Katrina Henderson](https://www.linkedin.com/in/katrinahenderson/) [@kchender](https://github.com/kchender)
151158

159+
[Ken Bains](linkedin.com/in/ken-bains) [@ken-Bains](https://github.com/ken-Bains)
160+
152161
[Kevin Park](https://www.linkedin.com/in/xkevinpark/) [@xkevinpark](https://github.com/xkevinpark)
153162

154163
[Khuong Nguyen](https://www.linkedin.com/in/khuong-nguyen/) [@khuongdn16](https://github.com/khuongdn16)
@@ -171,6 +180,8 @@ How to use
171180

172181
[Ron Fu](https://www.linkedin.com/in/ronfu)[@rfvisuals](https://github.com/rfvisuals)
173182

183+
[Salvatore Saluga](linkedin.com/in/salvatore-saluga) [@SalSaluga](https://github.com/SalSaluga)
184+
174185
[Sean Sadykoff](https://www.linkedin.com/in/sean-sadykoff/) [@sean1292](https://github.com/sean1292)
175186

176187
[Shana Hoehn](https://www.linkedin.com/in/shana-hoehn-70297b169/) [@slhoehn](https://github.com/slhoehn)

__tests__/contextReducer.test.js

Lines changed: 165 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,165 @@
1+
import subject from '../app/src/redux/reducers/slice/contextReducer';
2+
3+
describe('Context Reducer', () => {
4+
let state;
5+
6+
beforeEach(() => {
7+
state = {
8+
allContext: []
9+
};
10+
});
11+
12+
describe('default state', () => {
13+
it('should return a default state when given an undefined input', () => {
14+
expect(subject(undefined, { type: undefined })).toEqual(state);
15+
});
16+
});
17+
18+
describe('unrecognized action types', () => {
19+
it('should return the original state without any duplication', () => {
20+
expect(subject(state, { type: 'REMOVE_STATE' })).toBe(state);
21+
});
22+
});
23+
24+
describe('ADD_CONTEXT', () => {
25+
const action = {
26+
type: 'ADD_CONTEXT',
27+
payload: {
28+
name: 'Theme Context'
29+
}
30+
};
31+
32+
it('adds a context', () => {
33+
const { allContext } = subject(state, action);
34+
expect(allContext[0]).toEqual({
35+
name: 'Theme Context',
36+
values: [],
37+
components: []
38+
});
39+
});
40+
41+
it('returns a state object not strictly equal to the original', () => {
42+
const newState = subject(state, action);
43+
expect(newState).not.toBe(state);
44+
});
45+
46+
it('should immutably update the nested state object', () => {
47+
const { allContext } = subject(state, action);
48+
expect(allContext).not.toBe(state.allContext);
49+
});
50+
});
51+
52+
describe('ADD_CONTEXT_VALUES', () => {
53+
beforeEach(() => {
54+
state = {
55+
allContext: [
56+
{
57+
name: 'Theme Context',
58+
values: [],
59+
components: []
60+
}
61+
]
62+
};
63+
});
64+
65+
const action = {
66+
type: 'ADD_CONTEXT_VALUES',
67+
payload: {
68+
name: 'Theme Context',
69+
inputKey: 'Theme Color',
70+
inputValue: 'Dark'
71+
}
72+
};
73+
74+
it('adds a key-value pair to values array of the specified context', () => {
75+
const { allContext } = subject(state, action);
76+
expect(allContext[0].values.length).toEqual(1);
77+
expect(allContext[0].values[0].key).toEqual('Theme Color');
78+
expect(allContext[0].values[0].value).toEqual('Dark');
79+
});
80+
81+
it('includes an allContext not strictly equal to the original', () => {
82+
const { allContext } = subject(state, action);
83+
84+
expect(allContext).not.toBe(state.allContext);
85+
});
86+
});
87+
88+
describe('DELETE CONTEXT', () => {
89+
let action;
90+
beforeEach(() => {
91+
state = {
92+
allContext: [
93+
{
94+
name: 'Theme Context',
95+
values: [],
96+
components: []
97+
},
98+
{
99+
name: 'To be deleted',
100+
values: [],
101+
components: []
102+
}
103+
]
104+
};
105+
106+
action = {
107+
type: 'DELETE_CONTEXT',
108+
payload: {
109+
name: 'Theme Context'
110+
}
111+
};
112+
});
113+
114+
it('removes specified context from the state', () => {
115+
const { allContext } = subject(state, action);
116+
117+
expect(allContext.length).toEqual(1);
118+
});
119+
120+
it('includes an allContext not strictly equal to the original', () => {
121+
const { allContext } = subject(state, action);
122+
123+
expect(allContext).not.toBe(state.allContext);
124+
});
125+
});
126+
127+
describe('ADD_COMPONENT_TO_CONTEXT', () => {
128+
beforeEach(() => {
129+
state = {
130+
allContext: [
131+
{
132+
name: 'Theme Context',
133+
values: [],
134+
components: []
135+
}
136+
]
137+
};
138+
});
139+
140+
const action = {
141+
type: 'ADD_COMPONENT_TO_CONTEXT',
142+
payload: {
143+
context: {
144+
name: 'Theme Context'
145+
},
146+
component: {
147+
name: 'Main Component'
148+
}
149+
}
150+
};
151+
152+
it('adds a new component to the specified context', () => {
153+
const { allContext } = subject(state, action);
154+
155+
expect(allContext[0].components.length).toEqual(1);
156+
expect(allContext[0].components[0]).toEqual('Main Component');
157+
});
158+
159+
it('includes an allContext not strictly equal to the original', () => {
160+
const { allContext } = subject(state, action);
161+
162+
expect(allContext).not.toBe(state.allContext);
163+
});
164+
});
165+
});

__tests__/contextReducer.test.ts

Lines changed: 165 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,165 @@
1+
import subject from '../app/src/redux/reducers/slice/contextReducer';
2+
3+
describe('Context Reducer', () => {
4+
let state;
5+
6+
beforeEach(() => {
7+
state = {
8+
allContext: []
9+
};
10+
});
11+
12+
describe('default state', () => {
13+
it('should return a default state when given an undefined input', () => {
14+
expect(subject(undefined, { type: undefined })).toEqual(state);
15+
});
16+
});
17+
18+
describe('unrecognized action types', () => {
19+
it('should return the original state without any duplication', () => {
20+
expect(subject(state, { type: 'REMOVE_STATE' })).toBe(state);
21+
});
22+
});
23+
24+
describe('ADD_CONTEXT', () => {
25+
const action = {
26+
type: 'ADD_CONTEXT',
27+
payload: {
28+
name: 'Theme Context'
29+
}
30+
};
31+
32+
it('adds a context', () => {
33+
const { allContext } = subject(state, action);
34+
expect(allContext[0]).toEqual({
35+
name: 'Theme Context',
36+
values: [],
37+
components: []
38+
});
39+
});
40+
41+
it('returns a state object not strictly equal to the original', () => {
42+
const newState = subject(state, action);
43+
expect(newState).not.toBe(state);
44+
});
45+
46+
it('should immutably update the nested state object', () => {
47+
const { allContext } = subject(state, action);
48+
expect(allContext).not.toBe(state.allContext);
49+
});
50+
});
51+
52+
describe('ADD_CONTEXT_VALUES', () => {
53+
beforeEach(() => {
54+
state = {
55+
allContext: [
56+
{
57+
name: 'Theme Context',
58+
values: [],
59+
components: []
60+
}
61+
]
62+
};
63+
});
64+
65+
const action = {
66+
type: 'ADD_CONTEXT_VALUES',
67+
payload: {
68+
name: 'Theme Context',
69+
inputKey: 'Theme Color',
70+
inputValue: 'Dark'
71+
}
72+
};
73+
74+
it('adds a key-value pair to values array of the specified context', () => {
75+
const { allContext } = subject(state, action);
76+
expect(allContext[0].values.length).toEqual(1);
77+
expect(allContext[0].values[0].key).toEqual('Theme Color');
78+
expect(allContext[0].values[0].value).toEqual('Dark');
79+
});
80+
81+
it('includes an allContext not strictly equal to the original', () => {
82+
const { allContext } = subject(state, action);
83+
84+
expect(allContext).not.toBe(state.allContext);
85+
});
86+
});
87+
88+
describe('DELETE CONTEXT', () => {
89+
let action;
90+
beforeEach(() => {
91+
state = {
92+
allContext: [
93+
{
94+
name: 'Theme Context',
95+
values: [],
96+
components: []
97+
},
98+
{
99+
name: 'To be deleted',
100+
values: [],
101+
components: []
102+
}
103+
]
104+
};
105+
106+
action = {
107+
type: 'DELETE_CONTEXT',
108+
payload: {
109+
name: 'Theme Context'
110+
}
111+
};
112+
});
113+
114+
it('removes specified context from the state', () => {
115+
const { allContext } = subject(state, action);
116+
117+
expect(allContext.length).toEqual(1);
118+
});
119+
120+
it('includes an allContext not strictly equal to the original', () => {
121+
const { allContext } = subject(state, action);
122+
123+
expect(allContext).not.toBe(state.allContext);
124+
});
125+
});
126+
127+
describe('ADD_COMPONENT_TO_CONTEXT', () => {
128+
beforeEach(() => {
129+
state = {
130+
allContext: [
131+
{
132+
name: 'Theme Context',
133+
values: [],
134+
components: []
135+
}
136+
]
137+
};
138+
});
139+
140+
const action = {
141+
type: 'ADD_COMPONENT_TO_CONTEXT',
142+
payload: {
143+
context: {
144+
name: 'Theme Context'
145+
},
146+
component: {
147+
name: 'Main Component'
148+
}
149+
}
150+
};
151+
152+
it('adds a new component to the specified context', () => {
153+
const { allContext } = subject(state, action);
154+
155+
expect(allContext[0].components.length).toEqual(1);
156+
expect(allContext[0].components[0]).toEqual('Main Component');
157+
});
158+
159+
it('includes an allContext not strictly equal to the original', () => {
160+
const { allContext } = subject(state, action);
161+
162+
expect(allContext).not.toBe(state.allContext);
163+
});
164+
});
165+
});

0 commit comments

Comments
 (0)