mirror of
https://github.com/ansible/awx.git
synced 2024-11-01 08:21:15 +03:00
Expose the role's content_type field and reorder the objects in the UI
when the resource was stored on ActivityStream as object1 instead of object2. related #3841
This commit is contained in:
parent
0d3f1f4ac2
commit
250484339b
@ -128,7 +128,7 @@ SUMMARIZABLE_FK_FIELDS = {
|
||||
'inventory_source': ('source', 'last_updated', 'status'),
|
||||
'custom_inventory_script': DEFAULT_SUMMARY_FIELDS,
|
||||
'source_script': ('name', 'description'),
|
||||
'role': ('id', 'role_field'),
|
||||
'role': ('id', 'role_field', 'content_type'),
|
||||
'notification_template': DEFAULT_SUMMARY_FIELDS,
|
||||
'instance_group': {'id', 'name', 'controller_id'},
|
||||
'insights_credential': DEFAULT_SUMMARY_FIELDS,
|
||||
@ -5106,6 +5106,8 @@ class ActivityStreamSerializer(BaseSerializer):
|
||||
for field in related_fields:
|
||||
fval = getattr(thisItem, field, None)
|
||||
if fval is not None:
|
||||
if field == 'content_type':
|
||||
fval = str(fval)
|
||||
thisItemDict[field] = fval
|
||||
summary_fields[fk].append(thisItemDict)
|
||||
except ObjectDoesNotExist:
|
||||
|
@ -17,6 +17,16 @@ export default function BuildDescription(BuildAnchor, $log, i18n) {
|
||||
switch(activity.object_association){
|
||||
// explicit role dis+associations
|
||||
case 'role':
|
||||
var object1 = activity.object1;
|
||||
var object2 = activity.object2;
|
||||
|
||||
// if object1 winds up being the role's resource, we need to swap the objects
|
||||
// in order to make the sentence make sense.
|
||||
if (activity.summary_fields.role[0].content_type === object1) {
|
||||
object1 = activity.object2;
|
||||
object2 = activity.object1;
|
||||
}
|
||||
|
||||
// object1 field is resource targeted by the dis+association
|
||||
// object2 field is the resource the role is inherited from
|
||||
// summary_field.role[0] contains ref info about the role
|
||||
@ -24,23 +34,23 @@ export default function BuildDescription(BuildAnchor, $log, i18n) {
|
||||
// expected outcome: "disassociated <object2> role_name from <object1>"
|
||||
case 'disassociate':
|
||||
if (isGroupRelationship(activity)){
|
||||
activity.description += BuildAnchor(activity.summary_fields.group[1], activity.object2, activity) + activity.summary_fields.role[0].role_field +
|
||||
' from ' + BuildAnchor(activity.summary_fields.group[0], activity.object1, activity);
|
||||
activity.description += BuildAnchor(activity.summary_fields.group[1], object2, activity) + activity.summary_fields.role[0].role_field +
|
||||
' from ' + BuildAnchor(activity.summary_fields.group[0], object1, activity);
|
||||
}
|
||||
else{
|
||||
activity.description += BuildAnchor(activity.summary_fields[activity.object2][0], activity.object2, activity) + activity.summary_fields.role[0].role_field +
|
||||
' from ' + BuildAnchor(activity.summary_fields[activity.object1][0], activity.object1, activity);
|
||||
activity.description += BuildAnchor(activity.summary_fields[object2][0], object2, activity) + activity.summary_fields.role[0].role_field +
|
||||
' from ' + BuildAnchor(activity.summary_fields[object1][0], object1, activity);
|
||||
}
|
||||
break;
|
||||
// expected outcome: "associated <object2> role_name to <object1>"
|
||||
case 'associate':
|
||||
if (isGroupRelationship(activity)){
|
||||
activity.description += BuildAnchor(activity.summary_fields.group[1], activity.object2, activity) + activity.summary_fields.role[0].role_field +
|
||||
' to ' + BuildAnchor(activity.summary_fields.group[0], activity.object1, activity);
|
||||
activity.description += BuildAnchor(activity.summary_fields.group[1], object2, activity) + activity.summary_fields.role[0].role_field +
|
||||
' to ' + BuildAnchor(activity.summary_fields.group[0], object1, activity);
|
||||
}
|
||||
else{
|
||||
activity.description += BuildAnchor(activity.summary_fields[activity.object2][0], activity.object2, activity) + activity.summary_fields.role[0].role_field +
|
||||
' to ' + BuildAnchor(activity.summary_fields[activity.object1][0], activity.object1, activity);
|
||||
activity.description += BuildAnchor(activity.summary_fields[object2][0], object2, activity) + activity.summary_fields.role[0].role_field +
|
||||
' to ' + BuildAnchor(activity.summary_fields[object1][0], object1, activity);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user