Skip to content

Add basic comments module#250

Merged
josepjaume merged 91 commits intomasterfrom
feature/comments-module
Dec 12, 2016
Merged

Add basic comments module#250
josepjaume merged 91 commits intomasterfrom
feature/comments-module

Conversation

@beagleknight
Copy link
Copy Markdown
Contributor

@beagleknight beagleknight commented Nov 17, 2016

🎩 What? Why?

This adds the engine decidim-comments and will add the capability to add comments to any component using a simple Rails helper like this:

<%= comments_for @proposal %>

This is the first engine using frontend components with React. Since is an isolated engine it's using its own way to compile assets merging the Rails assets pipeline with Webpack.

We are gonna start simple: just one level of hierarchy without extra features like voting or arguing comments.

📋 Related documentation

📌 Related Issues

📋 Subtasks

  • Basic static components
  • Components test suite
  • Make components dynamic using Apollo Client
  • Create comments backend
  • Add types to GraphQL schema
  • Seeds
  • Add comment form
  • Add addComment command
  • Add feature tests
  • Pagination (out of scope for this pr)
  • I18n
  • Authentication (out of scope for this pr, fallback to cookies)
  • What do with bundle.js
  • Documentation

📷 Screenshots (optional)

None

👻 GIF

None

@mention-bot
Copy link
Copy Markdown

@beagleknight, thanks for your PR! By analyzing the history of the files in this pull request, we identified @josepjaume, @oriolgual and @mrcasals to be potential reviewers.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing top-level module documentation comment.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Final newline missing.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indent the first parameter one step more than options.merge!(.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing top-level module documentation comment.

@beagleknight beagleknight changed the title Feature/comments module Add basic comments module Nov 17, 2016
@beagleknight beagleknight force-pushed the feature/comments-module branch from f823abe to e80c261 Compare November 21, 2016 10:32
@codecov-io
Copy link
Copy Markdown

codecov-io commented Nov 21, 2016

Current coverage is 61.00% (diff: 100%)

Merging #250 into master will increase coverage by 0.28%

@@             master       #250   diff @@
==========================================
  Files          2976       3053     +77   
  Lines        122687     123694   +1007   
  Methods           0          0           
  Messages          0          0           
  Branches          0          0           
==========================================
+ Hits          74495      75456    +961   
- Misses        48192      48238     +46   
  Partials          0          0           

Powered by Codecov. Last update 24aa8b5...a6022db

@beagleknight beagleknight force-pushed the feature/comments-module branch from d07c5bc to fd76c2c Compare November 21, 2016 13:46
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing top-level module documentation comment.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing top-level module documentation comment.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indent the first parameter one step more than options.merge!(.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indent the first parameter one step more than options.merge!(.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing top-level module documentation comment.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing top-level module documentation comment.

@beagleknight beagleknight force-pushed the feature/comments-module branch from 67cc7fa to 30f9b07 Compare November 24, 2016 08:27
field :body, !types.String, "The comment message"
end
end
end No newline at end of file
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Final newline missing.

end
end
end
end No newline at end of file
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Final newline missing.

@@ -0,0 +1,12 @@
module Decidim
module Comments
class Comment
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing top-level class documentation comment.

type !types[ CommentType]
description "Lists all comments."

resolve -> (_obj, _args, ctx) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused block argument - ctx. If it's necessary, use _ or _ctx as an argument name to indicate that it won't be used. Also consider using a proc without arguments instead of a lambda if you want it to accept any arguments but don't care about them.

end

field :comments do
type !types[ CommentType]
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Space inside square brackets detected.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Final newline missing.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use the lambda method for multiline lambdas.
Unused block argument - ctx. If it's necessary, use _ or _ctx as an argument name to indicate that it won't be used.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Final newline missing.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use snake_case for variable names.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Final newline missing.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing frozen string literal comment.

@beagleknight beagleknight force-pushed the feature/comments-module branch 3 times, most recently from 6b0ed7d to 8faf977 Compare December 11, 2016 18:11
let!(:participatory_process) { create(:participatory_process, organization: current_organization) }

let(:query) {
"{ addComment(commentableId: \"#{participatory_process.id}\", commentableType: \"Decidim::ParticipatoryProcess\", body: \"This is a new comment\") { id, body } }"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It feels weird to me that the frontend knows internals of the backend (ie the name of the class of the participatory process). The CommentsHelper sets automatically this field (resource.class.name), but it still feels weird to me that the frontend knows these things. If we want to make a mobile app that is not linked with the Rails backend, so that it can't set resource.class.name, then the mobile app needs to know the name of the Rails class.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rather have an addProcessComments(id, body), or an addComments scoped to a process(it that exists in GraphQL)

Copy link
Copy Markdown
Contributor Author

@beagleknight beagleknight Dec 12, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with you. We can tweak de API in a future PR. It's not a big deal because graphql and apollo make changes easy 😄

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add an issue for this.

let!(:participatory_process) { create(:participatory_process, organization: current_organization) }

let(:query) {
"{ addComment(commentableId: \"#{participatory_process.id}\", commentableType: \"Decidim::ParticipatoryProcess\", body: \"This is a new comment\") { id, body } }"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rather have an addProcessComments(id, body), or an addComments scoped to a process(it that exists in GraphQL)

attr_reader :form

def create_comment
@comment = Comment.create(author: @author,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be create!

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to solve this before merging

Gem::Specification.new do |s|
Decidim.add_default_gemspec_properties(s)

s.files = Dir["{app,config,db,lib,vendor}/**/*", "LICENSE.txt", "Rakefile", "README.md"]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The LICENSE.txt file does not exist.


field :name, types.String, "The user's name"
end
end No newline at end of file
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Final newline missing.

#
# Returns a div which contain a RectComponent to be rendered by `react_ujs`
def comments_for(resource)
react_component("Comments", commentableType: resource.class.name, commentableId: resource.id.to_s, locale: I18n.locale) + javascript_include_tag("decidim/comments/comments")
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line is too long. [181/180]

describe "currentUser" do
let(:query) { "{ currentUser { name } } " }

context "If the user is logged in" do
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/if/when pleaseeeee

end
end

context "If the user is not logged in" do
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/if/when pleaseeeee


helper.comments_for(commentable)
end
it "should render the react component `Comments` with the correct data" do
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/should render/renders

# This type represents a User.
UserType = GraphQL::ObjectType.define do
name "User"
description "An user"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/An/A


field :currentUser do
type UserType
description "Return's information about the user logged in"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/about the user logged in/about the logged in user

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use snake_case for variable names.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use snake_case for variable names.

@beagleknight beagleknight force-pushed the feature/comments-module branch from ecef8ed to a6022db Compare December 12, 2016 11:18
@josepjaume josepjaume merged commit 5f3d15b into master Dec 12, 2016
@josepjaume josepjaume deleted the feature/comments-module branch December 12, 2016 13:53
@mrcasals mrcasals mentioned this pull request Dec 12, 2016
2 tasks
@mrcasals mrcasals mentioned this pull request Mar 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants