+ performVCAction(dispatch, {softwareProductId, action, version, comment}) {
+ return MergeEditorActionHelper.analyzeSyncResult(dispatch, {itemId: softwareProductId, version}).then(({inMerge, isDirty, updatedVersion}) => {
+ if (updatedVersion.status === catalogItemStatuses.CERTIFIED &&
+ (action === VersionControllerActionsEnum.COMMIT || action === VersionControllerActionsEnum.SYNC)) {
+ versionPageActionHelper.fetchVersions(dispatch, {itemType: itemTypes.SOFTWARE_PRODUCT, itemId: softwareProductId});
+ dispatch({
+ type: modalActionTypes.GLOBAL_MODAL_WARNING,
+ data: {
+ title: i18n('Commit error'),
+ msg: i18n('Item version already Certified'),
+ cancelButtonText: i18n('Cancel')
+ }
+ });
+ return Promise.resolve(updatedVersion);
+ }
+ if (!inMerge) {
+ if (action === VersionControllerActionsEnum.SUBMIT) {
+ return this.manageSubmitAction(dispatch, {softwareProductId, version, isDirty});
+ }
+ else {
+ let isCallActionValid = action !== VersionControllerActionsEnum.COMMIT || isDirty;
+ if(isCallActionValid) {
+ return ItemsHelper.performVCAction({itemId: softwareProductId, action, version, comment}).then(() => {
+ versionPageActionHelper.fetchVersions(dispatch, {itemType: itemTypes.LICENSE_MODEL, itemId: softwareProductId});
+ if (action === VersionControllerActionsEnum.SYNC) {
+ return MergeEditorActionHelper.analyzeSyncResult(dispatch, {itemId: softwareProductId, version}).then(({updatedVersion}) => {
+ return Promise.resolve(updatedVersion);
+ });
+ } else {
+ return ItemsHelper.checkItemStatus(dispatch, {itemId: softwareProductId, versionId: version.id});
+ }
+ });
+ }
+ else {
+ dispatch({
+ type: modalActionTypes.GLOBAL_MODAL_ERROR,
+ data: {
+ title: i18n('Commit Failed'),
+ msg: i18n('There is nothing to commit')
+ }
+ });
+ }
+ }
+ }