-
Notifications
You must be signed in to change notification settings - Fork 2.7k
MM-10657 Adding ability for plugin to hook the file upload button. #1488
Conversation
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.
Anything in particular you'd like me to review?
Wondering if BrightScout would like to help try this since they were gonna build a plugin using this component for a customer
@jasonblais I have uploaded the zoom demo plugin. Just check how the menu that pops up looks and feels. |
@@ -55,7 +56,7 @@ const holders = defineMessages({ | |||
|
|||
const OVERLAY_TIMEOUT = 500; | |||
|
|||
export default class FileUpload extends PureComponent { | |||
export default class FileUpload extends Component { |
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 not use a PureComponent here any 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.
Because it's not pure anymore. It has state.
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.
PureComponents can still have state. They just only re-render when their state or props change like you'd implemented a shouldComponentUpdate method
const FileDropdownComponent = (props) => { | ||
return ( | ||
<button | ||
onClick={(e) => { |
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.
Could this just use onClick={props.onClick}
? Most of the time that we use e.preventDefault
is because the click handler was on an <a>
tag which would append a number sign to the URL, but since this is a <button>
, it might not be necessary
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.
Sure. I was just copying what was there.
<li> | ||
<a> | ||
<i className='fa fa-files-o'/> | ||
{'Your Computer'} |
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.
This should be localizable
Look and feel seems okay otherwise. Verified that file upload icon continues to be hidden when file uploads are disabled, as expected. @asaadmahmood any feedback? The attached is the same on desktop and mobile view; and on center channel and RHS. Note that the change does not apply to mobile apps. |
@asaadmahmood I'm wondering if it's clear what |
|
@crspeller Sure, will fix the alignment issue. |
Spinmint test server created at: http:https://i-044313ddc36aad70d.test.spinmint.com Test Admin Account: Username: Test User Account: Username: Instance ID: i-044313ddc36aad70d |
@jasonblais Spinmint is ready for re-review. |
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 a question for Asaad, but DM'd him on pre-release. Doesn't block this PR.
Thanks Chris!
Spinmint test server destroyed |
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.
Code looks good, just one comment
plugins/registry.js
Outdated
return dispatchPluginComponentAction('PostDropdownMenuItem', this.id, component); | ||
} | ||
|
||
// Register a post menu list item by providing some text and an action function. |
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.
Copy/paste error
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 commented above, but the FileUpload component should still be a PureComponent since "pure" in this context means that the component only re-renders if it's state and/or props change
…attermost#1488) * Adding ability for plugin to hook the file upload button. * Tweaks and localization. * Updating icons * Fix docs. * Move back to pure-component.
This is experimental. I have not actually written a plugin capable of using this functionality for real. There may be additional hooks required for a properly functioning file upload plugin.
Mattermost demo plugin PR: mattermost/mattermost-plugin-demo#2