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

[ui_actions] Remove declare module pattern for trigger/action mappings #82790

Closed
lukeelmers opened this issue Nov 5, 2020 · 2 comments
Closed
Labels
Feature:UIActions UI actions. These are client side only, not related to the server side actions.. impact:low Addressing this issue will have a low level of impact on the quality/strength of our product. loe:small Small Level of Effort technical debt Improvement of the software architecture and operational architecture

Comments

@lukeelmers
Copy link
Member

Currently the ui_actions plugin exposes TriggerContextMapping and ActionContextMapping as interfaces that can be augmented by other plugins which are registering custom triggers/actions like so (example from data):

declare module '../../ui_actions/public' {
  export interface TriggerContextMapping {
    [APPLY_FILTER_TRIGGER]: ApplyGlobalFilterActionContext;
  }

  export interface ActionContextMapping {
    [ACTION_GLOBAL_APPLY_FILTER]: ApplyGlobalFilterActionContext;
    [ACTION_SELECT_RANGE]: SelectRangeActionContext;
    [ACTION_VALUE_CLICK]: ValueClickActionContext;
  }
}

This pattern was originally borrowed from core's RouteHandlerContext, however this is something we are looking to move away from.

While the simplicity of importing a single interface for everything in a registry is convenient, it can create implicit dependencies between plugins. (If your plugin depends on a trigger registered by another plugin, you should import any necessary types directly from that plugin instead of accessing it indirectly via the ui_actions typings).

One strategy for solving this could be removing the "mapping" interfaces and instead modifying generic type params where applicable, so that folks can specify the expected return types which you cast to internally, e.g.

uiActions.getTrigger<ValueClickActionContext>(ACTION_VALUE_CLICK);

Alternatively you can put the responsibility on consumers to directly do casting:

uiActions.getTrigger(ACTION_VALUE_CLICK) as ValueClickActionContext;
@lukeelmers lukeelmers added technical debt Improvement of the software architecture and operational architecture Team:AppArch Feature:UIActions UI actions. These are client side only, not related to the server side actions.. labels Nov 5, 2020
@elasticmachine
Copy link
Contributor

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

@exalate-issue-sync exalate-issue-sync bot added impact:low Addressing this issue will have a low level of impact on the quality/strength of our product. loe:small Small Level of Effort labels Jun 21, 2021
@vadimkibana
Copy link
Contributor

Closing as this was completed some time ago.

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.. impact:low Addressing this issue will have a low level of impact on the quality/strength of our product. loe:small Small Level of Effort technical debt Improvement of the software architecture and operational architecture
Projects
None yet
Development

No branches or pull requests

3 participants