{
+ private pagination = {};
+ private _isMounted = false;
- constructor(props) {
+ constructor(props: TableListViewProps) {
super(props);
- const initialPageSize = npStart.core.uiSettings.get('savedObjects:perPage');
+ const initialPageSize = props.uiSettings.get('savedObjects:perPage');
this.pagination = {
initialPageIndex: 0,
initialPageSize,
- pageSizeOptions: _.uniq([10, 20, 50, initialPageSize]).sort(),
+ pageSizeOptions: uniq([10, 20, 50, initialPageSize]).sort(),
};
this.state = {
items: [],
@@ -67,10 +106,9 @@ class TableListViewUi extends React.Component {
isDeletingItems: false,
showDeleteModal: false,
showLimitError: false,
- filter: this.props.initialFilter,
+ filter: props.initialFilter,
selectedIds: [],
};
-
}
componentWillMount() {
@@ -86,7 +124,7 @@ class TableListViewUi extends React.Component {
this.fetchItems();
}
- debouncedFetch = _.debounce(async (filter) => {
+ debouncedFetch = debounce(async (filter: string) => {
const response = await this.props.findItems(filter);
if (!this._isMounted) {
@@ -100,7 +138,7 @@ class TableListViewUi extends React.Component {
this.setState({
hasInitialFetchReturned: true,
isFetchingItems: false,
- items: (!filter ? _.sortBy(response.hits, 'title') : response.hits),
+ items: !filter ? sortBy(response.hits, 'title') : response.hits,
totalItems: response.total,
showLimitError: response.total > this.props.listingLimit,
});
@@ -108,26 +146,29 @@ class TableListViewUi extends React.Component {
}, 300);
fetchItems = () => {
- this.setState({
- isFetchingItems: true,
- }, this.debouncedFetch.bind(null, this.state.filter));
- }
+ this.setState(
+ {
+ isFetchingItems: true,
+ },
+ this.debouncedFetch.bind(null, this.state.filter)
+ );
+ };
deleteSelectedItems = async () => {
- if (this.state.isDeletingItems) {
+ if (this.state.isDeletingItems || !this.props.deleteItems) {
return;
}
this.setState({
- isDeletingItems: true
+ isDeletingItems: true,
});
try {
- const itemsById = _.indexBy(this.state.items, 'id');
+ const itemsById = indexBy(this.state.items, 'id');
await this.props.deleteItems(this.state.selectedIds.map(id => itemsById[id]));
} catch (error) {
- toastNotifications.addDanger({
+ this.props.toastNotifications.addDanger({
title: (
@@ -138,25 +179,28 @@ class TableListViewUi extends React.Component {
this.fetchItems();
this.setState({
isDeletingItems: false,
- selectedIds: []
+ selectedIds: [],
});
this.closeDeleteModal();
- }
+ };
closeDeleteModal = () => {
this.setState({ showDeleteModal: false });
- }
+ };
openDeleteModal = () => {
this.setState({ showDeleteModal: true });
- }
+ };
- setFilter(filter) {
+ setFilter({ queryText }: { queryText: string }) {
// If the user is searching, we want to clear the sort order so that
// results are ordered by Elasticsearch's relevance.
- this.setState({
- filter: filter.queryText,
- }, this.fetchItems);
+ this.setState(
+ {
+ filter: queryText,
+ },
+ this.fetchItems
+ );
}
hasNoItems() {
@@ -170,14 +214,14 @@ class TableListViewUi extends React.Component {
renderConfirmDeleteModal() {
let deleteButton = (
);
if (this.state.isDeletingItems) {
deleteButton = (
);
@@ -188,11 +232,14 @@ class TableListViewUi extends React.Component {
}
@@ -201,7 +248,7 @@ class TableListViewUi extends React.Component {
onConfirm={this.deleteSelectedItems}
cancelButtonText={
}
@@ -210,7 +257,7 @@ class TableListViewUi extends React.Component {
>
@@ -227,7 +274,7 @@ class TableListViewUi extends React.Component {
}
@@ -236,26 +283,22 @@ class TableListViewUi extends React.Component {
>
- listingLimit
-
- ),
+ listingLimitText: listingLimit,
advancedSettingsLink: (
- )
+ ),
}}
/>
@@ -268,18 +311,15 @@ class TableListViewUi extends React.Component {
renderNoItemsMessage() {
if (this.props.noItemsFragment) {
- return (
- this.props.noItemsFragment
- );
+ return this.props.noItemsFragment;
} else {
return (
);
-
}
}
@@ -302,11 +342,12 @@ class TableListViewUi extends React.Component {
data-test-subj="deleteSelectedItems"
>
@@ -314,25 +355,34 @@ class TableListViewUi extends React.Component {
}
renderTable() {
- const selection = this.props.deleteItems ? {
- onSelectionChange: (selection) => {
- this.setState({
- selectedIds: selection.map(item => { return item.id; })
- });
- }
- } : null;
-
- const actions = [{
- name: i18n.translate('kbn.table_list_view.listing.table.editActionName', {
- defaultMessage: 'Edit'
- }),
- description: i18n.translate('kbn.table_list_view.listing.table.editActionDescription', {
- defaultMessage: 'Edit'
- }),
- icon: 'pencil',
- type: 'icon',
- onClick: this.props.editItem
- }];
+ const selection = this.props.deleteItems
+ ? {
+ onSelectionChange: (obj: Item[]) => {
+ this.setState({
+ selectedIds: obj
+ .map(item => item.id)
+ .filter((id: undefined | string): id is string => Boolean(id)),
+ });
+ },
+ }
+ : null;
+
+ const actions = [
+ {
+ name: i18n.translate('kibana-react.tableListView.listing.table.editActionName', {
+ defaultMessage: 'Edit',
+ }),
+ description: i18n.translate(
+ 'kibana-react.tableListView.listing.table.editActionDescription',
+ {
+ defaultMessage: 'Edit',
+ }
+ ),
+ icon: 'pencil',
+ type: 'icon',
+ onClick: this.props.editItem,
+ },
+ ];
const search = {
onChange: this.setFilter.bind(this),
@@ -346,17 +396,17 @@ class TableListViewUi extends React.Component {
const columns = this.props.tableColumns.slice();
if (this.props.editItem) {
columns.push({
- name: i18n.translate('kbn.table_list_view.listing.table.actionTitle', {
- defaultMessage: 'Actions'
+ name: i18n.translate('kibana-react.tableListView.listing.table.actionTitle', {
+ defaultMessage: 'Actions',
}),
width: '100px',
- actions
+ actions,
});
}
const noItemsMessage = (
@@ -397,7 +447,7 @@ class TableListViewUi extends React.Component {
fill
>
@@ -412,14 +462,11 @@ class TableListViewUi extends React.Component {
-
- {this.props.tableListTitle}
-
+ {this.props.tableListTitle}
{createButton}
-
@@ -450,34 +497,10 @@ class TableListViewUi extends React.Component {
className="itemListing__page"
restrictWidth
>
-
- {this.renderPageContent()}
-
+ {this.renderPageContent()}
);
}
}
-TableListViewUi.propTypes = {
- tableColumns: PropTypes.array.isRequired,
-
- noItemsFragment: PropTypes.object,
-
- findItems: PropTypes.func.isRequired,
- deleteItems: PropTypes.func,
- createItem: PropTypes.func,
- editItem: PropTypes.func,
-
- listingLimit: PropTypes.number,
- initialFilter: PropTypes.string,
-
- entityName: PropTypes.string.isRequired,
- entityNamePlural: PropTypes.string.isRequired,
- tableListTitle: PropTypes.string.isRequired,
-};
-
-TableListViewUi.defaultProps = {
- initialFilter: EMPTY_FILTER,
-};
-
-export const TableListView = injectI18n(TableListViewUi);
+export { TableListView };
diff --git a/x-pack/legacy/plugins/graph/public/components/listing.tsx b/x-pack/legacy/plugins/graph/public/components/listing.tsx
index 99df013548840..047590d8d562d 100644
--- a/x-pack/legacy/plugins/graph/public/components/listing.tsx
+++ b/x-pack/legacy/plugins/graph/public/components/listing.tsx
@@ -10,15 +10,14 @@ import React, { Fragment } from 'react';
import { EuiEmptyPrompt, EuiLink, EuiButton } from '@elastic/eui';
import { CoreStart, ApplicationStart } from 'kibana/public';
-// @ts-ignore
-import { TableListView } from '../../../../../../src/legacy/core_plugins/kibana/public/table_list_view/table_list_view';
+import { TableListView } from '../../../../../../src/plugins/kibana_react/public';
import { GraphWorkspaceSavedObject } from '../types';
export interface ListingProps {
coreStart: CoreStart;
createItem: () => void;
- findItems: (query: string, limit: number) => Promise;
- deleteItems: (ids: string[]) => Promise;
+ findItems: (query: string) => Promise<{ total: number; hits: GraphWorkspaceSavedObject[] }>;
+ deleteItems: (records: GraphWorkspaceSavedObject[]) => Promise;
editItem: (record: GraphWorkspaceSavedObject) => void;
getViewUrl: (record: GraphWorkspaceSavedObject) => string;
listingLimit: number;
@@ -31,10 +30,10 @@ export function Listing(props: ListingProps) {
return (
);
diff --git a/x-pack/plugins/translations/translations/ja-JP.json b/x-pack/plugins/translations/translations/ja-JP.json
index 28db2197638ff..6e92f8068bc9e 100644
--- a/x-pack/plugins/translations/translations/ja-JP.json
+++ b/x-pack/plugins/translations/translations/ja-JP.json
@@ -656,6 +656,20 @@
"core.euiSuperUpdateButton.refreshButtonLabel": "更新",
"core.euiSuperUpdateButton.updateButtonLabel": "更新",
"core.euiSuperUpdateButton.updatingButtonLabel": "更新中",
+ "kibana-react.tableListView.listing.deleteButtonMessage": "{itemCount} 件の {entityName} を削除",
+ "kibana-react.tableListView.listing.deleteConfirmModalDescription": "削除された {entityNamePlural} は復元できません。",
+ "kibana-react.tableListView.listing.deleteSelectedItemsConfirmModal.cancelButtonLabel": "キャンセル",
+ "kibana-react.tableListView.listing.deleteSelectedItemsConfirmModal.confirmButtonLabel": "削除",
+ "kibana-react.tableListView.listing.deleteSelectedItemsConfirmModal.confirmButtonLabelDeleting": "削除中",
+ "kibana-react.tableListView.listing.listingLimitExceeded.advancedSettingsLinkText": "高度な設定",
+ "kibana-react.tableListView.listing.listingLimitExceededDescription": "{totalItems} 件の {entityNamePlural} がありますが、{listingLimitText} の設定により {listingLimitValue} 件までしか下の表に表示できません。この設定は {advancedSettingsLink} で変更できます。",
+ "kibana-react.tableListView.listing.listingLimitExceededTitle": "リスティング制限超過",
+ "kibana-react.tableListView.listing.noAvailableItemsMessage": "利用可能な {entityNamePlural} がありません。",
+ "kibana-react.tableListView.listing.noMatchedItemsMessage": "検索条件に一致する {entityNamePlural} がありません。",
+ "kibana-react.tableListView.listing.table.actionTitle": "アクション",
+ "kibana-react.tableListView.listing.table.editActionDescription": "編集",
+ "kibana-react.tableListView.listing.table.editActionName": "編集",
+ "kibana-react.tableListView.listing.unableToDeleteDangerMessage": "{entityName} を削除できません",
"kibana-react.exitFullScreenButton.exitFullScreenModeButtonAreaLabel": "全画面モードを終了",
"kibana-react.exitFullScreenButton.exitFullScreenModeButtonLabel": "全画面を終了",
"kibana-react.exitFullScreenButton.fullScreenModeDescription": "ESC キーで全画面モードを終了します。",
@@ -2371,20 +2385,6 @@
"kbn.server.tutorials.zookeeperMetrics.nameTitle": "Zookeeper メトリック",
"kbn.server.tutorials.zookeeperMetrics.shortDescription": "Zookeeper サーバーから内部メトリックを取得します。",
"kbn.settings.advancedSettings.voiceAnnouncement.searchResultScreenReaderMessage": "{query} を検索しました。{sectionLenght, plural, one {# セクション} other {# セクション}}に{optionLenght, plural, one {# オプション} other { # オプション}}があります。",
- "kbn.table_list_view.listing.deleteButtonMessage": "{itemCount} 件の {entityName} を削除",
- "kbn.table_list_view.listing.deleteConfirmModalDescription": "削除された {entityNamePlural} は復元できません。",
- "kbn.table_list_view.listing.deleteSelectedItemsConfirmModal.cancelButtonLabel": "キャンセル",
- "kbn.table_list_view.listing.deleteSelectedItemsConfirmModal.confirmButtonLabel": "削除",
- "kbn.table_list_view.listing.deleteSelectedItemsConfirmModal.confirmButtonLabelDeleting": "削除中",
- "kbn.table_list_view.listing.listingLimitExceeded.advancedSettingsLinkText": "高度な設定",
- "kbn.table_list_view.listing.listingLimitExceededDescription": "{totalItems} 件の {entityNamePlural} がありますが、{listingLimitText} の設定により {listingLimitValue} 件までしか下の表に表示できません。この設定は {advancedSettingsLink} で変更できます。",
- "kbn.table_list_view.listing.listingLimitExceededTitle": "リスティング制限超過",
- "kbn.table_list_view.listing.noAvailableItemsMessage": "利用可能な {entityNamePlural} がありません。",
- "kbn.table_list_view.listing.noMatchedItemsMessage": "検索条件に一致する {entityNamePlural} がありません。",
- "kbn.table_list_view.listing.table.actionTitle": "アクション",
- "kbn.table_list_view.listing.table.editActionDescription": "編集",
- "kbn.table_list_view.listing.table.editActionName": "編集",
- "kbn.table_list_view.listing.unableToDeleteDangerMessage": "{entityName} を削除できません",
"kbn.topNavMenu.openInspectorButtonLabel": "検査",
"kbn.topNavMenu.refreshButtonLabel": "更新",
"kbn.topNavMenu.saveVisualizationButtonLabel": "保存",
diff --git a/x-pack/plugins/translations/translations/zh-CN.json b/x-pack/plugins/translations/translations/zh-CN.json
index 6cf125aee8f96..582770dba940f 100644
--- a/x-pack/plugins/translations/translations/zh-CN.json
+++ b/x-pack/plugins/translations/translations/zh-CN.json
@@ -660,6 +660,20 @@
"kibana-react.exitFullScreenButton.exitFullScreenModeButtonAreaLabel": "退出全屏模式",
"kibana-react.exitFullScreenButton.exitFullScreenModeButtonLabel": "退出全屏",
"kibana-react.exitFullScreenButton.fullScreenModeDescription": "在全屏模式下,按 ESC 键可退出。",
+ "kibana-react.tableListView.listing.deleteButtonMessage": "删除 {itemCount} 个{entityName}",
+ "kibana-react.tableListView.listing.deleteConfirmModalDescription": "您无法恢复删除的{entityNamePlural}。",
+ "kibana-react.tableListView.listing.deleteSelectedItemsConfirmModal.cancelButtonLabel": "取消",
+ "kibana-react.tableListView.listing.deleteSelectedItemsConfirmModal.confirmButtonLabel": "删除",
+ "kibana-react.tableListView.listing.deleteSelectedItemsConfirmModal.confirmButtonLabelDeleting": "正在删除",
+ "kibana-react.tableListView.listing.listingLimitExceeded.advancedSettingsLinkText": "高级设置",
+ "kibana-react.tableListView.listing.listingLimitExceededDescription": "您有 {totalItems} 个{entityNamePlural},但您的“{listingLimitText}”设置阻止下表显示 {listingLimitValue} 个以上。您可以在“{advancedSettingsLink}”下更改此设置。",
+ "kibana-react.tableListView.listing.listingLimitExceededTitle": "已超过列表限制",
+ "kibana-react.tableListView.listing.noAvailableItemsMessage": "没有可用的{entityNamePlural}",
+ "kibana-react.tableListView.listing.noMatchedItemsMessage": "没有任何{entityNamePlural}匹配您的搜索。",
+ "kibana-react.tableListView.listing.table.actionTitle": "操作",
+ "kibana-react.tableListView.listing.table.editActionDescription": "编辑",
+ "kibana-react.tableListView.listing.table.editActionName": "编辑",
+ "kibana-react.tableListView.listing.unableToDeleteDangerMessage": "无法删除{entityName}",
"inspector.closeButton": "关闭检查器",
"inspector.reqTimestampDescription": "记录请求启动的时间",
"inspector.reqTimestampKey": "请求时间戳",
@@ -2372,20 +2386,6 @@
"kbn.server.tutorials.zookeeperMetrics.nameTitle": "Zookeeper 指标",
"kbn.server.tutorials.zookeeperMetrics.shortDescription": "从 Zookeeper 服务器提取内部指标。",
"kbn.settings.advancedSettings.voiceAnnouncement.searchResultScreenReaderMessage": "您已搜索 {query}。{sectionLenght, plural, one {# 个部分} other {# 个部分}}中有 {optionLenght, plural, one {# 个选项} other {# 个选项}}",
- "kbn.table_list_view.listing.deleteButtonMessage": "删除 {itemCount} 个{entityName}",
- "kbn.table_list_view.listing.deleteConfirmModalDescription": "您无法恢复删除的{entityNamePlural}。",
- "kbn.table_list_view.listing.deleteSelectedItemsConfirmModal.cancelButtonLabel": "取消",
- "kbn.table_list_view.listing.deleteSelectedItemsConfirmModal.confirmButtonLabel": "删除",
- "kbn.table_list_view.listing.deleteSelectedItemsConfirmModal.confirmButtonLabelDeleting": "正在删除",
- "kbn.table_list_view.listing.listingLimitExceeded.advancedSettingsLinkText": "高级设置",
- "kbn.table_list_view.listing.listingLimitExceededDescription": "您有 {totalItems} 个{entityNamePlural},但您的“{listingLimitText}”设置阻止下表显示 {listingLimitValue} 个以上。您可以在“{advancedSettingsLink}”下更改此设置。",
- "kbn.table_list_view.listing.listingLimitExceededTitle": "已超过列表限制",
- "kbn.table_list_view.listing.noAvailableItemsMessage": "没有可用的{entityNamePlural}",
- "kbn.table_list_view.listing.noMatchedItemsMessage": "没有任何{entityNamePlural}匹配您的搜索。",
- "kbn.table_list_view.listing.table.actionTitle": "操作",
- "kbn.table_list_view.listing.table.editActionDescription": "编辑",
- "kbn.table_list_view.listing.table.editActionName": "编辑",
- "kbn.table_list_view.listing.unableToDeleteDangerMessage": "无法删除{entityName}",
"kbn.topNavMenu.openInspectorButtonLabel": "检查",
"kbn.topNavMenu.refreshButtonLabel": "刷新",
"kbn.topNavMenu.saveVisualizationButtonLabel": "保存",