Skip to content

Commit

Permalink
[APM] Make all error messages on tables consistence (#111690)
Browse files Browse the repository at this point in the history
* make all error messages on tables consistence

* rename variable

* fix conflict and delete not needed component

* fix empty array left after testing
  • Loading branch information
MiriamAparicio authored Sep 15, 2021
1 parent 7195317 commit 5488c20
Show file tree
Hide file tree
Showing 15 changed files with 212 additions and 246 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ import {
EuiToolTip,
} from '@elastic/eui';
import numeral from '@elastic/numeral';
import { i18n } from '@kbn/i18n';
import { FormattedMessage } from '@kbn/i18n/react';
import { useUrlParams } from '../../../../context/url_params_context/use_url_params';
import { useFetcher } from '../../../../hooks/use_fetcher';
import { FETCH_STATUS, useFetcher } from '../../../../hooks/use_fetcher';
import { I18LABELS } from '../translations';
import { CsmSharedContext } from '../CsmSharedContext';
import { ErrorDetailLink } from '../../../shared/Links/apm/ErrorDetailLink';
Expand Down Expand Up @@ -125,14 +126,21 @@ export function JSErrors() {
)
}
description={I18LABELS.totalErrors}
isLoading={status !== 'success'}
isLoading={status === FETCH_STATUS.LOADING}
/>
</EuiFlexItem>
</EuiFlexGroup>
<EuiSpacer size="s" />
<EuiBasicTable
data-test-subj={'uxJsErrorTable'}
loading={status !== 'success'}
loading={status === FETCH_STATUS.LOADING}
error={
status === FETCH_STATUS.FAILURE
? i18n.translate('xpack.apm.rum.jsErrorsTable.errorMessage', {
defaultMessage: 'Failed to fetch',
})
: ''
}
responsive={false}
compressed={true}
columns={cols}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ export function CorrelationsTable<T extends FieldValuePair>({
status === FETCH_STATUS.LOADING ? loadingText : noDataText
}
loading={status === FETCH_STATUS.LOADING}
error={status === FETCH_STATUS.FAILURE ? errorMessage : ''}
columns={columns}
rowProps={(term) => {
return {
Expand Down Expand Up @@ -121,3 +122,8 @@ const noDataText = i18n.translate(
'xpack.apm.correlations.correlationsTable.noDataText',
{ defaultMessage: 'No data' }
);

const errorMessage = i18n.translate(
'xpack.apm.correlations.correlationsTable.errorMessage',
{ defaultMessage: 'Failed to fetch' }
);
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@
* 2.0.
*/

import { EuiFlexGroup, EuiFlexItem, EuiLink } from '@elastic/eui';
import {
EuiFlexGroup,
EuiFlexItem,
EuiLink,
EuiEmptyPrompt,
} from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import React, { useEffect } from 'react';
import uuid from 'uuid';
Expand All @@ -20,7 +25,6 @@ import { useTimeRange } from '../../../hooks/use_time_range';
import { useUpgradeAssistantHref } from '../../shared/Links/kibana';
import { SearchBar } from '../../shared/search_bar';
import { getTimeRangeComparison } from '../../shared/time_comparison/get_time_range_comparison';
import { NoServicesMessage } from './no_services_message';
import { ServiceList } from './service_list';
import { MLCallout } from './service_list/MLCallout';

Expand Down Expand Up @@ -179,6 +183,21 @@ export function ServiceInventory() {
canCreateJob &&
!userHasDismissedCallout;

const isLoading = mainStatisticsStatus === FETCH_STATUS.LOADING;
const isFailure = mainStatisticsStatus === FETCH_STATUS.FAILURE;
const noItemsMessage = (
<EuiEmptyPrompt
title={
<div>
{i18n.translate('xpack.apm.servicesTable.notFoundLabel', {
defaultMessage: 'No services found',
})}
</div>
}
titleSize="s"
/>
);

return (
<>
<SearchBar showTimeComparison />
Expand All @@ -190,10 +209,11 @@ export function ServiceInventory() {
)}
<EuiFlexItem>
<ServiceList
isLoading={mainStatisticsStatus === FETCH_STATUS.LOADING}
isLoading={isLoading}
isFailure={isFailure}
items={mainStatisticsData.items}
comparisonData={comparisonData}
noItemsMessage={<NoServicesMessage status={mainStatisticsStatus} />}
noItemsMessage={noItemsMessage}
/>
</EuiFlexItem>
</EuiFlexGroup>
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -214,13 +214,15 @@ interface Props {
comparisonData?: ServicesDetailedStatisticsAPIResponse;
noItemsMessage?: React.ReactNode;
isLoading: boolean;
isFailure?: boolean;
}

export function ServiceList({
items,
noItemsMessage,
comparisonData,
isLoading,
isFailure,
}: Props) {
const breakpoints = useBreakpoints();
const displayHealthStatus = items.some((item) => 'healthStatus' in item);
Expand Down Expand Up @@ -296,6 +298,7 @@ export function ServiceList({
<EuiFlexItem>
<ManagedTable
isLoading={isLoading}
error={isFailure}
columns={columns}
items={items}
noItemsMessage={noItemsMessage}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import { useUrlParams } from '../../../../context/url_params_context/use_url_par
import { FETCH_STATUS, useFetcher } from '../../../../hooks/use_fetcher';
import { APIReturnType } from '../../../../services/rest/createCallApmApi';
import { ErrorOverviewLink } from '../../../shared/Links/apm/ErrorOverviewLink';
import { TableFetchWrapper } from '../../../shared/table_fetch_wrapper';
import { getTimeRangeComparison } from '../../../shared/time_comparison/get_time_range_comparison';
import { OverviewTableContainer } from '../../../shared/overview_table_container';
import { getColumns } from './get_columns';
Expand Down Expand Up @@ -204,58 +203,64 @@ export function ServiceOverviewErrorsTable({ serviceName }: Props) {
</EuiFlexGroup>
</EuiFlexItem>
<EuiFlexItem>
<TableFetchWrapper status={status}>
<OverviewTableContainer
fixedHeight={true}
isEmptyAndNotInitiated={
totalItems === 0 && status === FETCH_STATUS.NOT_INITIATED
<OverviewTableContainer
fixedHeight={true}
isEmptyAndNotInitiated={
totalItems === 0 && status === FETCH_STATUS.NOT_INITIATED
}
>
<EuiBasicTable
error={
status === FETCH_STATUS.FAILURE
? i18n.translate(
'xpack.apm.serviceOverview.errorsTable.errorMessage',
{ defaultMessage: 'Failed to fetch' }
)
: ''
}
>
<EuiBasicTable
noItemsMessage={
status === FETCH_STATUS.LOADING
? i18n.translate(
'xpack.apm.serviceOverview.errorsTable.loading',
{ defaultMessage: 'Loading...' }
)
: i18n.translate(
'xpack.apm.serviceOverview.errorsTable.noResults',
{ defaultMessage: 'No errors found' }
)
}
columns={columns}
items={items}
pagination={{
pageIndex,
pageSize: PAGE_SIZE,
totalItemCount: totalItems,
pageSizeOptions: [PAGE_SIZE],
hidePerPageOptions: true,
}}
loading={status === FETCH_STATUS.LOADING}
onChange={(newTableOptions: {
page?: {
index: number;
};
sort?: { field: string; direction: SortDirection };
}) => {
setTableOptions({
pageIndex: newTableOptions.page?.index ?? 0,
sort: newTableOptions.sort
? {
field: newTableOptions.sort.field as SortField,
direction: newTableOptions.sort.direction,
}
: DEFAULT_SORT,
});
}}
sorting={{
enableAllColumns: true,
sort,
}}
/>
</OverviewTableContainer>
</TableFetchWrapper>
noItemsMessage={
status === FETCH_STATUS.LOADING
? i18n.translate(
'xpack.apm.serviceOverview.errorsTable.loading',
{ defaultMessage: 'Loading...' }
)
: i18n.translate(
'xpack.apm.serviceOverview.errorsTable.noResults',
{ defaultMessage: 'No errors found' }
)
}
columns={columns}
items={items}
pagination={{
pageIndex,
pageSize: PAGE_SIZE,
totalItemCount: totalItems,
pageSizeOptions: [PAGE_SIZE],
hidePerPageOptions: true,
}}
loading={status === FETCH_STATUS.LOADING}
onChange={(newTableOptions: {
page?: {
index: number;
};
sort?: { field: string; direction: SortDirection };
}) => {
setTableOptions({
pageIndex: newTableOptions.page?.index ?? 0,
sort: newTableOptions.sort
? {
field: newTableOptions.sort.field as SortField,
direction: newTableOptions.sort.direction,
}
: DEFAULT_SORT,
});
}}
sorting={{
enableAllColumns: true,
sort,
}}
/>
</OverviewTableContainer>
</EuiFlexItem>
</EuiFlexGroup>
);
Expand Down
Loading

0 comments on commit 5488c20

Please sign in to comment.