[GH-484] Add Collapsed Flag + Make Flags Accept Boolean - #545
rinkimekari wants to merge 6 commits into
Conversation
|
Hello @rinkimekari, Thanks for your pull request! A Core Committer will review your pull request soon. For code contributions, you can learn more about the review process here. |
|
@rinkimekari That you very much for the constitution 👍 Could you please outline what the difference between your PR and #534 is? |
|
@hanzei Obviously the info changes based on the event. Another thing is that my pull request makes it easier for future flags to implement arguments. Also another difference is that I implemented parsing for the flags so it tells the user if they used an invalid flag and helps them use it correctly. With some adjustments to fit the new flag parsing I made, the title-only flag can also be added as an option for those who want the least amount of screen real estate used. They wouldn't conflict with each other, though there should probably be a check to see if both are enabled and respond accordingly. PS: I was going to try out the title-only flag using the submitted branch for further comparison, but I can't seem to get it to work. Is it working for you?
Edit for clarity: I can deploy the plugin and autocomplete for the flag works perfectly, but when using the flag, it still shows the normal large messages. I'll put my issues in the PR so the submitter can view them. Edit again: I read some more code and I was wrong about it not acting based on subscriptions. My bad. |
|
@hanzei #484 and #470 seem to be duplicate tickets, which this PR and the #484, the issue linked in this PR, was claimed over a month ago by the author of this PR. It seems we have duplicate work submitted between these PRs. The other PR states it is "title-only", but reading the code of the PR, it looks like it indeed contains the PR author's name etc. So it seems we have have duplicate PRs here. How should we handle this case when we have duplicate tickets with one of them claimed but not submitted before the other ticket was implemented, but was not claimed? |
mickmister
left a comment
There was a problem hiding this comment.
Thanks for the PR @rinkimekari 🎉
I have a few requests regarding the parsing of the command's provided arguments, and some requests for wording changes. Otherwise the PR is looking great 👍
| - The following flags are supported: | ||
| - `--exclude-org-member`: events triggered by organization members will not be delivered. It will be locked to the organization provided in the plugin configuration and it will only work for users whose membership is public. Note that organization members and collaborators are not the same. | ||
| - `--exclude-org-member [true/false]`: events triggered by organization members will not be delivered. It will be locked to the organization provided in the plugin configuration and it will only work for users whose membership is public. Note that organization members and collaborators are not the same. | ||
| - `--collapsed [true/false]`: All notifications about events from the plugin will be collapsed and save space if set to true. The default is false, which shows large, informational messages for notifications, taking up more space. |
There was a problem hiding this comment.
| - `--collapsed [true/false]`: All notifications about events from the plugin will be collapsed and save space if set to true. The default is false, which shows large, informational messages for notifications, taking up more space. | |
| - `--collapsed [true/false]`: All notifications about events from the plugin will be collapsed, if set to `true`. The default is `false`, which shows large, informational messages, including the issue's description, for notifications related issue creations and PR creations. Using the `--collapsed` flag allows the posts to take up less space and as a result, cause ;less the noise in the subscription's channel. |
@cwarnermm Can you please take a look at the wording here?
There was a problem hiding this comment.
A few typos, but I fixed those and it'll be in my next commit.
| excludeOrgMemberFlag = "exclude-org-member" | ||
| collapseNotificationsFlag = "collapsed" |
There was a problem hiding this comment.
We should probably namespace these with a prefix:
| excludeOrgMemberFlag = "exclude-org-member" | |
| collapseNotificationsFlag = "collapsed" | |
| commandFlagExcludeOrgMember = "exclude-org-member" | |
| commandFlagCollapsed = "collapsed" |
| func validFlagsString() string { | ||
| flags := "" | ||
| for s, i := range validFlags { | ||
| if i { | ||
| flags += s + ", " | ||
| } | ||
| } | ||
|
|
||
| return strings.TrimSuffix(flags, ", ") | ||
| } |
There was a problem hiding this comment.
There are other commands that use flags, such as the /github mute command. So I suppose if we want this function, it should probably be made general purpose, by accepting a map[string]bool.
There was a problem hiding this comment.
Good idea. I'll change it.
There was a problem hiding this comment.
One thought. What are those flags and where are they? They should also be handled the same way as these flags right?
| if err != "" { | ||
| return err | ||
| } | ||
| i++ |
There was a problem hiding this comment.
This implicit increment at the end of the for loop seems like a bit of an anti-pattern. I would expect the loop's i variable to be incremented exclusively by the for loop definition.
We can instead split the parameters into groups like so:
arguments := parameters[1:]
numGroups := (len(arguments) + 1) / 2
for i := 1; i < numGroups; i++ {
if len(arguments) < i * 2 {
return "Please use the correct format for flags. For example: `--collapsed true`. Valid flags include " + validFlagsString()
}
start := (i - 1) * 2
name, value := arguments[start], arguments[start + 1]
}| HelpText: "Expand notifications", | ||
| }, | ||
| } | ||
| subscriptionsAdd.AddNamedStaticListArgument("collapsed", "Whether or not to collapse event notifications. The default is expanded.", false, collapsedFlagItems) |
There was a problem hiding this comment.
| subscriptionsAdd.AddNamedStaticListArgument("collapsed", "Whether or not to collapse event notifications. The default is expanded.", false, collapsedFlagItems) | |
| subscriptionsAdd.AddNamedStaticListArgument("collapsed", "Issue creation and PR creation posts will be collapsed, like posts for other event types. The default is false.", false, collapsedFlagItems) |
| UserId: p.BotUserID, | ||
| Type: "custom_git_issue", | ||
| Message: renderedMessage, | ||
| Message: "", |
There was a problem hiding this comment.
We don't need to place this here, as Go will use the empty string by default. If this field was a pointer, it would be possible to be nil, but in this case it's guaranteed to be a valid string, defaulting to the empty string.
Another spot above also uses this pattern and should be changed to let the struct implicitly set its Message
|
After reviewing the code some more, @mickmister is correct in that it shows more than just the title, and it still keeps the larger font. That being said, it might be a good idea to create a |
Co-authored-by: Michael Kochell <6913320+mickmister@users.noreply.github.com>
Codecov Report
@@ Coverage Diff @@
## master #545 +/- ##
==========================================
- Coverage 15.57% 15.52% -0.05%
==========================================
Files 15 15
Lines 4136 4233 +97
==========================================
+ Hits 644 657 +13
- Misses 3450 3534 +84
Partials 42 42
Continue to review full report at Codecov.
|
Co-authored-by: Michael Kochell <6913320+mickmister@users.noreply.github.com>
Co-authored-by: Michael Kochell <6913320+mickmister@users.noreply.github.com>
|
This PR has some overlap with #534 which has been merged, so I'm going to close this one. Thanks for your work on this PR @rinkimekari 👍 |
|
👍 |

This addresses #484, which requests a feature that allows for collapsing large notification messages. Examples:
/github subscriptions add owner/repo pulls,issues --collapsed true/github subscriptions add owner/repo pulls,issues --exclude-org-members trueWhen set to true, this flag makes posts that normally use larger text for titles into smaller, inline posts with a less detailed summary of the repo, pr/issue name, label name if applicable, and who the action was committed by. Of course, when set to false, the default behavior is used. Autocomplete behavior for all flags has been added and adjusted to complete possible parameters as well.
To allow for the addition of parameters such as booleans to flags, the behavior for the
--exclude-org-memberflag has changed as well. However, it is also the same logic - you just puttrueorfalseafter it to do what you want.Thanks for reviewing!