Skip to content

Commit

Permalink
Show status in snapshot list
Browse files Browse the repository at this point in the history
  • Loading branch information
SoniaSanzV committed Dec 4, 2024
1 parent 0de9743 commit 2b8e981
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,7 @@ describe('<SnapshotRestoreHome />', () => {
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
Expand Down Expand Up @@ -738,7 +739,7 @@ describe('<SnapshotRestoreHome />', () => {

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()
Expand Down Expand Up @@ -788,10 +789,10 @@ describe('<SnapshotRestoreHome />', () => {
};

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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ export enum SNAPSHOT_STATE {
SUCCESS = 'SUCCESS',
FAILED = 'FAILED',
PARTIAL = 'PARTIAL',
INCOMPATIBLE = 'INCOMPATIBLE',
}

const INDEX_SETTING_SUGGESTIONS: string[] = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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[]
Expand Down Expand Up @@ -93,6 +94,18 @@ export const SnapshotTable: React.FunctionComponent<Props> = (props: Props) => {
</EuiLink>
),
},
{
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) => <SnapshotState state={state} tooltipIcon={false} />,
},
{
field: 'repository',
name: i18n.translate('xpack.snapshotRestore.snapshotList.table.repositoryColumnTitle', {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Props> = ({ state }) => {
export const SnapshotState: React.FC<Props> = ({ state, tooltipIcon }) => {
const { i18n } = useServices();

const stateMap: any = {
[SNAPSHOT_STATE.IN_PROGRESS]: {
icon: <EuiLoadingSpinner size="m" />,
icon: <EuiIcon color="primary" type="dot" />,
label: i18n.translate('xpack.snapshotRestore.snapshotState.inProgressLabel', {
defaultMessage: 'Taking snapshot…',
defaultMessage: 'In Progress',
}),
},
[SNAPSHOT_STATE.SUCCESS]: {
icon: <EuiIcon color="success" type="check" />,
icon: <EuiIcon color="success" type="dot" />,
label: i18n.translate('xpack.snapshotRestore.snapshotState.completeLabel', {
defaultMessage: 'Snapshot complete',
defaultMessage: 'Complete',
}),
},
[SNAPSHOT_STATE.FAILED]: {
icon: <EuiIcon color="danger" type="cross" />,
icon: <EuiIcon color="danger" type="dot" />,
label: i18n.translate('xpack.snapshotRestore.snapshotState.failedLabel', {
defaultMessage: 'Snapshot failed',
defaultMessage: 'Failed',
}),
},
[SNAPSHOT_STATE.PARTIAL]: {
icon: <EuiIcon color="warning" type="warning" />,
icon: <EuiIcon color="warning" type="dot" />,
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: <EuiIcon color="warning" type="warning" />,
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]) {
Expand All @@ -65,14 +57,14 @@ export const SnapshotState: React.FC<Props> = ({ state }) => {

const { icon, label, tip } = stateMap[state];

const iconTip = tip && (
const iconTip = tip && tooltipIcon && (
<Fragment>
{' '}
<EuiIconTip content={tip} />
</Fragment>
);

return (
const snapshotInfo = (
<EuiFlexGroup gutterSize="xs" alignItems="center" responsive={false}>
<EuiFlexItem grow={false}>{icon}</EuiFlexItem>

Expand All @@ -85,4 +77,12 @@ export const SnapshotState: React.FC<Props> = ({ state }) => {
</EuiFlexItem>
</EuiFlexGroup>
);

return tip && tooltipIcon ? (
snapshotInfo
) : (
<EuiToolTip position="top" content={tip}>
{snapshotInfo}
</EuiToolTip>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export const TabSummary: React.FC<Props> = ({ snapshotDetails }) => {
</EuiDescriptionListTitle>

<EuiDescriptionListDescription className="eui-textBreakWord" data-test-subj="value">
<SnapshotState state={state} />
<SnapshotState state={state} tooltipIcon={true} />
</EuiDescriptionListDescription>
</EuiFlexItem>

Expand Down

0 comments on commit 2b8e981

Please sign in to comment.