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

Fix data passing from plugins to DialogActions #814

Closed
wants to merge 1 commit into from
Closed

Fix data passing from plugins to DialogActions #814

wants to merge 1 commit into from

Conversation

daltonmatos
Copy link
Contributor

Hello all,

Plugins are currently unable to show any usable dialogs. Any call to

PluginHelper.callAction(PluginActions.DIALOG_ALERT, {
  title: "Hello world",
  message: "Hi, Plugin speaking here."
});

will result in a blank Alert Dialog Box. The problem seems to be on the
transformation that action.data suffers prior to be passed to
proxy.actionFunction().

With action.data being an object, in this case, {title: "...", message: "..."}, when calling actionFunction(...action.data) the result is
actionFunction([]), which creates the empty Dialog Box.

This happens because every registered actionFunction, in this case
DialogActions.{alert,insert,updatem,delete}, already has its signature
as DialogActions.<func-name>(...data).

If we prefer to leave this elipsis also on the callling side, another
way to fix is to change tha call to:

proxy.actionFunction(...[action.data]);

Let me know what you all think about this change. The code example was extracted from the example plugin, here.

Plugins are currently unable to show any usable dialogs. Any call to

```
PluginHelper.callAction(PluginActions.DIALOG_ALERT, {
  title: "Hello world",
  message: "Hi, Plugin speaking here."
});
```

will result in a blank Alert Dialog Box. The problem seems to be on the
transformation that `action.data` suffers prior to be passed to
`proxy.actionFunction()`.

With `action.data` being an object, in this case, `{title: "...",
message: "..."}`, when calling `actionFunction(...action.data)` the result is
`actionFunction([])`, which creates the empty Dialog Box.

This happens because every registered actionFunction, in this case
`DialogActions.{alert,insert,updatem,delete}`, already has its signature
as `DialogActions.<func-name>(...data)`.

If we prefer to leave this elipsis also on the callling side, another
way to fix is to change tha call to:

```
proxy.actionFunction(...[action.data]);
```
@Poltergeist
Copy link
Contributor

Hi @daltonmatos,

Thanks for the Pull request. I will look into the pull request in the next days.

@daltonmatos
Copy link
Contributor Author

daltonmatos commented Aug 25, 2017

Thanks @Poltergeist,

Let me know what you think. Feel free to point out any adjustments.

@daltonmatos
Copy link
Contributor Author

Hello @Poltergeist, have yo had any time to review this PR?

Thanks,

@orlandohohmeier
Copy link
Contributor

@daltonmatos We're using the spread syntax to pass multiple values to actionFunction, thus you should always pass an arguments array to PluginHelper.callAction. This allows us to also proxy actions that require more than argument, but we might wanna change the property name from data to args to document the intention.

Example

PluginHelper.callAction(PluginActions.DIALOG_ALERT, [{
  title: "Hello world",
  message: "Hi, Plugin speaking here."
}]);

I just checked and have to admit that the example plugin is actually wrong. I opened a PR to address the issue and would love if you could review my changes.

mesosphere/marathon-ui-example-plugin#6

I'm going to close this PR as the change is not desired. Hope that is ok with you.

@daltonmatos
Copy link
Contributor Author

Sure, @orlandohohmeier. Thanks for the clarifications!

I just reviewed the example-plugin code and it works as expected. This PR here does not make sense, indeed.

Thanks a lot!

@daltonmatos daltonmatos deleted the feature/fix-plugin-action-proxy branch August 30, 2017 13:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants