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

Feature/translate monitoring table #24973

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
c7ec189
Merge pull request #1 from elastic/master
Nox911 Sep 24, 2018
fa01b88
Merge pull request #2 from elastic/master
Nox911 Sep 27, 2018
70f6c7e
Merge branch 'master' of https://github.com/elastic/kibana
Nox911 Sep 27, 2018
68587a0
Merge branch 'master' of https://github.com/elastic/kibana
Nox911 Sep 28, 2018
42aa7d3
Merge branch 'master' of https://github.com/elastic/kibana
Nox911 Oct 2, 2018
efeaefe
Merge branch 'master' of https://github.com/elastic/kibana
Nox911 Oct 2, 2018
8a054ed
Merge branch 'master' of https://github.com/elastic/kibana
Nox911 Oct 8, 2018
b0d1660
Merge branch 'master' of https://github.com/elastic/kibana
Nox911 Oct 16, 2018
62b6ad1
Merge branch 'master' of https://github.com/elastic/kibana
Nox911 Oct 17, 2018
acbad4b
Merge branch 'master' of https://github.com/elastic/kibana
Nox911 Oct 18, 2018
a850650
Merge branch 'master' of https://github.com/elastic/kibana
Nox911 Oct 22, 2018
0a200ce
Merge branch 'master' of https://github.com/elastic/kibana
Nox911 Oct 25, 2018
b2a8244
Merge branch 'master' of https://github.com/elastic/kibana
Nox911 Oct 29, 2018
b4b979e
Merge branch 'master' of https://github.com/elastic/kibana
Nox911 Oct 30, 2018
d349a4f
Merge branch 'master' of https://github.com/elastic/kibana
Nox911 Oct 31, 2018
77abc02
Translate monitoring -> summary_status, table, main.html in directives
Nox911 Nov 1, 2018
d3a497b
Fix issues
Nox911 Nov 1, 2018
ae285b9
Merge branch 'master' of https://github.com/elastic/kibana
Nox911 Nov 2, 2018
eb0b9a8
Merge branch 'master' into feature/translate-monitoring-monitoring_table
Nox911 Nov 2, 2018
ae38a0c
Fix tests
Nox911 Nov 2, 2018
21bfb81
Add disable eslint for unused var intl
Nox911 Nov 2, 2018
43139db
Merge branch 'master' into feature/translate-monitoring-monitoring_table
maryia-lapata Nov 14, 2018
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 @@ -9,6 +9,8 @@ import PropTypes from 'prop-types';
import { isEmpty, capitalize } from 'lodash';
import { EuiFlexGroup, EuiFlexItem } from '@elastic/eui';
import { StatusIcon } from '../status_icon/index.js';
import { FormattedMessage } from '@kbn/i18n/react';
import { i18n } from '@kbn/i18n';

const wrapChild = ({ label, value, dataTestSubj }, index) => (
<EuiFlexItem
Expand All @@ -29,9 +31,23 @@ const wrapChild = ({ label, value, dataTestSubj }, index) => (

const DefaultIconComponent = ({ status }) => (
<Fragment>
Status: {(
<StatusIcon type={status.toUpperCase()} label={`Status: ${status}`} />
)}
<FormattedMessage
id="xpack.monitoring.summaryStatus.statusIconTitle"
defaultMessage="Status: {statusIcon}"
values={{
statusIcon: (
<StatusIcon
type={status.toUpperCase()}
label={i18n.translate('xpack.monitoring.summaryStatus.statusIconLabel', {
defaultMessage: 'Status: {status}',
values: {
status
}
})}
/>
)
}}
/>
</Fragment>
);

Expand All @@ -52,7 +68,8 @@ const StatusIndicator = ({ status, isOnline, IconComponent }) => {
);
};

export function SummaryStatus({ metrics, status, isOnline, IconComponent = DefaultIconComponent, ...props }) {
// eslint-disable-next-line no-unused-vars
export function SummaryStatus({ metrics, status, isOnline, IconComponent = DefaultIconComponent, intl, ...props }) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you add intl if you aren't using it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we add 'intl' here because in the test for SummaryStatus we use 'renderWithIntl'.
https://github.com/elastic/kibana/pull/24973/files#diff-9e2803564a1fa0f70e630c1d9f61814fR29
'renderWithIntl' add 'intl' in the props.
If we don't add 'intl' as argument, 'intl' drops to ...props here https://github.com/elastic/kibana/pull/24973/files#diff-e87682e532627ab40213f0d0af2dbb95R75
and we are getting unexpected result in snapshot.

return (
<div className="monSummaryStatus" role="status">
<div {...props}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/

import React from 'react';
import { render } from 'enzyme';
import { renderWithIntl } from '../../../../../test_utils/enzyme_helpers';
import { SummaryStatus } from './summary_status';

describe('Summary Status Component', () => {
Expand All @@ -26,7 +26,7 @@ describe('Summary Status Component', () => {
status: 'green'
};

expect(render(<SummaryStatus {...props} />)).toMatchSnapshot();
expect(renderWithIntl(<SummaryStatus {...props} />)).toMatchSnapshot();
});

it('should allow label to be optional', () => {
Expand All @@ -45,7 +45,7 @@ describe('Summary Status Component', () => {
status: 'yellow'
};

expect(render(<SummaryStatus {...props} />)).toMatchSnapshot();
expect(renderWithIntl(<SummaryStatus {...props} />)).toMatchSnapshot();
});

it('should allow status to be optional', () => {
Expand All @@ -64,6 +64,6 @@ describe('Summary Status Component', () => {
]
};

expect(render(<SummaryStatus {...props} />)).toMatchSnapshot();
expect(renderWithIntl(<SummaryStatus {...props} />)).toMatchSnapshot();
});
});
11 changes: 10 additions & 1 deletion x-pack/plugins/monitoring/public/components/table/footer.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,22 @@ import {
KuiToolBarFooterSection,
KuiToolBarText
} from '@kbn/ui-framework/components';
import { FormattedMessage } from '@kbn/i18n/react';

export function MonitoringTableFooter({ pageIndexFirstRow, pageIndexLastRow, rowsFiltered, paginationControls }) {
return (
<KuiToolBarFooter>
<KuiToolBarFooterSection>
<KuiToolBarText>
{ pageIndexFirstRow } &ndash; { pageIndexLastRow } of { rowsFiltered }
<FormattedMessage
id="xpack.monitoring.table.footer.pageRowsDescription"
defaultMessage="{pageIndexFirstRow} &ndash; {pageIndexLastRow} of {rowsFiltered}"
values={{
pageIndexFirstRow,
pageIndexLastRow,
rowsFiltered
}}
/>
</KuiToolBarText>

{ paginationControls }
Expand Down
24 changes: 20 additions & 4 deletions x-pack/plugins/monitoring/public/components/table/table.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { MonitoringTableToolBar } from './toolbar';
import { MonitoringTableNoData } from './no_data';
import { MonitoringTableFooter } from './footer';
import classNames from 'classnames';
import { FormattedMessage, injectI18n } from '@kbn/i18n/react';

/*
* State and data management for Monitoring Tables
Expand All @@ -46,7 +47,7 @@ import classNames from 'classnames';
* }
* ];
*/
export class MonitoringTable extends React.Component {
class MonitoringTableUI extends React.Component {
constructor(props) {
super(props);

Expand Down Expand Up @@ -121,7 +122,13 @@ export class MonitoringTable extends React.Component {
this.resetPaging();
break;
default:
throw new Error(`Unknown table action type ${action}! This shouldn't happen!`);
throw new Error(
this.props.intl.formatMessage({
id: 'xpack.monitoring.table.unknownTableActionTypeErrorMessage',
defaultMessage: `Unknown table action type {action}! This shouldn't happen!` }, {
action
})
);
}
}

Expand Down Expand Up @@ -403,7 +410,14 @@ export class MonitoringTable extends React.Component {

if (this.state.rows === null) {
// rows are null, show loading message
table = <MonitoringTableNoData message="Loading..." />;
table = (<MonitoringTableNoData
message={(
<FormattedMessage
id="xpack.monitoring.table.loadingTitle"
defaultMessage="Loading…"
/>
)}
/>);
} else if (numVisibleRows > 0) {
// data has some rows, show them
const RowComponent = this.props.rowComponent;
Expand Down Expand Up @@ -450,10 +464,12 @@ const defaultGetNoDataMessage = filterText => {
return DEFAULT_NO_DATA_MESSAGE;
};

MonitoringTable.defaultProps = {
MonitoringTableUI.defaultProps = {
rows: [],
filterFields: [],
getNoDataMessage: defaultGetNoDataMessage,
alwaysShowPageControls: false,
rowsPerPage: 20
};

export const MonitoringTable = injectI18n(MonitoringTableUI);
9 changes: 8 additions & 1 deletion x-pack/plugins/monitoring/public/components/table/toolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
KuiToolBarSection,
KuiToolBarText
} from '@kbn/ui-framework/components';
import { FormattedMessage } from '@kbn/i18n/react';

export function MonitoringTableToolBar(props) {
const searchBox = props.showSearchBox
Expand Down Expand Up @@ -40,7 +41,13 @@ export function MonitoringTableToolBar(props) {
const totalRows = Boolean(props.showTotalRows)
? (
<p tabIndex="0" className="monitoringTableToolbarTotalRows">
{props.totalRows} in total
<FormattedMessage
id="xpack.monitoring.table.toolbar.totalRowsDescription"
defaultMessage="{totalRows} in total"
values={{
totalRows: props.totalRows
}}
/>
</p>
)
: null;
Expand Down
19 changes: 11 additions & 8 deletions x-pack/plugins/monitoring/public/directives/alerts/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { FormattedAlert } from 'plugins/monitoring/components/alerts/formatted_a
import { mapSeverity } from 'plugins/monitoring/components/alerts/map_severity';
import { formatTimestampToDuration } from '../../../common/format_timestamp_to_duration';
import { formatDateTimeLocal } from '../../../common/formatting';
import { I18nProvider } from '@kbn/i18n/react';

const linkToCategories = {
'elasticsearch/nodes': 'Elasticsearch Nodes',
Expand Down Expand Up @@ -96,14 +97,16 @@ uiModule.directive('monitoringClusterAlertsListing', kbnUrl => {

scope.$watch('alerts', (alerts = []) => {
const alertsTable = (
<MonitoringTable
className="alertsTable"
rows={alerts}
placeholder="Filter Alerts..."
filterFields={filterFields}
columns={columns}
rowComponent={alertRowFactory(scope, kbnUrl)}
/>
<I18nProvider>
<MonitoringTable
className="alertsTable"
rows={alerts}
placeholder="Filter Alerts..."
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be translated too?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

filterFields={filterFields}
columns={columns}
rowComponent={alertRowFactory(scope, kbnUrl)}
/>
</I18nProvider>
);
render(alertsTable, $el[0]);
});
Expand Down
37 changes: 20 additions & 17 deletions x-pack/plugins/monitoring/public/directives/beats/listing/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { MonitoringTable } from 'plugins/monitoring/components/table';
import {
EuiLink,
} from '@elastic/eui';
import { I18nProvider } from '@kbn/i18n/react';

const filterFields = [ 'name', 'type', 'version', 'output' ];
const columns = [
Expand Down Expand Up @@ -108,24 +109,26 @@ uiModule.directive('monitoringBeatsListing', (kbnUrl) => {

scope.$watch('data', (data = {}) => {
render((
<div>
<Stats stats={data.stats} />
<div className="page-row">
<MonitoringTable
className="beatsTable"
rows={data.listing}
pageIndex={scope.pageIndex}
filterText={scope.filterText}
sortKey={scope.sortKey}
sortOrder={scope.sortOrder}
onNewState={scope.onNewState}
placeholder="Filter Beats..."
filterFields={filterFields}
columns={columns}
rowComponent={beatRowFactory(scope, kbnUrl)}
/>
<I18nProvider>
<div>
<Stats stats={data.stats} />
<div className="page-row">
<MonitoringTable
className="beatsTable"
rows={data.listing}
pageIndex={scope.pageIndex}
filterText={scope.filterText}
sortKey={scope.sortKey}
sortOrder={scope.sortOrder}
onNewState={scope.onNewState}
placeholder="Filter Beats..."
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be translated?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

filterFields={filterFields}
columns={columns}
rowComponent={beatRowFactory(scope, kbnUrl)}
/>
</div>
</div>
</div>
</I18nProvider>
), $el[0]);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import { MonitoringTable } from 'plugins/monitoring/components/table';
import { Tooltip } from 'plugins/monitoring/components/tooltip';
import { AlertsIndicator } from 'plugins/monitoring/components/cluster/listing/alerts_indicator';
import { SORT_ASCENDING } from '../../../../common/constants';
import { I18nProvider } from '@kbn/i18n/react';

const filterFields = [ 'cluster_name', 'status', 'license.type' ];
const columns = [
Expand Down Expand Up @@ -285,19 +286,21 @@ uiModule.directive('monitoringClusterListing', ($injector) => {

scope.$watch('clusters', (clusters = []) => {
const clusterTable = (
<MonitoringTable
className="clusterTable"
rows={clusters}
pageIndex={scope.pageIndex}
filterText={scope.filterText}
sortKey={scope.sortKey}
sortOrder={scope.sortOrder}
onNewState={scope.onNewState}
placeholder="Filter Clusters..."
filterFields={filterFields}
columns={columns}
rowComponent={clusterRowFactory(scope, globalState, kbnUrl, showLicenseExpiration)}
/>
<I18nProvider>
<MonitoringTable
className="clusterTable"
rows={clusters}
pageIndex={scope.pageIndex}
filterText={scope.filterText}
sortKey={scope.sortKey}
sortOrder={scope.sortOrder}
onNewState={scope.onNewState}
placeholder="Filter Clusters..."
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be translated?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

filterFields={filterFields}
columns={columns}
rowComponent={clusterRowFactory(scope, globalState, kbnUrl, showLicenseExpiration)}
/>
</I18nProvider>
);
render(clusterTable, $el[0]);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { LARGE_ABBREVIATED, LARGE_BYTES } from '../../../../common/formatting';
import {
EuiLink,
} from '@elastic/eui';
import { I18nProvider } from '@kbn/i18n/react';

const filterFields = [ 'job_id', 'state', 'node.name' ];
const columns = [
Expand Down Expand Up @@ -92,20 +93,22 @@ Try changing the filter or time range.`

scope.$watch('jobs', (jobs = []) => {
const mlTable = (
<MonitoringTable
className="mlJobsTable"
rows={jobs}
pageIndex={scope.pageIndex}
filterText={scope.filterText}
sortKey={scope.sortKey}
sortOrder={scope.sortOrder}
onNewState={scope.onNewState}
placeholder="Filter Jobs..."
filterFields={filterFields}
columns={columns}
rowComponent={jobRowFactory(scope, kbnUrl)}
getNoDataMessage={getNoDataMessage}
/>
<I18nProvider>
<MonitoringTable
className="mlJobsTable"
rows={jobs}
pageIndex={scope.pageIndex}
filterText={scope.filterText}
sortKey={scope.sortKey}
sortOrder={scope.sortOrder}
onNewState={scope.onNewState}
placeholder="Filter Jobs..."
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be translated?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

filterFields={filterFields}
columns={columns}
rowComponent={jobRowFactory(scope, kbnUrl)}
getNoDataMessage={getNoDataMessage}
/>
</I18nProvider>
);
render(mlTable, $el[0]);
});
Expand Down
Loading