decidim-comments 0.0.6 → 0.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +33 -0
- data/app/assets/javascripts/decidim/comments/bundle.js +44 -44
- data/app/assets/javascripts/decidim/comments/bundle.js.map +1 -1
- data/app/assets/javascripts/decidim/comments/comments.js.erb +2 -0
- data/app/frontend/application/{apollo_client.js → apollo_client.ts} +5 -5
- data/app/frontend/application/application.component.test.tsx +36 -0
- data/app/frontend/application/application.component.tsx +37 -0
- data/app/frontend/application/icon.component.test.tsx +49 -0
- data/app/frontend/application/icon.component.tsx +35 -0
- data/app/frontend/comments/{add_comment_form.component.test.jsx → add_comment_form.component.test.tsx} +98 -92
- data/app/frontend/comments/{add_comment_form.component.jsx → add_comment_form.component.tsx} +152 -153
- data/app/frontend/comments/{comment.component.test.jsx → comment.component.test.tsx} +59 -71
- data/app/frontend/comments/{comment.component.jsx → comment.component.tsx} +114 -116
- data/app/frontend/comments/comment_order_selector.component.test.tsx +21 -0
- data/app/frontend/comments/comment_order_selector.component.tsx +88 -0
- data/app/frontend/comments/comment_thread.component.test.tsx +65 -0
- data/app/frontend/comments/comment_thread.component.tsx +70 -0
- data/app/frontend/comments/{comments.component.test.jsx → comments.component.test.tsx} +38 -81
- data/app/frontend/comments/{comments.component.jsx → comments.component.tsx} +49 -63
- data/app/frontend/comments/down_vote_button.component.test.tsx +39 -0
- data/app/frontend/comments/down_vote_button.component.tsx +89 -0
- data/app/frontend/comments/up_vote_button.component.test.tsx +39 -0
- data/app/frontend/comments/up_vote_button.component.tsx +89 -0
- data/app/frontend/comments/vote_button.component.tsx +36 -0
- data/app/frontend/comments/{vote_button_component.test.jsx → vote_button_component.test.tsx} +16 -20
- data/app/frontend/entry.ts +19 -0
- data/app/frontend/{comments → fragments}/add_comment_form_commentable.fragment.graphql +1 -1
- data/app/frontend/{comments → fragments}/add_comment_form_session.fragment.graphql +1 -1
- data/app/frontend/{comments → fragments}/comment.fragment.graphql +3 -1
- data/app/frontend/{comments → fragments}/comment_data.fragment.graphql +6 -3
- data/app/frontend/{comments → fragments}/comment_thread.fragment.graphql +3 -1
- data/app/frontend/{comments/down_vote.fragment.graphql → fragments/down_vote_button.fragment.graphql} +2 -2
- data/app/frontend/{comments/up_vote.fragment.graphql → fragments/up_vote_button.fragment.graphql} +2 -2
- data/app/frontend/{comments/add_comment_form.mutation.graphql → mutations/add_comment.mutation.graphql} +3 -1
- data/app/frontend/{comments → mutations}/down_vote.mutation.graphql +3 -1
- data/app/frontend/{comments → mutations}/up_vote.mutation.graphql +3 -1
- data/app/frontend/{comments → queries}/comments.query.graphql +4 -1
- data/app/frontend/support/{asset_url.js → asset_url.ts} +1 -1
- data/app/frontend/support/{generate_comments_data.js → generate_comments_data.ts} +11 -6
- data/app/frontend/support/{generate_user_data.js → generate_user_data.ts} +2 -2
- data/app/frontend/support/{generate_user_group_data.js → generate_user_group_data.ts} +2 -2
- data/app/frontend/support/graphql_transformer.js +32 -0
- data/app/frontend/support/load_translations.ts +44 -0
- data/app/frontend/support/{require_all.js → require_all.ts} +1 -1
- data/app/frontend/support/{resolve_graphql_query.js → resolve_graphql_query.ts} +7 -7
- data/app/frontend/support/schema.ts +119 -0
- data/config/locales/eu.yml +29 -5
- metadata +49 -51
- data/app/frontend/application/application.component.jsx +0 -37
- data/app/frontend/application/application.component.test.jsx +0 -33
- data/app/frontend/application/icon.component.jsx +0 -26
- data/app/frontend/application/icon.component.test.jsx +0 -53
- data/app/frontend/comments/comment_order_selector.component.jsx +0 -72
- data/app/frontend/comments/comment_order_selector.component.test.jsx +0 -20
- data/app/frontend/comments/comment_thread.component.jsx +0 -75
- data/app/frontend/comments/comment_thread.component.test.jsx +0 -83
- data/app/frontend/comments/down_vote_button.component.jsx +0 -98
- data/app/frontend/comments/down_vote_button.component.test.jsx +0 -48
- data/app/frontend/comments/featured_comment.component.jsx +0 -23
- data/app/frontend/comments/featured_comment.component.test.jsx +0 -15
- data/app/frontend/comments/up_vote_button.component.jsx +0 -98
- data/app/frontend/comments/up_vote_button.component.test.jsx +0 -48
- data/app/frontend/comments/vote_button.component.jsx +0 -32
- data/app/frontend/entry.js +0 -17
- data/app/frontend/entry.test.js +0 -31
- data/app/frontend/support/load_translations.js +0 -23
- data/app/frontend/support/stub_component.js +0 -29
@@ -1,48 +0,0 @@
|
|
1
|
-
import { shallow } from 'enzyme';
|
2
|
-
import { filter } from 'graphql-anywhere';
|
3
|
-
import gql from 'graphql-tag';
|
4
|
-
|
5
|
-
import { UpVoteButton } from './up_vote_button.component';
|
6
|
-
|
7
|
-
import VoteButton from './vote_button.component';
|
8
|
-
|
9
|
-
import upVoteFragment from './up_vote.fragment.graphql';
|
10
|
-
|
11
|
-
import stubComponent from '../support/stub_component';
|
12
|
-
import generateCommentsData from '../support/generate_comments_data';
|
13
|
-
|
14
|
-
describe("<UpVoteButton />", () => {
|
15
|
-
let comment = {};
|
16
|
-
const upVote = () => {};
|
17
|
-
|
18
|
-
stubComponent(VoteButton);
|
19
|
-
|
20
|
-
beforeEach(() => {
|
21
|
-
let commentsData = generateCommentsData(1);
|
22
|
-
|
23
|
-
const fragment = gql`
|
24
|
-
${upVoteFragment}
|
25
|
-
`;
|
26
|
-
|
27
|
-
comment = filter(fragment, commentsData[0]);
|
28
|
-
});
|
29
|
-
|
30
|
-
it("should render a VoteButton component with the correct props", () => {
|
31
|
-
const wrapper = shallow(<UpVoteButton comment={comment} upVote={upVote} />);
|
32
|
-
expect(wrapper.find(VoteButton)).to.have.prop("buttonClassName").equal("comment__votes--up");
|
33
|
-
expect(wrapper.find(VoteButton)).to.have.prop("iconName").equal("icon-chevron-top");
|
34
|
-
expect(wrapper.find(VoteButton)).to.have.prop("votes").equal(comment.upVotes);
|
35
|
-
});
|
36
|
-
|
37
|
-
it("should pass disabled prop as true if comment upVoted is true", () => {
|
38
|
-
comment.upVoted = true;
|
39
|
-
const wrapper = shallow(<UpVoteButton comment={comment} upVote={upVote} />);
|
40
|
-
expect(wrapper.find(VoteButton)).to.have.prop("disabled").equal(true);
|
41
|
-
});
|
42
|
-
|
43
|
-
it("should pass disabled prop as true if comment downVoted is true", () => {
|
44
|
-
comment.downVoted = true;
|
45
|
-
const wrapper = shallow(<UpVoteButton comment={comment} upVote={upVote} />);
|
46
|
-
expect(wrapper.find(VoteButton)).to.have.prop("disabled").equal(true);
|
47
|
-
});
|
48
|
-
});
|
@@ -1,32 +0,0 @@
|
|
1
|
-
import { Component, PropTypes } from 'react';
|
2
|
-
import Icon from '../application/icon.component';
|
3
|
-
|
4
|
-
class VoteButton extends Component {
|
5
|
-
render() {
|
6
|
-
const { buttonClassName, iconName, votes, voteAction, disabled, selectedClass } = this.props;
|
7
|
-
let voteClasses = `${buttonClassName} ${selectedClass}`;
|
8
|
-
|
9
|
-
return (
|
10
|
-
<button className={voteClasses} onClick={() => voteAction()} disabled={disabled}>
|
11
|
-
<Icon name={iconName} iconExtraClassName="icon--small" />
|
12
|
-
{ ` ${votes}` }
|
13
|
-
</button>
|
14
|
-
);
|
15
|
-
}
|
16
|
-
}
|
17
|
-
|
18
|
-
VoteButton.propTypes = {
|
19
|
-
buttonClassName: PropTypes.string.isRequired,
|
20
|
-
iconName: PropTypes.string.isRequired,
|
21
|
-
votes: PropTypes.number.isRequired,
|
22
|
-
voteAction: PropTypes.func.isRequired,
|
23
|
-
selectedClass: PropTypes.string,
|
24
|
-
disabled: PropTypes.bool
|
25
|
-
};
|
26
|
-
|
27
|
-
VoteButton.defaultProps = {
|
28
|
-
selectedClass: "selected",
|
29
|
-
disabled: false
|
30
|
-
};
|
31
|
-
|
32
|
-
export default VoteButton;
|
data/app/frontend/entry.js
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
import ReactDOM from 'react-dom';
|
2
|
-
|
3
|
-
import loadTranslations from './support/load_translations';
|
4
|
-
import Comments from './comments/comments.component';
|
5
|
-
|
6
|
-
// Expose global components
|
7
|
-
window.DecidimComments.renderCommentsComponent = (nodeId, props) => {
|
8
|
-
var node = $(`#${nodeId}`)[0];
|
9
|
-
|
10
|
-
ReactDOM.render(
|
11
|
-
React.createElement(Comments, props),
|
12
|
-
node
|
13
|
-
);
|
14
|
-
};
|
15
|
-
|
16
|
-
// Load component locales from yaml files
|
17
|
-
loadTranslations();
|
data/app/frontend/entry.test.js
DELETED
@@ -1,31 +0,0 @@
|
|
1
|
-
// ---------------------------------------
|
2
|
-
// Test Environment Setup
|
3
|
-
// ---------------------------------------
|
4
|
-
import sinon from 'sinon/pkg/sinon';
|
5
|
-
import chai from 'chai';
|
6
|
-
import sinonChai from 'sinon-chai';
|
7
|
-
import chaiAsPromised from 'chai-as-promised';
|
8
|
-
import chaiEnzyme from 'chai-enzyme';
|
9
|
-
import loadTranslations from './support/load_translations';
|
10
|
-
import requireAll from './support/require_all';
|
11
|
-
|
12
|
-
require('jquery');
|
13
|
-
|
14
|
-
//
|
15
|
-
chai.use(sinonChai)
|
16
|
-
chai.use(chaiAsPromised)
|
17
|
-
chai.use(chaiEnzyme())
|
18
|
-
//
|
19
|
-
window.chai = chai
|
20
|
-
window.sinon = sinon
|
21
|
-
window.expect = chai.expect
|
22
|
-
window.should = chai.should()
|
23
|
-
|
24
|
-
// ---------------------------------------
|
25
|
-
// Require Tests
|
26
|
-
// ---------------------------------------
|
27
|
-
requireAll(require.context('./application/', true, /\.test\.jsx?$/));
|
28
|
-
requireAll(require.context('./comments/', true, /\.test\.jsx?$/));
|
29
|
-
|
30
|
-
// Load component locales from yaml files
|
31
|
-
loadTranslations();
|
@@ -1,23 +0,0 @@
|
|
1
|
-
/* eslint-disable no-param-reassign */
|
2
|
-
import { I18n } from 'react-i18nify';
|
3
|
-
import requireAll from './require_all';
|
4
|
-
|
5
|
-
/**
|
6
|
-
* Load components translations from yaml files and import them into
|
7
|
-
* react-i18ify system so they can be used via `I18n.t` method.
|
8
|
-
* @returns {Void} - Nothing
|
9
|
-
*/
|
10
|
-
const loadTranslations = () => {
|
11
|
-
const translationsContext = require.context('../../../config/locales/', true, /\.yml$/);
|
12
|
-
const translationFiles = requireAll(translationsContext);
|
13
|
-
|
14
|
-
const translations = translationsContext.keys().reduce((acc, key, index) => {
|
15
|
-
const locale = key.match(/\.\/(.*)\.yml/)[1];
|
16
|
-
acc[locale] = translationFiles[index][locale].decidim;
|
17
|
-
return acc;
|
18
|
-
}, {});
|
19
|
-
|
20
|
-
I18n.setTranslations(translations);
|
21
|
-
};
|
22
|
-
|
23
|
-
export default loadTranslations;
|
@@ -1,29 +0,0 @@
|
|
1
|
-
/* eslint-disable no-param-reassign */
|
2
|
-
|
3
|
-
/**
|
4
|
-
* A helper function to stub the `propTypes` and `fragments` of a component.
|
5
|
-
* Useful for testing isolated components so the children propTypes are not
|
6
|
-
* evaluated.
|
7
|
-
* @param {ReactComponent} componentClass - A component constructor function or class
|
8
|
-
* @param {Object} options - An object which properties are used to stub component properties.
|
9
|
-
* @returns {ReactComponent} - A component with some properties stubbed
|
10
|
-
*/
|
11
|
-
const stubComponent = function(componentClass, options = {}) {
|
12
|
-
let originalPropTypes = {};
|
13
|
-
let originalFragments = {};
|
14
|
-
|
15
|
-
beforeEach(function() {
|
16
|
-
originalPropTypes = componentClass.propTypes;
|
17
|
-
originalFragments = componentClass.fragments;
|
18
|
-
|
19
|
-
componentClass.propTypes = options.propTypes || {};
|
20
|
-
componentClass.fragments = options.fragments || {};
|
21
|
-
});
|
22
|
-
|
23
|
-
afterEach(function() {
|
24
|
-
componentClass.propTypes = originalPropTypes;
|
25
|
-
componentClass.fragments = originalFragments;
|
26
|
-
});
|
27
|
-
};
|
28
|
-
|
29
|
-
export default stubComponent;
|