diff --git a/awx/ui_next/src/api/index.js b/awx/ui_next/src/api/index.js
index f5f0c05330..cddf01e259 100644
--- a/awx/ui_next/src/api/index.js
+++ b/awx/ui_next/src/api/index.js
@@ -1,3 +1,4 @@
+import ActivityStream from './models/ActivityStream';
import AdHocCommands from './models/AdHocCommands';
import Applications from './models/Applications';
import Auth from './models/Auth';
@@ -39,6 +40,7 @@ import WorkflowJobTemplateNodes from './models/WorkflowJobTemplateNodes';
import WorkflowJobTemplates from './models/WorkflowJobTemplates';
import WorkflowJobs from './models/WorkflowJobs';
+const ActivityStreamAPI = new ActivityStream();
const AdHocCommandsAPI = new AdHocCommands();
const ApplicationsAPI = new Applications();
const AuthAPI = new Auth();
@@ -81,6 +83,7 @@ const WorkflowJobTemplatesAPI = new WorkflowJobTemplates();
const WorkflowJobsAPI = new WorkflowJobs();
export {
+ ActivityStreamAPI,
AdHocCommandsAPI,
ApplicationsAPI,
AuthAPI,
diff --git a/awx/ui_next/src/api/models/ActivityStream.js b/awx/ui_next/src/api/models/ActivityStream.js
new file mode 100644
index 0000000000..99b65bc634
--- /dev/null
+++ b/awx/ui_next/src/api/models/ActivityStream.js
@@ -0,0 +1,10 @@
+import Base from '../Base';
+
+class ActivityStream extends Base {
+ constructor(http) {
+ super(http);
+ this.baseUrl = '/api/v2/activity_stream/';
+ }
+}
+
+export default ActivityStream;
diff --git a/awx/ui_next/src/routeConfig.js b/awx/ui_next/src/routeConfig.js
index 0b9e0591fa..a343a7d1e0 100644
--- a/awx/ui_next/src/routeConfig.js
+++ b/awx/ui_next/src/routeConfig.js
@@ -1,5 +1,6 @@
import { t } from '@lingui/macro';
+import ActivityStream from './screens/ActivityStream';
import Applications from './screens/Application';
import Credentials from './screens/Credential';
import CredentialTypes from './screens/CredentialType';
@@ -44,6 +45,11 @@ function getRouteConfig(i18n) {
path: '/schedules',
screen: Schedules,
},
+ {
+ title: i18n._(t`Activity Stream`),
+ path: '/activity_stream',
+ screen: ActivityStream,
+ },
{
title: i18n._(t`Workflow Approvals`),
path: '/workflow_approvals',
diff --git a/awx/ui_next/src/screens/ActivityStream/ActivityStream.jsx b/awx/ui_next/src/screens/ActivityStream/ActivityStream.jsx
new file mode 100644
index 0000000000..86b715ebc1
--- /dev/null
+++ b/awx/ui_next/src/screens/ActivityStream/ActivityStream.jsx
@@ -0,0 +1,228 @@
+import React, { Fragment, useState, useEffect, useCallback } from 'react';
+import { useLocation, useHistory } from 'react-router-dom';
+import { withI18n } from '@lingui/react';
+import { t } from '@lingui/macro';
+import {
+ Card,
+ PageSection,
+ PageSectionVariants,
+ Select,
+ SelectVariant,
+ SelectOption,
+ Title,
+} from '@patternfly/react-core';
+
+import DatalistToolbar from '../../components/DataListToolbar';
+import PaginatedTable, {
+ HeaderRow,
+ HeaderCell,
+} from '../../components/PaginatedTable';
+import useRequest from '../../util/useRequest';
+import { getQSConfig, parseQueryString } from '../../util/qs';
+import { ActivityStreamAPI } from '../../api';
+
+import ActivityStreamListItem from './ActivityStreamListItem';
+
+function ActivityStream({ i18n }) {
+ const { light } = PageSectionVariants;
+
+ const [isTypeDropdownOpen, setIsTypeDropdownOpen] = useState(false);
+ const location = useLocation();
+ const history = useHistory();
+ const urlParams = new URLSearchParams(location.search);
+
+ const activityStreamType = urlParams.get('type');
+
+ let typeParams = {};
+
+ if (activityStreamType !== 'all') {
+ typeParams = {
+ or__object1__in: activityStreamType,
+ or__object2__in: activityStreamType,
+ };
+ }
+
+ const QS_CONFIG = getQSConfig(
+ 'activity_stream',
+ {
+ page: 1,
+ page_size: 20,
+ order_by: '-timestamp',
+ },
+ ['id', 'page', 'page_size']
+ );
+
+ const {
+ result: { results, count, relatedSearchableKeys, searchableKeys },
+ error: contentError,
+ isLoading,
+ request: fetchActivityStream,
+ } = useRequest(
+ useCallback(
+ async () => {
+ const params = parseQueryString(QS_CONFIG, location.search);
+ const [response, actionsResponse] = await Promise.all([
+ ActivityStreamAPI.read({ ...params, ...typeParams }),
+ ActivityStreamAPI.readOptions(),
+ ]);
+ return {
+ results: response.data.results,
+ count: response.data.count,
+ relatedSearchableKeys: (
+ actionsResponse?.data?.related_search_fields || []
+ ).map(val => val.slice(0, -8)),
+ searchableKeys: Object.keys(
+ actionsResponse.data.actions?.GET || {}
+ ).filter(key => actionsResponse.data.actions?.GET[key].filterable),
+ };
+ },
+ [location] // eslint-disable-line react-hooks/exhaustive-deps
+ ),
+ {
+ results: [],
+ count: 0,
+ relatedSearchableKeys: [],
+ searchableKeys: [],
+ }
+ );
+ useEffect(() => {
+ fetchActivityStream();
+ }, [fetchActivityStream]);
+
+ return (
+
+
+
+ {i18n._(t`Activity Stream`)}
+
+
+
+
+
+
+ {i18n._(t`Time`)}
+ {i18n._(t`Initiated by`)}
+ {i18n._(t`Event`)}
+ {i18n._(t`Actions`)}
+
+ }
+ renderToolbar={props => (
+
+ )}
+ renderRow={streamItem => (
+
+ )}
+ />
+
+
+
+ );
+}
+
+export default withI18n()(ActivityStream);
diff --git a/awx/ui_next/src/screens/ActivityStream/ActivityStream.test.jsx b/awx/ui_next/src/screens/ActivityStream/ActivityStream.test.jsx
new file mode 100644
index 0000000000..b5afeef3d6
--- /dev/null
+++ b/awx/ui_next/src/screens/ActivityStream/ActivityStream.test.jsx
@@ -0,0 +1,25 @@
+import React from 'react';
+
+import { mountWithContexts } from '../../../testUtils/enzymeHelpers';
+
+import ActivityStream from './ActivityStream';
+
+jest.mock('react-router-dom', () => ({
+ ...jest.requireActual('react-router-dom'),
+}));
+
+describe('', () => {
+ let pageWrapper;
+
+ beforeEach(() => {
+ pageWrapper = mountWithContexts();
+ });
+
+ afterEach(() => {
+ pageWrapper.unmount();
+ });
+
+ test('initially renders without crashing', () => {
+ expect(pageWrapper.length).toBe(1);
+ });
+});
diff --git a/awx/ui_next/src/screens/ActivityStream/ActivityStreamListItem.jsx b/awx/ui_next/src/screens/ActivityStream/ActivityStreamListItem.jsx
new file mode 100644
index 0000000000..ab961aeb06
--- /dev/null
+++ b/awx/ui_next/src/screens/ActivityStream/ActivityStreamListItem.jsx
@@ -0,0 +1,61 @@
+import React from 'react';
+import { shape } from 'prop-types';
+import { withI18n } from '@lingui/react';
+import { Tr, Td } from '@patternfly/react-table';
+import { t } from '@lingui/macro';
+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';
+
+function ActivityStreamListItem({ streamItem, i18n }) {
+ ActivityStreamListItem.propTypes = {
+ streamItem: shape({}).isRequired,
+ };
+
+ const buildUser = item => {
+ let link;
+ if (item?.summary_fields?.actor?.id) {
+ link = (
+
+ {item.summary_fields.actor.username}
+
+ );
+ } else if (item?.summary_fields?.actor) {
+ link = i18n._(t`${item.summary_fields.actor.username} (deleted)`);
+ } else {
+ link = i18n._(t`system`);
+ }
+ return link;
+ };
+
+ const labelId = `check-action-${streamItem.id}`;
+ const user = buildUser(streamItem);
+ const description = buildDescription(streamItem, i18n);
+
+ return (
+
+ |
+
+ {streamItem.timestamp ? formatDateString(streamItem.timestamp) : ''}
+ |
+ {user} |
+
+ {description}
+ |
+
+
+
+
+
+
+ );
+}
+export default withI18n()(ActivityStreamListItem);
diff --git a/awx/ui_next/src/screens/ActivityStream/ActivityStreamListItem.test.jsx b/awx/ui_next/src/screens/ActivityStream/ActivityStreamListItem.test.jsx
new file mode 100644
index 0000000000..c0f03d23ee
--- /dev/null
+++ b/awx/ui_next/src/screens/ActivityStream/ActivityStreamListItem.test.jsx
@@ -0,0 +1,22 @@
+import React from 'react';
+import { mountWithContexts } from '../../../testUtils/enzymeHelpers';
+import ActivityStreamListItem from './ActivityStreamListItem';
+
+jest.mock('../../api/models/ActivityStream');
+
+describe('', () => {
+ test('initially renders succesfully', () => {
+ mountWithContexts(
+
+ );
+ });
+});
diff --git a/awx/ui_next/src/screens/ActivityStream/StreamDetailButton.jsx b/awx/ui_next/src/screens/ActivityStream/StreamDetailButton.jsx
new file mode 100644
index 0000000000..b2e8dc368b
--- /dev/null
+++ b/awx/ui_next/src/screens/ActivityStream/StreamDetailButton.jsx
@@ -0,0 +1,64 @@
+import React, { useState } from 'react';
+import { withI18n } from '@lingui/react';
+import { t } from '@lingui/macro';
+import { Button, Modal } from '@patternfly/react-core';
+import { SearchPlusIcon } from '@patternfly/react-icons';
+
+import { formatDateString } from '../../util/dates';
+
+import { DetailList, Detail } from '../../components/DetailList';
+import { VariablesDetail } from '../../components/CodeMirrorInput';
+
+function StreamDetailButton({ i18n, streamItem, user, description }) {
+ const [isOpen, setIsOpen] = useState(false);
+
+ const setting = streamItem?.summary_fields?.setting;
+ const changeRows = Math.max(
+ Object.keys(streamItem?.changes || []).length + 2,
+ 6
+ );
+
+ return (
+ <>
+
+ setIsOpen(false)}
+ >
+
+
+
+
+
+
+
+
+
+ >
+ );
+}
+
+export default withI18n()(StreamDetailButton);
diff --git a/awx/ui_next/src/screens/ActivityStream/StreamDetailButton.test.jsx b/awx/ui_next/src/screens/ActivityStream/StreamDetailButton.test.jsx
new file mode 100644
index 0000000000..04c112c9e0
--- /dev/null
+++ b/awx/ui_next/src/screens/ActivityStream/StreamDetailButton.test.jsx
@@ -0,0 +1,21 @@
+import React from 'react';
+import { Link } from 'react-router-dom';
+
+import { mountWithContexts } from '../../../testUtils/enzymeHelpers';
+import StreamDetailButton from './StreamDetailButton';
+
+jest.mock('../../api/models/ActivityStream');
+
+describe('', () => {
+ test('initially renders succesfully', () => {
+ mountWithContexts(
+ Bob}
+ description={foo}
+ />
+ );
+ });
+});
diff --git a/awx/ui_next/src/screens/ActivityStream/buildActivityDescription.jsx b/awx/ui_next/src/screens/ActivityStream/buildActivityDescription.jsx
new file mode 100644
index 0000000000..6e9f12b9c9
--- /dev/null
+++ b/awx/ui_next/src/screens/ActivityStream/buildActivityDescription.jsx
@@ -0,0 +1,578 @@
+import React from 'react';
+import { Link } from 'react-router-dom';
+import { t } from '@lingui/macro';
+
+const buildAnchor = (obj, resource, activity) => {
+ let url;
+ let name;
+ // 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
+ try {
+ // catch-all case to avoid generating urls if a resource has been deleted
+ // if a resource still exists, it'll be serialized in the activity's summary_fields
+ if (!activity.summary_fields[resource]) {
+ throw new Error('The referenced resource no longer exists');
+ }
+ switch (resource) {
+ case 'custom_inventory_script':
+ url = `/inventory_scripts/${obj.id}/`;
+ break;
+ case 'group':
+ if (
+ activity.operation === 'create' ||
+ activity.operation === 'delete'
+ ) {
+ // the API formats the changes.inventory field as str 'myInventoryName-PrimaryKey'
+ const [inventory_id] = activity.changes.inventory
+ .split('-')
+ .slice(-1);
+ url = `/inventories/inventory/${inventory_id}/groups/${activity.changes.id}/details/`;
+ } else {
+ url = `/inventories/inventory/${
+ activity.summary_fields.inventory[0].id
+ }/groups/${activity.changes.id ||
+ activity.changes.object1_pk}/details/`;
+ }
+ break;
+ case 'host':
+ url = `/hosts/${obj.id}/`;
+ break;
+ case 'job':
+ url = `/jobs/${obj.id}/`;
+ break;
+ case 'inventory':
+ url =
+ obj?.kind === 'smart'
+ ? `/inventories/smart_inventory/${obj.id}/`
+ : `/inventories/inventory/${obj.id}/`;
+ break;
+ case 'schedule':
+ // schedule urls depend on the resource they're associated with
+ if (activity.summary_fields.job_template) {
+ const jt_id = activity.summary_fields.job_template[0].id;
+ url = `/templates/job_template/${jt_id}/schedules/${obj.id}/`;
+ } else if (activity.summary_fields.project) {
+ url = `/projects/${activity.summary_fields.project[0].id}/schedules/${obj.id}/`;
+ } else if (activity.summary_fields.system_job_template) {
+ url = null;
+ } else {
+ // urls for inventory sync schedules currently depend on having
+ // an inventory id and group id
+ throw new Error(
+ 'activity.summary_fields to build this url not implemented yet'
+ );
+ }
+ break;
+ case 'setting':
+ url = `/settings/`;
+ break;
+ case 'notification_template':
+ url = `/notification_templates/${obj.id}/`;
+ break;
+ case 'role':
+ throw new Error(
+ 'role object management is not consolidated to a single UI view'
+ );
+ case 'job_template':
+ url = `/templates/job_template/${obj.id}/`;
+ break;
+ case 'workflow_job_template':
+ url = `/templates/workflow_job_template/${obj.id}/`;
+ break;
+ case 'workflow_job_template_node': {
+ const {
+ wfjt_id,
+ wfjt_name,
+ } = activity.summary_fields.workflow_job_template[0];
+ url = `/templates/workflow_job_template/${wfjt_id}/`;
+ name = wfjt_name;
+ break;
+ }
+ case 'workflow_job':
+ url = `/workflows/${obj.id}/`;
+ break;
+ case 'label':
+ url = null;
+ break;
+ case 'inventory_source': {
+ const inventoryId = (obj.inventory || '').split('-').reverse()[0];
+ url = `/inventories/inventory/${inventoryId}/sources/${obj.id}/details/`;
+ break;
+ }
+ case 'o_auth2_application':
+ url = `/applications/${obj.id}/`;
+ break;
+ case 'workflow_approval':
+ url = `/jobs/workflow/${activity.summary_fields.workflow_job[0].id}/output/`;
+ name = `${activity.summary_fields.workflow_job[0].name} | ${activity.summary_fields.workflow_approval[0].name}`;
+ break;
+ case 'workflow_approval_template':
+ url = `/templates/workflow_job_template/${activity.summary_fields.workflow_job_template[0].id}/visualizer/`;
+ name = `${activity.summary_fields.workflow_job_template[0].name} | ${activity.summary_fields.workflow_approval_template[0].name}`;
+ break;
+ default:
+ url = `/${resource}s/${obj.id}/`;
+ }
+
+ name = name || obj.name || obj.username;
+
+ if (url) {
+ return {name};
+ }
+
+ return {name};
+ } catch (err) {
+ return {obj.name || obj.username || ''};
+ }
+};
+
+const getPastTense = item => {
+ return /e$/.test(item) ? `${item}d ` : `${item}ed `;
+};
+
+const isGroupRelationship = item => {
+ return (
+ item.object1 === 'group' &&
+ item.object2 === 'group' &&
+ item.summary_fields.group.length > 1
+ );
+};
+
+const buildLabeledLink = (label, link) => {
+ return (
+
+ {label} {link}
+
+ );
+};
+
+export default (activity, i18n) => {
+ 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
+ try {
+ switch (activity.object_association) {
+ // explicit role dis+associations
+ case 'role': {
+ let { object1, object2 } = activity;
+
+ // 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.object_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
+ switch (activity.operation) {
+ // expected outcome: "disassociated role_name from "
+ case 'disassociate':
+ if (isGroupRelationship(activity)) {
+ labeledLinks.push(
+ buildLabeledLink(
+ getPastTense(activity.operation),
+ buildAnchor(
+ activity.summary_fields.group[1],
+ object2,
+ activity
+ )
+ )
+ );
+ labeledLinks.push(
+ buildLabeledLink(
+ `${activity.summary_fields.role[0].role_field} from`,
+ buildAnchor(
+ activity.summary_fields.group[0],
+ object1,
+ activity
+ )
+ )
+ );
+ } else {
+ labeledLinks.push(
+ buildLabeledLink(
+ getPastTense(activity.operation),
+ buildAnchor(
+ activity.summary_fields[object2][0],
+ object2,
+ activity
+ )
+ )
+ );
+ labeledLinks.push(
+ buildLabeledLink(
+ `${activity.summary_fields.role[0].role_field} from`,
+ buildAnchor(
+ activity.summary_fields[object1][0],
+ object1,
+ activity
+ )
+ )
+ );
+ }
+ break;
+ // expected outcome: "associated role_name to "
+ case 'associate':
+ if (isGroupRelationship(activity)) {
+ labeledLinks.push(
+ buildLabeledLink(
+ getPastTense(activity.operation),
+ buildAnchor(
+ activity.summary_fields.group[1],
+ object2,
+ activity
+ )
+ )
+ );
+ labeledLinks.push(
+ buildLabeledLink(
+ `${activity.summary_fields.role[0].role_field} to `,
+ buildAnchor(
+ activity.summary_fields.group[0],
+ object1,
+ activity
+ )
+ )
+ );
+ } else {
+ labeledLinks.push(
+ buildLabeledLink(
+ getPastTense(activity.operation),
+ buildAnchor(
+ activity.summary_fields[object2][0],
+ object2,
+ activity
+ )
+ )
+ );
+ labeledLinks.push(
+ buildLabeledLink(
+ `${activity.summary_fields.role[0].role_field} to `,
+ buildAnchor(
+ activity.summary_fields[object1][0],
+ object1,
+ activity
+ )
+ )
+ );
+ }
+ break;
+ default:
+ break;
+ }
+ break;
+ // inherited role dis+associations (logic identical to case 'role')
+ }
+ case 'parents':
+ // 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
+ switch (activity.operation) {
+ // expected outcome: "disassociated role_name from "
+ case 'disassociate':
+ if (isGroupRelationship(activity)) {
+ labeledLinks.push(
+ buildLabeledLink(
+ `${getPastTense(activity.operation)} ${activity.object2}`,
+ buildAnchor(
+ activity.summary_fields.group[1],
+ activity.object2,
+ activity
+ )
+ )
+ );
+ labeledLinks.push(
+ buildLabeledLink(
+ `from ${activity.object1}`,
+ buildAnchor(
+ activity.summary_fields.group[0],
+ activity.object1,
+ activity
+ )
+ )
+ );
+ } else {
+ labeledLinks.push(
+ buildLabeledLink(
+ getPastTense(activity.operation),
+ buildAnchor(
+ activity.summary_fields[activity.object2][0],
+ activity.object2,
+ activity
+ )
+ )
+ );
+ labeledLinks.push(
+ buildLabeledLink(
+ `${activity.summary_fields.role[0].role_field} from`,
+ buildAnchor(
+ activity.summary_fields[activity.object1][0],
+ activity.object1,
+ activity
+ )
+ )
+ );
+ }
+ break;
+ // expected outcome: "associated role_name to "
+ case 'associate':
+ if (isGroupRelationship(activity)) {
+ labeledLinks.push(
+ buildLabeledLink(
+ `${getPastTense(activity.operation)} ${activity.object1}`,
+ buildAnchor(
+ activity.summary_fields.group[0],
+ activity.object1,
+ activity
+ )
+ )
+ );
+ labeledLinks.push(
+ buildLabeledLink(
+ `to ${activity.object2}`,
+ buildAnchor(
+ activity.summary_fields.group[1],
+ activity.object2,
+ activity
+ )
+ )
+ );
+ } else {
+ labeledLinks.push(
+ buildLabeledLink(
+ getPastTense(activity.operation),
+ buildAnchor(
+ activity.summary_fields[activity.object2][0],
+ activity.object2,
+ activity
+ )
+ )
+ );
+ labeledLinks.push(
+ buildLabeledLink(
+ `${activity.summary_fields.role[0].role_field} to`,
+ buildAnchor(
+ activity.summary_fields[activity.object1][0],
+ activity.object1,
+ activity
+ )
+ )
+ );
+ }
+ break;
+ default:
+ break;
+ }
+ break;
+ // CRUD operations / resource on resource dis+associations
+ default:
+ switch (activity.operation) {
+ // expected outcome: "disassociated from "
+ case 'disassociate':
+ if (isGroupRelationship(activity)) {
+ labeledLinks.push(
+ buildLabeledLink(
+ `${getPastTense(activity.operation)} ${activity.object2}`,
+ buildAnchor(
+ activity.summary_fields.group[1],
+ activity.object2,
+ activity
+ )
+ )
+ );
+ labeledLinks.push(
+ buildLabeledLink(
+ `from ${activity.object1}`,
+ buildAnchor(
+ activity.summary_fields.group[0],
+ activity.object1,
+ activity
+ )
+ )
+ );
+ } else if (
+ activity.object1 === 'workflow_job_template_node' &&
+ activity.object2 === 'workflow_job_template_node'
+ ) {
+ labeledLinks.push(
+ buildLabeledLink(
+ `${getPastTense(activity.operation)} two nodes on workflow`,
+ buildAnchor(
+ activity.summary_fields[activity.object1[0]],
+ activity.object1,
+ activity
+ )
+ )
+ );
+ } else {
+ labeledLinks.push(
+ buildLabeledLink(
+ `${getPastTense(activity.operation)} ${activity.object2}`,
+ buildAnchor(
+ activity.summary_fields[activity.object2][0],
+ activity.object2,
+ activity
+ )
+ )
+ );
+ labeledLinks.push(
+ buildLabeledLink(
+ `from ${activity.object1}`,
+ buildAnchor(
+ activity.summary_fields[activity.object1][0],
+ activity.object1,
+ activity
+ )
+ )
+ );
+ }
+ break;
+ // expected outcome "associated to "
+ case 'associate':
+ // groups are the only resource that can be associated/disassociated into each other
+ if (isGroupRelationship(activity)) {
+ labeledLinks.push(
+ buildLabeledLink(
+ `${getPastTense(activity.operation)} ${activity.object1}`,
+ buildAnchor(
+ activity.summary_fields.group[0],
+ activity.object1,
+ activity
+ )
+ )
+ );
+ labeledLinks.push(
+ buildLabeledLink(
+ `to ${activity.object2}`,
+ buildAnchor(
+ activity.summary_fields.group[1],
+ activity.object2,
+ activity
+ )
+ )
+ );
+ } else if (
+ activity.object1 === 'workflow_job_template_node' &&
+ activity.object2 === 'workflow_job_template_node'
+ ) {
+ labeledLinks.push(
+ buildLabeledLink(
+ `${getPastTense(activity.operation)} two nodes on workflow`,
+ buildAnchor(
+ activity.summary_fields[activity.object1[0]],
+ activity.object1,
+ activity
+ )
+ )
+ );
+ } else {
+ labeledLinks.push(
+ buildLabeledLink(
+ `${getPastTense(activity.operation)} ${activity.object1}`,
+ buildAnchor(
+ activity.summary_fields[activity.object1][0],
+ activity.object1,
+ activity
+ )
+ )
+ );
+ labeledLinks.push(
+ buildLabeledLink(
+ `to ${activity.object2}`,
+ buildAnchor(
+ activity.summary_fields[activity.object2][0],
+ activity.object2,
+ activity
+ )
+ )
+ );
+ }
+ break;
+ case 'delete':
+ labeledLinks.push(
+ buildLabeledLink(
+ `${getPastTense(activity.operation)} ${activity.object1}`,
+ buildAnchor(activity.changes, activity.object1, activity)
+ )
+ );
+ break;
+ // expected outcome: "operation "
+ case 'update':
+ if (
+ activity.object1 === 'workflow_approval' &&
+ activity?.changes?.status?.length === 2
+ ) {
+ let operationText = '';
+ if (activity.changes.status[1] === 'successful') {
+ operationText = i18n._(t`approved`);
+ } else if (activity.changes.status[1] === 'failed') {
+ if (
+ activity.changes.timed_out &&
+ activity.changes.timed_out[1] === true
+ ) {
+ operationText = i18n._(t`timed out`);
+ } else {
+ operationText = i18n._(t`denied`);
+ }
+ } else {
+ operationText = i18n._(t`updated`);
+ }
+ labeledLinks.push(
+ buildLabeledLink(
+ `${operationText} ${activity.object1}`,
+ buildAnchor(
+ activity.summary_fields[activity.object1][0],
+ activity.object1,
+ activity
+ )
+ )
+ );
+ } else {
+ labeledLinks.push(
+ buildLabeledLink(
+ `${getPastTense(activity.operation)} ${activity.object1}`,
+ buildAnchor(
+ activity.summary_fields[activity.object1][0],
+ activity.object1,
+ activity
+ )
+ )
+ );
+ }
+ break;
+ case 'create':
+ labeledLinks.push(
+ buildLabeledLink(
+ `${getPastTense(activity.operation)} ${activity.object1}`,
+ buildAnchor(activity.changes, activity.object1, activity)
+ )
+ );
+ break;
+ default:
+ break;
+ }
+ break;
+ }
+ } catch (err) {
+ return {i18n._(t`Event summary not available`)};
+ }
+
+ return (
+
+ {labeledLinks.reduce(
+ (acc, x) =>
+ acc === null ? (
+ x
+ ) : (
+ <>
+ {acc} {x}
+ >
+ ),
+ null
+ )}
+
+ );
+};
diff --git a/awx/ui_next/src/screens/ActivityStream/buildActivityDescription.test.jsx b/awx/ui_next/src/screens/ActivityStream/buildActivityDescription.test.jsx
new file mode 100644
index 0000000000..3d90ef5915
--- /dev/null
+++ b/awx/ui_next/src/screens/ActivityStream/buildActivityDescription.test.jsx
@@ -0,0 +1,10 @@
+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);
+ });
+});
diff --git a/awx/ui_next/src/screens/ActivityStream/index.js b/awx/ui_next/src/screens/ActivityStream/index.js
new file mode 100644
index 0000000000..5c0c72d9ef
--- /dev/null
+++ b/awx/ui_next/src/screens/ActivityStream/index.js
@@ -0,0 +1 @@
+export { default } from './ActivityStream';