Merge pull request #5159 from mabashian/4995-links

Fixed template link open in new tab regressions
This commit is contained in:
Michael Abashian
2017-02-03 09:06:22 -05:00
committed by GitHub
4 changed files with 25 additions and 18 deletions

View File

@@ -28,13 +28,13 @@ export default
function createList(list) { function createList(list) {
// smartStatus?, launchUrl, editUrl, name // smartStatus?, launchUrl, editUrl, name
scope.job_templates = _.map(list, function(job_template){ return { scope.templates = _.map(list, function(template){ return {
recent_jobs: job_template.summary_fields.recent_jobs, recent_jobs: template.summary_fields.recent_jobs,
launch_url: job_template.url, launch_url: template.url,
edit_url: job_template.url.replace('api/v1', '#'), edit_url: template.url.replace('api/v1', '#'),
name: job_template.name, name: template.name,
id: job_template.id, id: template.id,
type: job_template.type type: template.type
}; }); }; });
scope.snapRows = (list.length < 4); scope.snapRows = (list.length < 4);
@@ -44,7 +44,7 @@ export default
return (status === "successful"); return (status === "successful");
}; };
scope.launchJobTemplate = function(template){ scope.launchTemplate = function(template){
if(template) { if(template) {
if(template.type && (template.type === 'Job Template' || template.type === 'job_template')) { if(template.type && (template.type === 'Job Template' || template.type === 'job_template')) {
InitiatePlaybookRun({ scope: scope, id: template.id, job_type: 'job_template' }); InitiatePlaybookRun({ scope: scope, id: template.id, job_type: 'job_template' });
@@ -63,8 +63,15 @@ export default
} }
}; };
scope.editJobTemplate = function (jobTemplateId) { scope.editTemplate = function (template) {
$state.go('templates.editJobTemplate', {job_template_id: jobTemplateId}); if(template) {
if(template.type && (template.type === 'Job Template' || template.type === 'job_template')) {
$state.go('templates.editJobTemplate', {job_template_id: template.id});
}
else if(template.type && (template.type === 'Workflow Job Template' || template.type === 'workflow_job_template')) {
$state.go('templates.editWorkflowJobTemplate', {workflow_job_template_id: template.id});
}
}
}; };
} }
}]; }];

View File

@@ -23,21 +23,21 @@
<tr class="List-tableRow" <tr class="List-tableRow"
ng-class-odd="'List-tableRow--oddRow'" ng-class-odd="'List-tableRow--oddRow'"
ng-class-even="'List-tableRow--evenRow'" ng-class-even="'List-tableRow--evenRow'"
ng-repeat = "job_template in job_templates"> ng-repeat = "template in templates">
<td class="DashboardList-nameCell"> <td class="DashboardList-nameCell">
<a href="#/templates/{{ job_template.id }}" class="DashboardList-nameContainer"> <a ng-href="#/templates/{{template.type}}/{{template.id}}" class="DashboardList-nameContainer">
{{ job_template.name }} {{ template.name }}
</a> </a>
</td> </td>
<td class="DashboardList-activityCell"> <td class="DashboardList-activityCell">
<aw-smart-status jobs="job_template.recent_jobs"></aw-smart-status> <aw-smart-status jobs="template.recent_jobs"></aw-smart-status>
</td> </td>
<td class="List-actionsContainer"> <td class="List-actionsContainer">
<div class="List-actionButtonCell"> <div class="List-actionButtonCell">
<button class="List-actionButton" ng-click="launchJobTemplate(job_template)"> <button class="List-actionButton" ng-click="launchTemplate(template)">
<i class="icon-launch"></i> <i class="icon-launch"></i>
</button> </button>
<button class="List-actionButton" ng-click="editJobTemplate(job_template.id)"> <button class="List-actionButton" ng-click="editTemplate(template)">
<i class="fa fa-pencil"></i> <i class="fa fa-pencil"></i>
</button> </button>
</div> </div>

View File

@@ -25,7 +25,7 @@ export default
key: true, key: true,
label: i18n._('Name'), label: i18n._('Name'),
columnClass: 'col-lg-2 col-md-2 col-sm-4 col-xs-9', columnClass: 'col-lg-2 col-md-2 col-sm-4 col-xs-9',
ngClick: "editJobTemplate(template)" ngHref: '#/templates/{{template.type}}/{{template.id}}'
}, },
type: { type: {
label: i18n._('Type'), label: i18n._('Type'),

View File

@@ -46,7 +46,7 @@ export default ['workflowData',
$scope.workflow_template_link = '/#/templates/workflow_job_template/'+$scope.workflow.workflow_job_template; $scope.workflow_template_link = '/#/templates/workflow_job_template/'+$scope.workflow.workflow_job_template;
$scope.created_by_link = getTowerLink('created_by'); $scope.created_by_link = getTowerLink('created_by');
$scope.scheduled_by_link = getTowerLink('schedule');console.log($scope.scheduled_by_link); $scope.scheduled_by_link = getTowerLink('schedule');
$scope.cloud_credential_link = getTowerLink('cloud_credential'); $scope.cloud_credential_link = getTowerLink('cloud_credential');
$scope.network_credential_link = getTowerLink('network_credential'); $scope.network_credential_link = getTowerLink('network_credential');
}; };