1
0
mirror of https://github.com/ansible/awx.git synced 2024-11-01 08:21:15 +03:00

Merge pull request #4041 from mabashian/wf-execute-unsaved

Fixes bug where save changes modal was shown to user with execute permissions

Reviewed-by: Michael Abashian
             https://github.com/mabashian
This commit is contained in:
softwarefactory-project-zuul[bot] 2019-06-14 13:45:33 +00:00 committed by GitHub
commit 612373c849
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 9 additions and 11 deletions

View File

@ -498,7 +498,7 @@ angular.module('templates', [surveyMaker.name, jobTemplates.name, labels.name, p
}, },
views: { views: {
'modal': { 'modal': {
template: `<workflow-maker ng-if="includeWorkflowMaker" workflow-job-template-obj="workflow_job_template_obj" can-add-workflow-job-template="canAddWorkflowJobTemplate"></workflow-maker>` template: `<workflow-maker ng-if="includeWorkflowMaker" workflow-job-template-obj="workflow_job_template_obj" can-add-or-edit="canAddOrEdit"></workflow-maker>`
}, },
'jobTemplateList@templates.editWorkflowJobTemplate.workflowMaker': { 'jobTemplateList@templates.editWorkflowJobTemplate.workflowMaker': {
templateProvider: function(WorkflowMakerJobTemplateList, generateList) { templateProvider: function(WorkflowMakerJobTemplateList, generateList) {

View File

@ -20,7 +20,7 @@ export default [
const workflowTemplate = resolvedModels[1]; const workflowTemplate = resolvedModels[1];
$scope.canAddWorkflowJobTemplate = workflowTemplate.options('actions.POST'); $scope.canAddOrEdit = workflowTemplate.options('actions.POST');
$scope.canEditOrg = true; $scope.canEditOrg = true;
$scope.canEditInventory = true; $scope.canEditInventory = true;

View File

@ -26,12 +26,6 @@ export default [
$scope.sufficientRoleForNotif = isNotificationAdmin || $scope.user_is_system_auditor; $scope.sufficientRoleForNotif = isNotificationAdmin || $scope.user_is_system_auditor;
$scope.missingTemplates = _.has(workflowLaunch, 'node_templates_missing') && workflowLaunch.node_templates_missing.length > 0 ? true : false; $scope.missingTemplates = _.has(workflowLaunch, 'node_templates_missing') && workflowLaunch.node_templates_missing.length > 0 ? true : false;
$scope.$watch('workflow_job_template_obj.summary_fields.user_capabilities.edit', function(val) {
if (val === false) {
$scope.canAddWorkflowJobTemplate = false;
}
});
const criteriaObj = { const criteriaObj = {
from: (state) => state.name === 'templates.editWorkflowJobTemplate.workflowMaker', from: (state) => state.name === 'templates.editWorkflowJobTemplate.workflowMaker',
to: (state) => state.name === 'templates.editWorkflowJobTemplate' to: (state) => state.name === 'templates.editWorkflowJobTemplate'
@ -289,7 +283,7 @@ export default [
$scope.workflow_job_template_obj = workflowJobTemplateData; $scope.workflow_job_template_obj = workflowJobTemplateData;
$scope.name = workflowJobTemplateData.name; $scope.name = workflowJobTemplateData.name;
$scope.can_edit = workflowJobTemplateData.summary_fields.user_capabilities.edit; $scope.can_edit = $scope.canAddOrEdit = workflowJobTemplateData.summary_fields.user_capabilities.edit;
$scope.breadcrumb.workflow_job_template_name = $scope.name; $scope.breadcrumb.workflow_job_template_name = $scope.name;
let fld, i; let fld, i;
for (fld in form.fields) { for (fld in form.fields) {

View File

@ -11,7 +11,7 @@ export default ['templateUrl', 'CreateDialog', 'Wait', '$state', '$window',
return { return {
scope: { scope: {
workflowJobTemplateObj: '=', workflowJobTemplateObj: '=',
canAddWorkflowJobTemplate: '=' canAddOrEdit: '='
}, },
restrict: 'E', restrict: 'E',
templateUrl: templateUrl('templates/workflows/workflow-maker/workflow-maker'), templateUrl: templateUrl('templates/workflows/workflow-maker/workflow-maker'),
@ -63,7 +63,11 @@ export default ['templateUrl', 'CreateDialog', 'Wait', '$state', '$window',
}); });
scope.closeDialog = function(exitWithUnsavedChanges) { scope.closeDialog = function(exitWithUnsavedChanges) {
if (exitWithUnsavedChanges || !(scope.workflowChangesUnsaved || scope.workflowChangesStarted)) { if (
!scope.canAddOrEdit ||
exitWithUnsavedChanges ||
!(scope.workflowChangesUnsaved || scope.workflowChangesStarted)
) {
scope.unsavedChangesVisible = false; scope.unsavedChangesVisible = false;
$('#workflow-modal-dialog').dialog('destroy'); $('#workflow-modal-dialog').dialog('destroy');
$('body').removeClass('WorkflowMaker-preventBodyScrolling'); $('body').removeClass('WorkflowMaker-preventBodyScrolling');