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

Media: add media section #11822

Merged
merged 30 commits into from
Mar 10, 2017
Merged

Media: add media section #11822

merged 30 commits into from
Mar 10, 2017

Conversation

retrofox
Copy link
Contributor

@retrofox retrofox commented Mar 7, 2017

This PR makes a number of improvements to the media section and updates the media modal to include an action bar at the top. The media section is controlled by the manage/media feature flag. This is currently enabled in dev, wpcalypso, horizon and test. The media section can be shown by clicking on the Media option into the sidebar.

Related Design Discussion: #10805

The whole picture

image

Primary Changes

Beyond add the media library this PR implements many changes. Following, the most important ones:

Media -> Add item

It allows adding a new item quickly.

Media -> Actions bar

Media -> Plan storage nudge

A plan storage nudge is shown in the filter bar is the site doesn't have a business plan.

Media -> Item detail dialog

  • Added DONE and DELETE buttons

image

Post editor -> add media -> Item detail dialog

  • Actions buttons were removed from the bottom
  • Added the actions bar above the media gallery


Testing Instructions:

Media Modal

screen shot 2017-03-09 at 12 18 11 pm

  • The new action bar appears at the top.
  • The plan storage component in the top right corner can be seen for folks with a wpcom free/personal/premium plan.

screen shot 2017-03-09 at 12 18 27 pm

  • Clicking "Add new" opens the file picker

screen shot 2017-03-09 at 12 21 10 pm

  • Click on the chevron next to "add new" gives you this option:

screen shot 2017-03-09 at 12 21 43 pm

  • Clicking on Add Via Url updates the interface:

screen shot 2017-03-09 at 12 21 43 pm

  • Selecting items adds an edit and delete button to the action bar

screen shot 2017-03-09 at 12 22 33 pm

  • Search works as expected
  • Other media modal flows work as expected

Media Section

  • Click on the add button of the media section

screen shot 2017-03-09 at 12 37 08 pm

  • The media section should open with the file picker ready
  • Clicking on the section link outside of "add" should just open the media section
  • The media section visually looks ok

screen shot 2017-03-09 at 12 38 15 pm

  • We can edit media like we can do in the media modal
  • scrolling down, stickies the action bar:

screen shot 2017-03-09 at 12 39 46 pm

Site Icon

Known Visual Issues

There are a few known visual issues in the media section that should be addressed after this feature branch lands. It should be safe to land with these quirks since the media section is not enabled in prod yet. We're hoping to land the feature branch quickly to avoid drift and a larger diff.

  • Image Editor in Media Section shows too many buttons:
    pasted_image_at_2017_03_09_05_46_pm_360
  • Visual quirks at smaller sizes with the sticky bar

screen shot 2017-03-09 at 11 42 10 am

Pull Requests

This process was done working in different patches:

h/t to @iamtakashi @artpi @retrofox @gwwar

@retrofox retrofox added [Feature] Media The media screen in Calypso, general media management, or integration with third party media. [Status] In Progress labels Mar 7, 2017
@matticbot
Copy link
Contributor

matticbot commented Mar 7, 2017

@matticbot matticbot added the [Size] XL Probably needs to be broken down into multiple smaller issues label Mar 7, 2017
@retrofox retrofox force-pushed the try/media-section-v2 branch from 66fce78 to 2474f28 Compare March 8, 2017 17:02
@matticbot matticbot added the [Size] XL Probably needs to be broken down into multiple smaller issues label Mar 8, 2017
@retrofox retrofox force-pushed the try/media-section-v2 branch from 5d54642 to 98cdd8e Compare March 8, 2017 21:34
@matticbot matticbot added the [Size] XL Probably needs to be broken down into multiple smaller issues label Mar 8, 2017
@retrofox retrofox force-pushed the try/media-section-v2 branch from 9ae39f5 to 2e280ee Compare March 9, 2017 18:55
@matticbot matticbot added the [Size] XL Probably needs to be broken down into multiple smaller issues label Mar 9, 2017
@retrofox retrofox changed the title [wip] Try/media section v2 Media: add media section Mar 9, 2017
@gwwar
Copy link
Contributor

