Skip to content

Commit

Permalink
[Upgrade Assistant] Removed "closed index" warning that reindexing mi…
Browse files Browse the repository at this point in the history
…ght take longer than usual, which is not the case
  • Loading branch information
yuliacech committed Oct 13, 2021
1 parent e335205 commit 3299d7b
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 70 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,11 @@ const buttonLabel = (status?: ReindexStatus) => {
* Displays a flyout that shows the current reindexing status for a given index.
*/
export const ChecklistFlyoutStep: React.FunctionComponent<{
renderGlobalCallouts: () => React.ReactNode;
closeFlyout: () => void;
reindexState: ReindexState;
startReindex: () => void;
cancelReindex: () => void;
}> = ({ closeFlyout, reindexState, startReindex, cancelReindex, renderGlobalCallouts }) => {
}> = ({ closeFlyout, reindexState, startReindex, cancelReindex }) => {
const { loadingState, status, hasRequiredPrivileges } = reindexState;
const loading = loadingState === LoadingState.Loading || status === ReindexStatus.inProgress;
const isCompleted = status === ReindexStatus.completed;
Expand Down Expand Up @@ -116,7 +115,6 @@ export const ChecklistFlyoutStep: React.FunctionComponent<{
</EuiCallOut>
</>
)}
{renderGlobalCallouts()}
<EuiCallOut
title={
<FormattedMessage
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,10 @@
*/

import React, { useState } from 'react';
import { DocLinksStart } from 'kibana/public';
import { i18n } from '@kbn/i18n';
import { FormattedMessage } from '@kbn/i18n/react';
import { EuiCallOut, EuiFlyoutHeader, EuiLink, EuiSpacer, EuiTitle } from '@elastic/eui';
import { EuiFlyoutHeader, EuiSpacer, EuiTitle } from '@elastic/eui';

import {
EnrichedDeprecationInfo,
ReindexAction,
ReindexStatus,
} from '../../../../../../../common/types';
import { useAppContext } from '../../../../../app_context';
import { EnrichedDeprecationInfo, ReindexStatus } from '../../../../../../../common/types';

import type { ReindexStateContext } from '../context';
import { ChecklistFlyoutStep } from './checklist_step';
Expand All @@ -33,47 +26,6 @@ export interface ReindexFlyoutProps extends ReindexStateContext {
closeFlyout: () => void;
}

const getOpenAndCloseIndexDocLink = (docLinks: DocLinksStart) => (
<EuiLink target="_blank" href={`${docLinks.links.apis.openIndex}`}>
{i18n.translate(
'xpack.upgradeAssistant.checkupTab.reindexing.flyout.openAndCloseDocumentation',
{ defaultMessage: 'documentation' }
)}
</EuiLink>
);

const getIndexClosedCallout = (docLinks: DocLinksStart) => (
<>
<EuiCallOut
title={i18n.translate(
'xpack.upgradeAssistant.checkupTab.reindexing.flyout.indexClosedCallout.calloutTitle',
{ defaultMessage: 'Index closed' }
)}
color="warning"
iconType="alert"
>
<p>
<FormattedMessage
id="xpack.upgradeAssistant.checkupTab.reindexing.flyout.indexClosedCallout.calloutDetails"
defaultMessage="This index is currently closed. The Upgrade Assistant will open, reindex and then close the index. {reindexingMayTakeLongerEmph}. Please see the {docs} for more information."
values={{
docs: getOpenAndCloseIndexDocLink(docLinks),
reindexingMayTakeLongerEmph: (
<b>
{i18n.translate(
'xpack.upgradeAssistant.checkupTab.reindexing.flyout.indexClosedCallout.calloutDetails.reindexingTakesLongerEmphasis',
{ defaultMessage: 'Reindexing may take longer than usual' }
)}
</b>
),
}}
/>
</p>
</EuiCallOut>
<EuiSpacer size="m" />
</>
);

export const ReindexFlyout: React.FunctionComponent<ReindexFlyoutProps> = ({
reindexState,
startReindex,
Expand All @@ -82,12 +34,8 @@ export const ReindexFlyout: React.FunctionComponent<ReindexFlyoutProps> = ({
deprecation,
}) => {
const { status, reindexWarnings } = reindexState;
const { index, correctiveAction } = deprecation;
const {
services: {
core: { docLinks },
},
} = useAppContext();
const { index } = deprecation;

// If there are any warnings and we haven't started reindexing, show the warnings step first.
const [currentFlyoutStep, setCurrentFlyoutStep] = useState<ReindexFlyoutStep>(
reindexWarnings && reindexWarnings.length > 0 && status === undefined
Expand All @@ -97,16 +45,10 @@ export const ReindexFlyout: React.FunctionComponent<ReindexFlyoutProps> = ({

let flyoutContents: React.ReactNode;

const globalCallout =
(correctiveAction as ReindexAction).blockerForReindexing === 'index-closed' &&
reindexState.status !== ReindexStatus.completed
? getIndexClosedCallout(docLinks)
: undefined;
switch (currentFlyoutStep) {
case ReindexFlyoutStep.reindexWarnings:
flyoutContents = (
<WarningsFlyoutStep
renderGlobalCallouts={() => globalCallout}
closeFlyout={closeFlyout}
warnings={reindexState.reindexWarnings!}
advanceNextStep={() => setCurrentFlyoutStep(ReindexFlyoutStep.checklist)}
Expand All @@ -116,7 +58,6 @@ export const ReindexFlyout: React.FunctionComponent<ReindexFlyoutProps> = ({
case ReindexFlyoutStep.checklist:
flyoutContents = (
<ChecklistFlyoutStep
renderGlobalCallouts={() => globalCallout}
closeFlyout={closeFlyout}
reindexState={reindexState}
startReindex={startReindex}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ const warningToComponentMap: {

export const idForWarning = (id: number) => `reindexWarning-${id}`;
interface WarningsConfirmationFlyoutProps {
renderGlobalCallouts: () => React.ReactNode;
closeFlyout: () => void;
warnings: ReindexWarning[];
advanceNextStep: () => void;
Expand All @@ -53,7 +52,6 @@ interface WarningsConfirmationFlyoutProps {
*/
export const WarningsFlyoutStep: React.FunctionComponent<WarningsConfirmationFlyoutProps> = ({
warnings,
renderGlobalCallouts,
closeFlyout,
advanceNextStep,
}) => {
Expand Down Expand Up @@ -88,8 +86,6 @@ export const WarningsFlyoutStep: React.FunctionComponent<WarningsConfirmationFly
return (
<>
<EuiFlyoutBody>
{renderGlobalCallouts()}

<EuiCallOut
title={
<FormattedMessage
Expand Down

0 comments on commit 3299d7b

Please sign in to comment.