Skip to content
This repository was archived by the owner on Sep 1, 2022. It is now read-only.

Commit 3f6db69

Browse files
author
Parth Shah
authored
Merge pull request #24 from githubtraining/replace-octokit
Replace all mentions of the octokit action
2 parents eebeeb3 + 540784e commit 3f6db69

12 files changed

+220
-269
lines changed

config.yml

+43-269
Original file line numberDiff line numberDiff line change
@@ -31,41 +31,9 @@ steps:
3131
- type: respond
3232
with: 01-components.md
3333
issue: Changes
34-
- type: octokit
35-
method: pullRequests.createComment
36-
owner: '%payload.repository.owner.login%'
37-
repo: '%payload.repository.name%'
38-
number: '%payload.number%'
39-
commit_id: '%payload.pull_request.head.sha%'
40-
path: src/App.jsx
41-
body: |
42-
### Add a header component
43-
Let's add a couple of child components and give our app a header.
44-
45-
Replace the line where it says to replace with this header component:
46-
47-
```jsx
48-
<h3 className="Box-title d-flex flex-justify-center">GradeBook</h3>
49-
```
50-
51-
### Run your code
52-
To run your code, inside your repo folder in your termainal run `npm start`.
53-
54-
### What your code should look like
55-
56-
Your app should look like this!
57-
![App with header](https://user-images.githubusercontent.com/25253905/61294086-eb352e80-a789-11e9-96ab-8b6cb09b3791.png)
58-
59-
### Push your code
60-
Let's push your code to GitHub
61-
62-
Run the following lines inside your repo folder in your terminal.
63-
64-
```
65-
git add src/App.jsx
66-
git commit -m "added a header"
67-
git push origin changes
68-
```
34+
- type: createPullRequestComment
35+
body: header-component-activity.md
36+
file: src/App.jsx
6937
position: 85
7038
- title: Props
7139
actions:
@@ -79,91 +47,21 @@ steps:
7947
- type: respond
8048
with: 02-props.md
8149
issue: Changes
82-
- type: octokit
83-
method: pullRequests.createComment
84-
owner: '%actions.metaPR2.data.head.repo.owner.login%'
85-
repo: '%actions.metaPR2.data.head.repo.name%'
86-
number: '%actions.metaPR2.data.number%'
87-
commit_id: '%actions.metaPR2.data.head.sha%'
88-
path: src/App.jsx
89-
body: |
90-
### Import a Child Component
91-
92-
Navigate to `List.jsx`. You'll see that we made our own component, `List`.
93-
94-
Let's go ahead and import that component.
95-
96-
At the top of `App.jsx`, replace the line with
97-
98-
```js
99-
import List from "./List";
100-
```
101-
102-
Scroll down for the next step.
50+
- type: createPullRequestComment
51+
body: import-child-component-activity.md
52+
file: src/App.jsx
10353
position: 3
104-
- type: octokit
105-
method: pullRequests.createComment
106-
owner: '%actions.metaPR2.data.head.repo.owner.login%'
107-
repo: '%actions.metaPR2.data.head.repo.name%'
108-
number: '%actions.metaPR2.data.number%'
109-
commit_id: '%actions.metaPR2.data.head.sha%'
110-
path: src/App.jsx
111-
body: |
112-
## Uncomment Assignments Section
113-
114-
Go ahead and uncomment the conditional statement underneath where it says to
115-
116-
`Uncomment below for step 2`
117-
118-
119-
### Run your code
120-
121-
To run your code, move inside your repo folder in your terminal and run `npm start`
122-
123-
### What your code should look like
124-
125-
![No Title Assignments](https://user-images.githubusercontent.com/25253905/61294177-1ddf2700-a78a-11e9-963d-8b6d2a4f7b82.png)
126-
127-
### Code Explanation
128-
129-
Let's take a look at what this code means. Basically, what it is saying is that when we click the `Assignments` button, the list for assignments will be assigned to the variable `tabChoice`. In our `render` method, we see that `tabChoice` is rendered.
130-
131-
But how do we specialize the `List` for our assignments? This where our props come into play. We create properties such as `placeholder`, and `currList`. We then assign values to them.
132-
133-
Scroll below for more code to add!
54+
pullRequest: '%actions.metaPR2.data.number%'
55+
- type: createPullRequestComment
56+
body: uncomment-assignments-activity.md
57+
file: src/App.jsx
13458
position: 46
135-
- type: octokit
136-
method: pullRequests.createComment
137-
owner: '%actions.metaPR2.data.head.repo.owner.login%'
138-
repo: '%actions.metaPR2.data.head.repo.name%'
139-
number: '%actions.metaPR2.data.number%'
140-
commit_id: '%actions.metaPR2.data.head.sha%'
141-
path: src/List.jsx
142-
body: |
143-
### Replace the title
144-
145-
But what does the `List` component do with this information? Let's take a look.
146-
147-
Go to `List.jsx`. In the `render` method, in our input tag, you see that we set our `placeholder` to `this.props.placeholder`, and then at the bottom of our `render` method, we loop through out `this.props.currList`, to show each item in the list that we pass. Adding `this.props` tells the component to look for that property that was passed to it.
148-
149-
Let's go ahead and replace that ugly title with a prop. In our `render` method in `List.jsx`, where it says to replace the title with a prop, replace that with `{this.props.title}`.
150-
151-
### Run your code
152-
153-
To run your code, move inside your repo folder in your terminal and run `npm start`
154-
155-
### Push your code
156-
Awesome! We are using props! You already learned so much!
157-
158-
To push your code to Github, run the following lines inside the repo folder in your terminal.
159-
160-
```
161-
git add src/App.jsx
162-
git add src/List.jsx
163-
git commit -m "using props for List component"
164-
git push origin changes
165-
```
59+
pullRequest: '%actions.metaPR2.data.number%'
60+
- type: createPullRequestComment
61+
body: replace-title-activity.md
62+
file: src/List.jsx
16663
position: 5
64+
pullRequest: '%actions.metaPR2.data.number%'
16765
description: Learn how to pass data to child components
16866
event: push
16967
link: '{{ repoUrl }}/issues/2'
@@ -190,96 +88,26 @@ steps:
19088
- type: respond
19189
with: 03-state.md
19290
issue: Changes
193-
- type: octokit
194-
method: pullRequests.createComment
195-
owner: '%actions.metaPR2.data.head.repo.owner.login%'
196-
repo: '%actions.metaPR2.data.head.repo.name%'
197-
number: '%actions.metaPR2.data.number%'
198-
commit_id: '%actions.metaPR2.data.head.sha%'
199-
path: src/App.jsx
200-
body: |
201-
### Add a state variable
202-
203-
In React, we store dynamic data in **state variables**. Let's take a look at how we store state variables. In `App.jsx`, take a look at the constructor. You'll see that we declare our state variables using `this.state = {.....}`.
204-
205-
206-
Currently, in `App`, we have three state variables:
207-
- `buttonClicked` - This stores which button was clicked. It is a state variable because the button that is clicked has the ability to change.
208-
- `assignments` - This stores the list of assignments. It is a state variable because the list changes every time a new assignment is added.
209-
- `grades` - This should store the grade for each student. However, we have no way to store students, so let's fix that!
210-
211-
Add a state variable to `App` and name it `students`. Set it equal to an empty list. Make sure to add the comma!
91+
- type: createPullRequestComment
92+
body: add-state-variable-activity.md
93+
file: src/App.jsx
21294
position: 12
213-
- type: octokit
214-
method: pullRequests.createComment
215-
owner: '%actions.metaPR2.data.head.repo.owner.login%'
216-
repo: '%actions.metaPR2.data.head.repo.name%'
217-
number: '%actions.metaPR2.data.number%'
218-
commit_id: '%actions.metaPR2.data.head.sha%'
219-
path: src/App.jsx
220-
body: |
221-
222-
### Explaining `this.setState`
223-
224-
Ok, so now we added a state variable, how do we actually change the data?
225-
226-
Unfortunatley, we can't just do `this.state.studentsList = .....` to change data. I wish it was that simple!
227-
228-
To set the state of a state variable we have to use the method, `this.setState`.
229-
230-
Take a look at the above code in `App.jsx`
231-
232-
When this method is called, it setting the state variable `buttonClicked` to the argument, `buttonName` using `this.setState`.
233-
234-
In our `render` method we see that `handleButtonClicked` is called when each button is clicked with it's respective arguments. For instance, when the `Assignments` button is clicked, we call `handleButtonClicked("assignments")`.
235-
236-
We are going to set some state in next steps.
95+
pullRequest: '%actions.metaPR2.data.number%'
96+
- type: createPullRequestComment
97+
body: explaining-this-state-activity.md
98+
file: src/App.jsx
23799
position: 32
238-
- type: octokit
239-
method: pullRequests.createComment
240-
owner: '%actions.metaPR2.data.head.repo.owner.login%'
241-
repo: '%actions.metaPR2.data.head.repo.name%'
242-
number: '%actions.metaPR2.data.number%'
243-
commit_id: '%actions.metaPR2.data.head.sha%'
244-
path: src/App.jsx
245-
body: |
246-
247-
### Create `addStudent` Function
248-
249-
Now that we see how it works with assignments, let's try it with students!
250-
251-
create a method called `addStudent` below the comment
252-
253-
`addStudent` should take `studentName` as a parameter and then concat that `studentName` to the end of `students` list that we created earlier.
100+
pullRequest: '%actions.metaPR2.data.number%'
101+
- type: createPullRequestComment
102+
body: create-addstudent-activity.md
103+
file: src/App.jsx
254104
position: 38
255-
- type: octokit
256-
method: pullRequests.createComment
257-
owner: '%actions.metaPR2.data.head.repo.owner.login%'
258-
repo: '%actions.metaPR2.data.head.repo.name%'
259-
number: '%actions.metaPR2.data.number%'
260-
commit_id: '%actions.metaPR2.data.head.sha%'
261-
path: src/App.jsx
262-
body: |
263-
264-
### Bind the function
265-
266-
Also, since we created a method that changes the a state variable, we have to bind it to our class, so that when we call it, we know what method to reference.
267-
268-
Go ahead and uncomment this line.
269-
270-
### Run your code
271-
Run your code with `npm start` to make sure there are no errors.
272-
273-
274-
### Push your code
275-
276-
```
277-
git add src/App.jsx
278-
git commit -m "using students state variable and setting state"
279-
git push origin changes
280-
281-
```
105+
pullRequest: '%actions.metaPR2.data.number%'
106+
- type: createPullRequestComment
107+
body: bind-function-activity.md
108+
file: src/App.jsx
282109
position: 20
110+
pullRequest: '%actions.metaPR2.data.number%'
283111
description: Learn how to deal with dynamic data
284112
event: push
285113
link: '{{ repoUrl }}/issues/2'
@@ -317,78 +145,24 @@ steps:
317145
- type: respond
318146
with: 04-callbackfunctions.md
319147
issue: Changes
320-
- type: octokit
321-
method: pullRequests.createComment
322-
owner: '%actions.metaPR2.data.head.repo.owner.login%'
323-
repo: '%actions.metaPR2.data.head.repo.name%'
324-
number: '%actions.metaPR2.data.number%'
325-
commit_id: '%actions.metaPR2.data.head.sha%'
326-
path: src/App.jsx
327-
body: |
328-
329-
### Passing Functions as Props
330-
331-
So where exactly are those functions we created to set state getting called?
332-
333-
So it looks like we pass the `addAssignment` function as a prop in this chunk of code.
148+
- type: createPullRequestComment
149+
body: passing-functions-activity.md
150+
file: src/App.jsx
334151
position: 52
152+
pullRequest: '%actions.metaPR2.data.number%'
335153
- type: respond
336154
with: callback-example.md
337155
issue: Changes
338-
- type: octokit
339-
method: pullRequests.createComment
340-
owner: '%actions.metaPR2.data.head.repo.owner.login%'
341-
repo: '%actions.metaPR2.data.head.repo.name%'
342-
number: '%actions.metaPR2.data.number%'
343-
commit_id: '%actions.metaPR2.data.head.sha%'
344-
path: src/App.jsx
345-
body: |
346-
### Change the props for Students
347-
348-
Take a look at this conditional in `App.jsx`.
349-
350-
We are trying to render the correct component when we click `Students`. Go ahead and uncomment the entire conditional statement.
351-
352-
Hmmm, there's some stuff wrong about this code. We want to be modifying the `students` list, not the `assignments` list.
353-
354-
Let's go ahead and change some props!
355-
356-
- Change the `placeholder` prop to `"Add Student..."`
357-
- Change the `currList` prop to `{this.state.students}`
358-
- Change the `addFunction` prop to `{this.addStudent}`
156+
- type: createPullRequestComment
157+
body: change-props-students-activity.md
158+
file: src/App.jsx
359159
position: 68
360-
- type: octokit
361-
method: pullRequests.createComment
362-
owner: '%actions.metaPR2.data.head.repo.owner.login%'
363-
repo: '%actions.metaPR2.data.head.repo.name%'
364-
number: '%actions.metaPR2.data.number%'
365-
commit_id: '%actions.metaPR2.data.head.sha%'
366-
path: src/App.jsx
367-
body: |
368-
### Uncomment the Grades Section
369-
370-
LAST THING! Let's get our grades working!
371-
372-
Uncomment this last conditional statement for the grades tab!
373-
374-
### Run your code
375-
To run your code, move inside your repo folder in your terminal and run `npm start`
376-
377-
### What your code should look like
378-
379-
Your code should now be able to add assignments, students, and grades! You are done!
380-
381-
### Push your code
382-
To push your code to Github, run the following lines inside the repo folder in your terminal.
383-
384-
```
385-
git add src/App.jsx
386-
git commit -m "used callback functions to complete project"
387-
git push origin changes
388-
```
160+
pullRequest: '%actions.metaPR2.data.number%'
161+
- type: createPullRequestComment
162+
body: uncomment-grades-activity.md
163+
file: src/App.jsx
389164
position: 78
390-
391-
165+
pullRequest: '%actions.metaPR2.data.number%'
392166
description: Learn how to pass data back to parent components
393167
event: push
394168
link: '{{ repoUrl }}/issues/2'
+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
### Add a state variable
2+
3+
In React, we store dynamic data in **state variables**. Let's take a look at how we store state variables. In `App.jsx`, take a look at the constructor. You'll see that we declare our state variables using `this.state = {.....}`.
4+
5+
6+
Currently, in `App`, we have three state variables:
7+
- `buttonClicked` - This stores which button was clicked. It is a state variable because the button that is clicked has the ability to change.
8+
- `assignments` - This stores the list of assignments. It is a state variable because the list changes every time a new assignment is added.
9+
- `grades` - This should store the grade for each student. However, we have no way to store students, so let's fix that!
10+
11+
Add a state variable to `App` and name it `students`. Set it equal to an empty list. Make sure to add the comma!

responses/bind-function-activity.md

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
### Bind the function
2+
3+
Also, since we created a method that changes the a state variable, we have to bind it to our class, so that when we call it, we know what method to reference.
4+
5+
Go ahead and uncomment this line.
6+
7+
### Run your code
8+
Run your code with `npm start` to make sure there are no errors.
9+
10+
11+
### Push your code
12+
13+
```
14+
git add src/App.jsx
15+
git commit -m "using students state variable and setting state"
16+
git push origin changes
17+
18+
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
### Change the props for Students
2+
3+
Take a look at this conditional in `App.jsx`.
4+
5+
We are trying to render the correct component when we click `Students`. Go ahead and uncomment the entire conditional statement.
6+
7+
Hmmm, there's some stuff wrong about this code. We want to be modifying the `students` list, not the `assignments` list.
8+
9+
Let's go ahead and change some props!
10+
11+
- Change the `placeholder` prop to `"Add Student..."`
12+
- Change the `currList` prop to `{this.state.students}`
13+
- Change the `addFunction` prop to `{this.addStudent}`

0 commit comments

Comments
 (0)