Action hook call back not happening

28 views
Skip to first unread message

Ayush Singhal

unread,
Jun 22, 2017, 3:14:34 AM6/22/17
to reviewboard
Hi,

I have added a button to action bar but call back is not happening, i have followed the example, it throws an error saying RBCallback is not defined:

extension.py:-

from reviewboard.extensions.base import Extension, JSExtension
from reviewboard.extensions.hooks import (HeaderDropdownActionHook,
                                          ReviewRequestActionHook)
class actionJsExtention(JSExtension):
    model_class = 'RBCallback.Extension'

class navigationHook(Extension):

        # Single entry on review requests, consumed from JavaScript.
    def initialize(self):
        ReviewRequestActionHook(self, actions=[
            {
                'id': 'reject-id',
                'label': 'Reject',
                'url': '#',
            },
        ])


    js_extensions = [actionJsExtention]
    js_bundles = {
        'default': {
            'source_filenames': (
                'js/callback.js',
            )
        },
    }

callback.js:-

window.RBCallback = {};

(function() {
    console.log('In callback.js');
    RBCallback.Extension = RB.Extension.extend({

        initialize: function () {
            console.log('Initializing the extension');
            var _onRejectActionClicked;
            RB.Extension.initialize.call(this);

            _onRejectActionClicked = function(){
                if (confirm(gettext('Are you sure?'))) {
                    console.log('Click confirmed');
                }
                else {
                    console.log('Not confirmed');
                }
        };

            new RB.ReviewRequestActionHook({
                extension: this,
                callbacks: {
                    '#reject-id': _onRejectActionClicked,
                }
            });
        }
    });
})();

Christian Hammond

unread,
Jun 22, 2017, 6:53:36 AM6/22/17
to revie...@googlegroups.com
Hi Ayush,

Can you confirm that the page is loading callback.js?

Can you make sure you don't have DEBUG = True set in your sitedir/conf/settings_local.py file? It will need to be False unless you're running a development server.

Also, can you tell me more about your extension package setup? Are you building an egg or wheel package and then installing it, or using 'setup.py develop'?

If building a package, can you inspect the contents (it's a zip file, effectively) and make sure callback.js is in there?

Christian


--
Supercharge your Review Board with Power Pack: https://www.reviewboard.org/powerpack/
Want us to host Review Board for you? Check out RBCommons: https://rbcommons.com/
Happy user? Let us know! https://www.reviewboard.org/users/
---
You received this message because you are subscribed to the Google Groups "reviewboard" group.
To unsubscribe from this group and stop receiving emails from it, send an email to reviewboard...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
--
Christian Hammond
President/CEO of Beanbag
Makers of Review Board
Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted

Ayush Singhal

unread,
Jun 22, 2017, 9:50:35 AM6/22/17
to reviewboard
Hi Christian,

Thanks for the quick response.
No page is not loading.
In conf/settings_local.py file, DEBUG is False.
I am building egg package and using setup.py.
No, callback is not present in zip file.

setup.py:

from reviewboard.extensions.packaging import setup
from setuptools import find_packages


setup(
    name='Add_item_navigation',
    version='0.1',
    description='Add items to the navigation bar',
    author='Ayush Singhal',
    packages=find_packages(),
    entry_points={
        'reviewboard.extensions': [
            'sample_extension = navigation_hook.extension:navigationHook',
        ]
    },
)



Christian Hammond

unread,
Jun 22, 2017, 3:44:49 PM6/22/17
to revie...@googlegroups.com
Hi Ayush,

Where did you place the callback.js in your tree?

If your extension is in myextension/extension.py, then callback.js must be in myextension/static/callback.js.

Christian

--
Supercharge your Review Board with Power Pack: https://www.reviewboard.org/powerpack/
Want us to host Review Board for you? Check out RBCommons: https://rbcommons.com/
Happy user? Let us know! https://www.reviewboard.org/users/
---
You received this message because you are subscribed to the Google Groups "reviewboard" group.
To unsubscribe from this group and stop receiving emails from it, send an email to reviewboard+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--

黄鑫

unread,
May 16, 2019, 3:27:01 AM5/16/19
to Review Board Community
I met the same issue.

Try if this patch can fix the issue.

--- ReviewBoard-3.0.14/reviewboard/htdocs/static/rb/js/views/reviewRequestEditorView.js.old     2019-05-16 15:06:34.432177001 +0800
+++ ReviewBoard-3.0.14/reviewboard/htdocs/static/rb/js/views/reviewRequestEditorView.js 2019-05-16 15:06:52.535691603 +0800
@@ -693,7 +693,7 @@
             $uploadFile.click(this._onUploadFileClicked);

             RB.ReviewRequestActionHook.each(function (hook) {
-                _.each(hook.get('callbacks'), function (selector, handler) {
+                _.each(hook.get('callbacks'), function (handler, selector) {
                     return _this4.$(selector).click(handler);
                 });
             });




在 2017年6月22日星期四 UTC+8下午3:14:34,Ayush Singhal写道:
Reply all
Reply to author
Forward
0 new messages