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

[discuss][uiActions] How to force specific action execution? #72673

Closed
Dosant opened this issue Jul 21, 2020 · 6 comments
Closed

[discuss][uiActions] How to force specific action execution? #72673

Dosant opened this issue Jul 21, 2020 · 6 comments
Labels
Feature:UIActions UI actions. These are client side only, not related to the server side actions..

Comments

@Dosant
Copy link
Contributor

Dosant commented Jul 21, 2020

Assuming we have:

  • Trigger1,
  • ActionA attached to Trigger1
  • ActionB attached to Trigger1

When app executes Trigger1, context menu popup is shown and user has to pick either ActionA or ActionB.
But assume for some cases app knows it wants to execute ActionA

What is the best way to implement this?

Some options I thought of:

  1. just execute Action1 directly without using a trigger? (is it a hack and uiActions shouldn't be used like this? Or is this fine?)
  2. Implement more specific trigger: "Trigger2" and attach only ActionA to it. Execute Trigger2
  3. Introduce concept of "default" action and allow to specify during trigger execution uiActions.exec(Trigger1, {useDefaultAction: true}), where it knowns default is ActionA

Probably related to #47468?

@streamich, @ppisljar, @stacey-gammon what is your take on it?


Real use case where this came up:

After adding nested triggers and actions I refactored explore underlying data to use Apply_filter_action. This enabled "explore underlying data" for Maps. Instead of disabling this functionality completely, I'd like to leave it. But there are advanced cases where this popup spoils the UX and, for now, I'd just like to not show that popup for some cases, but apply filter directly. (see Nathan's comment #71445 (comment))

But I am not sure what is the correct way to do it.

@Dosant Dosant added Team:AppArch Feature:UIActions UI actions. These are client side only, not related to the server side actions.. labels Jul 21, 2020
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-app-arch (Team:AppArch)

@ppisljar
Copy link
Member

ppisljar commented Jul 22, 2020

i think 1. is fine. 3. doesn't make sense, it results in 1.

so if app wants to execute specific action, execute that action.
the only reason you would fire a trigger is that app doesn't care what happens and leaves that decision to the admin/user/consumer.

however for the case of maps i am not sure that is the case ? what happens when you put map embeddable somewhere where there is no filter manager (and no action that would apply that filter) ? If its something inside the application itself that would be fine, but for something inside embeddable triggers should be used.

@Dosant
Copy link
Contributor Author

Dosant commented Jul 22, 2020

@ppisljar, this specific case is about map embeddable.

In current scenario from inside map embeddable, depending on what exactly user did, I want to one of:

  1. Either exec apply filter trigger and show all available options; or
  2. Apply filter directly, because I don't want intermediate context menu to popup

What if in case of executing action directly we would first call isCompatible?

 if (action.isCompatible(context)) {
  action.exec(context)
} 

@ppisljar
Copy link
Member

we discussed over zoom and decided to try option 3. as its not true it will result in option 1. there is one big difference, app running executeTriggerActions will not know which action will execute, just that the default one will, which still allows us to provide different action implementations in different apps (for example apply_filter_action will look different in apps without filter bar and not using filter manager)

@Dosant
Copy link
Contributor Author

Dosant commented Aug 4, 2020

@ppisljar, @streamich please check how it might look if we just go with just execute Action1 directly without using a trigger. It seems like it is fine to call Apply_Filter action in that case, because it comes from embeddable plugin and not relies on global filter bar.

WDYT?

#73067


for future more advanced cases we could get back and implement: #72673 (comment)

@Dosant
Copy link
Contributor Author

Dosant commented Sep 8, 2020

I guess this can be closed for now. Maps implement this using approach similar to #73067.

@Dosant Dosant closed this as completed Sep 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:UIActions UI actions. These are client side only, not related to the server side actions..
Projects
None yet
Development

No branches or pull requests

3 participants