mirror of
https://github.com/ansible/awx.git
synced 2026-01-11 01:57:35 -03:30
update activity stream file structure to be consistent with other routes and aid in testing
This commit is contained in:
parent
f07818f04a
commit
06ff178f9e
@ -1,6 +1,7 @@
|
||||
import React from 'react';
|
||||
import { Link } from 'react-router-dom';
|
||||
import { t } from '@lingui/macro';
|
||||
import { withI18n } from '@lingui/react';
|
||||
|
||||
const buildAnchor = (obj, resource, activity) => {
|
||||
let url;
|
||||
@ -150,7 +151,7 @@ const buildLabeledLink = (label, link) => {
|
||||
);
|
||||
};
|
||||
|
||||
export default (activity, i18n) => {
|
||||
function ActivityStreamDescription({ i18n, activity }) {
|
||||
const labeledLinks = [];
|
||||
// Activity stream objects will outlive the resources they reference
|
||||
// in that case, summary_fields will not be available - show generic error text instead
|
||||
@ -578,4 +579,6 @@ export default (activity, i18n) => {
|
||||
)}
|
||||
</span>
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
export default withI18n()(ActivityStreamDescription);
|
||||
@ -0,0 +1,12 @@
|
||||
import React from 'react';
|
||||
import { mountWithContexts } from '../../../testUtils/enzymeHelpers';
|
||||
import ActivityStreamDescription from './ActivityStreamDescription';
|
||||
|
||||
describe('ActivityStreamDescription', () => {
|
||||
test('initially renders succesfully', () => {
|
||||
const description = mountWithContexts(
|
||||
<ActivityStreamDescription activity={{}} />
|
||||
);
|
||||
expect(description.find('span').length).toBe(1);
|
||||
});
|
||||
});
|
||||
@ -9,7 +9,7 @@ import { formatDateString } from '../../util/dates';
|
||||
import { DetailList, Detail } from '../../components/DetailList';
|
||||
import { VariablesDetail } from '../../components/CodeMirrorInput';
|
||||
|
||||
function StreamDetailButton({ i18n, streamItem, user, description }) {
|
||||
function ActivityStreamDetailButton({ i18n, streamItem, user, description }) {
|
||||
const [isOpen, setIsOpen] = useState(false);
|
||||
|
||||
const setting = streamItem?.summary_fields?.setting;
|
||||
@ -50,15 +50,17 @@ function StreamDetailButton({ i18n, streamItem, user, description }) {
|
||||
value={setting && setting[0]?.name}
|
||||
/>
|
||||
<Detail fullWidth label={i18n._(t`Action`)} value={description} />
|
||||
<VariablesDetail
|
||||
label={i18n._(t`Changes`)}
|
||||
rows={changeRows}
|
||||
value={streamItem?.changes}
|
||||
/>
|
||||
{streamItem?.changes && (
|
||||
<VariablesDetail
|
||||
label={i18n._(t`Changes`)}
|
||||
rows={changeRows}
|
||||
value={streamItem?.changes}
|
||||
/>
|
||||
)}
|
||||
</DetailList>
|
||||
</Modal>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
export default withI18n()(StreamDetailButton);
|
||||
export default withI18n()(ActivityStreamDetailButton);
|
||||
@ -2,14 +2,14 @@ import React from 'react';
|
||||
import { Link } from 'react-router-dom';
|
||||
|
||||
import { mountWithContexts } from '../../../testUtils/enzymeHelpers';
|
||||
import StreamDetailButton from './StreamDetailButton';
|
||||
import ActivityStreamDetailButton from './ActivityStreamDetailButton';
|
||||
|
||||
jest.mock('../../api/models/ActivityStream');
|
||||
|
||||
describe('<StreamDetailButton />', () => {
|
||||
describe('<ActivityStreamDetailButton />', () => {
|
||||
test('initially renders succesfully', () => {
|
||||
mountWithContexts(
|
||||
<StreamDetailButton
|
||||
<ActivityStreamDetailButton
|
||||
streamItem={{
|
||||
timestamp: '12:00:00',
|
||||
}}
|
||||
@ -8,8 +8,8 @@ import { Link } from 'react-router-dom';
|
||||
import { formatDateString } from '../../util/dates';
|
||||
import { ActionsTd, ActionItem } from '../../components/PaginatedTable';
|
||||
|
||||
import StreamDetailButton from './StreamDetailButton';
|
||||
import buildDescription from './buildActivityDescription';
|
||||
import ActivityStreamDetailButton from './ActivityStreamDetailButton';
|
||||
import ActivityStreamDescription from './ActivityStreamDescription';
|
||||
|
||||
function ActivityStreamListItem({ streamItem, i18n }) {
|
||||
ActivityStreamListItem.propTypes = {
|
||||
@ -34,7 +34,7 @@ function ActivityStreamListItem({ streamItem, i18n }) {
|
||||
|
||||
const labelId = `check-action-${streamItem.id}`;
|
||||
const user = buildUser(streamItem);
|
||||
const description = buildDescription(streamItem, i18n);
|
||||
const description = <ActivityStreamDescription activity={streamItem} />;
|
||||
|
||||
return (
|
||||
<Tr id={streamItem.id} aria-labelledby={labelId}>
|
||||
@ -48,7 +48,7 @@ function ActivityStreamListItem({ streamItem, i18n }) {
|
||||
</Td>
|
||||
<ActionsTd dataLabel={i18n._(t`Actions`)}>
|
||||
<ActionItem visible tooltip={i18n._(t`View event details`)}>
|
||||
<StreamDetailButton
|
||||
<ActivityStreamDetailButton
|
||||
streamItem={streamItem}
|
||||
user={user}
|
||||
description={description}
|
||||
|
||||
@ -1,10 +0,0 @@
|
||||
import { mount } from 'enzyme';
|
||||
|
||||
import buildDescription from './buildActivityDescription';
|
||||
|
||||
describe('buildActivityStream', () => {
|
||||
test('initially renders succesfully', () => {
|
||||
const description = mount(buildDescription({}, {}));
|
||||
expect(description.find('span').length).toBe(1);
|
||||
});
|
||||
});
|
||||
@ -31,7 +31,10 @@ function Inventories({ i18n }) {
|
||||
if (passedInventory && passedInventory.name !== inventory?.name) {
|
||||
setInventory(passedInventory);
|
||||
}
|
||||
if (passedNestedObject && passedNestedObject.name !== nestedObject?.name) {
|
||||
if (
|
||||
passedNestedObject &&
|
||||
passedNestedObject.name !== nestedObject?.name
|
||||
) {
|
||||
setNestedGroup(passedNestedObject);
|
||||
}
|
||||
if (passedSchedule && passedSchedule.name !== schedule?.name) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user