Custom code after Git/commit
Having trouble deploying Oxygen XML Web Author? Got a bug to report? Post it all here.
Custom code after Git/commit
Hi,
I want to add some custom javascript code after a git-commit-actions has completed successfully.
I already managed to execute some code (console.log() for testing) after the action. But how do I check if the commit was successful? Currently it is also executed when the user aborts in the commit dialog.
My current code looks like this (also checking for the document to be valid before the commit):
Thanks and regards,
Patrik
I want to add some custom javascript code after a git-commit-actions has completed successfully.
I already managed to execute some code (console.log() for testing) after the action. But how do I check if the commit was successful? Currently it is also executed when the user aborts in the commit dialog.
My current code looks like this (also checking for the document to be valid before the commit):
Code: Select all
goog.events.listenOnce(e.editor, sync.api.Editor.EventTypes.ACTIONS_LOADED, function(e) {
var commitAction = editor.getActionsManager().getActionById('Git/Commit');
var oldActionPerformed = commitAction.actionPerformed;
commitAction.actionPerformed = function(callback) {
editor.getActionsManager().invokeOperation(
'com.gdvdl.webauth.IsDocumentValid',
{}, // no parameters
function (err, result) {
console.log('Git/Commit - isValid: ' + result);
if (result == 'true') {
console.log('Git/Commit - valid');
oldActionPerformed.call(commitAction, function(callback) {
console.log('Git/Commit - Done!');
// TODO: check for successfull commit and perform some post-commit-action
});
} else {
[...] (error message)
}
},
null,
true // This is a background operation - it does not update the document
);
};
});
Thanks and regards,
Patrik
-
- Posts: 513
- Joined: Thu Sep 04, 2014 4:22 pm
Re: Custom code after Git/commit
Post by cristi_talau »
Hello,
Yes. The action callback is called after the action is executed regardless of its "successfulness" - in general, it is hard to say what success means for an action, although for commit it is pretty clear.
One option would be to check if the editor is dirty: https://www.oxygenxml.com/maven/com/oxy ... ml#isDirty .
Best,
Cristian
Yes. The action callback is called after the action is executed regardless of its "successfulness" - in general, it is hard to say what success means for an action, although for commit it is pretty clear.
One option would be to check if the editor is dirty: https://www.oxygenxml.com/maven/com/oxy ... ml#isDirty .
Best,
Cristian
Re: Custom code after Git/commit
Thanks for the idea. I also added some check to only enable a commit of dirty documents. This way I know for sure that a non-dirty document after commit has been commited.
Regards,
Patrik
Regards,
Patrik
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service