function MentoringWithStepsEdit(runtime, element) {
    "use strict";
    // Disable "add" buttons when a message of that type already exists:
    var $buttons = $('.add-xblock-component-button[data-category=pb-message]', element);
    var updateButtons = function() {
        $buttons.each(function() {
            var msg_type = $(this).data('boilerplate');
            $(this).toggleClass('disabled', $('.xblock .submission-message.'+msg_type).length > 0);
        });
    };
    updateButtons();
    $buttons.click(function(ev) {
        if ($(this).is('.disabled')) {
            ev.preventDefault();
            ev.stopPropagation();
        } else {
            $(this).addClass('disabled');
        }
    });

    ProblemBuilderUtil.transformClarifications(element);
    StudioEditableXBlockMixin(runtime, element);
}

function MentoringWithStepsEdit(runtime, element) {
    "use strict";

    var blockIsPresent = function(klass) {
        return $('.xblock ' + klass).length > 0;
    };

    var updateButton = function(button, condition) {
        button.toggleClass('disabled', condition);
    };

    var disableButton = function(ev) {
        if ($(this).is('.disabled')) {
            ev.preventDefault();
            ev.stopPropagation();
        } else {
            $(this).addClass('disabled');
        }
    };

    var initButtons = function(dataCategory) {
        var $buttons = $('.add-xblock-component-button[data-category='+dataCategory+']', element);
        $buttons.each(function() {
            if (dataCategory === 'pb-message') {
                var msg_type = $(this).data('boilerplate');
                updateButton($(this), blockIsPresent('.submission-message.'+msg_type));
            } else {
                updateButton($(this), blockIsPresent('.xblock-header-sb-review-step'));
            }
        });
        $buttons.on('click', disableButton);
    };

    initButtons('pb-message');
    initButtons('sb-review-step');

    ProblemBuilderUtil.transformClarifications(element);
    StudioEditableXBlockMixin(runtime, element);
}

Allow only one review step per mentoring block.
Allow only one review step per mentoring block.
