Skip to content

Commit 069a32d

Browse files
authored
Merge pull request #1388 from processing/bug/collection-adding-multiples
Bug/collection adding multiples
2 parents 5a79a84 + 82f892a commit 069a32d

File tree

6 files changed

+28
-34
lines changed

6 files changed

+28
-34
lines changed

client/modules/IDE/actions/collections.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import axios from 'axios';
2+
import { browserHistory } from 'react-router';
23
import * as ActionTypes from '../../../constants';
34
import { startLoader, stopLoader } from './loader';
45
import { setToastText, showToast } from './toast';
@@ -47,20 +48,22 @@ export function createCollection(collection) {
4748
});
4849
dispatch(stopLoader());
4950

50-
const collectionName = response.data.name;
51-
dispatch(setToastText(`Created "${collectionName}"`));
51+
const newCollection = response.data;
52+
dispatch(setToastText(`Created "${newCollection.name}"`));
5253
dispatch(showToast(TOAST_DISPLAY_TIME_MS));
5354

54-
return response.data;
55+
const pathname = `/${newCollection.owner.username}/collections/${newCollection.id}`;
56+
const location = { pathname, state: { skipSavingPath: true } };
57+
58+
browserHistory.push(location);
5559
})
5660
.catch((response) => {
61+
console.error('Error creating collection', response.data);
5762
dispatch({
5863
type: ActionTypes.ERROR,
5964
error: response.data
6065
});
6166
dispatch(stopLoader());
62-
63-
return response.data;
6467
});
6568
};
6669
}

client/modules/IDE/components/QuickAddList/QuickAddList.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ const QuickAddList = ({
5353
{...item}
5454
onSelect={
5555
(event) => {
56-
event.target.blur();
56+
event.stopPropagation();
57+
event.currentTarget.blur();
5758
handleAction(item);
5859
}
5960
}

client/modules/User/components/Collection.jsx

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -380,15 +380,15 @@ Collection.propTypes = {
380380
}).isRequired,
381381
getCollections: PropTypes.func.isRequired,
382382
collection: PropTypes.shape({
383-
id: PropTypes.string.isRequired,
384-
name: PropTypes.string.isRequired,
383+
id: PropTypes.string,
384+
name: PropTypes.string,
385385
slug: PropTypes.string,
386386
description: PropTypes.string,
387387
owner: PropTypes.shape({
388-
username: PropTypes.string.isRequired,
388+
username: PropTypes.string,
389389
}).isRequired,
390390
items: PropTypes.arrayOf(PropTypes.shape({})),
391-
}).isRequired,
391+
}),
392392
username: PropTypes.string,
393393
loading: PropTypes.bool.isRequired,
394394
toggleDirectionForField: PropTypes.func.isRequired,
@@ -401,7 +401,14 @@ Collection.propTypes = {
401401
};
402402

403403
Collection.defaultProps = {
404-
username: undefined
404+
username: undefined,
405+
collection: {
406+
id: undefined,
407+
items: [],
408+
owner: {
409+
username: undefined
410+
}
411+
}
405412
};
406413

407414
function mapStateToProps(state, ownProps) {

client/modules/User/components/CollectionCreate.jsx

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import PropTypes from 'prop-types';
22
import React from 'react';
33
import { Helmet } from 'react-helmet';
44
import { connect } from 'react-redux';
5-
import { browserHistory } from 'react-router';
65
import { bindActionCreators } from 'redux';
76
import * as CollectionsActions from '../../IDE/actions/collections';
87

@@ -39,19 +38,7 @@ class CollectionCreate extends React.Component {
3938
handleCreateCollection = (event) => {
4039
event.preventDefault();
4140

42-
this.props.createCollection(this.state.collection)
43-
.then(({ id, owner }) => {
44-
const pathname = `/${owner.username}/collections/${id}`;
45-
const location = { pathname, state: { skipSavingPath: true } };
46-
47-
browserHistory.replace(location);
48-
})
49-
.catch((error) => {
50-
console.error('Error creating collection', error);
51-
this.setState({
52-
creationError: error,
53-
});
54-
});
41+
this.props.createCollection(this.state.collection);
5542
}
5643

5744
render() {
@@ -107,12 +94,7 @@ CollectionCreate.propTypes = {
10794
username: PropTypes.string,
10895
authenticated: PropTypes.bool.isRequired
10996
}).isRequired,
110-
createCollection: PropTypes.func.isRequired,
111-
collection: PropTypes.shape({}).isRequired, // TODO
112-
sorting: PropTypes.shape({
113-
field: PropTypes.string.isRequired,
114-
direction: PropTypes.string.isRequired
115-
}).isRequired
97+
createCollection: PropTypes.func.isRequired
11698
};
11799

118100
function mapStateToProps(state, ownProps) {

client/modules/User/pages/CollectionView.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ function mapStateToProps(state) {
7272
}
7373

7474
function mapDispatchToProps(dispatch) {
75+
return {};
7576
}
7677

7778
CollectionView.propTypes = {
@@ -84,7 +85,7 @@ CollectionView.propTypes = {
8485
}).isRequired,
8586
theme: PropTypes.string.isRequired,
8687
user: PropTypes.shape({
87-
username: PropTypes.string.isRequired,
88+
username: PropTypes.string,
8889
}),
8990
};
9091

client/styles/abstracts/_placeholders.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,15 +87,15 @@
8787
fill: getThemifyVariable('button-color');
8888
opacity: 1;
8989
}
90-
&:enabled:hover {
90+
&:not(disabled):hover {
9191
border-color: getThemifyVariable('button-background-hover-color');
9292
background-color: getThemifyVariable('button-background-hover-color');
9393
color: getThemifyVariable('button-hover-color');
9494
& g {
9595
fill: getThemifyVariable('button-hover-color');
9696
}
9797
}
98-
&:enabled:active {
98+
&:not(disabled):active {
9999
border-color: getThemifyVariable('button-background-active-color');
100100
background-color: getThemifyVariable('button-background-active-color');
101101
color: getThemifyVariable('button-active-color');

0 commit comments

Comments
 (0)