Git Merge Request #308: Adding Reaction support (merged)

Merging...

Merged

Something went wrong. Please, merge manually

Checking if merge is possible...

Something went wrong. Please, merge manually

Shalitha Suranga wants to merge 12 commits from /u/shalithasuranga/allura/ to master, 2018-11-08

This is for [#8253]. Can someone check this approach and test. I created a mixin ReactableArtificat that applies to comments

Commit Date  
[749724] (patch10) by Shalitha Suranga Shalitha Suranga

[#8253] Add emoji setting info to development.ini

2018-11-08 06:06:17 Tree
[617e03] by Shalitha Suranga Shalitha Suranga

[#8253] Remove unwanted emoji unicode response

2018-11-08 06:05:20 Tree
[18f916] by Shalitha Suranga Shalitha Suranga

[#8253] Chunk assertions to lines

2018-11-05 08:07:54 Tree
[cf46ff] by Shalitha Suranga Shalitha Suranga

[#8253] Refactor logic and cleanup codes

2018-11-05 08:07:19 Tree
[3a9618] by Shalitha Suranga Shalitha Suranga

Merge branch 'patch10' of https://forge-allura.apache.org/git/u/shalithasuranga/allura into patch10

2018-11-05 05:49:23 Tree
[07bf03] by Shalitha Suranga Shalitha Suranga

Merge branch 'master' of https://git-wip-us.apache.org/repos/asf/allura into patch10

2018-11-05 05:40:36 Tree
[9b57b7] by Shalitha Shalitha

[#8253] Refactor codes and customizable emojis for reactions

2018-11-01 09:48:50 Tree
[dfe980] by Shalitha Suranga Shalitha Suranga

[#8253] Add unit cases for reaction endpoint

2018-10-31 08:55:04 Tree
[983158] by Shalitha Shalitha

[#8253] Adding reaction support for UI

2018-10-30 16:36:07 Tree
[294b80] by Shalitha Shalitha

[#8253] Adding reaction scripts to base

2018-10-30 16:35:34 Tree
[9f274a] by Shalitha Shalitha

[#8253] JSON Endpoint for reactions

2018-10-30 16:34:01 Tree
[13a384] by Shalitha Shalitha

[#8253] Adding Reactable artifact class

2018-10-30 16:32:04 Tree

Discussion

  • Updated with some unit tests

     
  • Dave Brondsema

    Dave Brondsema - 2018-10-31

    We should be thoughtful about the reactions list: 'thumbs_up', 'thumbs_down', 'laugh', 'hooray', 'confused', 'heart' Looks like the same ones GitHub offers. GitLab lets people pick any emoji at all. Should we consider more, or less? "laugh" surprised me, it is just a smile when GitHub renders it. I think we should call it "smile" since that's what the emoji is. And also "tada" instead of "hooray"? One idea would be to make it configurable for site administrators via a .ini setting. One of allura's strengths is its flexibility and customizability, so that might be a nice way to do it. Another thought would be to let every project customize it, but that seems like too much probably.

    Maybe the counts should be a dictionary like react_users is, so that it can be more flexible if any are added or removed later. Would also make some methods like update_react_count a bit simpler.

    Although VotableArtifact has a __mongometa__ too, neither get used since they are mixins. The data gets stored in the main class' collection, not vote or reaction. So probably good to remove those.

    I'll test a bit more thoroughly after you look into those things too.

     
  • Hi..Dave.

    I just hard coded current emoji list because this related merge request mentioned Github's reaction list. I also think customizablity via ini is good feature.

    Appreaciate your ideas and made updates as per below

    • User can override default emoji list by setting eg: reactions.emoji_list = :+1:, :-1:, :smile: in config ini. I just currently splitting value do we need to validate it ?
    • changed persistant data structure as dict for counts
    • made update_react_count by adding boolean parameter
    • Update test cases (Currently I have added few cases I will check more situations and add if needed)
    • removed counts and user lists when those gets 0 and [] respectively

    Notices

    I had to use utils.py to add a common method. moved js code from allura-base to widget since it is dynamic. updated app_globals with emojize method because it is required inside jinja templates

    Can you advice regarding the changes

    Thanks

     
  • Dave Brondsema

    Dave Brondsema - 2018-11-02

    Hey Shalitha,

    This is great as far as functionality and configuration go. Mostly feedback on code setup / cleanup:

    • JS inside of python files isn't a great pattern, even though there are many places in the code that do it. Can it be moved out into a regular .js file, so we promote better patterns? Classes and data- attributes can be a way to provide values that currently are dynamic inserted with %s.
    • Also onclick isn't ideal, although allura code in other places does it too. Better to have regular .js file do some jquery with the class selectors.
    • get_reaction_tooltip_content and other places use backticks aka template literals, but those aren't quite supported everywhere, so it'd be nice to not use them, so IE works still. https://caniuse.com/#feat=template-literals
    • another option that could help is to output a global JS variable once from a master template and then reference it from the .js file: var reactions = {{h.escape_json(reactions)|safe}};
    • in the tests, instead of assert ... and .. and .. can you split those into separate statements? That when when a test fails its clear exactly which part the problem is.

    For the config setting, splitting it without validation is fine. If someone makes a mistake, its only site administrators and they can fix it :) What I would do though is put a reactions.emoji_list example in development.ini like we do for other settings so people can find it and see how it works.

    If you wanted to add more functionality at this point, it could be nice to indicate which reaction you currently have. And be able to click on it to remove it.

    Getting excited 😁

     
  • Hi.. Dave

    Thanks for the feedback. Please check these modifications done...

    • move js snippet to reactions.js in widgets and it will be linked via Thread widget
    • added JQuery onclick instead onclick html event
    • Removed backticks and replaced with single quotation
    • Added global variable global_reactions via Thread widget and moved modified function to utils
    • chunked logical assertions in to lines
     
    • current reaction display can be done simply checking user in react_users dict. But will it afect performance if there are huge list of comments? Better to do in another ticket + MR?

       
      • Dave Brondsema

        Dave Brondsema - 2018-11-05

        A separate ticket for currrent reaction makes sense. Regarding performance, I don't think it'll be a problem unless there are thousands of reactions or more. Once data is in memory, looping through is quite quick.

         
        • Okay. Agree I will go with separate ticket after we add this one

           
  • Also emoji_unicode in json response is no longer needed since we already have list of emojis as a global var. Can we remove it from response. but there is rare situation when user reacts and at the same time admin changes emoji list

    What do you think?

     
    • Dave Brondsema

      Dave Brondsema - 2018-11-05

      Yea I think that situation would be extremely rare, so cleaning that up would be fine.

      Can you put a reactions.emoji_list example in development.ini like we do for other settings so people can find it and see how it works.

      Then I think we're good to go with this

       
      • Okay Thanks. I will do the cleaning and ini modification

         
    • Summary: Adding Reaction support - Updating --> Adding Reaction support
     
  • Hi.. Dave

    I updated branch with modifications please check

    👍

     
  • Dave Brondsema

    Dave Brondsema - 2018-11-08

    🥳

     
  • Dave Brondsema

    Dave Brondsema - 2018-11-08
    • Status: open --> merged
     
    👍
    1

Log in to post a comment.