Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RAC] Toolbar total number units fixed #109252

Merged
merged 1 commit into from
Aug 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ export interface OwnProps {
utilityBar?: (refetch: inputsModel.Refetch, totalCount: number) => React.ReactNode;
additionalFilters?: React.ReactNode;
hasAlertsCrud?: boolean;
unit?: (n: number) => string;
}

type Props = OwnProps & PropsFromRedux;
Expand Down Expand Up @@ -105,6 +106,7 @@ const StatefulEventsViewerComponent: React.FC<Props> = ({
// If truthy, the graph viewer (Resolver) is showing
graphEventId,
hasAlertsCrud = false,
unit,
}) => {
const { timelines: timelinesUi } = useKibana().services;
const {
Expand Down Expand Up @@ -187,6 +189,7 @@ const StatefulEventsViewerComponent: React.FC<Props> = ({
leadingControlColumns,
trailingControlColumns,
tGridEventRenderedViewEnabled,
unit,
})
) : (
<EventsViewer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export const eventsStackByOptions: MatrixHistogramOption[] = [
];

const DEFAULT_STACK_BY = 'event.action';
const unit = (n: number) => i18n.EVENTS_UNIT(n);

export const histogramConfigs: MatrixHistogramConfigs = {
defaultStackByOption:
Expand Down Expand Up @@ -119,6 +120,7 @@ const EventsQueryTabBodyComponent: React.FC<HostsComponentsQueryProps> = ({
scopeId={SourcererScopeName.default}
start={startDate}
pageFilters={pageFilters}
unit={unit}
/>
</>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,9 @@ export const ERROR_FETCHING_EVENTS_DATA = i18n.translate(
defaultMessage: 'Failed to query events data',
}
);

export const EVENTS_UNIT = (totalCount: number) =>
i18n.translate('xpack.securitySolution.hosts.navigaton.eventsUnit', {
values: { totalCount },
defaultMessage: `{totalCount, plural, =1 {event} other {events}}`,
});
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ interface OwnProps {
hasAlertsCrud?: boolean;
}

const basicUnit = (n: number) => i18n.UNIT(n);
const defaultUnit = (n: number) => i18n.ALERTS_UNIT(n);
const NUM_OF_ICON_IN_TIMELINE_ROW = 2;

export const hasAdditionalActions = (id: TimelineId): boolean =>
Expand Down Expand Up @@ -273,7 +273,7 @@ export const BodyComponent = React.memo<StatefulBodyProps>(
totalItems,
totalPages,
trailingControlColumns = EMPTY_CONTROL_COLUMNS,
unit = basicUnit,
unit = defaultUnit,
hasAlertsCrud,
}) => {
const dispatch = useDispatch();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,8 @@ export const INVESTIGATE_IN_RESOLVER_DISABLED = i18n.translate(
}
);

export const UNIT = (totalCount: number) =>
i18n.translate('xpack.timelines.timeline.body.unit', {
export const ALERTS_UNIT = (totalCount: number) =>
i18n.translate('xpack.timelines.timeline.alertsUnit', {
values: { totalCount },
defaultMessage: `{totalCount, plural, =1 {event} other {events}}`,
defaultMessage: `{totalCount, plural, =1 {alert} other {alerts}}`,
});
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ import { useTimelineEvents } from '../../../container';
import { StatefulBody } from '../body';
import { Footer, footerHeight } from '../footer';
import { SELECTOR_TIMELINE_GLOBAL_CONTAINER, UpdatedFlexGroup, UpdatedFlexItem } from '../styles';
import * as i18n from '../translations';
import { Sort } from '../body/sort';
import { InspectButton, InspectButtonContainer } from '../../inspect';
import { SummaryViewSelector, ViewSelection } from '../event_rendered_view/selector';
Expand Down Expand Up @@ -138,6 +137,7 @@ export interface TGridIntegratedProps {
data?: DataPublicPluginStart;
tGridEventRenderedViewEnabled: boolean;
hasAlertsCrud: boolean;
unit?: (n: number) => string;
}

const TGridIntegratedComponent: React.FC<TGridIntegratedProps> = ({
Expand Down Expand Up @@ -175,6 +175,7 @@ const TGridIntegratedComponent: React.FC<TGridIntegratedProps> = ({
tGridEventRenderedViewEnabled,
data,
hasAlertsCrud,
unit,
}) => {
const dispatch = useDispatch();
const columnsHeader = isEmpty(columns) ? defaultHeaders : columns;
Expand All @@ -183,7 +184,6 @@ const TGridIntegratedComponent: React.FC<TGridIntegratedProps> = ({

const [tableView, setTableView] = useState<ViewSelection>('gridView');
const getManageTimeline = useMemo(() => tGridSelectors.getManageTimelineById(), []);
const unit = useMemo(() => (n: number) => i18n.ALERTS_UNIT(n), []);
const { queryFields, title } = useDeepEqualSelector((state) =>
getManageTimeline(state, id ?? '')
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ import { StatefulBody } from '../body';
import { Footer, footerHeight } from '../footer';
import { LastUpdatedAt } from '../..';
import { SELECTOR_TIMELINE_GLOBAL_CONTAINER, UpdatedFlexItem, UpdatedFlexGroup } from '../styles';
import * as i18n from '../translations';
import { InspectButton, InspectButtonContainer } from '../../inspect';
import { useFetchIndex } from '../../../container/source';
import { AddToCaseAction } from '../../actions/timeline/cases/add_to_case_action';
Expand Down Expand Up @@ -113,9 +112,8 @@ export interface TGridStandaloneProps {
trailingControlColumns: ControlColumnProps[];
bulkActions?: BulkActionsProp;
data?: DataPublicPluginStart;
unit: (total: number) => React.ReactNode;
unit?: (total: number) => React.ReactNode;
}
const basicUnit = (n: number) => i18n.UNIT(n);

const TGridStandaloneComponent: React.FC<TGridStandaloneProps> = ({
afterCaseSelection,
Expand Down Expand Up @@ -145,7 +143,7 @@ const TGridStandaloneComponent: React.FC<TGridStandaloneProps> = ({
leadingControlColumns,
trailingControlColumns,
data,
unit = basicUnit,
unit,
}) => {
const dispatch = useDispatch();
const columnsHeader = isEmpty(columns) ? defaultHeaders : columns;
Expand Down
12 changes: 0 additions & 12 deletions x-pack/plugins/timelines/public/components/t_grid/translations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,6 @@ export const EVENTS_TABLE_ARIA_LABEL = ({
defaultMessage: 'events; Page {activePage} of {totalPages}',
});

export const UNIT = (totalCount: number) =>
i18n.translate('xpack.timelines.timeline.unit', {
values: { totalCount },
defaultMessage: `{totalCount, plural, =1 {event} other {events}}`,
});

export const ALERTS_UNIT = (totalCount: number) =>
i18n.translate('xpack.timelines.timeline.alertsUnit', {
values: { totalCount },
defaultMessage: `{totalCount, plural, =1 {alert} other {alerts}}`,
});

export const BULK_ACTION_OPEN_SELECTED = i18n.translate(
'xpack.timelines.timeline.openSelectedTitle',
{
Expand Down