decidim-comments 0.23.1 → 0.24.0.rc2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/decidim/comments/bundle.js.map +1 -1
- data/app/assets/javascripts/decidim/comments/comments.component.js.es6 +292 -0
- data/app/assets/javascripts/decidim/comments/comments.component.test.js +581 -0
- data/app/assets/javascripts/decidim/comments/comments.js.erb +1 -1
- data/app/cells/decidim/comments/comment/actions.erb +7 -0
- data/app/cells/decidim/comments/comment/alignment_badge.erb +4 -0
- data/app/cells/decidim/comments/comment/author.erb +1 -0
- data/app/cells/decidim/comments/comment/show.erb +40 -0
- data/app/cells/decidim/comments/comment/utilities.erb +13 -0
- data/app/cells/decidim/comments/comment/votes.erb +25 -0
- data/app/cells/decidim/comments/comment_card_cell.rb +22 -0
- data/app/cells/decidim/comments/comment_cell.rb +142 -8
- data/app/cells/decidim/comments/comment_form/comment_as.erb +10 -0
- data/app/cells/decidim/comments/comment_form/show.erb +24 -0
- data/app/cells/decidim/comments/comment_form_cell.rb +94 -0
- data/app/cells/decidim/comments/comment_m/top.erb +1 -1
- data/app/cells/decidim/comments/comment_thread/show.erb +6 -0
- data/app/cells/decidim/comments/comment_thread/title.erb +3 -0
- data/app/cells/decidim/comments/comment_thread_cell.rb +30 -0
- data/app/cells/decidim/comments/comments/add_comment.erb +30 -0
- data/app/cells/decidim/comments/comments/blocked_comments_warning.erb +3 -0
- data/app/cells/decidim/comments/comments/order_control.erb +37 -0
- data/app/cells/decidim/comments/comments/show.erb +32 -0
- data/app/cells/decidim/comments/comments/single_comment_warning.erb +9 -0
- data/app/cells/decidim/comments/comments/user_comments_blocked_warning.erb +3 -0
- data/app/cells/decidim/comments/comments_cell.rb +134 -0
- data/app/commands/decidim/comments/vote_comment.rb +34 -10
- data/app/controllers/decidim/comments/application_controller.rb +16 -0
- data/app/controllers/decidim/comments/comments_controller.rb +122 -0
- data/app/controllers/decidim/comments/votes_controller.rb +41 -0
- data/app/events/decidim/comments/comment_created_event.rb +1 -1
- data/app/events/decidim/comments/comment_downvoted_event.rb +8 -0
- data/app/events/decidim/comments/comment_event.rb +0 -15
- data/app/events/decidim/comments/comment_upvoted_event.rb +8 -0
- data/app/events/decidim/comments/comment_voted_event.rb +26 -0
- data/app/forms/decidim/comments/comment_form.rb +6 -2
- data/app/models/decidim/comments/comment.rb +33 -11
- data/app/models/decidim/comments/seed.rb +1 -1
- data/app/permissions/decidim/comments/permissions.rb +59 -0
- data/app/queries/decidim/comments/metrics/comment_participants_metric_measure.rb +2 -2
- data/app/queries/decidim/comments/metrics/comments_metric_manage.rb +5 -6
- data/app/queries/decidim/comments/sorted_comments.rb +18 -14
- data/app/views/decidim/comments/comments/_comment.html.erb +5 -0
- data/app/views/decidim/comments/comments/_comments.html.erb +1 -0
- data/app/views/decidim/comments/comments/create.js.erb +16 -0
- data/app/views/decidim/comments/comments/error.js.erb +1 -0
- data/app/views/decidim/comments/comments/index.js.erb +24 -0
- data/app/views/decidim/comments/comments/reload.js.erb +21 -0
- data/app/views/decidim/comments/votes/create.js.erb +23 -0
- data/app/views/decidim/comments/votes/error.js.erb +1 -0
- data/config/locales/ar.yml +0 -2
- data/config/locales/ca.yml +17 -2
- data/config/locales/cs.yml +20 -3
- data/config/locales/de.yml +46 -30
- data/config/locales/el.yml +0 -2
- data/config/locales/en.yml +17 -2
- data/config/locales/es-MX.yml +17 -2
- data/config/locales/es-PY.yml +17 -2
- data/config/locales/es.yml +17 -2
- data/config/locales/eu.yml +0 -2
- data/config/locales/fi-plain.yml +17 -2
- data/config/locales/fi.yml +17 -2
- data/config/locales/fr-CA.yml +17 -2
- data/config/locales/fr.yml +17 -2
- data/config/locales/gl.yml +20 -2
- data/config/locales/hu.yml +0 -2
- data/config/locales/id-ID.yml +0 -2
- data/config/locales/is-IS.yml +0 -1
- data/config/locales/it.yml +5 -2
- data/config/locales/ja.yml +14 -10
- data/config/locales/lv.yml +0 -2
- data/config/locales/nl.yml +7 -9
- data/config/locales/no.yml +0 -2
- data/config/locales/pl.yml +22 -4
- data/config/locales/pt-BR.yml +0 -2
- data/config/locales/pt.yml +0 -2
- data/config/locales/ro-RO.yml +0 -2
- data/config/locales/ru.yml +0 -2
- data/config/locales/si-LK.yml +1 -0
- data/config/locales/sk.yml +0 -2
- data/config/locales/sv.yml +7 -2
- data/config/locales/sw-KE.yml +1 -0
- data/config/locales/tr-TR.yml +60 -35
- data/config/locales/uk.yml +0 -1
- data/config/locales/zh-CN.yml +0 -2
- data/lib/decidim/api/add_comment_type.rb +13 -0
- data/lib/decidim/api/comment_mutation_type.rb +22 -0
- data/lib/decidim/api/comment_type.rb +89 -0
- data/lib/decidim/api/commentable_interface.rb +50 -0
- data/lib/decidim/api/commentable_mutation_type.rb +30 -0
- data/{app/types/decidim/comments → lib/decidim/api}/commentable_type.rb +2 -5
- data/lib/decidim/comments.rb +1 -3
- data/lib/decidim/comments/api.rb +12 -0
- data/lib/decidim/comments/comments_helper.rb +10 -52
- data/lib/decidim/comments/engine.rb +9 -7
- data/lib/decidim/comments/mutation_extensions.rb +22 -22
- data/lib/decidim/comments/query_extensions.rb +12 -14
- data/lib/decidim/comments/test.rb +1 -0
- data/lib/decidim/comments/test/shared_examples/comment_voted_event.rb +65 -0
- data/lib/decidim/comments/version.rb +1 -1
- metadata +72 -69
- data/app/assets/javascripts/decidim/comments/bundle.js +0 -268
- data/app/frontend/application/apollo_client.ts +0 -12
- data/app/frontend/application/application.component.test.tsx +0 -23
- data/app/frontend/application/application.component.tsx +0 -35
- data/app/frontend/application/icon.component.test.tsx +0 -38
- data/app/frontend/application/icon.component.tsx +0 -46
- data/app/frontend/comments/add_comment_form.component.test.tsx +0 -265
- data/app/frontend/comments/add_comment_form.component.tsx +0 -482
- data/app/frontend/comments/comment.component.test.tsx +0 -490
- data/app/frontend/comments/comment.component.tsx +0 -677
- data/app/frontend/comments/comment_order_selector.component.test.tsx +0 -29
- data/app/frontend/comments/comment_order_selector.component.tsx +0 -106
- data/app/frontend/comments/comment_thread.component.test.tsx +0 -82
- data/app/frontend/comments/comment_thread.component.tsx +0 -81
- data/app/frontend/comments/comments.component.test.tsx +0 -150
- data/app/frontend/comments/comments.component.tsx +0 -289
- data/app/frontend/comments/down_vote_button.component.test.tsx +0 -59
- data/app/frontend/comments/down_vote_button.component.tsx +0 -133
- data/app/frontend/comments/up_vote_button.component.test.tsx +0 -59
- data/app/frontend/comments/up_vote_button.component.tsx +0 -133
- data/app/frontend/comments/vote_button.component.tsx +0 -50
- data/app/frontend/comments/vote_button_component.test.tsx +0 -64
- data/app/frontend/entry.ts +0 -38
- data/app/frontend/entry_test.ts +0 -6
- data/app/frontend/fragments/add_comment_form_commentable.fragment.graphql +0 -4
- data/app/frontend/fragments/add_comment_form_session.fragment.graphql +0 -6
- data/app/frontend/fragments/comment.fragment.graphql +0 -14
- data/app/frontend/fragments/comment_data.fragment.graphql +0 -27
- data/app/frontend/fragments/comment_thread.fragment.graphql +0 -6
- data/app/frontend/fragments/down_vote_button.fragment.graphql +0 -6
- data/app/frontend/fragments/up_vote_button.fragment.graphql +0 -6
- data/app/frontend/mutations/add_comment.mutation.graphql +0 -9
- data/app/frontend/mutations/down_vote.mutation.graphql +0 -9
- data/app/frontend/mutations/up_vote.mutation.graphql +0 -9
- data/app/frontend/queries/comments.query.graphql +0 -26
- data/app/frontend/support/asset_url.ts +0 -11
- data/app/frontend/support/generate_comments_data.ts +0 -49
- data/app/frontend/support/generate_user_data.ts +0 -14
- data/app/frontend/support/generate_user_group_data.ts +0 -14
- data/app/frontend/support/graphql_transformer.js +0 -32
- data/app/frontend/support/load_translations.ts +0 -48
- data/app/frontend/support/require_all.ts +0 -10
- data/app/frontend/support/resolve_graphql_query.ts +0 -37
- data/app/frontend/support/schema.ts +0 -2026
- data/app/types/decidim/comments/commentable_interface.rb +0 -61
- data/app/types/decidim/comments/commentable_mutation_type.rb +0 -33
- data/lib/decidim/comments/api/add_comment_type.rb +0 -13
- data/lib/decidim/comments/api/comment_mutation_type.rb +0 -20
- data/lib/decidim/comments/api/comment_type.rb +0 -89
@@ -1,59 +0,0 @@
|
|
1
|
-
import { shallow } from "enzyme";
|
2
|
-
import * as React from "react";
|
3
|
-
|
4
|
-
import { UpVoteButton } from "./up_vote_button.component";
|
5
|
-
import VoteButton from "./vote_button.component";
|
6
|
-
|
7
|
-
import generateCommentsData from "../support/generate_comments_data";
|
8
|
-
import generateUserData from "../support/generate_user_data";
|
9
|
-
|
10
|
-
import { UpVoteButtonFragment } from "../support/schema";
|
11
|
-
|
12
|
-
describe("<UpVoteButton />", () => {
|
13
|
-
const orderBy = "older";
|
14
|
-
const rootCommentable = {
|
15
|
-
id: "1",
|
16
|
-
type: "Decidim::DummyResources::DummyResource"
|
17
|
-
};
|
18
|
-
let comment: UpVoteButtonFragment;
|
19
|
-
let session: any = null;
|
20
|
-
const upVote = jasmine.createSpy("upVote");
|
21
|
-
|
22
|
-
beforeEach(() => {
|
23
|
-
const commentsData = generateCommentsData(1);
|
24
|
-
session = {
|
25
|
-
user: generateUserData()
|
26
|
-
};
|
27
|
-
comment = commentsData[0];
|
28
|
-
});
|
29
|
-
|
30
|
-
it("should render a VoteButton component with the correct props", () => {
|
31
|
-
const wrapper = shallow(<UpVoteButton session={session} comment={comment} upVote={upVote} rootCommentable={rootCommentable} orderBy={orderBy} />);
|
32
|
-
expect(wrapper.find(VoteButton).prop("buttonClassName")).toEqual("comment__votes--up");
|
33
|
-
expect(wrapper.find(VoteButton).prop("iconName")).toEqual("icon-chevron-top");
|
34
|
-
expect(wrapper.find(VoteButton).prop("votes")).toEqual(comment.upVotes);
|
35
|
-
});
|
36
|
-
|
37
|
-
it("should pass disabled prop as false if comment upVoted is true", () => {
|
38
|
-
comment.upVoted = true;
|
39
|
-
const wrapper = shallow(<UpVoteButton session={session} comment={comment} upVote={upVote} rootCommentable={rootCommentable} orderBy={orderBy} />);
|
40
|
-
expect(wrapper.find(VoteButton).prop("disabled")).toBeFalsy();
|
41
|
-
});
|
42
|
-
|
43
|
-
it("should pass disabled prop as false if comment downVoted is true", () => {
|
44
|
-
comment.downVoted = true;
|
45
|
-
const wrapper = shallow(<UpVoteButton session={session} comment={comment} upVote={upVote} rootCommentable={rootCommentable} orderBy={orderBy} />);
|
46
|
-
expect(wrapper.find(VoteButton).prop("disabled")).toBeFalsy();
|
47
|
-
});
|
48
|
-
|
49
|
-
describe("when session is not present", () => {
|
50
|
-
beforeEach(() => {
|
51
|
-
session = null;
|
52
|
-
});
|
53
|
-
|
54
|
-
it("should pass userLoggedIn as false", () => {
|
55
|
-
const wrapper = shallow(<UpVoteButton session={session} comment={comment} upVote={upVote} rootCommentable={rootCommentable} orderBy={orderBy} />);
|
56
|
-
expect(wrapper.find(VoteButton).prop("userLoggedIn")).toBeFalsy();
|
57
|
-
});
|
58
|
-
});
|
59
|
-
});
|
@@ -1,133 +0,0 @@
|
|
1
|
-
import * as React from "react";
|
2
|
-
import { graphql, MutationFunc } from "react-apollo";
|
3
|
-
|
4
|
-
const PropTypes = require("prop-types");
|
5
|
-
|
6
|
-
import VoteButton from "./vote_button.component";
|
7
|
-
|
8
|
-
const { I18n } = require("react-i18nify");
|
9
|
-
|
10
|
-
import {
|
11
|
-
AddCommentFormCommentableFragment,
|
12
|
-
AddCommentFormSessionFragment,
|
13
|
-
CommentFragment,
|
14
|
-
GetCommentsQuery,
|
15
|
-
UpVoteButtonFragment,
|
16
|
-
UpVoteMutation
|
17
|
-
} from "../support/schema";
|
18
|
-
|
19
|
-
interface UpVoteButtonProps {
|
20
|
-
session: AddCommentFormSessionFragment & {
|
21
|
-
user: any;
|
22
|
-
} | null;
|
23
|
-
comment: UpVoteButtonFragment;
|
24
|
-
upVote?: (context: any) => void;
|
25
|
-
rootCommentable: AddCommentFormCommentableFragment;
|
26
|
-
orderBy: string;
|
27
|
-
}
|
28
|
-
|
29
|
-
export const UpVoteButton: React.SFC<UpVoteButtonProps> = (
|
30
|
-
{
|
31
|
-
session,
|
32
|
-
comment: { upVotes, upVoted, downVoted },
|
33
|
-
upVote
|
34
|
-
},
|
35
|
-
context) => {
|
36
|
-
let selectedClass = "";
|
37
|
-
|
38
|
-
if (upVoted) {
|
39
|
-
selectedClass = "is-vote-selected";
|
40
|
-
} else if (downVoted) {
|
41
|
-
selectedClass = "is-vote-notselected";
|
42
|
-
}
|
43
|
-
|
44
|
-
const userLoggedIn = session && session.user;
|
45
|
-
const disabled = false;
|
46
|
-
const voteAction = () => upVote && upVote(context);
|
47
|
-
|
48
|
-
return (
|
49
|
-
<VoteButton
|
50
|
-
buttonClassName="comment__votes--up"
|
51
|
-
iconName="icon-chevron-top"
|
52
|
-
text={I18n.t("components.up_vote_button.text")}
|
53
|
-
votes={upVotes}
|
54
|
-
voteAction={voteAction}
|
55
|
-
disabled={disabled}
|
56
|
-
selectedClass={selectedClass}
|
57
|
-
userLoggedIn={userLoggedIn}
|
58
|
-
/>
|
59
|
-
);
|
60
|
-
};
|
61
|
-
|
62
|
-
UpVoteButton.contextTypes = {
|
63
|
-
locale: PropTypes.string,
|
64
|
-
toggleTranslations: PropTypes.bool
|
65
|
-
};
|
66
|
-
|
67
|
-
const upVoteMutation = require("../mutations/up_vote.mutation.graphql");
|
68
|
-
const getCommentsQuery = require("../queries/comments.query.graphql");
|
69
|
-
|
70
|
-
const UpVoteButtonWithMutation = graphql<UpVoteMutation, UpVoteButtonProps>(upVoteMutation, {
|
71
|
-
props: ({ ownProps, mutate }: { ownProps: UpVoteButtonProps, mutate: MutationFunc<UpVoteMutation> }) => ({
|
72
|
-
upVote: ({ locale, toggleTranslations }: any) => mutate({
|
73
|
-
variables: {
|
74
|
-
locale,
|
75
|
-
toggleTranslations,
|
76
|
-
id: ownProps.comment.id
|
77
|
-
},
|
78
|
-
optimisticResponse: {
|
79
|
-
__typename: "Mutation",
|
80
|
-
comment: {
|
81
|
-
__typename: "CommentMutation",
|
82
|
-
upVote: {
|
83
|
-
__typename: "Comment",
|
84
|
-
...ownProps.comment,
|
85
|
-
upVotes: ownProps.comment.upVotes + (ownProps.comment.upVoted ? -1 : 1),
|
86
|
-
upVoted: true
|
87
|
-
}
|
88
|
-
}
|
89
|
-
},
|
90
|
-
update: (store, { data }: { data: UpVoteMutation }) => {
|
91
|
-
const variables = {
|
92
|
-
locale,
|
93
|
-
toggleTranslations,
|
94
|
-
commentableId: ownProps.rootCommentable.id,
|
95
|
-
commentableType: ownProps.rootCommentable.type,
|
96
|
-
orderBy: ownProps.orderBy,
|
97
|
-
singleCommentId: null
|
98
|
-
};
|
99
|
-
|
100
|
-
const commentReducer = (comment: CommentFragment): CommentFragment => {
|
101
|
-
const replies = comment.comments || [];
|
102
|
-
|
103
|
-
if (comment.id === ownProps.comment.id && data.comment) {
|
104
|
-
return data.comment.upVote;
|
105
|
-
}
|
106
|
-
|
107
|
-
return {
|
108
|
-
...comment,
|
109
|
-
comments: replies.map(commentReducer)
|
110
|
-
};
|
111
|
-
};
|
112
|
-
|
113
|
-
const prev = store.readQuery<GetCommentsQuery>({ query: getCommentsQuery, variables });
|
114
|
-
|
115
|
-
if (prev) {
|
116
|
-
store.writeQuery({
|
117
|
-
query: getCommentsQuery,
|
118
|
-
data: {
|
119
|
-
...prev,
|
120
|
-
commentable: {
|
121
|
-
...prev.commentable,
|
122
|
-
comments: prev.commentable.comments.map(commentReducer)
|
123
|
-
}
|
124
|
-
},
|
125
|
-
variables
|
126
|
-
});
|
127
|
-
}
|
128
|
-
}
|
129
|
-
})
|
130
|
-
})
|
131
|
-
})(UpVoteButton);
|
132
|
-
|
133
|
-
export default UpVoteButtonWithMutation;
|
@@ -1,50 +0,0 @@
|
|
1
|
-
import * as React from "react";
|
2
|
-
import Icon from "../application/icon.component";
|
3
|
-
|
4
|
-
interface VoteButtonProps {
|
5
|
-
buttonClassName: string;
|
6
|
-
iconName: string;
|
7
|
-
text: string;
|
8
|
-
votes: number;
|
9
|
-
voteAction?: () => void;
|
10
|
-
disabled?: boolean;
|
11
|
-
selectedClass?: string;
|
12
|
-
userLoggedIn: boolean;
|
13
|
-
}
|
14
|
-
|
15
|
-
const preventDefault = (event: any) => {
|
16
|
-
event.preventDefault();
|
17
|
-
};
|
18
|
-
|
19
|
-
const VoteButton: React.SFC<VoteButtonProps> = ({
|
20
|
-
buttonClassName,
|
21
|
-
iconName,
|
22
|
-
text,
|
23
|
-
votes,
|
24
|
-
voteAction,
|
25
|
-
disabled,
|
26
|
-
selectedClass,
|
27
|
-
userLoggedIn
|
28
|
-
}) => (
|
29
|
-
<button
|
30
|
-
className={`${buttonClassName} ${selectedClass}`}
|
31
|
-
onClick={userLoggedIn ? voteAction : preventDefault}
|
32
|
-
disabled={disabled}
|
33
|
-
title={text}
|
34
|
-
data-open={userLoggedIn ? null : "loginModal"}
|
35
|
-
>
|
36
|
-
<span className="show-for-sr">{text}</span>
|
37
|
-
<Icon name={iconName} iconExtraClassName="icon--small" />
|
38
|
-
{` ${votes}`}
|
39
|
-
</button>
|
40
|
-
);
|
41
|
-
|
42
|
-
VoteButton.defaultProps = {
|
43
|
-
buttonClassName: "",
|
44
|
-
iconName: "",
|
45
|
-
votes: 0,
|
46
|
-
selectedClass: "selected",
|
47
|
-
disabled: false
|
48
|
-
};
|
49
|
-
|
50
|
-
export default VoteButton;
|
@@ -1,64 +0,0 @@
|
|
1
|
-
import { shallow } from "enzyme";
|
2
|
-
import * as React from "react";
|
3
|
-
import Icon from "../application/icon.component";
|
4
|
-
import VoteButton from "./vote_button.component";
|
5
|
-
|
6
|
-
describe("<VoteButton />", () => {
|
7
|
-
const voteAction: jasmine.Spy = jasmine.createSpy("voteAction");
|
8
|
-
const preventDefault: jasmine.Spy = jasmine.createSpy("preventDefault");
|
9
|
-
|
10
|
-
beforeEach(() => {
|
11
|
-
voteAction.calls.reset();
|
12
|
-
preventDefault.calls.reset();
|
13
|
-
});
|
14
|
-
|
15
|
-
it("should render the number of votes passed as a prop", () => {
|
16
|
-
const wrapper = shallow(<VoteButton votes={10} buttonClassName="vote-button" iconName="vote-icon" text="Test" voteAction={voteAction} userLoggedIn={true} />);
|
17
|
-
expect(wrapper.find("button").text()).toMatch(/10/);
|
18
|
-
});
|
19
|
-
|
20
|
-
it("should render a button with the given buttonClassName", () => {
|
21
|
-
const wrapper = shallow(<VoteButton votes={10} buttonClassName="vote-button" iconName="vote-icon" text="Test" voteAction={voteAction} userLoggedIn={true} />);
|
22
|
-
expect(wrapper.find("button.vote-button").exists()).toBeTruthy();
|
23
|
-
});
|
24
|
-
|
25
|
-
it("should render a Icon component with the correct name prop", () => {
|
26
|
-
const wrapper = shallow(<VoteButton votes={10} buttonClassName="vote-button" iconName="vote-icon" text="Test" voteAction={voteAction} userLoggedIn={true} />);
|
27
|
-
expect(wrapper.find(Icon).prop("name")).toEqual("vote-icon");
|
28
|
-
});
|
29
|
-
|
30
|
-
it("should render a button with the text as title attribute and screen reader visible element", () => {
|
31
|
-
const wrapper = shallow(<VoteButton votes={10} buttonClassName="vote-button" iconName="vote-icon" text="Test" voteAction={voteAction} userLoggedIn={true} />);
|
32
|
-
expect(wrapper.find("button").prop("title")).toBe("Test");
|
33
|
-
expect(wrapper.find("button span.show-for-sr").text()).toEqual("Test");
|
34
|
-
});
|
35
|
-
|
36
|
-
it("should call the voteAction prop on click", () => {
|
37
|
-
const wrapper = shallow(<VoteButton votes={10} buttonClassName="vote-button" iconName="vote-icon" text="Test" voteAction={voteAction} userLoggedIn={true} />);
|
38
|
-
wrapper.find("button").simulate("click");
|
39
|
-
expect(voteAction).toHaveBeenCalled();
|
40
|
-
});
|
41
|
-
|
42
|
-
it("should disable the button based on the disabled prop", () => {
|
43
|
-
const wrapper = shallow(<VoteButton votes={10} buttonClassName="vote-button" iconName="vote-icon" text="Test" voteAction={voteAction} disabled={true} userLoggedIn={true} />);
|
44
|
-
expect(wrapper.find("button").props()).toHaveProperty("disabled");
|
45
|
-
});
|
46
|
-
|
47
|
-
it("should render a button with the given selectedClass", () => {
|
48
|
-
const wrapper = shallow(<VoteButton votes={10} buttonClassName="vote-button" iconName="vote-icon" text="Test" voteAction={voteAction} disabled={true} selectedClass="is-vote-selected" userLoggedIn={true} />);
|
49
|
-
expect(wrapper.find(".is-vote-selected").exists()).toBeTruthy();
|
50
|
-
});
|
51
|
-
|
52
|
-
describe("when userLoggedIn prop is false", () => {
|
53
|
-
it("should add data-open prop as 'loginModal' to the button", () => {
|
54
|
-
const wrapper = shallow(<VoteButton votes={10} buttonClassName="vote-button" iconName="vote-icon" text="Test" voteAction={voteAction} userLoggedIn={false} />);
|
55
|
-
expect(wrapper.find("button").prop("data-open")).toBe("loginModal");
|
56
|
-
});
|
57
|
-
|
58
|
-
it("should call the event preventDefault method", () => {
|
59
|
-
const wrapper = shallow(<VoteButton votes={10} buttonClassName="vote-button" iconName="vote-icon" text="Test" voteAction={voteAction} userLoggedIn={false} />);
|
60
|
-
wrapper.find("button").simulate("click", { preventDefault });
|
61
|
-
expect(preventDefault).toHaveBeenCalled();
|
62
|
-
});
|
63
|
-
});
|
64
|
-
});
|
data/app/frontend/entry.ts
DELETED
@@ -1,38 +0,0 @@
|
|
1
|
-
import * as React from "react";
|
2
|
-
import * as ReactDOM from "react-dom";
|
3
|
-
|
4
|
-
import Comments, { CommentsApplicationProps } from "./comments/comments.component";
|
5
|
-
import loadTranslations from "./support/load_translations";
|
6
|
-
|
7
|
-
window.DecidimComments = window.DecidimComments || {};
|
8
|
-
|
9
|
-
interface StorageDict {
|
10
|
-
[key: string]: string;
|
11
|
-
}
|
12
|
-
|
13
|
-
window.DecidimComments.renderCommentsComponent = (nodeId: string, props: CommentsApplicationProps) => {
|
14
|
-
const node = window.$(`#${nodeId}`)[0];
|
15
|
-
const queryDict: StorageDict = {};
|
16
|
-
window
|
17
|
-
.location
|
18
|
-
.search
|
19
|
-
.substr(1)
|
20
|
-
.split("&")
|
21
|
-
.forEach(item => queryDict[item.split("=")[0]] = item.split("=")[1]);
|
22
|
-
|
23
|
-
props = { ...props, singleCommentId: queryDict.commentId };
|
24
|
-
|
25
|
-
ReactDOM.render(
|
26
|
-
React.createElement(Comments, props),
|
27
|
-
node
|
28
|
-
);
|
29
|
-
|
30
|
-
if (queryDict.commentId) {
|
31
|
-
$([document.documentElement, document.body]).animate({
|
32
|
-
scrollTop: $("#comments").offset()!.top
|
33
|
-
}, 2000);
|
34
|
-
}
|
35
|
-
};
|
36
|
-
|
37
|
-
// Load component locales from yaml files
|
38
|
-
loadTranslations();
|
data/app/frontend/entry_test.ts
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
#import "../fragments/up_vote_button.fragment.graphql"
|
2
|
-
#import "../fragments/down_vote_button.fragment.graphql"
|
3
|
-
|
4
|
-
fragment CommentData on Comment {
|
5
|
-
id
|
6
|
-
sgid
|
7
|
-
type
|
8
|
-
body
|
9
|
-
formattedBody
|
10
|
-
createdAt
|
11
|
-
formattedCreatedAt
|
12
|
-
author {
|
13
|
-
name
|
14
|
-
nickname
|
15
|
-
avatarUrl
|
16
|
-
profilePath
|
17
|
-
deleted
|
18
|
-
badge
|
19
|
-
}
|
20
|
-
hasComments
|
21
|
-
acceptsNewComments
|
22
|
-
userAllowedToComment
|
23
|
-
alignment
|
24
|
-
alreadyReported
|
25
|
-
...UpVoteButton
|
26
|
-
...DownVoteButton
|
27
|
-
}
|
@@ -1,9 +0,0 @@
|
|
1
|
-
#import "../fragments/comment_thread.fragment.graphql"
|
2
|
-
|
3
|
-
mutation addComment($commentableId: String!, $commentableType: String!, $body: String!, $alignment: Int, $userGroupId: ID, $locale: String!, $toggleTranslations: Boolean!) {
|
4
|
-
commentable(id: $commentableId, type: $commentableType, locale: $locale, toggleTranslations: $toggleTranslations) {
|
5
|
-
addComment(body: $body, alignment: $alignment, userGroupId: $userGroupId) {
|
6
|
-
...CommentThread
|
7
|
-
}
|
8
|
-
}
|
9
|
-
}
|