Widget action not found


#1

I’m using the new widget api to add a download button to the post menu. The button renders correctly but my action is not called. What am I doing wrong? I am attach an action in the same initializer as I am adding the button as following.

withPluginApi('0.1', api => {

    api.addPostMenuButton('download', (post) => {
      if (post.upload_url) {
        return {
          action: 'downloadFile',
          icon: 'download',
          className: 'download-file',
          title: 'files.download',
          position: 'first'
        };
      }
    });

    api.attachWidgetAction('post', 'downloadFile', function() {
      const post = this.model;
      const upload_url = post.get('upload_url');
      return upload_url;
    });

});

I get the following error.

WARNING: downloadFile not found


(cpradio) #2

This should be

api.attachWidgetAction('post-menu', 'downloadFile', function() {

Example to compare it to


#3

Wow thanx! Of course it should be attached to the widget not the model. :slight_smile: