Gitea: [UI] Group Label Changed Comments in timeline

Created on 22 Oct 2020  路  18Comments  路  Source: go-gitea/gitea

group label changes witch are only 1-2sec away from each other ...

at the moment:

Screenshot at 2020-10-22 19-06-42

with proposed feature:

Screenshot at 2020-10-22 19-06-22

Hacktoberfest kinproposal kinui

Most helpful comment

it puts a 1 in the comment field if it was added, nothing if it was deleted so you could check with

 if comment.Content {
    /*added*/ } else {
    /* deleted */ 
 }

All 18 comments

:point_up: as gh does it too :) - save space

Mind if I take this? It'd be good if I can get some pointers too, but I think I can figure it out on my own

I've gone into the translation and added issues.add_labels_at, but I assume I will need some sort of macro for the label badge in order to loop them, since AFAIK the translations aren't static. should I add another option to comments.tmpl for the multiple badges in-line?

You should probably figure out the overal design/plan first if you have questions as "some sort of macro" would be the entire problem to solve here -- golang template loops are super limited to just range unfortunately and our design currently is based on ranging one entry at a time inside template which makes this problem more annoying than it should be : (

I'm thinking having the loop over the labels on the function that actually calls the template, then this way we avoid looping inside the template.

The template loops over ever single "comment" entry for an issue, some of which will be "xx added y label" type comments" and they are all stored as individual comment entries in the db. there is no individual label loop

Oh no that isn't what I meant, I meant that before we pass the comments along to the template, we find the labels that were added at the same time and group them together into one "comment". Seems like the most feasible option to me.

Okay, so here's what I'm doing:

  1. Create a new comment type (I guess comment type 32, to not mess with the rest of the types) that has multiple issues wrapped into a single "comment"

    • Alternatively, I can put this into the original issue comment type, and have an array of issues instead of a single, if multiple are wrapped into one. This might be a better way, just check if there is more than one issue on the comment.

  2. Create a function to filter through the comments that wraps multiple issues added by the same person in the span of ~30s into a single comment.
  3. Create a function to be called from the template that creates the HTML for the issue tags, instead of relying on that HTML being inside the translation.

What do you think?

Also, I think this might mess with the translations, should I add a new translation string? Since non-up-to-date translations will have the HTML for the label, which will now be inserted with a function.

@pta2002 Yes, please.

Should I add a "Labels" field to the Comment model?

So something like:

type Comment struct {
  ...
  Labels  []*Label
  ...
}

I think you can add a function like GetGroupedLabels() for the Comment type witch return []*Label ... this way the struct dont get more overloaded and you still be able to use it in the template

How'd this work? Something like this wouldn't filter out the other label comments from getting passed into the view.

I'm trying to check how the "removed" comments work, but as far as I can tell it checks for the Content field in the Label struct. What does this field contain? How should I check if a comment is for an added Label or for a removed Label?

it puts a 1 in the comment field if it was added, nothing if it was deleted so you could check with

 if comment.Content {
    /*added*/ } else {
    /* deleted */ 
 }

How'd this work? Something like this wouldn't filter out the other label comments from getting passed into the view.

Hmm in the end adding a Labels []*Labels `xorm:"-"` field to Comment struct + new CommentType is the easyest way of doing so...

Closed since #13304 merged.

Was this page helpful?
0 / 5 - 0 ratings