-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Rules migration] Implement workflow tour - Rule Translation (#11384) #207425
Merged
e40pud
merged 8 commits into
elastic:main
from
e40pud:security/siem-migrations/11384-translated-rules-guide
Jan 27, 2025
+333
−13
Merged
Changes from 6 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
127f580
[Rules migration] Implement workflow tour - Rule Translation (#11384)
e40pud cbb99c0
Update SIEM tour component location
e40pud 2a3c89b
Fix translations validation
e40pud cd17aed
Merge branch 'main' into security/siem-migrations/11384-translated-ru…
e40pud d0af750
Fix translations
e40pud ee5f3fd
Merge branch 'main' into security/siem-migrations/11384-translated-ru…
e40pud 24a4b76
Merge branch 'main' into security/siem-migrations/11384-translated-ru…
e40pud 37d5846
Review feedback
e40pud File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
182 changes: 182 additions & 0 deletions
182
...curity_solution/public/siem_migrations/rules/components/tours/translation_guide/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,182 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import React, { useCallback, useEffect, useMemo, useState } from 'react'; | ||
import type { PopoverAnchorPosition } from '@elastic/eui'; | ||
import { EuiButtonEmpty, EuiTourStep } from '@elastic/eui'; | ||
import { noop } from 'lodash'; | ||
import { FormattedMessage } from '@kbn/i18n-react'; | ||
import { DocLink } from '../../../../../common/components/links_to_docs/doc_link'; | ||
import { useIsElementMounted } from '../../../../../detection_engine/rule_management_ui/components/rules_table/rules_table/guided_onboarding/use_is_element_mounted'; | ||
import { | ||
NEW_FEATURES_TOUR_STORAGE_KEYS, | ||
SecurityPageName, | ||
} from '../../../../../../common/constants'; | ||
import { useKibana } from '../../../../../common/lib/kibana'; | ||
import { SIEM_MIGRATIONS_STATUS_HEADER_ID } from '../../rules_table_columns'; | ||
import { SIEM_MIGRATIONS_SELECT_MIGRATION_BUTTON_ID } from '../../header_buttons'; | ||
import * as i18n from './translations'; | ||
|
||
export const SECURITY_GET_STARTED_BUTTON_ANCHOR = `solutionSideNavCustomIconItem-${SecurityPageName.landing}`; | ||
|
||
const tourConfig = { | ||
currentTourStep: 1, | ||
isTourActive: true, | ||
tourPopoverWidth: 360, | ||
}; | ||
|
||
const tourSteps: Array<{ | ||
step: number; | ||
title: string; | ||
content: React.ReactNode; | ||
anchorPosition: PopoverAnchorPosition; | ||
}> = [ | ||
{ | ||
step: 1, | ||
title: i18n.MIGRATION_RULES_SELECTOR_TOUR_STEP_TITLE, | ||
content: i18n.MIGRATION_RULES_SELECTOR_TOUR_STEP_CONTENT, | ||
anchorPosition: 'downCenter', | ||
}, | ||
{ | ||
step: 2, | ||
title: i18n.TRANSLATION_STATUS_TOUR_STEP_TITLE, | ||
content: ( | ||
<FormattedMessage | ||
id="xpack.securitySolution.siemMigrations.rules.tour.statusStepContent" | ||
defaultMessage="{installed} rules have a check mark. Click {view} to access rule details. {translated} rules are ready to {install}, or for your to {edit}. Rules with errors can be {reprocessed}. Learn more about our AI Translations here. | ||
{lineBreak}{lineBreak} | ||
Learn more about our {link}" | ||
values={{ | ||
lineBreak: <br />, | ||
install: <b>{i18n.INSTALL_LABEL}</b>, | ||
installed: <b>{i18n.INSTALLED_LABEL}</b>, | ||
view: <b>{i18n.VIEW_LABEL}</b>, | ||
edit: <b>{i18n.EDIT_LABEL}</b>, | ||
translated: <b>{i18n.TRANSLATED_LABEL}</b>, | ||
reprocessed: <b>{i18n.REPROCESSED_LABEL}</b>, | ||
// TODO: Update doc path once available | ||
link: <DocLink docPath="index.html" linkText={i18n.SIEM_MIGRATIONS_LINK_LABEL} />, | ||
}} | ||
/> | ||
), | ||
anchorPosition: 'rightCenter', | ||
}, | ||
{ | ||
step: 3, | ||
title: i18n.MIGRATION_GUIDE_TOUR_STEP_TITLE, | ||
content: i18n.MIGRATION_GUIDE_TOUR_STEP_CONTENT, | ||
anchorPosition: 'rightCenter', | ||
}, | ||
]; | ||
|
||
export const SiemTranslatedRulesTour: React.FC = React.memo(() => { | ||
const { siemMigrations, storage } = useKibana().services; | ||
|
||
const isSelectMigrationAnchorMounted = useIsElementMounted( | ||
SIEM_MIGRATIONS_SELECT_MIGRATION_BUTTON_ID | ||
); | ||
const isStatusHeaderAnchorMounted = useIsElementMounted(SIEM_MIGRATIONS_STATUS_HEADER_ID); | ||
const isGetStartedNavigationAnchorMounted = useIsElementMounted( | ||
SECURITY_GET_STARTED_BUTTON_ANCHOR | ||
); | ||
|
||
const [tourState, setTourState] = useState(() => { | ||
const restoredTourState = storage.get( | ||
NEW_FEATURES_TOUR_STORAGE_KEYS.SIEM_RULE_TRANSLATION_PAGE | ||
); | ||
if (restoredTourState != null) { | ||
return restoredTourState; | ||
} | ||
return tourConfig; | ||
}); | ||
|
||
const onTourFinished = useCallback(() => { | ||
setTourState({ | ||
...tourState, | ||
isTourActive: false, | ||
}); | ||
}, [tourState]); | ||
|
||
const onTourNext = useCallback(() => { | ||
setTourState({ | ||
...tourState, | ||
currentTourStep: tourState.currentTourStep + 1, | ||
}); | ||
}, [tourState]); | ||
|
||
useEffect(() => { | ||
storage.set(NEW_FEATURES_TOUR_STORAGE_KEYS.SIEM_RULE_TRANSLATION_PAGE, tourState); | ||
}, [tourState, storage]); | ||
|
||
const isTourActive = useMemo(() => { | ||
return siemMigrations.rules.isAvailable() && tourState.isTourActive; | ||
}, [siemMigrations.rules, tourState]); | ||
|
||
const selectMigrationStepData = tourSteps[0]; | ||
const statusHeaderStepData = tourSteps[1]; | ||
const getStartedStepData = tourSteps[2]; | ||
|
||
return ( | ||
<> | ||
{isSelectMigrationAnchorMounted && ( | ||
<EuiTourStep | ||
title={selectMigrationStepData.title} | ||
content={selectMigrationStepData.content} | ||
onFinish={noop} | ||
step={1} | ||
stepsTotal={tourSteps.length} | ||
isStepOpen={isTourActive && tourState.currentTourStep === 1} | ||
anchor={`#${SIEM_MIGRATIONS_SELECT_MIGRATION_BUTTON_ID}`} | ||
anchorPosition={selectMigrationStepData.anchorPosition} | ||
maxWidth={tourState.tourPopoverWidth} | ||
footerAction={ | ||
<EuiButtonEmpty size="xs" color="text" flush="right" onClick={onTourNext}> | ||
{i18n.NEXT_TOUR_STEP_BUTTON} | ||
</EuiButtonEmpty> | ||
} | ||
/> | ||
)} | ||
{isStatusHeaderAnchorMounted && ( | ||
<EuiTourStep | ||
title={statusHeaderStepData.title} | ||
content={statusHeaderStepData.content} | ||
onFinish={noop} | ||
step={2} | ||
stepsTotal={tourSteps.length} | ||
isStepOpen={isTourActive && tourState.currentTourStep === 2} | ||
anchor={`#${SIEM_MIGRATIONS_STATUS_HEADER_ID}`} | ||
anchorPosition={statusHeaderStepData.anchorPosition} | ||
maxWidth={tourState.tourPopoverWidth} | ||
footerAction={ | ||
<EuiButtonEmpty size="xs" color="text" flush="right" onClick={onTourNext}> | ||
{i18n.NEXT_TOUR_STEP_BUTTON} | ||
</EuiButtonEmpty> | ||
} | ||
/> | ||
)} | ||
{isGetStartedNavigationAnchorMounted && ( | ||
<EuiTourStep | ||
title={getStartedStepData.title} | ||
content={getStartedStepData.content} | ||
onFinish={noop} | ||
step={3} | ||
stepsTotal={tourSteps.length} | ||
isStepOpen={isTourActive && tourState.currentTourStep === 3} | ||
anchor={`#${SECURITY_GET_STARTED_BUTTON_ANCHOR}`} | ||
anchorPosition={getStartedStepData.anchorPosition} | ||
maxWidth={tourState.tourPopoverWidth} | ||
footerAction={ | ||
<EuiButtonEmpty size="xs" color="text" flush="right" onClick={onTourFinished}> | ||
{i18n.FINISH_TOUR_BUTTON} | ||
</EuiButtonEmpty> | ||
} | ||
/> | ||
)} | ||
</> | ||
); | ||
}); | ||
SiemTranslatedRulesTour.displayName = 'SiemTranslatedRulesTour'; |
108 changes: 108 additions & 0 deletions
108
..._solution/public/siem_migrations/rules/components/tours/translation_guide/translations.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { i18n } from '@kbn/i18n'; | ||
|
||
export const MIGRATION_RULES_SELECTOR_TOUR_STEP_TITLE = i18n.translate( | ||
'xpack.securitySolution.siemMigrations.rules.tour.translationRuleGuide.title', | ||
{ | ||
defaultMessage: 'Translated rules in one place', | ||
} | ||
); | ||
|
||
export const MIGRATION_RULES_SELECTOR_TOUR_STEP_CONTENT = i18n.translate( | ||
'xpack.securitySolution.siemMigrations.rules.tour.translationRuleGuide.content', | ||
{ | ||
defaultMessage: | ||
'Each migration’s translated rules appear on its SIEM rule translations page. Switch between your migrations using this dropdown. Start a new migration by clicking “Upload more rules for translation”.', | ||
} | ||
); | ||
|
||
export const TRANSLATION_STATUS_TOUR_STEP_TITLE = i18n.translate( | ||
'xpack.securitySolution.siemMigrations.rules.tour.translationRuleGuide.statusStepTitle', | ||
{ | ||
defaultMessage: 'Translation status', | ||
} | ||
); | ||
|
||
export const MIGRATION_GUIDE_TOUR_STEP_TITLE = i18n.translate( | ||
'xpack.securitySolution.siemMigrations.rules.tour.translationRuleGuide.migrationGuideStepTitle', | ||
{ | ||
defaultMessage: 'SIEM Rule Migration guide', | ||
} | ||
); | ||
|
||
export const MIGRATION_GUIDE_TOUR_STEP_CONTENT = i18n.translate( | ||
'xpack.securitySolution.siemMigrations.rules.tour.translationRuleGuide.migrationGuideStepContent', | ||
{ | ||
defaultMessage: | ||
'Your guide and migrated rules can always be found in the Onboarding Hub. Use it to review previous rule migrations or start a new one.', | ||
} | ||
); | ||
|
||
export const NEXT_TOUR_STEP_BUTTON = i18n.translate( | ||
'xpack.securitySolution.siemMigrations.rules.tour.translationRuleGuide.nextStepButton', | ||
{ | ||
defaultMessage: 'Next', | ||
} | ||
); | ||
|
||
export const FINISH_TOUR_BUTTON = i18n.translate( | ||
'xpack.securitySolution.siemMigrations.rules.tour.translationRuleGuide.finishButton', | ||
{ | ||
defaultMessage: 'OK', | ||
} | ||
); | ||
|
||
export const INSTALL_LABEL = i18n.translate( | ||
'xpack.securitySolution.siemMigrations.rules.tour.translationRuleGuide.installLabel', | ||
{ | ||
defaultMessage: 'Install', | ||
} | ||
); | ||
|
||
export const INSTALLED_LABEL = i18n.translate( | ||
'xpack.securitySolution.siemMigrations.rules.tour.translationRuleGuide.installedLabel', | ||
{ | ||
defaultMessage: 'Installed', | ||
} | ||
); | ||
|
||
export const VIEW_LABEL = i18n.translate( | ||
'xpack.securitySolution.siemMigrations.rules.tour.translationRuleGuide.viewLabel', | ||
{ | ||
defaultMessage: 'View', | ||
} | ||
); | ||
|
||
export const EDIT_LABEL = i18n.translate( | ||
'xpack.securitySolution.siemMigrations.rules.tour.translationRuleGuide.editLabel', | ||
{ | ||
defaultMessage: 'Edit', | ||
} | ||
); | ||
|
||
export const TRANSLATED_LABEL = i18n.translate( | ||
'xpack.securitySolution.siemMigrations.rules.tour.translationRuleGuide.translatedLabel', | ||
{ | ||
defaultMessage: 'Translated', | ||
} | ||
); | ||
|
||
export const REPROCESSED_LABEL = i18n.translate( | ||
'xpack.securitySolution.siemMigrations.rules.tour.translationRuleGuide.reprocessedLabel', | ||
{ | ||
defaultMessage: 'Reprocessed', | ||
} | ||
); | ||
|
||
export const SIEM_MIGRATIONS_LINK_LABEL = i18n.translate( | ||
'xpack.securitySolution.siemMigrations.rules.tour.translationRuleGuide.siemMigrationsLinkLabel', | ||
{ | ||
defaultMessage: 'AI Translations here', | ||
} | ||
); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tiny nit/question: How come you don't store the anchors in here too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point! Addressed in 37d5846