disable next and show warning when default workflow inventory is removed

This commit is contained in:
Jake McDermott 2018-11-19 15:16:46 -05:00
parent 13e715aeb9
commit 951515da2f
No known key found for this signature in database
GPG Key ID: 9A6F084352C3A0B7
4 changed files with 28 additions and 17 deletions

View File

@ -15,17 +15,9 @@ export default [ 'Rest', 'GetBasePath', 'ProcessErrors', 'CredentialTypeModel',
scope = _scope_;
({ modal } = scope[scope.ns]);
vm.isInventoryOptional = false;
scope.$watch('vm.promptData.triggerModalOpen', () => {
vm.actionButtonClicked = false;
if(vm.promptData && vm.promptData.triggerModalOpen) {
if (vm.promptData.templateType === "workflow_job_template") {
vm.isInventoryOptional = true;
}
scope.$emit('launchModalOpen', true);
vm.promptDataClone = _.cloneDeep(vm.promptData);

View File

@ -45,7 +45,7 @@
<div class="Prompt-footer">
<button id="prompt_cancel" class="Prompt-defaultButton" ng-click="vm.cancel()" ng-show="!vm.readOnlyPrompts">{{:: vm.strings.get('CANCEL') }}</button>
<button id="prompt_close" class="Prompt-defaultButton" ng-click="vm.cancel()" ng-show="vm.readOnlyPrompts">{{:: vm.strings.get('CLOSE') }}</button>
<button id="prompt_inventory_next" class="Prompt-actionButton" ng-show="vm.steps.inventory.tab._active" ng-click="vm.next(vm.steps.inventory.tab)" ng-disabled="!vm.isInventoryOptional && !vm.promptDataClone.prompts.inventory.value.id && !vm.readOnlyPrompts">{{:: vm.strings.get('NEXT') }}</button>
<button id="prompt_inventory_next" class="Prompt-actionButton" ng-show="vm.steps.inventory.tab._active" ng-click="vm.next(vm.steps.inventory.tab)" ng-disabled="vm.promptData.templateType === 'workflow_job_template' && !vm.promptDataClone.prompts.inventory.value.id && vm.promptDataClone.launchConf.defaults.inventory.id && !vm.readOnlyPrompts">{{:: vm.strings.get('NEXT') }}</button>
<button id="prompt_credential_next" class="Prompt-actionButton"
ng-show="vm.steps.credential.tab._active"
ng-click="vm.next(vm.steps.credential.tab)"

View File

@ -47,17 +47,31 @@ export default [ 'templateUrl', 'QuerySet', 'GetBasePath', 'generateList', '$com
invList.disableRow = "{{ readOnlyPrompts }}";
invList.disableRowValue = "readOnlyPrompts";
const listConfig = {
const defaultWarning = i18n._("This inventory is applied to all job template nodes that prompt for an inventory.");
const missingWarning = i18n._("This workflow job template has a default inventory which must be included or replaced before proceeding.");
const updateInventoryWarning = () => {
scope.inventoryWarning = null;
if (scope.promptData.templateType === "workflow_job_template") {
scope.inventoryWarning = defaultWarning;
const isPrompted = _.get(scope.promptData, 'launchConf.ask_inventory_on_launch');
const isDefault = _.get(scope.promptData, 'launchConf.defaults.inventory.id');
const isSelected = _.get(scope.promptData, 'prompts.inventory.value.id', null) !== null;
if (isPrompted && isDefault && !isSelected) {
scope.inventoryWarning = missingWarning;
}
}
};
updateInventoryWarning();
let html = GenerateList.build({
list: invList,
input_type: 'radio',
mode: 'lookup',
};
if (scope.promptData.templateType === "workflow_job_template") {
listConfig.lookupMessage = i18n._("This inventory is applied to all job template nodes that prompt for an inventory.");
}
let html = GenerateList.build(listConfig);
});
scope.list = invList;
@ -74,6 +88,8 @@ export default [ 'templateUrl', 'QuerySet', 'GetBasePath', 'generateList', '$com
else {
scope.inventories[i].checked = 0;
}
updateInventoryWarning();
});
});
});

View File

@ -14,5 +14,8 @@
</div>
</div>
</div>
<div ng-if="inventoryWarning" class="Prompt-credentialTypeMissing">
<span class="fa fa-warning"></span>&nbsp; {{ inventoryWarning }}
</div>
<div id="prompt-inventory"></div>
</div>