-
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
Convert Autolink plugin into an App, and introduce autolink edit modal #159
Conversation
handle clearing the selected auto link
Codecov Report
@@ Coverage Diff @@
## master #159 +/- ##
==========================================
- Coverage 40.03% 39.57% -0.47%
==========================================
Files 6 6
Lines 602 609 +7
==========================================
Hits 241 241
- Misses 345 352 +7
Partials 16 16
Continue to review full report at Codecov.
|
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.
Great work. It's really exiting to see what app can enable in terms of UX possibilities.
A few comments below.
@@ -92,7 +92,7 @@ ifneq ($(wildcard $(ASSETS_DIR)/.),) | |||
cp -r $(ASSETS_DIR) dist/$(PLUGIN_ID)/ | |||
endif | |||
ifneq ($(HAS_PUBLIC),) | |||
cp -r public/ dist/$(PLUGIN_ID)/ | |||
cp -r public/ dist/$(PLUGIN_ID)/public |
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 stick with the starter template
cp -r public/ dist/$(PLUGIN_ID)/public | |
cp -r public dist/$(PLUGIN_ID)/ |
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 The code was originally putting the icon.png
file into the dist
folder, and not in the dist/public
folder. This was how I was able to get the icon in the right folder.
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.
You are using a mac, right? Could you please test my code?
func (a *app) handleIcon(w http.ResponseWriter, r *http.Request) { | ||
resp := a.getEmptyFormResponse() | ||
httputils.WriteJSON(w, resp) | ||
} |
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.
Unused?
adminRoutes.HandleFunc(bindingsRoute, a.handleBindings).Methods(http.MethodPost) | ||
adminRoutes.HandleFunc(editLinksRoute+"/form", a.handleFormFetch).Methods(http.MethodPost) | ||
adminRoutes.HandleFunc(editLinksRoute+"/submit", a.handleFormSubmit).Methods(http.MethodPost) | ||
adminRoutes.HandleFunc(editLinksCommandRoute+"/submit", a.handleCommandSubmit).Methods(http.MethodPost) |
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.
Is this really /edit-links-command/submit/submit
?
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.
Hmm that was happening before and I thought I fixed that. Not sure how/why it's working
} | ||
|
||
r.Body.Close() | ||
r.Body = ioutil.NopCloser(bytes.NewBuffer(b)) |
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 this needed?
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.
I'm reading from the body in this middleware, and want the http handlers to be able to read from the body as well. I don't like this solution
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.
Is the approach from servicenow suitable here? https://github.com/mattermost/mattermost-app-servicenow/blob/5c160ea3d7c07017a5b1327c1a3c0a9ec5062c53/routers/mattermost/mattermost.go#L43-L66
linkOption = values.Link | ||
} | ||
|
||
return &apps.Form{ |
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.
No icon?
}, | ||
{ | ||
Name: fieldScope, | ||
ModalLabel: "Scope", |
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.
Out of scope of this PR: This should be autocompleted
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.
I'm not sure how that would be autocompleted. Can you explain further?
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.
Scope
is either a channel or a team.
Sorry, maybe I missed something - I thought apps don't have the "MessageWillBePosted" hook. Is this operating on the "MessageHasBeenPsted" hook and then editing the message retroactively? If so, it's a bit different and worth documenting since in secure environments the data will have been committed to the DB layer and it may be part of the audit record, etc. Whereas, I believe the plugin Autolink would intercept the message before it is recorded anywhere. If so, we should document the slight difference for admins in the readme, that's all. Great stuff! |
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
@aaronrothschild The plugin will still be doing the string substitution with |
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.
I have not yet looked into the details of the app implementation, but a suggestion right away. Think big.
- In Apps: add an Epic "Apps to support plugins"
- Add a
Plugin
Upstream
(server/upstream/plugin
) that will invoke using the P2P "HTTP" interface - Add
[Un-]Install
REST API to plugin-apps - In Autolink:
1./autolink experimental as-app on/off
that would install itself using the API and unregister the old style command
github.com/gorilla/mux v1.7.4 | ||
github.com/mattermost/mattermost-server/v5 v5.28.1 | ||
github.com/mholt/archiver/v3 v3.3.0 | ||
github.com/go-sql-driver/mysql v1.6.0 // indirect |
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.
Is this tidy
-ed?
@hanzei I'm wanting to close this to clean up my open PR queue. What are your thoughts on this? |
Would be recommend customers to use this setting? Would be we fine to break it by introducing breaking changes in the Apps framework? |
@hanzei The feature received great positive feedback in the R&D demo, so I would imagine that it would be used by us as an organization.
I think if we introduce it as an experimental feature it would be fine. To clear up my original request, I was saying that we close this PR in favor of your PR #164. We can also merge your PR into this PR and continue here. |
This is _very_experimental to add to one of the most used plugins... |
I agree with Lev....this probably can go out later when the App framework is GA... |
Closing for now. Will re-open when we want to properly implement the feature on a stable Apps release |
Summary
One thing not done here is having the plugin automatically register itself as an app. I'm not sure how that would work with admin interaction. Right now you have to run
Then there are two autolink commands:
autolink
commandautolink-app edit
command to open the modalAdded features:
Ticket Link
Fixes #133
Related Pull Requests
mattermost/mattermost-plugin-apps#165
Screenshots