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

✨ Create whitelist for amp-viewer-assistance.updateActionState actionStatus #21630

Merged

Conversation

hellokoji
Copy link
Contributor

In response to this discussion comment, I created a whitelist for valid action statuses that can be passed via amp-viewer-assistance and updateActionState.

/cc @choumx

Change-Id: I9aeff992b2cde5215463a1f4ad717f7426818498
Change-Id: I9147bfe84b34bbe5ed0e86c59155cdf51e972cc6
*/
isValidActionStatusArgs_(args) {
const update = args['update'];
if (!update || !update['actionStatus']) {

Choose a reason for hiding this comment

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

Hm, not sure we support object literals outside of AMP.setState (syntax). What would this look like in HTML?

<!-- Is this the intention? -->
<button on="tap:amp-viewer-assistance.updateActionStatus(update={actionStatus: ACTIVE_ACTION_STATUS})">

<!-- 
  Or maybe we can do this (case-insensitive)? 
  Uppercase and append "_ACTION_STATUS" before sending viewer message. 
-->
<button on="tap:amp-viewer-assistance.updateActionStatus(status=active)">

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The first example is how it's usually implemented except with the payload being passed from an event:

<form id="my-form"
      action-xhr="some/XHR"
      on="submit-success:amp-viewer-assistance.updateActionState(update=event.response.result)">
 </form>

It's also important to note that the update payload can include additional data in another field (usually result), but it is too complex to validate on the run-time side.

{
  'actionStatus': 'COMPLETED_ACTION_STATUS',
  'result': { ... }
}

Choose a reason for hiding this comment

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

I see, thanks.

extensions/amp-viewer-assistance/amp-viewer-assistance.md Outdated Show resolved Hide resolved
*/
isValidActionStatusArgs_(args) {
const update = args['update'];
if (!update || !update['actionStatus']) {

Choose a reason for hiding this comment

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

I see, thanks.

Change-Id: I4673794d9e0a469e1bf5ee7a755682b40f8ae300
@dreamofabear dreamofabear merged commit cf42cef into ampproject:master Apr 3, 2019
@hellokoji hellokoji deleted the updateActionState-whitelist branch April 3, 2019 16:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants