-
Notifications
You must be signed in to change notification settings - Fork 152
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
[GH-618]: Added slack attachment for webhook posts, in order to comment, edit, and close issues. #636
base: master
Are you sure you want to change the base?
Conversation
…t and close issues (#13) * [MI-2502]:Added custom type for webhook post in order to comment, edit and close issues * [MI-2502]: Added EOF * [MI-2502]: Fixed lint errors * [MI-2502]: Review fixes done 1. Improved code quality 2. Made few contants * [MI-2502]: Review fixes done 1. Changed few files to .tsx 2. Improved code quality * [MI-2502]: Review fixes done 1. Improved code quality 2. Made a constant * [MI-2502]: Review fixes done 1. Improved code readability * [MI-2502]: Review fixes done 1. Made a package dor constants 2. Made a package for struct 3. Improved code redability * [MI-2502]: Review fixes done 1. Improved code quality 2. Fixed the issue that I was facing while creating issue or attaching a comment to the issue. 3. Changed few file names * [MI-2502]: Review fixes done 1. Changed the names of few functions 2. Improved code quality * [MI-2502]: Review fixes done 1.Improved code readability * [MI-2502]: Review fixes done 1. Improved code readability * [MI-2502]: Review done 1. Improved code quality * [MI-2502]: Review fixes done 1. Improved code quality
Hello @Nityanand13, 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. |
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.
That is a very nifty feature 🎉
One broad question before I dive into the code too much: The implementation currently uses a custom post and a webapp model. Could this feature also be implemented using interactive dialogues and post actions? That way it's supported on mobile.
@hanzei I think we can not implement this feature using interactive dialogues because in that we do not have any case in which we can select more than one option for a particular field. |
<Input | ||
label='Message Attached to GitHub Issue' | ||
type='textarea' | ||
isDisabled={true} | ||
value={this.props.post.message} | ||
value={post?.message} | ||
disabled={false} | ||
readOnly={true} | ||
/> |
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.
What box does this serve if the message is blank?
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.
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.
Let's just remove the box if there are no contents and the user isn't going to type anything there. Why is the box blank anyway? What case do we not have a post? Maybe we should let the user type in a message regardless?
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.
If the feature is to attach a comment, shouldn't we allow the user to type in a comment?
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.
In this PR I only fixed issue #618. Where if a user clicks on the comment button as shown in the image attached to the description of this PR. So a modal will open as shown below where a user can type a comment and attach that to the github issue.
Other than this a user can create a github issue or attach a message to the github issue from message actions. For now, I have not changed the logic of this thing and the image of the modal that you are seeing where the user cannot type anything is getting opened when a user wants to attach a message to the github issue from message action. So in this case the message field usually contains the content of that particular post. And in the case of slack attachment posts, this message field remains empty. So should I make this field editable or what do you say?
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.
So should I make this field editable or what do you say?
Yeah it probably should be editable, even though it wasn't editable before. The Jira plugin allows you to edit in this case, and I prefer that UX.
I'm trying to understand something still - Under what circumstance do we want to attach a comment, but have no text to send over to GitHub? It seems like a no-op to me in that case
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.
@mickmister Sure I will make it editable. If we want to attach a comment from message actions of slack attachment type post then the comment field remains empty.
webapp/src/components/modals/create_update_issue/create_update_issue.jsx
Outdated
Show resolved
Hide resolved
* [MI-2736]: Review fixes done 1. Improved code readability * [MI-2736]: Review fixes done 1. Fixed linting errors * [MI-2736]: Review fixes done 1. Fixed linting error
<Input | ||
label='Message Attached to GitHub Issue' | ||
type='textarea' | ||
isDisabled={true} | ||
value={this.props.post.message} | ||
value={post?.message} | ||
disabled={false} | ||
readOnly={true} | ||
/> |
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.
If the feature is to attach a comment, shouldn't we allow the user to type in a comment?
* [MI-2736]: Review fixes done 1. Improved code readability * [MI-2736]: Review fixes done 1. Fixed linting errors * [MI-2736]: Review fixes done 1. Fixed linting error * [MI-2736]: Review fixes done 1. Improved code readability * [MI-2736]: Review fixes done 1. Changed the case of few endpoints to snake case
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #636 +/- ##
==========================================
- Coverage 16.16% 14.79% -1.37%
==========================================
Files 17 15 -2
Lines 6021 5563 -458
==========================================
- Hits 973 823 -150
+ Misses 5003 4697 -306
+ Partials 45 43 -2 ☔ View full report in Codecov by Sentry. |
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.
Just a few more questions from my side. I can approve once conversation is wrapped up
button: { | ||
fontFamily: 'Open Sans', | ||
fontSize: '12px', | ||
fontWeight: 'bold', | ||
letterSpacing: '1px', | ||
lineHeight: '19px', | ||
margin: '12px 12px 8px 0px', | ||
borderRadius: '4px', | ||
color: theme.buttonColor, | ||
}, |
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.
Instead of these styles, can we make the buttons match the styling of most other buttons in the MM UI? There are class names used for this, in the footer of the modals in this project for instance. The current styling seems inconsistent with the rest of the application
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.
@DHaussermann I'm curious about your thoughts on this. Should these buttons be made to look like the slack attachment buttons as much as possible, or maybe the buttons that are at the bottom of the modals?
server/plugin/webhook.go
Outdated
if action == constants.ActionOpened { | ||
post.Type = "custom_git_issue" | ||
post.Props = map[string]interface{}{ | ||
constants.TitleForProps: *issue.Title, | ||
constants.IssueURLForProps: *issue.HTMLURL, | ||
constants.IssueNumberForProps: *issue.Number, | ||
constants.DescriptionForProps: description, |
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.
So the current conditions on this is to show these controls on a post created by the plugin, specifically for when an issue is opened.
I think it would be useful to have for PRs and when labeling issues. And possibly in the bot DMs as well, though that could get noisy. @hanzei What are your thoughts on this?
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.
1/5 that it's handy to have actions attached to the DM notification as this allows user to answer them directly in MM. Maybe we even add the buttons to all posts?
@asatkinson What do you think?
server/constants/constants.go
Outdated
@@ -0,0 +1,46 @@ | |||
package constants |
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.
From https://go.dev/blog/package-names
Avoid meaningless package names. Packages named util, common, or misc provide clients with no sense of what the package contains.
What value does a separate package provide?
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.
@hanzei Keeping things in separate package helps us in writing unit tests and creating mocks for packages.
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.
4/5 that a constants
package is not an idiomatic way to store variables, as it contradicts the above quote.
server/serializer/error.go
Outdated
@@ -0,0 +1,11 @@ | |||
package serializer |
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.
Same question about the package structure here.
server/plugin/api.go
Outdated
p.API.PublishWebSocketEvent( | ||
wsEventAttachCommentToIssue, | ||
map[string]interface{}{ | ||
"postId": post.Id, | ||
"owner": req.RepoOwner, | ||
"repo": req.RepoName, | ||
"number": req.IssueNumber, | ||
}, | ||
&model.WebsocketBroadcast{UserId: userID}, | ||
) |
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.
Why is the request to the plugin needed if it simply returns a websocket event?
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.
The same question goes for openCloseOrReopenIssueModal.
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.
Now we are not making any request for these cases
This PR has been automatically labelled "stale" because it hasn't had recent activity. |
Thanks @raghavaggarwal2308, the screenshot looks good, but could you update the test server? These changes aren't showing for me there. |
@matthewbirtch The test server is updated now. |
Thanks @raghavaggarwal2308. A few details:
Let me know if any of this is out of scope for this PR |
@matthewbirtch All these suggestions will take some time to fix. Also, we will have to handle styling of many things:
. What are your opinions on replacing the custom post with a slack attachment for webapp as well? |
I think that could work quite well and makes a lot of sense to me. @mickmister any objections to this? |
@raghavaggarwal2308 Sounds good to me 👍 |
…ation event on Github (#37) * [MM-617]: converted the custom post to slack attachment for issue creation * [MM-617]: fixed lint and testcases * [MM-617]: removed unused variables * [MM-617]: Fixed the title of the issue slackAttachment * [MM-617]: review fixes * [MM-617]: fixed lint * [MM-617]: Review fixes and code clean up * [MM-617]: removed the custom post file * [MM-617]: review fixes * [MM-617]: review fixes * [MM-617]: Fixed lint * [MM-617]: improved the error logging
@matthewbirtch Converted the custom post to slack attachment and updated the screenshot in description. The test server is also updated with the latest build. Please re-review. |
@raghavaggarwal2308 the webapp looks good to me, but this is not rendering at all on mobile for me on the test server.
|
@matthewbirtch We tried reproducing the issue but it works fine on my local server and the maintenance testing cloud server. |
@raghavaggarwal2308 it seems better now. Although, now I'm seeing a slightly different issue. I'm testing on your test server in the
RPReplay_Final1725453848.MP4 |
@matthewbirtch Sure, we will look into it. |
@matthewbirtch
|
I think this is the case. It's probably a leftover from the previous implementation of the custom component. I think we're good with this part.
For this one, I'll need support from @wiggin77 or @mickmister to identify if this is a plugin issue or a platform issue. |
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.
Can you please resolve the conflicts first?
@hanzei Resolved conflicts |
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.
@wiggin77 Can you please confirm from a product owner perspective that this is a feature we want to incorporate into the plugin?
Summary
Whenever a user creates an issue on github then three actions will be shown in the custom post created by the plugin's bot. The three actions are:
With the help of the above mentioned actions user can create a comment, edit, close, and reopen a github issue from the mattermost. As you see we haven't made a reopen button so when a user closes an issue then this close button will turn to reopen.
Ticket Link
Issue: #618