mirror of
https://github.com/ansible/awx.git
synced 2026-05-09 10:27:37 -02:30
Merge pull request #10267 from mabashian/10138-activity-stream
Fixes bug where activity stream changes were displaying as [object object] SUMMARY Resolves #10138 Here it is working: In this case the value passed to the VariablesDetail component is a straight up JSON object (not a stringified JSON object) which that component does not seem to like in its current state. Rather than looking at changing the VariablesDetail implementation I decided to just stringify the object before it gets passed in. Since this object is generated by the backend I think it's safe to assume it will always be an object. ISSUE TYPE Bugfix Pull Request COMPONENT NAME UI Reviewed-by: Kersom <None> Reviewed-by: Tiago Góes <tiago.goes2009@gmail.com>
This commit is contained in:
@@ -52,7 +52,9 @@ function ActivityStreamDetailButton({ streamItem, user, description }) {
|
|||||||
<VariablesDetail
|
<VariablesDetail
|
||||||
label={t`Changes`}
|
label={t`Changes`}
|
||||||
rows={changeRows}
|
rows={changeRows}
|
||||||
value={streamItem?.changes}
|
value={
|
||||||
|
streamItem?.changes ? JSON.stringify(streamItem.changes) : ''
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</DetailList>
|
</DetailList>
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { Link } from 'react-router-dom';
|
import { Link } from 'react-router-dom';
|
||||||
|
|
||||||
import { mountWithContexts } from '../../../testUtils/enzymeHelpers';
|
import { mountWithContexts } from '../../../testUtils/enzymeHelpers';
|
||||||
import ActivityStreamDetailButton from './ActivityStreamDetailButton';
|
import ActivityStreamDetailButton from './ActivityStreamDetailButton';
|
||||||
|
|
||||||
@@ -18,4 +17,64 @@ describe('<ActivityStreamDetailButton />', () => {
|
|||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
test('details are properly rendered', () => {
|
||||||
|
function assertDetail(label, value) {
|
||||||
|
expect(wrapper.find(`Detail[label="${label}"] dt`).text()).toBe(label);
|
||||||
|
expect(wrapper.find(`Detail[label="${label}"] dd`).text()).toBe(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
const wrapper = mountWithContexts(
|
||||||
|
<ActivityStreamDetailButton
|
||||||
|
streamItem={{
|
||||||
|
summary_fields: {
|
||||||
|
actor: {
|
||||||
|
id: 1,
|
||||||
|
username: 'Bob',
|
||||||
|
first_name: '',
|
||||||
|
last_name: '',
|
||||||
|
},
|
||||||
|
setting: [
|
||||||
|
{
|
||||||
|
category: 'system',
|
||||||
|
name: 'INSIGHTS_TRACKING_STATE',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
timestamp: '2021-05-25T18:17:59.835788Z',
|
||||||
|
operation: 'create',
|
||||||
|
changes: {
|
||||||
|
value: false,
|
||||||
|
id: 6,
|
||||||
|
},
|
||||||
|
object1: 'setting',
|
||||||
|
object2: '',
|
||||||
|
object_association: '',
|
||||||
|
action_node: 'awx_1',
|
||||||
|
object_type: '',
|
||||||
|
}}
|
||||||
|
user={<Link to="/users/1/details">Bob</Link>}
|
||||||
|
description={<span>foo</span>}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(wrapper.find('Modal[title="Event detail"]').prop('isOpen')).toBe(
|
||||||
|
false
|
||||||
|
);
|
||||||
|
|
||||||
|
wrapper.find('Button').simulate('click');
|
||||||
|
|
||||||
|
expect(wrapper.find('Modal[title="Event detail"]').prop('isOpen')).toBe(
|
||||||
|
true
|
||||||
|
);
|
||||||
|
|
||||||
|
assertDetail('Time', '5/25/2021, 6:17:59 PM');
|
||||||
|
assertDetail('Initiated by', 'Bob');
|
||||||
|
assertDetail('Setting category', 'system');
|
||||||
|
assertDetail('Setting name', 'INSIGHTS_TRACKING_STATE');
|
||||||
|
assertDetail('Action', 'foo');
|
||||||
|
|
||||||
|
const input = wrapper.find('VariablesDetail___StyledCodeEditor');
|
||||||
|
expect(input).toHaveLength(1);
|
||||||
|
expect(input.prop('value')).toEqual('{\n "value": false,\n "id": 6\n}');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user