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

[Lens] Drag dimension to replace #75895

Merged
merged 16 commits into from
Sep 4, 2020

Conversation

wylieconlon
Copy link
Contributor

@wylieconlon wylieconlon commented Aug 25, 2020

This only works when dragging dimensions to a different groups, such as "X-axis" to "Break down by". Example:

dragging with strikethrough

As a side effect of the drag changes, the table configuration is now split into "Break down by" and "Metrics":

Screen Shot 2020-08-25 at 12 11 15 PM

Still to do: Functional tests and Kibana docs update.

Part of #51739

Checklist

Delete any items that are not applicable to this PR.

@wylieconlon wylieconlon added Team:Visualizations Visualization editors, elastic-charts and infrastructure v8.0.0 Feature:Lens v7.10.0 labels Aug 25, 2020
@wylieconlon wylieconlon requested review from cchaos, dej611, mbondyra and a team August 25, 2020 16:14
@wylieconlon wylieconlon requested a review from a team as a code owner August 25, 2020 16:14
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-app (Team:KibanaApp)

@cchaos
Copy link
Contributor

cchaos commented Aug 25, 2020

Context: Reviewing solely the "Replace" functionality

Aside from some stylistic tweaks to the dragging item (hover & focus states), this behavior works pretty well. I think more than the strikethrough, the more evident thing we can do to show that this will be moving the config is to hide the original placement.

DnD across 2

When they're hovering over a new spot, whether a pre-existing config or empty config, the known paradigm will be that this will take its spot, so whatever we do to the styling of the new placement isn't as necessary.

Then we also need to be sure to use the correct grabbing cursor too. I had originally thought we should use copy for when hovering over any place that will accept it, but I think we should reserve that for when we can actual duplicate.

@wylieconlon
Copy link
Contributor Author

@cchaos Thanks for the feedback! I implemented a visibility: hidden style to the dragged item if it's a column, because it needs to maintain its position in the DOM but not be rendered. The other change you've asked for is more wide-reaching and will affect all drag & drop behavior in Lens, so I will not implement it as part of this PR. It sounds like I should expect your approval on the PR soon- if not, please be specific about what you're blocking approval on.

.lnsLayerPanel__dimension-replace {
text-decoration: line-through;
}

Copy link
Contributor

@mbondyra mbondyra Aug 26, 2020

Choose a reason for hiding this comment

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

To avoid the effect of 'x' button being slower than the rest when dragging, you could add a custom className and overwrite transition: all 250ms ease-in setting coming from EUI, eg: transition: all 250ms ease-out, visibility 0ms;
I found a better solution - can you instead animate opacity:0 and not visibility on .lnsLayerPanel__dimension-hidden? Opacity is more performant and solves the problem with the button.

Here's what I mean:

@@ -27,6 +27,14 @@
overflow: hidden;
}

