Skip to content
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

Closed
wants to merge 4 commits into from

Conversation

mickmister
Copy link
Contributor

@mickmister mickmister commented Apr 26, 2021

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

/apps debug-add-manifest http://localhost:8065/plugins/mattermost-autolink/app/v1/manifest
/apps install --app-id com.mattermost.autolink

Then there are two autolink commands:

  • The existing autolink command
  • A new autolink-app edit command to open the modal

Added features:

  • Renaming auto links
  • Deleting auto links
  • Testing auto links within the modal

Ticket Link

Fixes #133

Related Pull Requests

mattermost/mattermost-plugin-apps#165

Screenshots

image

image

@mickmister mickmister added 1: PM Review Requires review by a product manager 2: Dev Review Requires review by a core committer 3: QA Review Requires review by a QA tester labels Apr 26, 2021
@codecov-commenter
Copy link

codecov-commenter commented Apr 26, 2021

Codecov Report

Merging #159 (d92a803) into master (a868350) will decrease coverage by 0.46%.
The diff coverage is 40.00%.

Impacted file tree graph

@@            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              
Impacted Files Coverage Δ
server/api/api.go 58.33% <ø> (-2.96%) ⬇️
server/autolinkplugin/plugin.go 86.77% <40.00%> (-4.30%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a868350...d92a803. Read the comment docs.

Copy link
Contributor

@hanzei hanzei left a 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
Copy link
Contributor

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

Suggested change
cp -r public/ dist/$(PLUGIN_ID)/public
cp -r public dist/$(PLUGIN_ID)/

Copy link
Contributor Author

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.

Copy link
Contributor

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?

server/autolinkapp/app.go Show resolved Hide resolved
Comment on lines +130 to +133
func (a *app) handleIcon(w http.ResponseWriter, r *http.Request) {
resp := a.getEmptyFormResponse()
httputils.WriteJSON(w, resp)
}
Copy link
Contributor

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)
Copy link
Contributor

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?

Copy link
Contributor Author

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))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this needed?

Copy link
Contributor Author

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

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

linkOption = values.Link
}

return &apps.Form{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No icon?

server/autolinkapp/form.go Show resolved Hide resolved
},
{
Name: fieldScope,
ModalLabel: "Scope",
Copy link
Contributor

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

Copy link
Contributor Author

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?

Copy link
Contributor

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.

@aaronrothschild
Copy link

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!

Copy link

@aaronrothschild aaronrothschild left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@mickmister
Copy link
Contributor Author

@aaronrothschild The plugin will still be doing the string substitution with MessageWillBePosted. The "App" is embedded in the plugin, and is currently just used for this modal.

Copy link
Contributor

@levb levb left a 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.

  1. In Apps: add an Epic "Apps to support plugins"
  2. Add a Plugin Upstream (server/upstream/plugin) that will invoke using the P2P "HTTP" interface
  3. Add [Un-]Install REST API to plugin-apps
  4. 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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this tidy-ed?

@mickmister
Copy link
Contributor Author

@hanzei I'm wanting to close this to clean up my open PR queue. What are your thoughts on this?

@hanzei
Copy link
Contributor

hanzei commented Oct 10, 2021

Would be recommend customers to use this setting? Would be we fine to break it by introducing breaking changes in the Apps framework?

cc @aaronrothschild

@mickmister
Copy link
Contributor Author

Would be recommend customers to use this setting?

@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.

Would be we fine to break it by introducing breaking changes in the Apps framework?

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.

@levb
Copy link
Contributor

levb commented Oct 11, 2021

This is _very_experimental to add to one of the most used plugins...

@aaronrothschild
Copy link

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...

@mickmister
Copy link
Contributor Author

Closing for now. Will re-open when we want to properly implement the feature on a stable Apps release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1: PM Review Requires review by a product manager 2: Dev Review Requires review by a core committer 3: QA Review Requires review by a QA tester
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Autolink Admin UI can preview and test link
5 participants