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

[Canvas] Alignment and distribution #39132

Merged
merged 8 commits into from
Jun 27, 2019
Merged

[Canvas] Alignment and distribution #39132

merged 8 commits into from
Jun 27, 2019

Conversation

monfera
Copy link
Contributor

@monfera monfera commented Jun 17, 2019

Summary

Implements alignment and distribution.

Alignment:
align

Distribution, then some alignments:
distributealign

Checklist

Use strikethroughs to remove checklist items you don't feel are applicable to this PR.

For maintainers

@monfera monfera added release_note:enhancement WIP Work in progress enhancement New value added to drive a business result Team:Presentation Presentation Team for Dashboard, Input Controls, and Canvas v7.3.0 labels Jun 17, 2019
@monfera monfera requested a review from a team as a code owner June 17, 2019 21:17
@monfera monfera self-assigned this Jun 17, 2019
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-canvas

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@monfera monfera requested a review from cqliu1 June 18, 2019 17:05
@monfera monfera force-pushed the alignment-distribution branch 3 times, most recently from 8c2e4e5 to ffd0a10 Compare June 19, 2019 16:14
@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@elastic elastic deleted a comment from elasticmachine Jun 19, 2019
@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Copy link
Contributor

@ryankeairns ryankeairns left a comment

Choose a reason for hiding this comment

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

@monfera first off, this is fantastic, thank you!

The good news: there is a rather common set of icons we can use for these!
Screenshot 2019-06-19 15 54 29

The not-so-good news: I'm pretty backlogged at the moment and will need some time to get them done. If you'd like to get this merged, I can come back through add them once they're created. In the meantime, you can simply remove the icons for now.

I also have one small request that is quite subjective :) , can you remove the top borders on the Align elements and Distribute elements items so that we end up with this:

Screenshot 2019-06-19 16 00 28

These will be very well-received features.

@ryankeairns
Copy link
Contributor

Working on adding these icons to EUI in time for Kibana 7.3: elastic/eui#2070

@monfera
Copy link
Contributor Author

monfera commented Jun 21, 2019

Thanks @ryankeairns! Will they import like the other icons over there, or do I need to do something special, or are you planning to add a commit?

@ryankeairns
Copy link
Contributor

Thanks @ryankeairns! Will they import like the other icons over there, or do I need to do something special, or are you planning to add a commit?

Upon updating from Master, you would be able to simply change the icon type (i.e. name).

@monfera
Copy link
Contributor Author

monfera commented Jun 21, 2019

Those things are awesome, Ryan, thanks! I see it's merged into eui but kibana master apparently hasn't picked it up yet, if you know when it happens, can you tap me on the shoulder? Or should I bump it myself in this PR and I don't do damage with it? Btw. should editorItemRight in your PR be editorItemAlignRight?

Lines now removed!

@monfera monfera force-pushed the alignment-distribution branch from ffd0a10 to 72e9fc2 Compare June 21, 2019 21:49
@monfera monfera changed the title [Canvas][WIP] Alignment and distribution [Canvas] Alignment and distribution Jun 21, 2019
@monfera monfera added review and removed WIP Work in progress labels Jun 21, 2019
@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@ryankeairns
Copy link
Contributor

@monfera Greg is working on a new release and will then update Kibana. If your PR is ready prior to that happening, you can merge yours and I will add the icons once Kibana has been updated.

It looks like editorItemRight is only in my CHAGELOG comment 😌 ... I'll get that fixed in my next PR!

@monfera
Copy link
Contributor Author

monfera commented Jun 24, 2019

Thanks @ryankeairns - I should've looked further in the code indeed, it's just in the comment (this PR uses the compliant name)

@monfera monfera force-pushed the alignment-distribution branch from 72e9fc2 to 881a524 Compare June 25, 2019 08:46
@ryankeairns
Copy link
Contributor

The design (icon) changes look good, just waiting on the EUI update in Kibana to come through.

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@cqliu1 cqliu1 added the v8.0.0 label Jun 25, 2019
Copy link
Contributor

@cqliu1 cqliu1 left a comment

Choose a reason for hiding this comment

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

This is such a neat feature! It makes lining up multiple elements so much easier. I just had a couple comments, but the rest looks good.

@@ -95,6 +95,25 @@ export const basicHandlerCreators = {
},
};

