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
2 changed files with 34 additions and 22 deletions
|
@ -30,6 +30,11 @@ const activityFeed = [
|
||||||
target: 'http://localhost:3002/ws/org/sources',
|
target: 'http://localhost:3002/ws/org/sources',
|
||||||
timestamp: '2020-06-24 16:34:16',
|
timestamp: '2020-06-24 16:34:16',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
id: '(foo@example.com)',
|
||||||
|
message: 'joined the organization',
|
||||||
|
timestamp: '2021-07-02 16:38:27',
|
||||||
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
describe('RecentActivity', () => {
|
describe('RecentActivity', () => {
|
||||||
|
@ -46,13 +51,14 @@ describe('RecentActivity', () => {
|
||||||
it('renders an activityFeed with links', () => {
|
it('renders an activityFeed with links', () => {
|
||||||
setMockValues({ activityFeed });
|
setMockValues({ activityFeed });
|
||||||
const wrapper = shallow(<RecentActivity />);
|
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 = sourceActivityItem.find('[data-test-subj="viewSourceDetailsLink"]');
|
||||||
|
|
||||||
const link = activity.find('[data-test-subj="viewSourceDetailsLink"]');
|
|
||||||
link.simulate('click');
|
link.simulate('click');
|
||||||
expect(mockTelemetryActions.sendWorkplaceSearchTelemetry).toHaveBeenCalled();
|
expect(mockTelemetryActions.sendWorkplaceSearchTelemetry).toHaveBeenCalled();
|
||||||
|
|
||||||
|
expect(newUserActivityItem.find('[data-test-subj="newUserTextWrapper"]')).toHaveLength(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('renders activity item error state', () => {
|
it('renders activity item error state', () => {
|
||||||
|
|
|
@ -29,7 +29,7 @@ export interface FeedActivity {
|
||||||
id: string;
|
id: string;
|
||||||
message: string;
|
message: string;
|
||||||
timestamp: string;
|
timestamp: string;
|
||||||
sourceId: string;
|
sourceId?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const RecentActivity: React.FC = () => {
|
export const RecentActivity: React.FC = () => {
|
||||||
|
@ -98,23 +98,29 @@ export const RecentActivityItem: React.FC<FeedActivity> = ({
|
||||||
return (
|
return (
|
||||||
<div className={`activity ${status ? `activity--${status}` : ''}`}>
|
<div className={`activity ${status ? `activity--${status}` : ''}`}>
|
||||||
<div className="activity__message">
|
<div className="activity__message">
|
||||||
<EuiLinkTo
|
{sourceId ? (
|
||||||
onClick={onClick}
|
<EuiLinkTo
|
||||||
color={status === 'error' ? 'danger' : 'primary'}
|
onClick={onClick}
|
||||||
to={getContentSourcePath(SOURCE_DETAILS_PATH, sourceId, true)}
|
color={status === 'error' ? 'danger' : 'primary'}
|
||||||
data-test-subj="viewSourceDetailsLink"
|
to={getContentSourcePath(SOURCE_DETAILS_PATH, sourceId, true)}
|
||||||
>
|
data-test-subj="viewSourceDetailsLink"
|
||||||
{id} {message}
|
>
|
||||||
{status === 'error' && (
|
{id} {message}
|
||||||
<span className="activity--error__label">
|
{status === 'error' && (
|
||||||
{' '}
|
<span className="activity--error__label">
|
||||||
<FormattedMessage
|
{' '}
|
||||||
id="xpack.enterpriseSearch.workplaceSearch.recentActivitySourceLink.linkLabel"
|
<FormattedMessage
|
||||||
defaultMessage="View Source"
|
id="xpack.enterpriseSearch.workplaceSearch.recentActivitySourceLink.linkLabel"
|
||||||
/>
|
defaultMessage="View Source"
|
||||||
</span>
|
/>
|
||||||
)}
|
</span>
|
||||||
</EuiLinkTo>
|
)}
|
||||||
|
</EuiLinkTo>
|
||||||
|
) : (
|
||||||
|
<div data-test-subj="newUserTextWrapper">
|
||||||
|
{id} {message}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
<div className="activity__date">{moment.utc(timestamp).fromNow()}</div>
|
<div className="activity__date">{moment.utc(timestamp).fromNow()}</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in a new issue