gwwar commented Mar 9, 2017

cc @alisterscott @hoverduck would it be possible to run e2e's against this branch? Let us know if we need to update any test suites.

@matticbot matticbot added the [Size] XL Probably needs to be broken down into multiple smaller issues label Mar 9, 2017
@retrofox retrofox force-pushed the try/media-section-v2 branch from c735f39 to e6e6b0b Compare March 9, 2017 20:08
@matticbot matticbot added the [Size] XL Probably needs to be broken down into multiple smaller issues label Mar 9, 2017
@gwwar gwwar added [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. and removed [Status] In Progress labels Mar 9, 2017
@hoverduck
Copy link
Contributor

@gwwar The e2e tests look good except (unsurprisingly) the media upload test needs some updates. Since you're the original author can you take a look? If not I can get to it tomorrow

const eventProperties = { cta_name: 'plan-media-storage' };
return (
<PlanStorage siteId={ this.props.site.ID }>
<TrackComponentView eventName={ eventName } eventProperties={ eventProperties } />
Copy link
Member

Choose a reason for hiding this comment

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

fun fact! when I'm just passing named properties like this I find the spread syntax helpful…

<TrackComponentView { ...{
	eventName,
	eventProperties
} } />

@gwwar
Copy link
Contributor

gwwar commented Mar 9, 2017

Thanks @hoverduck I'll try to take a look at that today


if ( isError || ! this.props.site ) {
event.preventDefault();
Copy link
Contributor

@klimeryk klimeryk Mar 9, 2017

Choose a reason for hiding this comment

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

Just a quick drive-by comment - it seems we need to call event.preventDefault() in both cases, so it should probably be called once (before this if branch and removed from line 45) - otherwise someone might think that one of these calls should not be there :)

Copy link
Contributor Author

@retrofox retrofox Mar 9, 2017

Choose a reason for hiding this comment

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

I'm sorry Igor, I don't understand completely what do you mean. Could you point straight in the file of this PR? I'm sorry. It seemed to be a connection issue since I couldn't see this comment here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Now I got it. You're right. Thanks.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, sorry. So, no matter which flow we take in this function we end up calling event.preventDefault. Either here: https://github.com/Automattic/wp-calypso/pull/11822/files#diff-246b58e6f07d7dce525ca439d82eccf9R41 or here: https://github.com/Automattic/wp-calypso/pull/11822/files#diff-246b58e6f07d7dce525ca439d82eccf9R45.
So I thought that this call should be "deduplicated" and moved to a single call, somewhere above https://github.com/Automattic/wp-calypso/pull/11822/files#diff-246b58e6f07d7dce525ca439d82eccf9R40. Less chances of one of these calls getting deleted and it shows the intent (always prevent default behaviour of the event) better.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually, this line seems to be unneeded. Good one 👍


accept( confirmMessage, accepted => {
if ( ! accepted ) {
return null;
Copy link
Contributor

Choose a reason for hiding this comment

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

Seems like just return; should suffice :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, agree. But I've gotten feedback from other PR that we should be explicit in this sense. Although return returns a null if nothing is defined, it's more understandable when the null value is defined explicitly.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, got it - I was thrown off by no explicit return in the success scenario, but if that's intended then cool 👍

Copy link
Contributor Author

@retrofox retrofox Mar 9, 2017

Choose a reason for hiding this comment

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

yes ... we aren't being consistent with this. :-|

Copy link
Member

Choose a reason for hiding this comment

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

Although return returns a null if nothing is defined, it's more understandable when the null value is defined explicitly.

interesting…what reason was given to be explicit in the return value there?

also this is wrong. return returns undefined if no value is given.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

also this is wrong. return returns undefined if no value is given.

You're right. Another reason to return null ;-)

Copy link
Member

Choose a reason for hiding this comment

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

You're right. Another reason to return null ;-)

the way I typically do it is that if my only reason to use return is to early-abort from a function then I'll just return because that's how it would have happened if the function had returned normally given no explicit value.

if, on the other hand, the function is designed to return a value and something else is counting on it I'll want to explicitly return something. bonus points if it's the same data type as would otherwise return.

for example, an empty string could be more appropriate for a string function than null, a 0 might be more appropriate for a number function, an empty list for a list function, etc…

but if I'm calling a function for its side-effects only and don't expect a value, I think getting something back could also be confusing

Copy link
Contributor

Choose a reason for hiding this comment

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

But I've gotten feedback from other PR that we should be explicit in this sense. Although return returns a null if nothing is defined, it's more understandable when the null value is defined explicitly.

Do you have the link @retrofox? We might have gotten confused that this was a render helper. A return null for rending is an explicit indication for React that we want to render nothing.

I missed this on the original PR, but it doesn't look like anything uses this return value, in which case we should just return; I agree with @dmsnell on consistency. A function should either always return some value if we're using it, or nothing if we don't.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, sorry. Last night I forgot to leave my answer here.
I was confusing with the render method of React component. Let me update the code. I'm sorry again and thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

rebased and updated

@alisterscott
Copy link
Contributor

Thanks @hoverduck I'll try to take a look at that today

@gwwar: if you don't find time please LMK and I can do this for you

@matticbot matticbot added the [Size] XL Probably needs to be broken down into multiple smaller issues label Mar 9, 2017
@gwwar
Copy link
Contributor

gwwar commented Mar 10, 2017

Thanks @folletto for testing!

(1) Media -> Actions bar Would be ideal if the popup text wasn't small and uppercase, but normal and with a standard font

@retrofox let's update styling for this

(2) Media -> Plan storage nudge I'd leave the final decision to @iamtakashi, but I think the whole area should be clickable, not just "Upgrade" (3) Media -> Item detail dialog I'd also add a "Cancel" / "Close" button.

I think we can follow up pretty quickly and discuss points 2 and 3 after the feature branch lands.

@retrofox
Copy link
Contributor Author

(1) Media -> Actions bar Would be ideal if the popup text wasn't small and uppercase, but normal and with a standard font

@retrofox let's update styling for this

sure.

Thanks @folletto for the feedback. Let's create and add issues for (2) and (3) in our backlog as well.

@retrofox retrofox force-pushed the try/media-section-v2 branch from f1f89b0 to eefefd6 Compare March 10, 2017 16:25
@matticbot matticbot added the [Size] XL Probably needs to be broken down into multiple smaller issues label Mar 10, 2017
@retrofox
Copy link
Contributor Author

retrofox commented Mar 10, 2017

f5061c2

cc @folletto , @gwwar

@folletto
Copy link
Contributor

It's a nitpick, but i'd make the clickable item 33px tall too. :)

@retrofox
Copy link
Contributor Author

retrofox commented Mar 10, 2017

It's a nitpick

nop, it isn't.

but i'd make the clickable item 33px tall too. :)

Sorry, do you mean increase from 26px to 33px there?

@retrofox retrofox force-pushed the try/media-section-v2 branch from f5061c2 to fbb8ffc Compare March 10, 2017 16:54
@matticbot matticbot added the [Size] XL Probably needs to be broken down into multiple smaller issues label Mar 10, 2017
@retrofox retrofox force-pushed the try/media-section-v2 branch from fbb8ffc to 3d16a80 Compare March 10, 2017 17:07
@matticbot matticbot added the [Size] XL Probably needs to be broken down into multiple smaller issues label Mar 10, 2017
@folletto
Copy link
Contributor

Sorry, do you mean increase from 26px to 33px there?

Yep. The blue area basically.

screen shot 2017-03-10 at 17 10 02

@retrofox
Copy link
Contributor Author

retrofox commented Mar 10, 2017

Sorry, do you mean increase from 26px to 33px there?

Yep. The blue area basically.

yes, already done. I've removed the is-compact className from the PopoverMenuItem component.

@gwwar gwwar merged commit 0ef16de into master Mar 10, 2017
@matticbot matticbot removed the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label Mar 10, 2017
@gwwar gwwar deleted the try/media-section-v2 branch March 14, 2017 16:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Media The media screen in Calypso, general media management, or integration with third party media. [Size] XL Probably needs to be broken down into multiple smaller issues
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants