Change Comment mandatory

Is it possible to make the change comment mandatory for every change to a confluence page? I tested a solution with a jquery macro but it doesn't work correct.

Any idea.
Thank you.

9 answers

1 accepted

This widget could not be displayed.

Okay, i will test and find out, why it doesn't work under Firefox.

The solutiion is a good base for further developement.

Thank you.

This widget could not be displayed.

Has nobody a good idea for this problem or maybe a link to a good workaround?

This widget could not be displayed.

as of now this is not feasible in confluence and already submitted request to implement this @ https://jira.atlassian.com/browse/CONF-6373

This widget could not be displayed.

Have you tried something like this? Add it to the custom html in Confluence Admin. I would stick it in the box that says "At end of the BODY".

AJS.toInit(function() {
	var buttonID = 'rte-button-publish';
	var textID = 'versionComment';
	
	if(AJS.$('#' + buttonID).length > 0 && AJS.$("#" + textID).length > 0) {
		//Disable save button
		AJS.$('#' + buttonID).prop('disabled', true);
		
		//If the text box changes and there is content re-enable the save button
		AJS.$("#" + textID).keyup(function() {
			if(AJS.$(this).val() !== '') {
				AJS.$('#' + buttonID).prop('disabled', false);
			} else {
				AJS.$('#' + buttonID).prop('disabled', true);
			}
		});
	}
});

 

 

I need something like this that requires body text in confluence.  I tried pasting this into the At the end of the BODY section with no changes in behaviour on Chrome on Mac or Safari on Mac.   We are running 6.3.3.  Do we need to restart confluence after adding Custom HTML?  I wouldn't think so.

Davin Studer Community Champion Oct 30, 2017

Did you put it inside script tags? If not you need to do that for it to work.

<script type="text/javascript">
AJS.toInit(function() {
var buttonID = 'rte-button-publish';
var textID = 'versionComment';

if(AJS.$('#' + buttonID).length > 0 && AJS.$("#" + textID).length > 0) {
        //Disable save button
        AJS.$('#' + buttonID).prop('disabled', true);

        //If the text box changes and there is content re-enable the save button
        AJS.$("#" + textID).keyup(function() {
            if(AJS.$(this).val() !== '') {
                AJS.$('#' + buttonID).prop('disabled', false);
            } else {
                AJS.$('#' + buttonID).prop('disabled', true);
            }
        });
    }
});
</script>

Oh, wait ... Also since they have changed how the editor work you now have to bind to it when it is initialized. It used to be that the page would reload for editing, but not anymore. Here is an updated version for newer versions of Confluence.

<script type="text/javascript">
AJS.toInit(function(){
    AJS.bind('init.rte-control', function(){
        var buttonID = 'rte-button-publish';
        var textID = 'versionComment';
        
        if(AJS.$('#' + buttonID).length > 0 && AJS.$("#" + textID).length > 0) {
            //Disable save button
            AJS.$('#' + buttonID).prop('disabled', true);
            
            //If the text box changes and there is content re-enable the save button
            AJS.$("#" + textID).keyup(function() {
                if(AJS.$(this).val() !== '') {
                    AJS.$('#' + buttonID).prop('disabled', false);
                } else {
                    AJS.$('#' + buttonID).prop('disabled', true);
                }
            });
        }
    });
});
</script>

 

Thanks for this.  No I hadn't done the script tags.  Unfortunately, this still doesn't seem to be disabling the publish button?

Davin Studer Community Champion Oct 31, 2017

Did you also see that I updated the code right above your latest reply? I changed it to take into account the newer way that the editor is initialized.

Yes, but unfortunately it didn't seem to make a difference.

Just to be sure, I put that in the Custom HTML at the end of the body.  I did not restart confluence.  Here is a screenshot.Screen Shot 2017-11-07 at 9.47.34 AM.png

Davin Studer Community Champion Nov 07, 2017