.lnsLayerPanel__dimension-hidden {
Copy link
Contributor

Choose a reason for hiding this comment

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

nitpick: in other places in lens we use BEM notation with a format block__element--modifier so you might want to change it to .lnsLayerPanel__dimension--hidden and lnsLayerPanel__dimension--replace

Copy link
Contributor

Choose a reason for hiding this comment

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

BEM also indicates that you use a single dash for specific states. Like block__element-isDisabled. The single dash is technically correct here, but it's better to indicate state by adding the is in front like: lnsLayerPanel__dimension-isHidden

Copy link
Contributor

@mbondyra mbondyra left a comment

Choose a reason for hiding this comment

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

I left few small comments, but overall looks good 👍 I will leave my 'approve' when we're aligned with Caroline about the design details.

@cchaos
Copy link
Contributor

cchaos commented Aug 26, 2020

Two more situations to think more about or make sure we follow up on.

1. Dragging a config that has no where to go

Right now you can start dragging a Y-axis config, but there's no place for it to go.

Screen Recording 2020-08-26 at 11 18 00 AM

How should we handle this situation? I'm thinking that it's not right to completely disable the drag effect because it might look like a bug. Perhaps we need to not only indicate good drop zones but bad ones as well. Perhaps by just decreasing the opacity of the bad ones.

DnD across 7

It may be mostly a temporary measure since we should eventually get to a place where any configs can be replaced, but it does at least set us up with something in the event we come across this situation that will happen.

2. Dragging between layers

Screen Recording 2020-08-25 at 10 24 03 PM

@wylieconlon
Copy link
Contributor Author

@cchaos I can't tell which comments of yours are meant to be blocking approval, and which are meant for further discussion. Both of your most recent comments need more discussion, and I'm not sure that they should be done in this PR. Here's why they need more discussion:

  1. There are at least three approaches to adding a "not droppable" indicator:
    • Currently all draggable items behave the same in Lens. We could have separate behavior for fields and operations, and start having diverging styling for those two.
    • If an item can't be dropped anywhere, maybe we should prevent it from being dragged. This is more technically complex and would require a separate implementation.
    • Finally, the simplest implementation which I prefer is to apply these styles to all drop targets in Lens. This is how it looks:

drag with indication of non-droppable areas

The GIF here is showing my preferred way of doing it. If you agree, I'll implement in this PR. If you disagree, let's implement it in a separate PR due to technical complexity.

  1. Replacing operations between layers is a feature that I don't see a strong use case for. I can see it being useful for "copy" or "swap" behaviors. Can you explain why you want this?

@cchaos
Copy link
Contributor

cchaos commented Aug 27, 2020

Finally, the simplest implementation which I prefer is to apply these styles to all drop targets in Lens. This is how it looks:

I agree with this approach and your implementation looks good to me. Lets do it 👍

Replacing operations between layers is a feature that I don't see a strong use case for. I can see it being useful for "copy" or "swap" behaviors. Can you explain why you want this?

Because "Replacing" doesn't just replace an existing config, but can move an X-axis from layer 1 to the newly created X-axis of of the newly created (empty) layer 2. And it seemed to me like replacing is a precursor to being able to swap and copy. If you disagree with this approach, that's fine.

@wylieconlon
Copy link
Contributor Author

@cchaos I think this PR can be approved by you, if there is anything you're blocking approval on please be specific. I am not implementing dragging across layers in this PR. I'd welcome some clarification of the behavior you were expected in the parent issue. #51739

@wylieconlon wylieconlon requested a review from cchaos September 1, 2020 18:38
@wylieconlon
Copy link
Contributor Author

@cchaos I think the PR is approvable now. One of the changes you requested was already done, and the other is done now.

Copy link
Contributor

@cchaos cchaos left a comment

Choose a reason for hiding this comment

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

Functionally this LGTM. 🎉

I'll end up doing some design clean up to the different DnD states once we get them hall worked out functionally.

I think @myasonik may have some a11y concerns that he may want to bring up proactively so we can address them early before it's all been configured.

@myasonik
Copy link
Contributor

myasonik commented Sep 2, 2020

I took a look and this PR doesn't seem to make anything worse than what already existed so I'm actually not going to leave any a11y feedback right now

@wylieconlon wylieconlon requested a review from mbondyra September 2, 2020 18:39
@wylieconlon
Copy link
Contributor Author

@elasticmachine merge upstream

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Build metrics

page load bundle size

id value diff baseline
lens 873.9KB +6.6KB 867.3KB

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

@mbondyra
Copy link
Contributor

mbondyra commented Sep 4, 2020

Tested on Firefox, looks good!

@wylieconlon wylieconlon merged commit 9ca8551 into elastic:master Sep 4, 2020
@wylieconlon wylieconlon deleted the lens/drag-to-replace branch September 4, 2020 14:11
wylieconlon pushed a commit that referenced this pull request Sep 4, 2020
* [Lens] Drag to replace

* Add jest tests for drag and drop

* Fix bug in dragging to empty

* Hide dragged dimension when drag starts

* Make table metrics required

* Update class names

* Implement styles on non-droppable items

* Replace drag and drop image in docs

* Remove extra specificity

Co-authored-by: Elastic Machine <[email protected]>

Co-authored-by: Elastic Machine <[email protected]>
gmmorris added a commit to gmmorris/kibana that referenced this pull request Sep 4, 2020
* master: (47 commits)
  Do not require id & description when creating a logstash pipeline (elastic#76616)
  Remove commented src/core/tsconfig file (elastic#76792)
  Replaced whitelistedHosts with allowedHosts in actions ascii docs (elastic#76731)
  [Dashboard First] Genericize Attribute Service (elastic#76057)
  [ci-metrics] unify distributable file count metrics (elastic#76448)
  [Security Solution][Detections] Handle conflicts on alert status update (elastic#75492)
  [eslint] convert to @typescript-eslint/no-unused-expressions (elastic#76471)
  [DOCS] Add default time range filter to advanced settings (elastic#76414)
  [Security Solution] Refactor NetworkTopNFlow to use Search Strategy (elastic#76249)
  [Dashboard] Update Index Patterns when Child Index Patterns Change (elastic#76356)
  [ML] Add option to Advanced Settings to set default time range filter for AD jobs (elastic#76347)
  Add CSM app to CODEOWNERS (elastic#76793)
  [Security Solution][Exceptions] - Updates exception item find sort field (elastic#76685)
  [Security Solution][Detections][Tech Debt] - Move to using common io-ts types (elastic#75009)
  [Lens] Drag dimension to replace (elastic#75895)
  URI encode the index names we fetch in the fetchIndices lib function. (elastic#76584)
  [Security Solution] Resolver retrieve entity id of documents without field mapped (elastic#76562)
  [Ingest Manager] validate agent route using AJV instead kbn-config-schema (elastic#76546)
  Updated non-dev usages of node-forge (elastic#76699)
  [Ingest Pipelines] Processor forms for processors K-S (elastic#75638)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:Lens release_note:enhancement Team:Visualizations Visualization editors, elastic-charts and infrastructure v7.10.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants