From 2b8e98157e1b66b1a2cf799bcdebd4b632e439cc Mon Sep 17 00:00:00 2001 From: Sonia Sanz Vivas Date: Fri, 8 Nov 2024 11:53:53 +0100 Subject: [PATCH] Show status in snapshot list --- .../__jest__/client_integration/home.test.ts | 11 ++--- .../public/application/constants/index.ts | 1 - .../components/snapshot_table.tsx | 13 ++++++ .../snapshot_details/tabs/snapshot_state.tsx | 42 +++++++++---------- .../snapshot_details/tabs/tab_summary.tsx | 2 +- 5 files changed, 41 insertions(+), 28 deletions(-) diff --git a/x-pack/plugins/snapshot_restore/__jest__/client_integration/home.test.ts b/x-pack/plugins/snapshot_restore/__jest__/client_integration/home.test.ts index 222cc4e89c26e..4a9c93b548ca5 100644 --- a/x-pack/plugins/snapshot_restore/__jest__/client_integration/home.test.ts +++ b/x-pack/plugins/snapshot_restore/__jest__/client_integration/home.test.ts @@ -512,6 +512,7 @@ describe('', () => { expect(row).toEqual([ '', // Checkbox snapshot.snapshot, // Snapshot + 'Complete', // The displayed message when stats is success REPOSITORY_NAME, // Repository snapshot.indices.length.toString(), // Indices snapshot.shards.total.toString(), // Shards @@ -738,7 +739,7 @@ describe('', () => { expect(find('snapshotDetail.version.value').text()).toBe(version); expect(find('snapshotDetail.uuid.value').text()).toBe(uuid); - expect(find('snapshotDetail.state.value').text()).toBe('Snapshot complete'); + expect(find('snapshotDetail.state.value').text()).toBe('Complete'); expect(find('snapshotDetail.includeGlobalState.value').text()).toEqual('Yes'); expect( find('snapshotDetail.snapshotFeatureStatesSummary.featureStatesList').text() @@ -788,10 +789,10 @@ describe('', () => { }; const mapStateToMessage = { - [SNAPSHOT_STATE.IN_PROGRESS]: 'Taking snapshot…', - [SNAPSHOT_STATE.FAILED]: 'Snapshot failed', - [SNAPSHOT_STATE.PARTIAL]: 'Partial failure ', - [SNAPSHOT_STATE.INCOMPATIBLE]: 'Incompatible version ', + [SNAPSHOT_STATE.IN_PROGRESS]: 'In Progress', + [SNAPSHOT_STATE.FAILED]: 'Failed', + [SNAPSHOT_STATE.PARTIAL]: 'Partial', + [SNAPSHOT_STATE.SUCCESS]: 'Complete', }; // Call sequentially each state and verify that the message is ok diff --git a/x-pack/plugins/snapshot_restore/public/application/constants/index.ts b/x-pack/plugins/snapshot_restore/public/application/constants/index.ts index f319f1c995d0d..830af3c77f769 100644 --- a/x-pack/plugins/snapshot_restore/public/application/constants/index.ts +++ b/x-pack/plugins/snapshot_restore/public/application/constants/index.ts @@ -17,7 +17,6 @@ export enum SNAPSHOT_STATE { SUCCESS = 'SUCCESS', FAILED = 'FAILED', PARTIAL = 'PARTIAL', - INCOMPATIBLE = 'INCOMPATIBLE', } const INDEX_SETTING_SUGGESTIONS: string[] = [ diff --git a/x-pack/plugins/snapshot_restore/public/application/sections/home/snapshot_list/components/snapshot_table.tsx b/x-pack/plugins/snapshot_restore/public/application/sections/home/snapshot_list/components/snapshot_table.tsx index 69f9d1b2f9ffb..2e55ec544b88e 100644 --- a/x-pack/plugins/snapshot_restore/public/application/sections/home/snapshot_list/components/snapshot_table.tsx +++ b/x-pack/plugins/snapshot_restore/public/application/sections/home/snapshot_list/components/snapshot_table.tsx @@ -29,6 +29,7 @@ import { import { SnapshotListParams, SortDirection, SortField } from '../../../../lib'; import { DataPlaceholder, FormattedDateTime, SnapshotDeleteProvider } from '../../../../components'; import { SnapshotSearchBar } from './snapshot_search_bar'; +import { SnapshotState } from '../snapshot_details/tabs/snapshot_state'; const getLastSuccessfulManagedSnapshot = ( snapshots: SnapshotDetails[] @@ -93,6 +94,18 @@ export const SnapshotTable: React.FunctionComponent = (props: Props) => { ), }, + { + field: 'state', + name: i18n.translate('xpack.snapshotRestore.snapshotList.table.stateColumnTitle', { + defaultMessage: 'State', + }), + truncateText: false, + sortable: false, + description: i18n.translate('xpack.snapshotRestore.snapshotList.table.statePartialTooltip', { + defaultMessage: 'This is partial.', + }), + render: (state: string) => , + }, { field: 'repository', name: i18n.translate('xpack.snapshotRestore.snapshotList.table.repositoryColumnTitle', { diff --git a/x-pack/plugins/snapshot_restore/public/application/sections/home/snapshot_list/snapshot_details/tabs/snapshot_state.tsx b/x-pack/plugins/snapshot_restore/public/application/sections/home/snapshot_list/snapshot_details/tabs/snapshot_state.tsx index e4629f1160f38..c5eec5818e380 100644 --- a/x-pack/plugins/snapshot_restore/public/application/sections/home/snapshot_list/snapshot_details/tabs/snapshot_state.tsx +++ b/x-pack/plugins/snapshot_restore/public/application/sections/home/snapshot_list/snapshot_details/tabs/snapshot_state.tsx @@ -7,55 +7,47 @@ import React, { Fragment } from 'react'; -import { EuiFlexGroup, EuiFlexItem, EuiIcon, EuiIconTip, EuiLoadingSpinner } from '@elastic/eui'; +import { EuiFlexGroup, EuiFlexItem, EuiIcon, EuiIconTip, EuiToolTip } from '@elastic/eui'; import { SNAPSHOT_STATE } from '../../../../../constants'; import { useServices } from '../../../../../app_context'; interface Props { state: any; + tooltipIcon: boolean; } -export const SnapshotState: React.FC = ({ state }) => { +export const SnapshotState: React.FC = ({ state, tooltipIcon }) => { const { i18n } = useServices(); const stateMap: any = { [SNAPSHOT_STATE.IN_PROGRESS]: { - icon: , + icon: , label: i18n.translate('xpack.snapshotRestore.snapshotState.inProgressLabel', { - defaultMessage: 'Taking snapshot…', + defaultMessage: 'In Progress', }), }, [SNAPSHOT_STATE.SUCCESS]: { - icon: , + icon: , label: i18n.translate('xpack.snapshotRestore.snapshotState.completeLabel', { - defaultMessage: 'Snapshot complete', + defaultMessage: 'Complete', }), }, [SNAPSHOT_STATE.FAILED]: { - icon: , + icon: , label: i18n.translate('xpack.snapshotRestore.snapshotState.failedLabel', { - defaultMessage: 'Snapshot failed', + defaultMessage: 'Failed', }), }, [SNAPSHOT_STATE.PARTIAL]: { - icon: , + icon: , label: i18n.translate('xpack.snapshotRestore.snapshotState.partialLabel', { - defaultMessage: 'Partial failure', + defaultMessage: 'Partial', }), tip: i18n.translate('xpack.snapshotRestore.snapshotState.partialTipDescription', { defaultMessage: `Global cluster state was stored, but at least one shard wasn't stored successfully. See the 'Failed indices' tab.`, }), }, - [SNAPSHOT_STATE.INCOMPATIBLE]: { - icon: , - label: i18n.translate('xpack.snapshotRestore.snapshotState.incompatibleLabel', { - defaultMessage: 'Incompatible version', - }), - tip: i18n.translate('xpack.snapshotRestore.snapshotState.incompatibleTipDescription', { - defaultMessage: `Snapshot was created with a version of Elasticsearch incompatible with the cluster's version.`, - }), - }, }; if (!stateMap[state]) { @@ -65,14 +57,14 @@ export const SnapshotState: React.FC = ({ state }) => { const { icon, label, tip } = stateMap[state]; - const iconTip = tip && ( + const iconTip = tip && tooltipIcon && ( {' '} ); - return ( + const snapshotInfo = ( {icon} @@ -85,4 +77,12 @@ export const SnapshotState: React.FC = ({ state }) => { ); + + return tip && tooltipIcon ? ( + snapshotInfo + ) : ( + + {snapshotInfo} + + ); }; diff --git a/x-pack/plugins/snapshot_restore/public/application/sections/home/snapshot_list/snapshot_details/tabs/tab_summary.tsx b/x-pack/plugins/snapshot_restore/public/application/sections/home/snapshot_list/snapshot_details/tabs/tab_summary.tsx index 00ea3fa27109b..fb17120a2ed15 100644 --- a/x-pack/plugins/snapshot_restore/public/application/sections/home/snapshot_list/snapshot_details/tabs/tab_summary.tsx +++ b/x-pack/plugins/snapshot_restore/public/application/sections/home/snapshot_list/snapshot_details/tabs/tab_summary.tsx @@ -94,7 +94,7 @@ export const TabSummary: React.FC = ({ snapshotDetails }) => { - +