Hmmm ... It works on my install 6.4.2.  using the code above. If you open up your browser's developer tools (F12) do you see any JavaScript errors in the console ... especially when you enter edit mode.

Don't know why I didn't think of that.   Not seeing any of the code show up.   There is a javascript section earlier in the page, but I'm assuming you can have more than 1 code section in the body?

Screen Shot 2017-11-07 at 1.05.32 PM.png

OK, I'm stupid.  The code is working EXACTLY as its supposed to.  HOWEVER, what I was wanting was something slightly different.  I was wanting to require body content in every post before the publish button became available.   How can this code be modified to do that?

This widget could not be displayed.

Yes, i tested a solution with jquery, but it doesn't work. Your script doesn't disable the save button, it ist always enabled.

Davin Studer Community Champion Feb 04, 2014

What Confluence version are you on and what browser/verion are you using? This works just fine on my environments (Confluence 5.1.3 and 5.2.4).

This widget could not be displayed.

Okay, we are using Firefox. Now i have tested it with Chrome and IE and it works. But but why not with Firefox? Firefox is our preferred browser. I put debug messages to the script so i could see that the script was called but it was not able to disable the save button.

Davin Studer Community Champion Feb 05, 2014

I have tested it on my system with IE9,10,11, current Chrome, and current Firefox and all of them are working. I'm not sure why it isn't working on your system, but the code should work.

This widget could not be displayed.

I tried this using IE and Firefox and the save button is NOT disabled. DO I need to restart confluence on the server?

This widget could not be displayed.

Does anyone know if there is a newer or improved solution for this?  So far in my searching this answer is the one that seems most promising.

Davin Studer, I would like to enable mandatory change comments for a subset of pages within a space I own, but I don't have admin privlidges for the server - is this possible with your solution described above?

We are using version 5.8 server. 

Thanks!

Davin Studer Community Champion Jul 25, 2017

You would need to be a system admin. Also the JavaScript I provided would affect every page system wide.

Ok, that's what I thought but I appreciate the confirmation and the quick response.

This widget could not be displayed.

I tried the solution above (server 6.0.4), but the binding didn't work and also preview bypassed the control.

Below is my JS solution which always binds, including when previewing:

<script type="text/javascript">
function commentRequired() {
var buttonID = 'rte-button-publish';
var textID = 'versionComment';

// Find the button & text box, only work if they exist
if (AJS.$('#' + buttonID).length > 0 && AJS.$("#" + textID).length > 0) {
// Set status at start if necessary
if (AJS.$('#' + textID).val().length < 10) {
AJS.$('#' + buttonID).prop('disabled', true);
AJS.$("#" + textID).css('border-color','#f00')
AJS.$("#" + textID).css('background-color','#fff4f4')
}

//If the textbox changes update the status of button and textbox
AJS.$("#" + textID).keyup(function() {
if(AJS.$(this).val().length > 9) {
AJS.$('#' + buttonID).prop('disabled', false);
AJS.$("#" + textID).css('border-color','')
AJS.$("#" + textID).css('background-color','')
} else {
AJS.$('#' + buttonID).prop('disabled', true);
AJS.$("#" + textID).css('border-color','#f00')
AJS.$("#" + textID).css('background-color','#fff4f4')
}
});
}
}

AJS.bind('init.rte', function(a, e) {
$(e.editor.getWin().parent.document).bind("mode-changed", function() {
commentRequired();
});
$(e.editor.getWin().parent.document).bind("iframeAppended", function() {
commentRequired();
});
});
</script>

What I also did was used a Script Runner Script Fragment of type Web Panel to put this into the alt.editor.savebar area only for spaces matching certain criteria.

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Monday in Confluence

Why start from scratch? Introducing four new templates for Confluence Cloud

Hi my Community friends!  For those who don't know me, I'm a product marketer on the Confluence Cloud team - nice to meet you! For those of you who do, you know that I've been all up in your Co...

504 views 7 6
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you