Skip to content
This repository has been archived by the owner on Mar 13, 2024. It is now read-only.

MM-10657 Adding ability for plugin to hook the file upload button. #1488

Merged
merged 5 commits into from
Jul 31, 2018

Conversation

crspeller
Copy link
Member

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

@crspeller crspeller added the Setup Old Test Server Triggers the creation of a test server label Jul 27, 2018
Copy link
Contributor

@jasonblais jasonblais left a 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

@crspeller
Copy link
Member Author

@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 {
Copy link
Member

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?

Copy link
Member Author

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.

Copy link
Member

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) => {
Copy link
Member

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

Copy link
Member Author

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'}
Copy link
Member

Choose a reason for hiding this comment

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

This should be localizable

@jasonblais
Copy link
Contributor

@crspeller

  1. Can we dynamically left-align the text based on icon size across the different plugins?
    image
  2. Propose having Your computer instead of Your Computer as the default file upload option.
  3. I realize this is a bit out of scope from this webapp PR: But when uploading a file via something like GoogleDrive or OneDrive plugin, the upload flow will be controlled by that plugin, correct? Example: whether or not the GoogleDrive/OneDrive file is uploaded into the message drafts or directly as a message.

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.

image

@jasonblais
Copy link
Contributor

@asaadmahmood I'm wondering if it's clear what Your computer is in this context? Or should we have something like this in the dropdown instead

image

@crspeller
Copy link
Member Author

@jasonblais

  1. @asaadmahmood Can you do that? Not sure how to accomplish that with css.
  2. Done.
  3. Correct. I left that up to the plugin.

@asaadmahmood
Copy link
Contributor

@crspeller Sure, will fix the alignment issue.
@jasonblais For sure, we need a more representative icon. We have font-awesome icons we can use like: https://fontawesome.com/v4.7.0/icon/laptop

@jasonblais jasonblais removed the Setup Old Test Server Triggers the creation of a test server label Jul 30, 2018
@mattermost mattermost deleted a comment from mattermod Jul 30, 2018
@mattermost mattermost deleted a comment from mattermod Jul 30, 2018
@mattermost mattermost deleted a comment from mattermod Jul 30, 2018
@crspeller crspeller added the Setup Old Test Server Triggers the creation of a test server label Jul 30, 2018
@mattermod
Copy link
Contributor

Spinmint test server created at: http:https://i-044313ddc36aad70d.test.spinmint.com

Test Admin Account: Username: sysadmin | Password: sysadmin

Test User Account: Username: user-1 | Password: user-1

Instance ID: i-044313ddc36aad70d

@crspeller
Copy link
Member Author

@jasonblais Spinmint is ready for re-review.

Copy link
Contributor

@jasonblais jasonblais 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 a question for Asaad, but DM'd him on pre-release. Doesn't block this PR.

Thanks Chris!

@jasonblais jasonblais removed the request for review from asaadmahmood July 30, 2018 18:56
@jasonblais jasonblais added 2: Dev Review Requires review by a core commiter and removed 1: PM Review Requires review by a product manager labels Jul 30, 2018
@jasonblais jasonblais removed the Setup Old Test Server Triggers the creation of a test server label Jul 30, 2018
@mattermod
Copy link
Contributor

Spinmint test server destroyed

@mattermost mattermost deleted a comment from mattermod Jul 30, 2018
Copy link
Member

@jwilander jwilander left a 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

return dispatchPluginComponentAction('PostDropdownMenuItem', this.id, component);
}

// Register a post menu list item by providing some text and an action function.
Copy link
Member

Choose a reason for hiding this comment

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

Copy/paste error

@jwilander jwilander self-requested a review July 30, 2018 19:50
Copy link
Member

@hmhealey hmhealey left a 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

@hmhealey hmhealey removed the 2: Dev Review Requires review by a core commiter label Jul 31, 2018
@hmhealey hmhealey merged commit ceb0ca0 into master Jul 31, 2018
@hmhealey hmhealey deleted the mm-10657 branch July 31, 2018 17:13
@lindalumitchell lindalumitchell added the Tests/Not Needed Does not require new release tests label Aug 7, 2018
@amyblais amyblais added Changelog/Done Required changelog entry has been written Docs/Done Required documentation has been written labels Aug 8, 2018
fincha pushed a commit to fincha/mattermost-webapp that referenced this pull request Oct 21, 2018
…attermost#1488)

* Adding ability for plugin to hook the file upload button.

* Tweaks and localization.

* Updating icons

* Fix docs.

* Move back to pure-component.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Changelog/Done Required changelog entry has been written Docs/Done Required documentation has been written Tests/Not Needed Does not require new release tests
Projects
None yet
8 participants