// handlers for group and ungroup
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: Can you update this comment?

};

this._getAlignmentMenuItems(close).forEach(menuFiller);
this._getDistributionMenuItems(close).forEach(menuFiller);
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: You implemented this differently than I did with _getLayerMenuItems. Why do you return the object wrapped in an array here instead of just the MenuTuple object?

Since _getLayerMenuItems, _getAlignmentMenuItems, and _getDistributionMenuItems are all similar functions, they should be implemented the same way, so it'd be great if you could refactor _getLayerMenuItems like the two new functions or vice versa.

Also, would it make sense to take the conditional check for the number of selectedNodes out of the individual functions and wrap the condition around these two function calls?

Here's an example of how I imagine this code looking (with all of the functions returning a MenuTuple object)

Suggested change
this._getDistributionMenuItems(close).forEach(menuFiller);
const menuFiller = ({ menuItem, panel }: MenuTuple) => {
items.push(menuItem);
panels.push(panel);
};
if (showLayerControls) {
menuFiller(this._getLayerMenuItems();
}
if(selectedNodes.length > 2) {
menuFiller(this._getAlignmentMenuItems(close));
menuFiller(this._getDistributionMenuItems(close));
}

Or alternatively (with all of the functions returning a MenuTuple[] array):

Suggested change
this._getDistributionMenuItems(close).forEach(menuFiller);
const menuFiller = ({ menuItem, panel }: MenuTuple) => {
items.push(menuItem);
panels.push(panel);
};
if (showLayerControls) {
this._getLayerMenuItems(close).forEach(menuFiller);
}
if(selectedNodes.length > 2) {
this._getAlignmentMenuItems(close).forEach(menuFiller);
this._getDistributionMenuItems(close).forEach(menuFiller);
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@cqliu1 thanks for the feedback, looking at it with a fresh pair of eyes, uniformity and just plain simplicity supports your take, now pushed

@cqliu1
Copy link
Contributor

cqliu1 commented Jun 25, 2019

@monfera Were you planning to add shortcuts for these actions?

@monfera
Copy link
Contributor Author

monfera commented Jun 26, 2019

@cqliu1 I haven't seen shortcuts required and wasn't surprised as similar software often also doesn't have shortcuts for these. While technically possible, the concern is that there's an overload of shortcuts for a comparatively rare operation: 3 ops: align horizoontally, align vertically and distribute; 2 or 3 suboptions each. Either resulting in somewhat random keys or they somehow involve arrow keys and modifiers.

Having said it, we could get the discussion going on shortcuts, can be a follow-up PR if it doesn't fit the time frame.

Also it's a prime candidate for an eventual context menu

@ryankeairns
Copy link
Contributor

I agree with @monfera 's assessment. These operations don't typically have shortcuts (at least not that I have experienced) and we could always add them later if the case arises. A context menu seems like a good solution, with regards to discoverability, in the long run.

@ryankeairns
Copy link
Contributor

Kibana has been updated to EUI 12.1.0. Please rebase to see the new icons. Thanks!

@monfera monfera force-pushed the alignment-distribution branch from 34d1f13 to de67169 Compare June 26, 2019 19:25
@elastic elastic deleted a comment from elasticmachine Jun 26, 2019
@monfera monfera requested a review from cqliu1 June 26, 2019 20:16
@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Copy link
Contributor

@cqliu1 cqliu1 left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@ryankeairns ryankeairns self-requested a review June 27, 2019 01:42
Copy link
Contributor

@ryankeairns ryankeairns left a comment

Choose a reason for hiding this comment

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

👍 LGTM, well done, great addition!

@monfera monfera merged commit 5fb13a8 into master Jun 27, 2019
@monfera monfera deleted the alignment-distribution branch June 27, 2019 09:34
monfera added a commit that referenced this pull request Jun 27, 2019
[Canvas] Alignment and distribution
monfera added a commit to monfera/kibana that referenced this pull request Jun 27, 2019
[Canvas] Alignment and distribution
@kibanamachine kibanamachine mentioned this pull request Jul 12, 2019
16 tasks
@elasticmachine
Copy link
Contributor

💔 Build Failed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New value added to drive a business result release_note:enhancement review Team:Presentation Presentation Team for Dashboard, Input Controls, and Canvas v7.3.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants