fix activity stream inventory script url, handle update operations in a separate case, resolves #1721 kickback

This commit is contained in:
Leigh Johnson
2016-07-08 16:29:48 -04:00
parent 33547259e2
commit 03af6b3507

View File

@@ -28,11 +28,15 @@ angular.module('StreamWidget', ['RestServices', 'Utilities', 'StreamListDefiniti
// arguments are: a summary_field object, a resource type, an activity stream object // arguments are: a summary_field object, a resource type, an activity stream object
function ($log, $filter) { function ($log, $filter) {
return function (obj, resource, activity) { return function (obj, resource, activity) {
console.log(obj, resource)
var url = '/#/'; var url = '/#/';
// try/except pattern asserts that: // try/except pattern asserts that:
// if we encounter a case where a UI url can't or shouldn't be generated, just supply the name of the resource // if we encounter a case where a UI url can't or shouldn't be generated, just supply the name of the resource
try { try {
switch (resource) { switch (resource) {
case 'custom_inventory_script':
url += 'inventory_scripts/' + obj.id + '/';
break;
case 'group': case 'group':
if (activity.operation === 'create' || activity.operation === 'delete'){ if (activity.operation === 'create' || activity.operation === 'delete'){
// the API formats the changes.inventory field as str 'myInventoryName-PrimaryKey' // the API formats the changes.inventory field as str 'myInventoryName-PrimaryKey'
@@ -47,7 +51,7 @@ angular.module('StreamWidget', ['RestServices', 'Utilities', 'StreamListDefiniti
url += 'home/hosts/' + obj.id; url += 'home/hosts/' + obj.id;
break; break;
case 'job': case 'job':
url += 'jobs/?id=' + obj.id; url += 'jobs/' + obj.id;
break; break;
case 'inventory': case 'inventory':
url += 'inventories/' + obj.id + '/'; url += 'inventories/' + obj.id + '/';
@@ -192,11 +196,13 @@ angular.module('StreamWidget', ['RestServices', 'Utilities', 'StreamListDefiniti
case 'delete': case 'delete':
activity.description += activity.object1 + BuildAnchor(activity.changes, activity.object1, activity); activity.description += activity.object1 + BuildAnchor(activity.changes, activity.object1, activity);
break; break;
// equivalent to 'create' or 'update'
// expected outcome: "operation <object1>" // expected outcome: "operation <object1>"
default: case 'update':
activity.description += activity.object1 + BuildAnchor(activity.summary_fields[activity.object1][0], activity.object1, activity); activity.description += activity.object1 + BuildAnchor(activity.summary_fields[activity.object1][0], activity.object1, activity);
break; break;
case 'create':
activity.description += activity.object1 + BuildAnchor(activity.changes, activity.object1, activity);
break;
} }
break; break;
} }