mirror of
https://github.com/ansible/awx.git
synced 2026-05-13 04:17:36 -02:30
disable next and show warning when default workflow inventory is removed
This commit is contained in:
@@ -15,17 +15,9 @@ export default [ 'Rest', 'GetBasePath', 'ProcessErrors', 'CredentialTypeModel',
|
|||||||
scope = _scope_;
|
scope = _scope_;
|
||||||
({ modal } = scope[scope.ns]);
|
({ modal } = scope[scope.ns]);
|
||||||
|
|
||||||
vm.isInventoryOptional = false;
|
|
||||||
|
|
||||||
scope.$watch('vm.promptData.triggerModalOpen', () => {
|
scope.$watch('vm.promptData.triggerModalOpen', () => {
|
||||||
|
|
||||||
vm.actionButtonClicked = false;
|
vm.actionButtonClicked = false;
|
||||||
if(vm.promptData && vm.promptData.triggerModalOpen) {
|
if(vm.promptData && vm.promptData.triggerModalOpen) {
|
||||||
|
|
||||||
if (vm.promptData.templateType === "workflow_job_template") {
|
|
||||||
vm.isInventoryOptional = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
scope.$emit('launchModalOpen', true);
|
scope.$emit('launchModalOpen', true);
|
||||||
vm.promptDataClone = _.cloneDeep(vm.promptData);
|
vm.promptDataClone = _.cloneDeep(vm.promptData);
|
||||||
|
|
||||||
|
|||||||
@@ -45,7 +45,7 @@
|
|||||||
<div class="Prompt-footer">
|
<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_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_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"
|
<button id="prompt_credential_next" class="Prompt-actionButton"
|
||||||
ng-show="vm.steps.credential.tab._active"
|
ng-show="vm.steps.credential.tab._active"
|
||||||
ng-click="vm.next(vm.steps.credential.tab)"
|
ng-click="vm.next(vm.steps.credential.tab)"
|
||||||
|
|||||||
@@ -47,17 +47,31 @@ export default [ 'templateUrl', 'QuerySet', 'GetBasePath', 'generateList', '$com
|
|||||||
invList.disableRow = "{{ readOnlyPrompts }}";
|
invList.disableRow = "{{ readOnlyPrompts }}";
|
||||||
invList.disableRowValue = "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,
|
list: invList,
|
||||||
input_type: 'radio',
|
input_type: 'radio',
|
||||||
mode: 'lookup',
|
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;
|
scope.list = invList;
|
||||||
|
|
||||||
@@ -74,6 +88,8 @@ export default [ 'templateUrl', 'QuerySet', 'GetBasePath', 'generateList', '$com
|
|||||||
else {
|
else {
|
||||||
scope.inventories[i].checked = 0;
|
scope.inventories[i].checked = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updateInventoryWarning();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -14,5 +14,8 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div ng-if="inventoryWarning" class="Prompt-credentialTypeMissing">
|
||||||
|
<span class="fa fa-warning"></span> {{ inventoryWarning }}
|
||||||
|
</div>
|
||||||
<div id="prompt-inventory"></div>
|
<div id="prompt-inventory"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user