Skip to content

Fix: Show error message when creating Workspace failed. #13

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 1, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions app/components/Workspace/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,19 @@ export function toggleCreatingWorkspace (isCreating) {
return {type: WORKSPACE_CREATING, isCreating}
}

export const WORKSPACE_CREATING_ERROR = 'WORKSPACE_CREATING_ERROR'
export function toggleCreatingWorkspaceErr (msg) {
return {type: WORKSPACE_CREATING_ERROR, msg}
}

export function createWorkspace (url) {
return dispatch => {
dispatch(toggleCreatingWorkspace(true))
api.createWorkspace(url).then(ws => {
dispatch(fetchWorkspaceList())
dispatch(toggleCreatingWorkspace(false))
}).catch(e => {
dispatch(toggleCreatingWorkspaceErr(e.msg))
})
}
}
Expand Down
3 changes: 2 additions & 1 deletion app/components/Workspace/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class WorkspaceList extends Component {
}

render () {
const {workspaces, publicKey, fingerprint, isCreating, ...actionProps} = this.props
const {workspaces, publicKey, fingerprint, isCreating, errMsg, ...actionProps} = this.props
const {openWorkspace, createWorkspace, deleteWorkspace} = actionProps
return (
<div className='workspace-list'>
Expand All @@ -38,6 +38,7 @@ class WorkspaceList extends Component {
onClick={e => createWorkspace(this.gitUrlInput.value)}>Create</button> }
</div>
{ isCreating ? <p className='creating-workspace-indicator'>Creating</p> : null }
{ errMsg ? <p className='creating-workspace-indicator-error'>Error: {errMsg}</p> : null }
</div>
<div className='workspace-list-container'>
{ workspaces.map(ws =>
Expand Down
9 changes: 7 additions & 2 deletions app/components/Workspace/reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import {
WORKSPACE_FETCH_PUBLIC_KEY,
WORKSPACE_FETCH_LIST,
WORKSPACE_OPEN,
WORKSPACE_CREATING
WORKSPACE_CREATING,
WORKSPACE_CREATING_ERROR
} from './actions'

const defaultState = {
Expand All @@ -12,7 +13,8 @@ const defaultState = {
currentWorkspace: null,
publicKey: null,
fingerprint: null,
isCreating: false
isCreating: false,
errMsg: null
}

export default function (state = defaultState, action) {
Expand All @@ -32,6 +34,9 @@ export default function (state = defaultState, action) {
case WORKSPACE_CREATING:
return {...state, isCreating: action.isCreating}

case WORKSPACE_CREATING_ERROR:
return {...state, isCreating: false, errMsg: action.msg}

default:
return state
}
Expand Down
4 changes: 4 additions & 0 deletions app/styles/components/Workspace.styl
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,7 @@
animation: CREATING-WORKSPACE 3s infinite;
}
}
.creating-workspace-indicator-error {
opacity: 0.7;
color: red;
}