diff --git a/x-pack/plugins/watcher/public/application/sections/watch_list_page/watch_list_page.tsx b/x-pack/plugins/watcher/public/application/sections/watch_list_page/watch_list_page.tsx index 76a8328fb532a..37d73d0c8a25a 100644 --- a/x-pack/plugins/watcher/public/application/sections/watch_list_page/watch_list_page.tsx +++ b/x-pack/plugins/watcher/public/application/sections/watch_list_page/watch_list_page.tsx @@ -47,6 +47,80 @@ import { goToCreateThresholdAlert, goToCreateAdvancedWatch } from '../../lib/nav import { useAppContext } from '../../app_context'; import { PageError as GenericPageError } from '../../shared_imports'; +/* + * EuiMemoryTable relies on referential equality of a column's name field when sorting by that column. + * Therefore, we want the JSX elements preserved through renders. + */ +const stateColumnHeader = ( + + + {i18n.translate('xpack.watcher.sections.watchList.watchTable.stateHeader', { + defaultMessage: 'State', + })}{' '} + + + +); + +const conditionLastMetHeader = ( + + + {i18n.translate('xpack.watcher.sections.watchList.watchTable.lastFiredHeader', { + defaultMessage: 'Condition last met', + })}{' '} + + + +); + +const lastCheckedHeader = ( + + + {i18n.translate('xpack.watcher.sections.watchList.watchTable.lastTriggeredHeader', { + defaultMessage: 'Last checked', + })}{' '} + + + +); + +const commentHeader = ( + + + {i18n.translate('xpack.watcher.sections.watchList.watchTable.commentHeader', { + defaultMessage: 'Comment', + })}{' '} + + + +); + export const WatchListPage = () => { // hooks const { @@ -273,46 +347,14 @@ export const WatchListPage = () => { }, { field: 'watchStatus.state', - name: ( - - - {i18n.translate('xpack.watcher.sections.watchList.watchTable.stateHeader', { - defaultMessage: 'State', - })}{' '} - - - - ), + name: stateColumnHeader, sortable: true, width: '130px', render: (state: string) => , }, { field: 'watchStatus.lastMetCondition', - name: ( - - - {i18n.translate('xpack.watcher.sections.watchList.watchTable.lastFiredHeader', { - defaultMessage: 'Condition last met', - })}{' '} - - - - ), + name: conditionLastMetHeader, sortable: true, truncateText: true, width: '160px', @@ -322,23 +364,7 @@ export const WatchListPage = () => { }, { field: 'watchStatus.lastChecked', - name: ( - - - {i18n.translate('xpack.watcher.sections.watchList.watchTable.lastTriggeredHeader', { - defaultMessage: 'Last checked', - })}{' '} - - - - ), + name: lastCheckedHeader, sortable: true, truncateText: true, width: '160px', @@ -348,24 +374,7 @@ export const WatchListPage = () => { }, { field: 'watchStatus.comment', - name: ( - - - {i18n.translate('xpack.watcher.sections.watchList.watchTable.commentHeader', { - defaultMessage: 'Comment', - })}{' '} - - - - ), + name: commentHeader, sortable: true, truncateText: true, },