Skip to content

Commit

Permalink
Add external link to create an issue
Browse files Browse the repository at this point in the history
  • Loading branch information
leonardokl committed Mar 31, 2017
1 parent a5f3ebe commit 239974b
Show file tree
Hide file tree
Showing 11 changed files with 8,322 additions and 8,172 deletions.
16,405 changes: 8,252 additions & 8,153 deletions public/js/bundle.js

Large diffs are not rendered by default.

36 changes: 28 additions & 8 deletions src/components/NewIssue.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import React, { PropTypes, PureComponent } from 'react'
import { Button, Input, Form, TextArea } from 'semantic-ui-react'
import { Button, Input, Icon, Form, TextArea } from 'semantic-ui-react'
import FadeTransition from './FadeTransition'
import { preventDefault } from 'utils'
import './NewIssue.styl'

class NewIssue extends PureComponent {
Expand All @@ -12,44 +14,62 @@ class NewIssue extends PureComponent {
this.setState({ [key]: value})
}

handleSubmit = () => {
handleSubmit = preventDefault(() => {
this.props.onSubmit(this.state)
}
})

render () {
const { title, description } = this.state
const { loading } = this.props
const { loading, onExternal } = this.props

return (
<div className='NewIssue'>
<Form className='NewIssue_Form'>
<div className='NewIssue_Form_Description'>Title</div>
<FadeTransition className='NewIssue'>
<Form className='NewIssue_Form' onSubmit={this.handleSubmit}>
<div className='NewIssue_Form_Description'>
<div style={{ flex: 1 }}>Title</div>
<Icon
name='external'
link
color='blue'
title='Open on Gitlab'
onClick={onExternal}
/>
</div>
<Input
autoFocus
value={title}
disabled={loading}
onChange={this.handleChange('title')}
/>

<div className='NewIssue_Form_Description'>Description</div>
<TextArea
disabled={loading}
placeholder='Write a comment'
onChange={this.handleChange('description')}
/>
</Form>

<Button
positive
disabled={!title.trim() || loading}
loading={loading}
content='Submit issue'
onClick={this.handleSubmit}
/>
</div>
</FadeTransition>
)
}
}

NewIssue.propTypes = {
loading: PropTypes.bool,
onExternal: PropTypes.func.isRequired,
onSubmit: PropTypes.func.isRequired
}

NewIssue.propTypes = {
loading: false
}

export default NewIssue
6 changes: 6 additions & 0 deletions src/components/NewIssue.styl
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,19 @@
.NewIssue_Project
color gray
font-size 0.8em
overflow hidden
text-overflow ellipsis
white-space nowrap

.NewIssue_Form
display flex
flex 1
flex-direction column
.input
margin-bottom 10px

.NewIssue_Form_Description
display flex
margin-bottom 5px
align-items center

4 changes: 2 additions & 2 deletions src/components/TopBar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ class TopBar extends PureComponent {
}
{!!title &&
<div className='App__TopBar_Content_Title'>
{title}
<div className='NewIssue_Project'>
<div>{title}</div>
<div className='NewIssue_Project' title={description}>
{description}
</div>
</div>
Expand Down
1 change: 1 addition & 0 deletions src/components/TopBar.styl
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,4 @@
font-size 1.2em
font-weight bold
margin-right 10px
overflow hidden
13 changes: 10 additions & 3 deletions src/containers/NewIssue.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,27 @@ import { NewIssue } from 'components'
import * as actions from 'store/actions'
import { getIsCreatingIssue } from 'store/selectors'

const NewIssueContainer = ({ loading, onCreateIssue }) => (
<NewIssue loading={loading} onSubmit={onCreateIssue}/>
const NewIssueContainer = ({ loading, onCreateIssue, onOpenExternalNewIssue }) => (
<NewIssue
loading={loading}
onSubmit={onCreateIssue}
onExternal={onOpenExternalNewIssue}
/>
)

NewIssueContainer.propTypes = {
loading: PropTypes.bool,
onCreateIssue: PropTypes.func,
onOpenExternalNewIssue: PropTypes.func
}

const mapStateToProps = state => ({
loading: getIsCreatingIssue(state),
})

const mapDispatchToProps = ({
onCreateIssue: actions.createIssue
onCreateIssue: actions.createIssue,
onOpenExternalNewIssue: actions.openExternalNewIssue
})

export default connect(mapStateToProps, mapDispatchToProps)(NewIssueContainer)
7 changes: 4 additions & 3 deletions src/store/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@ export const setPage = createAction('SET_PAGE', page => ({ page }))
export const updateEntity = createAction('UPDATE_ENTITY')
export const openProfile = createAction('OPEN_PROFILE')
export const openSettings = createAction('OPEN_SETTINGS')
export const openNewIssue = createAction('OPEN_NEW_ISSUE')
export const newIssue = createAction('NEW_ISSUE')

export const openTab = createAction('OPEN_TAB', url => ({ url }))
export const getOpenedTab = createAction('GET_OPENED_TAB')
export const setIssueMessage = createAction('SET_ISSUE_MESSAGE')

// TOKEN
export const getPersonalToken = createAction('GET_PERSONAL_TOKEN')
Expand Down Expand Up @@ -40,5 +38,8 @@ export const requestTodos = createAction('REQUEST_TODOS')
export const requestTodosSuccess = createAction('REQUEST_TODOS_SUCCESS')

// ISSUES
export const openExternalNewIssue = createAction('OPEN_EXTERNAL_NEW_ISSUE')
export const newIssue = createAction('NEW_ISSUE')
export const setIssueMessage = createAction('SET_ISSUE_MESSAGE')
export const createIssue = createAction('CREATE_ISSUE')
export const createIssueSuccess = createAction('CREATE_ISSUE_SUCCESS')
9 changes: 8 additions & 1 deletion src/store/sagas.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,12 @@ function* handleCreateIssue ({ payload }) {
}
}

function* handleOpenExternalNewIssue () {
const { web_url } = yield select(getNewIssueProject)

yield put(actions.openTab(`${web_url}/issues/new?issue`))
}

export default function* () {
yield [
takeEvery(actions.load, handleLoad),
Expand All @@ -254,6 +260,7 @@ export default function* () {
takeEvery(actions.swapPinnedProjects, handleSwapPinnedProjects),
takeEvery(actions.getOpenedTab, handleGetOpenedTab),
takeEvery(actions.newIssue, handleNewIssue),
takeEvery(actions.createIssue, handleCreateIssue)
takeEvery(actions.createIssue, handleCreateIssue),
takeEvery(actions.openExternalNewIssue, handleOpenExternalNewIssue)
]
}
1 change: 1 addition & 0 deletions src/utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export gitlab from './gitlab'
export chrome from './chrome'
export when from './when'
export stopPropagation from './stopPropagation'
export preventDefault from './preventDefault'
export gitlabTab from './gitlabTab'
export notification from './notification'

Expand Down
8 changes: 8 additions & 0 deletions src/utils/preventDefault.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import curry from 'lodash/fp/curry'

const preventDefault = curry((callback, evt, ...args) => {
evt.preventDefault()
callback(evt, ...args)
})

export default preventDefault
4 changes: 2 additions & 2 deletions src/utils/stopPropagation.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import curry from 'lodash/fp/curry'

const stopPropagation = curry((callback, evt) => {
const stopPropagation = curry((callback, evt, ...args) => {
evt.stopPropagation()
callback(evt)
callback(evt, ...args)
})

export default stopPropagation

0 comments on commit 239974b

Please sign in to comment.