Skip to content

Commit

Permalink
feat(save): allow creating private repositories and specifying a desc…
Browse files Browse the repository at this point in the history
…ription

fix #3 fix #4
  • Loading branch information
jchartrand committed Aug 17, 2018
1 parent 0522636 commit b568b1f
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/Save.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class SaveCmp extends Component {

// action on button click in form
saveFile() {
this.setState({submitted:true, userPR: false})
this.setState({submitted:true, usePR: false})
}

// action on button click in form
Expand Down
64 changes: 54 additions & 10 deletions src/VerifyRepo.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, {Component} from 'react'
import ReactDOM from 'react-dom';
const cwrcGit = require('cwrc-git-server-client');
import { Modal, Button } from 'react-bootstrap';
import { Modal, Button, FormGroup, Checkbox, ControlLabel, FormControl, HelpBlock} from 'react-bootstrap';

const ErrorModal = ({cancel, error}) => (
<Modal
Expand All @@ -14,12 +14,12 @@ const ErrorModal = ({cancel, error}) => (
<Button
onClick={cancel}
bsStyle="success"
>Yes</Button>
>OK</Button>
</Modal.Footer>
</Modal>
)

const ConfirmModal = ({cancel, title, body, ok}) => (
const ConfirmModal = ({cancel, title, body, ok, buttonText}) => (
<Modal
show={true}>
<Modal.Header>{title}</Modal.Header>
Expand All @@ -33,7 +33,40 @@ const ConfirmModal = ({cancel, title, body, ok}) => (
<Button
onClick={ok}
bsStyle="success"
>Yes</Button>
>{buttonText}</Button>
</Modal.Footer>
</Modal>
)

const CreateModal = ({cancel,ok, repoDesc, isPrivate, handlePrivateChange, handleDescriptionChange}) => (
<Modal
show={true}>
<Modal.Header>Create Repository</Modal.Header>
<Modal.Body>
<p>This repository doesn't yet exist, would you like to create it?</p>
<FormGroup controlId='repoDesc'>
<ControlLabel>Description</ControlLabel>
<FormControl
type="text"
placeholder="A short description of your repository."
value={repoDesc}
onChange={handleDescriptionChange}
/>
<HelpBlock>The description will appear in the Github page for your new repository.</HelpBlock>
</FormGroup>
<Checkbox checked={isPrivate} onChange={handlePrivateChange}>
Make Private
<HelpBlock>You must have a paid Github account to create private repositories.</HelpBlock>
</Checkbox>
</Modal.Body>
<Modal.Footer>
<Button onClick={cancel} bsStyle="danger">
Cancel
</Button>
<Button
onClick={ok}
bsStyle="success"
>Create</Button>
</Modal.Footer>
</Modal>
)
Expand Down Expand Up @@ -107,6 +140,15 @@ class VerifyRepo extends Component {
)
}

// handles changes passed up from children
handleDescriptionChange(e) {
this.setState({repoDesc: e.target.value});
}

handlePrivateChange(e) {
this.setState({isPrivate: e.target.checked})
}

render() {
const {repoHasBeenChecked, doesRepoExist, error, checkingRepo} = this.state

Expand All @@ -125,12 +167,14 @@ class VerifyRepo extends Component {
cancel = {this.cancel.bind(this)}
/>
} else if (repoHasBeenChecked) {
return <ConfirmModal
title='Create Repository'
body="This repository doesn't yet exist, would you like to create it?"
buttonText='Create'
ok ={this.createRepo.bind(this)}
/>
return <CreateModal
ok = {this.createRepo.bind(this)}
cancel = {this.cancel.bind(this)}
handlePrivateChange = {this.handlePrivateChange.bind(this)}
handleDescriptionChange = {this.handleDescriptionChange.bind(this)}
isPrivate = {this.state.isPrivate}
repoDesc={this.state.repoDesc}
/>
} else {
return null;
}
Expand Down

0 comments on commit b568b1f

Please sign in to comment.