Skip to content

Commit

Permalink
finish code
Browse files Browse the repository at this point in the history
  • Loading branch information
stephmilovic committed Oct 16, 2024
1 parent 30ef626 commit 5e294bd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import {
} from '@kbn/elastic-assistant-common';
import { css } from '@emotion/react';
import { DataViewsContract } from '@kbn/data-views-plugin/public';
import { KnowledgeBaseTour } from '../../tour/knowledge_base';
import { AlertsSettingsManagement } from '../../assistant/settings/alerts_settings/alerts_settings_management';
import { useKnowledgeBaseEntries } from '../../assistant/api/knowledge_base/entries/use_knowledge_base_entries';
import { useAssistantContext } from '../../assistant_context';
Expand Down Expand Up @@ -295,7 +296,6 @@ export const KnowledgeBaseSettingsManagement: React.FC<Params> = React.memo(({ d
</>
);
}
// TODO tour step 2 here
return (
<>
<EuiPanel hasShadow={false} hasBorder paddingSize="l">
Expand Down Expand Up @@ -412,6 +412,7 @@ export const KnowledgeBaseSettingsManagement: React.FC<Params> = React.memo(({ d
<p>{i18n.DELETE_ENTRY_CONFIRMATION_CONTENT}</p>
</EuiConfirmModal>
)}
<KnowledgeBaseTour isKbSettingsPage />
</>
);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* */

import React, { useCallback, useEffect, useMemo, useState } from 'react';
import { EuiButton, EuiButtonEmpty, EuiTourStep } from '@elastic/eui';
import { EuiButton, EuiButtonEmpty, EuiTourStep, EuiTourStepProps } from '@elastic/eui';
import useLocalStorage from 'react-use/lib/useLocalStorage';
import { KNOWLEDGE_BASE_TAB } from '../../assistant/settings/const';
import { useAssistantContext } from '../../..';
Expand All @@ -24,7 +24,10 @@ interface TourState {
currentTourStep: number;
isTourActive: boolean;
}
const KnowledgeBaseTourComp: React.FC<{ children?: React.ReactNode }> = ({ children }) => {
const KnowledgeBaseTourComp: React.FC<{
children?: EuiTourStepProps['children'];
isKbSettingsPage: boolean;
}> = ({ children, isKbSettingsPage = false }) => {
const {
navigateToApp,
assistantFeatures: { assistantKnowledgeBaseByDefault: enableKnowledgeBaseByDefault },
Expand All @@ -34,7 +37,6 @@ const KnowledgeBaseTourComp: React.FC<{ children?: React.ReactNode }> = ({ child
NEW_FEATURES_TOUR_STORAGE_KEYS.KNOWLEDGE_BASE,
tourConfig
);
const pageName = 'TODO';

const advanceToVideoStep = useCallback(
() =>
Expand All @@ -46,10 +48,10 @@ const KnowledgeBaseTourComp: React.FC<{ children?: React.ReactNode }> = ({ child
);

useEffect(() => {
if (tourState?.isTourActive && pageName === 'SecurityPageName.knowledgeBase') {
if (tourState?.isTourActive && isKbSettingsPage) {
advanceToVideoStep();
}
}, [advanceToVideoStep, tourState?.isTourActive]);
}, [advanceToVideoStep, isKbSettingsPage, tourState?.isTourActive]);

const finishTour = useCallback(
() =>
Expand Down Expand Up @@ -93,14 +95,6 @@ const KnowledgeBaseTourComp: React.FC<{ children?: React.ReactNode }> = ({ child
// @ts-ignore
window.Cypress != null || // TODO: temporary workaround to disable the tour when running in Cypress, because the tour breaks other projects Cypress tests
navigator.webdriver === true; // TODO: temporary workaround to disable the tour when running in the FTR, because the tour breaks other projects FTR tests
console.log('tour conditions', {
con: !enableKnowledgeBaseByDefault || isTestAutomation || !tourState?.isTourActive,
con1: !enableKnowledgeBaseByDefault,
con2: isTestAutomation,
con3: !tourState?.isTourActive,
tourState,
children,
});

const [isTimerExhausted, setIsTimerExhausted] = useState(false);

Expand All @@ -127,14 +121,13 @@ const KnowledgeBaseTourComp: React.FC<{ children?: React.ReactNode }> = ({ child
panelProps={{
'data-test-subj': `knowledgeBase-tour-step-1`,
}}
// repositionOnScroll
step={1}
stepsTotal={1}
title={knowledgeBaseTourStepOne.title}
>
{children}
</EuiTourStep>
) : pageName === 'SecurityPageName.knowledgeBase' ? (
) : isKbSettingsPage ? (
<VideoToast onClose={finishTour} />
) : (
children ?? null
Expand Down

0 comments on commit 5e294bd

Please sign in to comment.