-
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
[SecuritySolution] update sourcer messages #129329
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
76ef45b
update wording for temporary sourcerer
angorayc fd381f2
Merge branch 'main' into issue-121984
kibanamachine ca61be2
update sourcer messages
angorayc e5cc68e
Merge branch 'main' of github.com:elastic/kibana into issue-121984
angorayc c4a8427
Merge branch 'issue-121984' of github.com:angorayc/kibana into issue-…
angorayc 35a40b2
add message utils
angorayc 7416f7a
Merge branch 'main' of github.com:elastic/kibana into issue-121984
angorayc 52320d2
fix FormattedMessage
angorayc 81281f0
remove unused i18n keys
angorayc 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
201 changes: 201 additions & 0 deletions
201
x-pack/plugins/security_solution/public/common/components/sourcerer/utils.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,201 @@ | ||
/* | ||
* 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 { EuiIcon, EuiLink, EuiToolTip } from '@elastic/eui'; | ||
import { FormattedMessage } from '@kbn/i18n-react'; | ||
import React, { useMemo } from 'react'; | ||
import { TimelineType } from '../../../../common/types'; | ||
import { Blockquote } from './helpers'; | ||
import * as i18n from './translations'; | ||
|
||
export const CurrentPatternsMessage = ({ | ||
activePatterns, | ||
deadPatterns, | ||
selectedPatterns, | ||
timelineType, | ||
}: { | ||
activePatterns: string[]; | ||
deadPatterns: string[]; | ||
selectedPatterns: string[]; | ||
timelineType: TimelineType; | ||
}) => { | ||
const tooltip = useMemo( | ||
() => | ||
deadPatterns.length > 0 ? ( | ||
<EuiToolTip | ||
content={ | ||
<NoMatchDataMessage | ||
activePatterns={activePatterns} | ||
selectedPatterns={selectedPatterns} | ||
timelineType={timelineType} | ||
/> | ||
} | ||
> | ||
<EuiIcon type="questionInCircle" title={i18n.INACTIVE_PATTERNS} /> | ||
</EuiToolTip> | ||
) : null, | ||
[activePatterns, deadPatterns.length, selectedPatterns, timelineType] | ||
); | ||
|
||
if (timelineType === TimelineType.template) { | ||
return ( | ||
<FormattedMessage | ||
data-test-subj="sourcerer-current-patterns-message" | ||
id="xpack.securitySolution.indexPatterns.timelineTemplate.currentPatterns" | ||
defaultMessage="The active index patterns in this timeline template are{tooltip}: {callout}" | ||
values={{ | ||
tooltip, | ||
callout: <Blockquote>{activePatterns.join(', ')}</Blockquote>, | ||
}} | ||
/> | ||
); | ||
} | ||
|
||
return ( | ||
<FormattedMessage | ||
data-test-subj="sourcerer-current-patterns-message" | ||
id="xpack.securitySolution.indexPatterns.timeline.currentPatterns" | ||
defaultMessage="The active index patterns in this timeline are{tooltip}: {callout}" | ||
values={{ | ||
tooltip, | ||
callout: <Blockquote>{activePatterns.join(', ')}</Blockquote>, | ||
}} | ||
/> | ||
); | ||
}; | ||
|
||
export const NoMatchDataMessage = ({ | ||
activePatterns, | ||
selectedPatterns, | ||
timelineType, | ||
}: { | ||
activePatterns: string[]; | ||
selectedPatterns: string[]; | ||
timelineType: TimelineType; | ||
}) => { | ||
const aliases = useMemo( | ||
() => selectedPatterns.filter((p) => !activePatterns.includes(p)).join(', '), | ||
[activePatterns, selectedPatterns] | ||
); | ||
if (timelineType === TimelineType.template) { | ||
return ( | ||
<FormattedMessage | ||
id="xpack.securitySolution.indexPatterns.timelineTemplate.noMatchData" | ||
defaultMessage="The following index patterns are saved to this timeline template but do not match any data streams, indices, or index aliases: {aliases}" | ||
values={{ | ||
aliases, | ||
}} | ||
/> | ||
); | ||
} | ||
|
||
return ( | ||
<FormattedMessage | ||
id="xpack.securitySolution.indexPatterns.timeline.noMatchData" | ||
defaultMessage="The following index patterns are saved to this timeline but do not match any data streams, indices, or index aliases: {aliases}" | ||
values={{ | ||
aliases, | ||
}} | ||
/> | ||
); | ||
}; | ||
|
||
export const BadCurrentPatternsMessage = ({ | ||
timelineType, | ||
selectedPatterns, | ||
}: { | ||
timelineType: TimelineType; | ||
selectedPatterns: string[]; | ||
}) => { | ||
const callout = useMemo( | ||
() => <Blockquote>{selectedPatterns.join(', ')}</Blockquote>, | ||
[selectedPatterns] | ||
); | ||
|
||
if (timelineType === TimelineType.template) { | ||
return ( | ||
<FormattedMessage | ||
id="xpack.securitySolution.indexPatterns.timelineTemplate.currentPatternsBad" | ||
defaultMessage="The current index patterns in this timeline template are: {callout}" | ||
values={{ | ||
callout, | ||
}} | ||
/> | ||
); | ||
} | ||
return ( | ||
<FormattedMessage | ||
id="xpack.securitySolution.indexPatterns.timeline.currentPatternsBad" | ||
defaultMessage="The current index patterns in this timeline are: {callout}" | ||
values={{ | ||
callout, | ||
}} | ||
/> | ||
); | ||
}; | ||
|
||
export const DeprecatedMessage = ({ | ||
onReset, | ||
timelineType, | ||
}: { | ||
onReset: () => void; | ||
timelineType: TimelineType; | ||
}) => { | ||
if (timelineType === TimelineType.template) { | ||
return ( | ||
<FormattedMessage | ||
data-test-subj="sourcerer-deprecated-message" | ||
id="xpack.securitySolution.indexPatterns.timelineTemplate.toggleToNewSourcerer" | ||
defaultMessage="We have preserved your timeline template by creating a temporary data view. If you'd like to modify your data, we can recreate your temporary data view with the new data view selector. You can also manually select a data view {link}." | ||
values={{ | ||
link: <EuiLink onClick={onReset}>{i18n.TOGGLE_TO_NEW_SOURCERER}</EuiLink>, | ||
}} | ||
/> | ||
); | ||
} | ||
return ( | ||
<FormattedMessage | ||
data-test-subj="sourcerer-deprecated-message" | ||
id="xpack.securitySolution.indexPatterns.timeline.toggleToNewSourcerer" | ||
defaultMessage="We have preserved your timeline by creating a temporary data view. If you'd like to modify your data, we can recreate your temporary data view with the new data view selector. You can also manually select a data view {link}." | ||
values={{ | ||
link: <EuiLink onClick={onReset}>{i18n.TOGGLE_TO_NEW_SOURCERER}</EuiLink>, | ||
}} | ||
/> | ||
); | ||
}; | ||
|
||
export const MissingPatternsMessage = ({ | ||
onReset, | ||
timelineType, | ||
}: { | ||
timelineType: TimelineType; | ||
onReset: () => void; | ||
}) => { | ||
if (timelineType === TimelineType.template) { | ||
return ( | ||
<FormattedMessage | ||
data-test-subj="sourcerer-missing-patterns-message" | ||
id="xpack.securitySolution.indexPatterns.missingPatterns.timelineTemplate.description" | ||
defaultMessage="We have preserved your timeline template by creating a temporary data view. If you'd like to modify your data, we can add the missing index patterns to the Security Data View. You can also manually select a data view {link}." | ||
values={{ | ||
link: <EuiLink onClick={onReset}>{i18n.TOGGLE_TO_NEW_SOURCERER}</EuiLink>, | ||
}} | ||
/> | ||
); | ||
} | ||
return ( | ||
<FormattedMessage | ||
data-test-subj="sourcerer-missing-patterns-message" | ||
id="xpack.securitySolution.indexPatterns.missingPatterns.timeline.description" | ||
defaultMessage="We have preserved your timeline by creating a temporary data view. If you'd like to modify your data, we can add the missing index patterns to the Security Data View. You can also manually select a data view {link}." | ||
values={{ | ||
link: <EuiLink onClick={onReset}>{i18n.TOGGLE_TO_NEW_SOURCERER}</EuiLink>, | ||
}} | ||
/> | ||
); | ||
}; |
Oops, something went wrong.
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.
FormattedMessage doesn’t accept its props to be variables (The build will fail and complain about this), so I created components to return messages by timeline type.