-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[Dashboard] [Controls] Use uiActions
for control hover actions
#153065
[Dashboard] [Controls] Use uiActions
for control hover actions
#153065
Conversation
259531d
to
344bc81
Compare
9545168
to
9bfa2ac
Compare
@@ -106,7 +106,7 @@ const SortableControlInner = forwardRef< | |||
style={style} | |||
> | |||
<ControlFrame | |||
enableActions={isEditable && draggingIndex === -1} | |||
enableActions={draggingIndex === -1} |
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.
The available actions are now determined based on their individual compatibility + the disabled actions from the control group - so, we don't need to know if the dashboard is in edit mode for this anymore.
// if the field name or data view id has changed in this editing session, reset all selections | ||
newInput.selectedOptions = undefined; | ||
newInput.existsSelected = undefined; | ||
newInput.exclude = undefined; | ||
newInput.sort = undefined; |
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.
Before these were added, existsSelected
, exclude
, and sort
were all remembered when the data view and/or field of a control was changed - while it doesn't cause any apparent issues (unlike selectedOptions
, which was the only thing included before), it goes against expected behaviour IMO. If the data view and/or field of a control is changed, I would expect the entire state of the control to be reset.
@@ -17,7 +17,7 @@ | |||
.presentationUtil__floatingActions { | |||
opacity: 1; | |||
visibility: visible; | |||
transition: visibility .1s, opacity .1s; | |||
transition: visibility $euiAnimSpeedFast, opacity $euiAnimSpeedFast; |
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.
cc @andreadelrio We talked about this 👍
const viewMode = select((state) => state.explicitInput.viewMode); | ||
const disabledActions = select((state) => state.explicitInput.disabledActions); |
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 tried to pull as much logic as possible into the FloatingActions
component to keep the consumers as clean as possible - this meant adding the action fetching logic to this component. However, this caused an issue where I needed things to be re-fetched when certain control group state changed - for example, view mode or the disabled actions.
To get around this, I am taking in the Redux state selector hook so that the FloatingActions
component can re-fetch the compatible actions as these parts of state change... I tried a few different things, including taking each piece of state as a prop instead, but this seemed the cleanest to me? It ties the FloatingActions
component to the ReduxEmbeddableState
though, so I'm open to other ideas 👀
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.
Makes sense to me. Thanks for the explanation.
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 think ideally we wouldn't want the floating actions tied to any sort of redux-specific state. Most embeddable containers won't use that I think. Is there any complexity in just passing in viewMode
and disabledActions
as props?
Pinging @elastic/kibana-presentation (Team:Presentation) |
// @ts-ignore - TODO: Remove this once https://github.com/elastic/eui/pull/6645 lands in Kibana | ||
focusTrapProps: { scrollLock: true }, |
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.
Refer to #153227
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.
Just for clarification, am I correct that adding scrollLock: true
in this PR does not help until #153227 is in main
? Basically, we need scrollLock on the .kbnBody
class, too?
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.
lgtm!
code review and tested in chrome.
AFAICT, the weird flyout rendering issue should be resolved in a future EUI update.
// @ts-ignore - TODO: Remove this once https://github.com/elastic/eui/pull/6645 lands in Kibana | ||
focusTrapProps: { scrollLock: true }, |
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.
Just for clarification, am I correct that adding scrollLock: true
in this PR does not help until #153227 is in main
? Basically, we need scrollLock on the .kbnBody
class, too?
const viewMode = select((state) => state.explicitInput.viewMode); | ||
const disabledActions = select((state) => state.explicitInput.disabledActions); |
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.
Makes sense to me. Thanks for the explanation.
Yup, that's correct! And it should be in |
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.
Looks like Nick beat me to it, but I figured I had enough content that it warranted a double-review. In short, everything looks good!
src/plugins/controls/public/control_group/actions/delete_control_action.tsx
Outdated
Show resolved
Hide resolved
let reduxEmbeddablePackage: ReduxEmbeddablePackage; | ||
|
||
beforeAll(async () => { | ||
reduxEmbeddablePackage = await lazyLoadReduxEmbeddablePackage(); |
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.
Would it be quicker to use a mocked version of this? I am not entirely sure if one exists yet, but if not I will be adding it in #150121
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.
It probably would be, yeah! We don't seem to have the mock yet, though - if you plan to add one, that would be awesome!
src/plugins/controls/public/control_group/actions/delete_control_action.test.tsx
Show resolved
Hide resolved
src/plugins/controls/public/control_group/actions/edit_control_action.tsx
Outdated
Show resolved
Hide resolved
src/plugins/controls/public/control_group/actions/edit_control_action.tsx
Show resolved
Hide resolved
|
||
const onCancel = () => { | ||
if ( | ||
isEqual(panel.explicitInput, { |
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.
As a follow-up in some other PR maybe we should look into fixing the bug where the confirm model is shown if you create a new control then immediately cancel.
const viewMode = select((state) => state.explicitInput.viewMode); | ||
const disabledActions = select((state) => state.explicitInput.disabledActions); |
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 think ideally we wouldn't want the floating actions tied to any sort of redux-specific state. Most embeddable containers won't use that I think. Is there any complexity in just passing in viewMode
and disabledActions
as props?
@ThomThomson Nope - if passing through props is preferred, then we can totally do that 💃 I just wasn't sure which style would be preferred, so I opted for fewest-props - but I didn't necessarily feel super strong one way or another. Moved to props in 505924e 👍 |
…-ref HEAD~1..HEAD --fix'
💛 Build succeeded, but was flaky
Failed CI StepsTest Failures
Metrics [docs]Module Count
Public APIs missing comments
Any counts in public APIs
Async chunks
Page load bundle
Unknown metric groupsAPI count
async chunk count
ESLint disabled line counts
Total ESLint disabled count
History
To update your PR or re-run it, just comment with: cc @Heenawter |
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.
Design changes LGTM. Amazing work @Heenawter!
Hello @Heenawter , @ThomThomson One thought/suggestion came to me mind regarding the Actions. In addition to This will help to make the control Let me know what you think. |
Closes #143585
Closes #151767
Closes #152609
Summary
This PR accomplishes three things, the first of which is moving the edit/delete control hover actions to use the
uiActions
service - this is the first step in moving existing panel actions (such as replacing the panel, opening the panel settings flyout, etc.) to this hover framework, which is outlined in this issue.While this was the primary goal of this PR, this also made the following fixes possible:
Since I was refactoring the control editor flyout code as part of this PR, I made it so that changes to the control's width/grow properties are only applied when the changes are saved rather than being automatically applied.
Since the edit control button is no longer a custom component, the tooltip now responds to focus as expected.
Checklist
For maintainers