mirror of
https://github.com/ansible/awx.git
synced 2026-01-14 19:30:39 -03:30
Merge pull request #4395 from mabashian/4163-template-list-audit
Various fixes to the templates list based on audit feedback
This commit is contained in:
commit
48e95a7abb
@ -47,6 +47,7 @@ export default
|
||||
label: i18n._('Labels'),
|
||||
type: 'labels',
|
||||
nosort: true,
|
||||
showDelete: true,
|
||||
columnClass: 'List-tableCell col-lg-2 col-md-4 hidden-sm hidden-xs'
|
||||
}
|
||||
},
|
||||
@ -58,7 +59,7 @@ export default
|
||||
basePaths: ['templates'],
|
||||
awToolTip: i18n._('Create a new template'),
|
||||
actionClass: 'btn List-dropdownSuccess',
|
||||
buttonContent: i18n._('ADD'),
|
||||
buttonContent: '+ ' + i18n._('ADD'),
|
||||
options: [
|
||||
{
|
||||
optionContent: i18n._('Job Template'),
|
||||
@ -109,7 +110,8 @@ export default
|
||||
awToolTip: i18n._('Edit template'),
|
||||
"class": 'btn-default btn-xs',
|
||||
dataPlacement: 'top',
|
||||
ngShow: 'template.summary_fields.user_capabilities.edit'
|
||||
ngShow: 'template.summary_fields.user_capabilities.edit',
|
||||
editStateParams: ['job_template_id', 'workflow_job_template_id']
|
||||
},
|
||||
view: {
|
||||
label: i18n._('View'),
|
||||
|
||||
@ -29,9 +29,9 @@
|
||||
</span>
|
||||
</div>
|
||||
<span ng-if="!options.showTipWhenDisabled">
|
||||
<div class="btn-group" ng-if="options.type === 'buttonDropdown'" ng-disabled="{{options.ngDisabled}}" aw-tool-tip="{{options.awToolTip}}" data-tip-watch="{{options.dataTipWatch}}" data-placement="{{options.dataPlacement}}" data-container="{{options.dataContainer}}">
|
||||
<div class="btn-group" ng-if="options.type === 'buttonDropdown'" ng-disabled="{{options.ngDisabled}}" aw-tool-tip="{{options.awToolTip}}" data-tip-watch="{{options.dataTipWatch}}" data-placement="{{options.dataPlacement}}" data-container="{{options.dataContainer}}" ng-show="{{options.ngShow}}">
|
||||
<button type="button" class="{{options.actionClass}} List-dropdownButton dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||
<span>{{options.buttonContent}} </span>
|
||||
<span ng-bind-html="options.buttonContent"></span>
|
||||
<span class="List-dropdownCarat"></span>
|
||||
<span class="sr-only">Toggle Dropdown</span>
|
||||
</button>
|
||||
|
||||
@ -355,6 +355,16 @@ export default ['$location', '$compile', '$rootScope', 'Attr', 'Icon',
|
||||
|
||||
innerTable += "<td class=\"List-actionsContainer\"><div class=\"List-actionButtonCell List-tableCell\">";
|
||||
|
||||
let handleEditStateParams = function(stateParams){
|
||||
let matchingConditions = [];
|
||||
|
||||
angular.forEach(stateParams, function(stateParam) {
|
||||
matchingConditions.push(`$stateParams['` + stateParam + `'] == ${list.iterator}.id`);
|
||||
});
|
||||
|
||||
return matchingConditions;
|
||||
};
|
||||
|
||||
for (field_action in list.fieldActions) {
|
||||
if (field_action !== 'columnClass') {
|
||||
if (list.fieldActions[field_action].type && list.fieldActions[field_action].type === 'DropDown') {
|
||||
@ -376,8 +386,19 @@ export default ['$location', '$compile', '$rootScope', 'Attr', 'Icon',
|
||||
innerTable += "class=\"List-actionButton ";
|
||||
innerTable += (field_action === 'delete' || field_action === 'cancel') ? "List-actionButton--delete" : "";
|
||||
innerTable += "\" ";
|
||||
// rowBeingEdited === '{{ " + list.iterator + ".id }}' && listBeingEdited === '" + list.name + "' ? 'List-tableRow--selected' : ''";
|
||||
innerTable += (field_action === 'edit') ? `ng-class="{'List-editButton--selected' : $stateParams['${list.iterator}_id'] == ${list.iterator}.id}"`: '';
|
||||
if(field_action === 'edit') {
|
||||
// editStateParams allows us to handle cases where a list might have different types of resources in it. As a result the edit
|
||||
// icon might now always point to the same state and differing states may have differing stateParams. Specifically this occurs
|
||||
// on the Templates list where editing a workflow job template takes you to a state where the param is workflow_job_template_id.
|
||||
// You can also edit a Job Template from this list so the stateParam there would be job_template_id.
|
||||
if(list.fieldActions[field_action].editStateParams) {
|
||||
let matchingConditions = handleEditStateParams(list.fieldActions[field_action].editStateParams);
|
||||
innerTable += `ng-class="{'List-editButton--selected' : ${matchingConditions.join(' || ')}}"`;
|
||||
}
|
||||
else {
|
||||
innerTable += `ng-class="{'List-editButton--selected' : $stateParams['${list.iterator}_id'] == ${list.iterator}.id}"`;
|
||||
}
|
||||
}
|
||||
innerTable += (fAction.awPopOver) ? "aw-pop-over=\"" + fAction.awPopOver + "\" " : "";
|
||||
innerTable += (fAction.dataPlacement) ? Attr(fAction, 'dataPlacement') : "";
|
||||
innerTable += (fAction.dataTitle) ? Attr(fAction, 'dataTitle') : "";
|
||||
|
||||
@ -8,7 +8,8 @@ export default
|
||||
'Prompt',
|
||||
'$q',
|
||||
'$filter',
|
||||
function(templateUrl, Wait, Rest, GetBasePath, ProcessErrors, Prompt, $q, $filter) {
|
||||
'$state',
|
||||
function(templateUrl, Wait, Rest, GetBasePath, ProcessErrors, Prompt, $q, $filter, $state) {
|
||||
return {
|
||||
restrict: 'E',
|
||||
scope: false,
|
||||
@ -54,29 +55,37 @@ export default
|
||||
scope.seeMoreInactive = true;
|
||||
};
|
||||
|
||||
scope.deleteLabel = function(templateId, templateName, labelId, labelName) {
|
||||
scope.deleteLabel = function(template, label) {
|
||||
var action = function () {
|
||||
$('#prompt-modal').modal('hide');
|
||||
scope.seeMoreInactive = true;
|
||||
Wait('start');
|
||||
var url = GetBasePath("job_templates") + templateId + "/labels/";
|
||||
Rest.setUrl(url);
|
||||
Rest.post({"disassociate": true, "id": labelId})
|
||||
.success(function () {
|
||||
// @issue: OLD SEARCH
|
||||
// scope.search("job_template", scope.$parent.job_template_page);
|
||||
Wait('stop');
|
||||
})
|
||||
.error(function (data, status) {
|
||||
Wait('stop');
|
||||
ProcessErrors(scope, data, status, null, { hdr: 'Error!',
|
||||
msg: 'Could not disassociate label from JT. Call to ' + url + ' failed. DELETE returned status: ' + status });
|
||||
});
|
||||
let url;
|
||||
if(template.type === 'job_template') {
|
||||
url = GetBasePath("job_templates") + template.id + "/labels/";
|
||||
}
|
||||
else if(template.type === 'workflow_job_template') {
|
||||
url = GetBasePath("workflow_job_templates") + template.id + "/labels/";
|
||||
}
|
||||
|
||||
if(url) {
|
||||
Rest.setUrl(url);
|
||||
Rest.post({"disassociate": true, "id": label.id})
|
||||
.success(function () {
|
||||
Wait('stop');
|
||||
$state.go('.', null, {reload: true});
|
||||
})
|
||||
.error(function (data, status) {
|
||||
Wait('stop');
|
||||
ProcessErrors(scope, data, status, null, { hdr: 'Error!',
|
||||
msg: 'Could not disassociate label from JT. Call to ' + url + ' failed. DELETE returned status: ' + status });
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
Prompt({
|
||||
hdr: 'Remove Label from ' + templateName ,
|
||||
body: '<div class="Prompt-bodyQuery">Confirm the removal of the <span class="Prompt-emphasis">' + $filter('sanitize')(labelName) + '</span> label.</div>',
|
||||
hdr: 'Remove Label from ' + template.name ,
|
||||
body: '<div class="Prompt-bodyQuery">Confirm the removal of the <span class="Prompt-emphasis">' + $filter('sanitize')(label.name) + '</span> label.</div>',
|
||||
action: action,
|
||||
actionText: 'REMOVE'
|
||||
});
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
<div class="LabelList-tagContainer" ng-repeat="label in labels">
|
||||
<div class="LabelList-deleteContainer"
|
||||
ng-click="deleteLabel(job_template.id, job_template.name, label.id, label.name)"
|
||||
ng-show="showDelete && job_template.summary_fields.can_edit">
|
||||
ng-click="deleteLabel(template, label)"
|
||||
ng-show="showDelete && template.summary_fields.user_capabilities.edit">
|
||||
<i class="fa fa-times LabelList-tagDelete"></i>
|
||||
</div>
|
||||
<div class="LabelList-tag" ng-class="{'LabelList-tag--deletable' : (showDelete && job_template.summary_fields.can_edit)}">
|
||||
<div class="LabelList-tag" ng-class="{'LabelList-tag--deletable' : (showDelete && template.summary_fields.user_capabilities.edit)}">
|
||||
<span class="LabelList-name">{{ label.name }}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -107,7 +107,7 @@ export default ['$scope', '$rootScope', '$location', '$stateParams', 'Rest', 'Al
|
||||
if(template) {
|
||||
Prompt({
|
||||
hdr: 'Delete',
|
||||
body: '<div class="Prompt-bodyQuery">Are you sure you want to delete the ' + (template.type === "Workflow Job Template" ? 'workflow ' : '') + 'job template below?</div><div class="Prompt-bodyTarget">' + $filter('sanitize')(template.name) + '</div>',
|
||||
body: '<div class="Prompt-bodyQuery">Are you sure you want to delete the template below?</div><div class="Prompt-bodyTarget">' + $filter('sanitize')(template.name) + '</div>',
|
||||
action: function() {
|
||||
|
||||
function handleSuccessfulDelete() {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user