-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#100 Integrate GitHub POST issue API call
- Loading branch information
1 parent
55052c5
commit 1fa4da8
Showing
16 changed files
with
285 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
import React, { Component } from 'react'; | ||
import { Link, withRouter } from 'react-router-dom'; | ||
import { Button, Container, Form, FormGroup, Input, Label } from 'reactstrap'; | ||
import AppNavbar from './AppNavbar'; | ||
|
||
class CreateIssue extends Component { | ||
|
||
emptyItem = { | ||
title: '', | ||
body: '', | ||
assignee: '', | ||
labels: '' | ||
}; | ||
|
||
constructor(props) { | ||
super(props); | ||
this.state = { | ||
item: this.emptyItem | ||
}; | ||
this.handleChange = this.handleChange.bind(this); | ||
this.handleSubmit = this.handleSubmit.bind(this); | ||
} | ||
|
||
async componentDidMount() { | ||
const issue = await (await fetch(`create-issue/${this.props.match.params.repo}`)).json(); | ||
this.setState({item: issue}); | ||
} | ||
|
||
handleChange(event) { | ||
const target = event.target; | ||
const value = target.value; | ||
const name = target.name; | ||
let item = {...this.state.item}; | ||
item[name] = value; | ||
this.setState({item}); | ||
} | ||
|
||
async handleSubmit(event) { | ||
event.preventDefault(); | ||
const {item} = this.state; | ||
console.log(item); | ||
await fetch(`/create-repo-issue/conorheffron/${this.props.match.params.repo}/`, { | ||
method: 'POST', | ||
headers: { | ||
'Accept': 'application/json', | ||
'Content-Type': 'application/json' | ||
}, | ||
body: JSON.stringify(item) | ||
}); | ||
this.props.history.push(`/issues/${this.props.match.params.repo}/`); | ||
} | ||
|
||
render() { | ||
const {item} = this.state; | ||
const title = <h2>Create Issue</h2>; | ||
|
||
return <div> | ||
<AppNavbar/><br /><br /> | ||
<Container fluid> | ||
<br /> | ||
<h2>{title}</h2> | ||
<Form onSubmit={this.handleSubmit}> | ||
<FormGroup> | ||
<Label for="title">Title</Label> | ||
<Input type="text" name="title" id="title" value={item.title || ''} | ||
onChange={this.handleChange} autoComplete="title"/> | ||
</FormGroup> | ||
<FormGroup> | ||
<Label for="body">Body</Label> | ||
<Input type="text" name="body" id="body" value={item.body || ''} | ||
onChange={this.handleChange} autoComplete="body"/> | ||
</FormGroup> | ||
<FormGroup> | ||
<Label for="assignee">Assignee</Label> | ||
<Input type="text" name="assignee" id="assignee" value={item.assignee || ''} | ||
onChange={this.handleChange} autoComplete="assignee"/> | ||
</FormGroup> | ||
<br /> | ||
<FormGroup> | ||
<Button color="primary" type="submit">Save</Button>{' '} | ||
</FormGroup> | ||
</Form> | ||
</Container> | ||
</div> | ||
} | ||
} | ||
export default withRouter(CreateIssue); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
src/main/java/com/ironoc/portfolio/domain/CreateIssueDomain.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.ironoc.portfolio.domain; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Builder | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
@Data | ||
public class CreateIssueDomain { | ||
|
||
private String title; | ||
|
||
private String body; | ||
|
||
private String assignee; | ||
|
||
private String labels; | ||
} |
32 changes: 32 additions & 0 deletions
32
src/main/java/com/ironoc/portfolio/dto/CreateIssueDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package com.ironoc.portfolio.dto; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
import java.util.List; | ||
import java.util.Map; | ||
|
||
@Builder | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
@Data | ||
public class CreateIssueDto { | ||
|
||
private String owner; | ||
|
||
private String repo; | ||
|
||
private String title; | ||
|
||
private String body; | ||
|
||
private List<String> assignees; | ||
|
||
private List<String> labels; | ||
|
||
private Integer milestone; | ||
|
||
private Map<String, String> headers; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.