1
0
mirror of https://github.com/ansible/awx.git synced 2024-10-31 06:51:10 +03:00

Merge pull request #3683 from mabashian/3565-workflow-template-popover

Leverages awPopOverWatch to generate popover dynamically on workflow node templates help

Reviewed-by: https://github.com/softwarefactory-project-zuul[bot]
This commit is contained in:
softwarefactory-project-zuul[bot] 2019-04-12 16:54:54 +00:00 committed by GitHub
commit dc833bbaa7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 28 additions and 10 deletions

View File

@ -1,4 +1,4 @@
<div class="List-infoCell" ng-if="wf_maker_template.type === 'job_template'">
<span class="Key-icon Key-icon--circle Key-icon--default" aw-pop-over="<dl><dt>{{ 'INVENTORY' | translate }}</dt><dd>{{wf_maker_template.popOverDetails.inventory | sanitize}}</dd></dl><dl><dt>{{ 'PROJECT' | translate }}</dt><dd>{{wf_maker_template.popOverDetails.project | sanitize}}</dd></dl><dl><dt>{{ 'PLAYBOOK' | translate }}</dt><dd>{{wf_maker_template.popOverDetails.playbook | sanitize}}</dd></dl><dl><dt>{{ 'CREDENTIAL' | translate }}</dt> <dd>{{wf_maker_template.popOverDetails.credentials | sanitize}}</dd></dl>"
<span class="Key-icon Key-icon--circle Key-icon--default" aw-pop-over aw-pop-over-watch="wf_maker_template.popOver"
data-popover-title="{{wf_maker_template.name| sanitize}}">?</span>
</div>

View File

@ -886,7 +886,7 @@ function(SettingsUtils, i18n, $rootScope) {
delay: 0,
title: title,
content: function() {
return scope[attrs.awPopOverWatch];
return _.get(scope, attrs.awPopOverWatch);
},
trigger: trigger,
html: true,

View File

@ -5,11 +5,11 @@
*************************************************/
export default ['$scope', 'TemplatesService', 'JobTemplateModel', 'PromptService', 'Rest', '$q',
'TemplatesStrings', 'CreateSelect2', 'Empty', 'generateList', 'QuerySet',
'TemplatesStrings', 'CreateSelect2', 'Empty', 'QuerySet', '$filter',
'GetBasePath', 'TemplateList', 'ProjectList', 'InventorySourcesList', 'ProcessErrors',
'i18n', 'ParseTypeChange', 'WorkflowJobTemplateModel',
function($scope, TemplatesService, JobTemplate, PromptService, Rest, $q,
TemplatesStrings, CreateSelect2, Empty, generateList, qs,
TemplatesStrings, CreateSelect2, Empty, qs, $filter,
GetBasePath, TemplateList, ProjectList, InventorySourcesList, ProcessErrors,
i18n, ParseTypeChange, WorkflowJobTemplate
) {
@ -657,25 +657,43 @@ export default ['$scope', 'TemplatesService', 'JobTemplateModel', 'PromptService
};
const formatPopOverDetails = (model) => {
model.popOverDetails = {};
model.popOverDetails.playbook = model.playbook || i18n._('NONE SELECTED');
const popOverDetails = {};
popOverDetails.playbook = model.playbook || i18n._('NONE SELECTED');
Object.keys(model.summary_fields).forEach(field => {
if (field === 'project') {
model.popOverDetails.project = model.summary_fields[field].name || i18n._('NONE SELECTED');
popOverDetails.project = model.summary_fields[field].name || i18n._('NONE SELECTED');
}
if (field === 'inventory') {
model.popOverDetails.inventory = model.summary_fields[field].name || i18n._('NONE SELECTED');
popOverDetails.inventory = model.summary_fields[field].name || i18n._('NONE SELECTED');
}
if (field === 'credentials') {
if (model.summary_fields[field].length <= 0) {
model.popOverDetails.credentials = i18n._('NONE SELECTED');
popOverDetails.credentials = i18n._('NONE SELECTED');
}
else {
const credentialNames = model.summary_fields[field].map(({name}) => name);
model.popOverDetails.credentials = credentialNames.join('<br />');
popOverDetails.credentials = credentialNames.join('<br />');
}
}
});
model.popOver = `
<dl>
<dt>${i18n._('INVENTORY')}</dt>
<dd>${$filter('sanitize')(popOverDetails.inventory)}</dd>
</dl>
<dl>
<dt>${i18n._('PROJECT')}</dt>
<dd>${$filter('sanitize')(popOverDetails.project)}</dd>
</dl>
<dl>
<dt>${i18n._('PLAYBOOK')}</dt>
<dd>${$filter('sanitize')(popOverDetails.playbook)}</dd>
</dl>
<dl>
<dt>${i18n._('CREDENTIAL')}</dt>
<dd>${$filter('sanitize')(popOverDetails.credentials)}</dd>
</dl>
`;
};
$scope.openPromptModal = () => {