Fix Overview page crashing (#104258)
The activity feed tried to render a link to a source for activity items like "New user joined organization". This couldn't be done and the page crashed. This PR accounts for this case by rendering an item with no link for such cases. This was already fixed before in ent-search in https://github.com/elastic/ent-search/pull/2574 But we didn't port the PR, because we thought there is no need to port a part of Standard auth functionality. Turned out there is. Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
parent
2a37ef8c5f
commit
1b92c29d18
|
@ -30,6 +30,11 @@ const activityFeed = [
|
|||
target: 'http://localhost:3002/ws/org/sources',
|
||||
timestamp: '2020-06-24 16:34:16',
|
||||
},
|
||||
{
|
||||
id: '(foo@example.com)',
|
||||
message: 'joined the organization',
|
||||
timestamp: '2021-07-02 16:38:27',
|
||||
},
|
||||
];
|
||||
|
||||
describe('RecentActivity', () => {
|
||||
|
@ -46,13 +51,14 @@ describe('RecentActivity', () => {
|
|||
it('renders an activityFeed with links', () => {
|
||||
setMockValues({ activityFeed });
|
||||
const wrapper = shallow(<RecentActivity />);
|
||||
const activity = wrapper.find(RecentActivityItem).dive();
|
||||
const sourceActivityItem = wrapper.find(RecentActivityItem).first().dive();
|
||||
const newUserActivityItem = wrapper.find(RecentActivityItem).last().dive();
|
||||
|
||||
expect(activity).toHaveLength(1);
|
||||
|
||||
const link = activity.find('[data-test-subj="viewSourceDetailsLink"]');
|
||||
const link = sourceActivityItem.find('[data-test-subj="viewSourceDetailsLink"]');
|
||||
link.simulate('click');
|
||||
expect(mockTelemetryActions.sendWorkplaceSearchTelemetry).toHaveBeenCalled();
|
||||
|
||||
expect(newUserActivityItem.find('[data-test-subj="newUserTextWrapper"]')).toHaveLength(1);
|
||||
});
|
||||
|
||||
it('renders activity item error state', () => {
|
||||
|
|
|
@ -29,7 +29,7 @@ export interface FeedActivity {
|
|||
id: string;
|
||||
message: string;
|
||||
timestamp: string;
|
||||
sourceId: string;
|
||||
sourceId?: string;
|
||||
}
|
||||
|
||||
export const RecentActivity: React.FC = () => {
|
||||
|
@ -98,23 +98,29 @@ export const RecentActivityItem: React.FC<FeedActivity> = ({
|
|||
return (
|
||||
<div className={`activity ${status ? `activity--${status}` : ''}`}>
|
||||
<div className="activity__message">
|
||||
<EuiLinkTo
|
||||
onClick={onClick}
|
||||
color={status === 'error' ? 'danger' : 'primary'}
|
||||
to={getContentSourcePath(SOURCE_DETAILS_PATH, sourceId, true)}
|
||||
data-test-subj="viewSourceDetailsLink"
|
||||
>
|
||||
{id} {message}
|
||||
{status === 'error' && (
|
||||
<span className="activity--error__label">
|
||||
{' '}
|
||||
<FormattedMessage
|
||||
id="xpack.enterpriseSearch.workplaceSearch.recentActivitySourceLink.linkLabel"
|
||||
defaultMessage="View Source"
|
||||
/>
|
||||
</span>
|
||||
)}
|
||||
</EuiLinkTo>
|
||||
{sourceId ? (
|
||||
<EuiLinkTo
|
||||
onClick={onClick}
|
||||
color={status === 'error' ? 'danger' : 'primary'}
|
||||
to={getContentSourcePath(SOURCE_DETAILS_PATH, sourceId, true)}
|
||||
data-test-subj="viewSourceDetailsLink"
|
||||
>
|
||||
{id} {message}
|
||||
{status === 'error' && (
|
||||
<span className="activity--error__label">
|
||||
{' '}
|
||||
<FormattedMessage
|
||||
id="xpack.enterpriseSearch.workplaceSearch.recentActivitySourceLink.linkLabel"
|
||||
defaultMessage="View Source"
|
||||
/>
|
||||
</span>
|
||||
)}
|
||||
</EuiLinkTo>
|
||||
) : (
|
||||
<div data-test-subj="newUserTextWrapper">
|
||||
{id} {message}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
<div className="activity__date">{moment.utc(timestamp).fromNow()}</div>
|
||||
</div>
|
||||
|
|
Loading…
Reference in a new issue