-
Notifications
You must be signed in to change notification settings - Fork 58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add enable on update (fixes #36) #79
Add enable on update (fixes #36) #79
Conversation
fdd22b1
to
0c963af
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@grubbins Thank you for the contribution! Do you mind updating the test https://github.com/mattermost/mattermost-plugin-autolink/blob/ba7743d9a4dccc33a708f4a521f2015e3ff81004/server/plugin_test.go#L221 to cover this functionality?
This will need to merge #80 to build |
I'll look at a test case, yes. I am working on getting the CLA signed... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Besides the tests comments, looks good to me. Thanks @grubbins! 🎉
/check-cla |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
/check-cla |
@grubbins were you able to sign the CLA? |
This issue has been automatically labelled "stale" because it hasn't had recent activity. /cc @jasonblais @hanzei |
Hi @grubbins, let us know if you have any questions about the CLA? Happy to help clarify anything |
Sorry for the delay all - the CLA will be fine but I need to get it signed at my employer and then resubmit this change under a new account that's a member of their organisation account. |
@grubbins no worries, thanks for the heads up! |
/check-cla |
/update-branch |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All good, but 1/5 I'd like to see a test added.
dffa8c1
to
2feacc6
Compare
Added this to |
Actually no. The test is ineffective. Give me a minute... |
2feacc6
to
cc1f690
Compare
OK now the test actually does fail if I remove the update handling :) I did not explicitly test that the plugin does not modify an updated post if the config item is disabled (although I did see that behaviour). |
@@ -220,13 +221,54 @@ func TestSpecialCases(t *testing.T) { | |||
|
|||
for _, tt := range tests { | |||
t.Run(tt.inputMessage, func(t *testing.T) { | |||
post := &model.Post{ | |||
Message: tt.inputMessage, | |||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LOL, that's an interesting way of formatting! 0/5 a slight preference to make each "block" a separate t.Run, and use the test names for comments - makes the logs pretty?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I don't have a lot of experience structuring go tests, but I also felt the whole test could probably be re-arranged to more clearly report which test failed. I decided that would be better tackled by others...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I'll do it later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BTW in case it's not obvious, the separate blocks are there to ensure we destroy the post
instances because the plugin mutates the ones passed in... and it seemed even more messy to declare them all with separate names.
@DHaussermann ready for you to test |
@grubbins Thanks for this improvement! It is functional. When I update a post the pattern is applied as expected. |
I am not sure what's expected here actually. I would not expect the config file to be updated when a plugin is uploaded. Maybe next time mattermost saves its config (i.e. exits, or you hit a save button in system console) it would write all the config fields? |
@DHaussermann I just tried uploading the plugin to our test server (over-writing existing). There is no config section for this plugin in |
Strange. I believe the line above it for @levb do you have any thoughts on this? |
@DHaussermann I believe that is because the |
@grubbins since you implemented the config setting as a global flag, perhaps it is indeed worth adding it to Also, this made me think that perhaps it should have been implemented as a per-link setting, rather than a global one? I hate to go back and re-do it but it really does seem more appropriate, what do you think?
This is only done this way because of the limitations of what we could do with the system console (fixed, predeclared configuration with a limited set of types). We are going to be soon running a campaign to elevate most commonly-used links to visible in config, on a case-by-case basis. If you are interested in co-starting it, please ping me on community, we can discuss and file the first ticket for it. cc @jfrerich |
I could look at adding it to the I don't want to make it per-link. I added this functionality in the first case because my users were very confused that the behaviour works on new posts but not updates (and assumed this was a bug), and everyone asked for it to work on update; I think it would be even more confusing if this happened for some link rules and not others. Conversely the argument for leaving this feature turned off, if I understand rightly, is that it gives users a way to undo/suppress the autolink action. In that case I guess the users on that mattermost instance would need to be told this, so they can make use of it. Again, I think it would then be more confusing for them if this worked for some link rules and not others. (I also strongly feel that if we want an intuitive way for users to suppress the autolinking, turning off enable on update is not the solution) So I would really prefer to get this merged, and if the need for per-link setting is really there then this global flag can act as a default and we could later add over-rides per link - how about that? |
cc1f690
to
a163b89
Compare
@grubbins the change implemented is working. As it is now, this is already very useful! I have no issue with addressing the follow-up concerns in a separate issue. However, since the flag is not exposed in the UI, we would at least need to update the read-me to include this option (I did not see a change for this). cc @aaronrothschild ☝️. |
@DHaussermann agreed - I pushed another version which has the new setting in |
OK, I tested it again with the entry in |
@grubbins I am convinced! Thanks for the detailed reasoning! |
@DHaussermann I think we just need your ok on the newly visible flag in the UI. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested and passed
- Confirmed new True / False config exists in the UI
- Added test coverage for this in release testing
LGTM!
Thanks @grubbins
@levb @grubbins I got this comment from a customer - thoughts on this scenario? Separate PR (I know this is merged already)?
|
@aaronrothschild - I think it is a new ticket, and maybe something for the platform team to consider (versioning the post, in its most general manifestation). |
Config item
EnableOnUpdate
allows processing on updated posts too.