-
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
[App Search] New log retention components + major i18n refactors #88237
Conversation
- Will shortly be used by Analytics view
- this correctly localizes the dates when Kibana is in different languages, e.g. zh-CN, ja-JP
- Convert to all JSX/React vs plain strings (makes it easier to deal with FormattedDate/FormattedMessages) - Consolidate to single component that takes various log types (e.g. analytics, api) - This is important for adding future switches & toggles - there is *significantly* less complex strings to localize this way (2 short strings vs 5+ long sentences)
- to account for new i18n logs type values & IDs
const logRetentionSettings = logRetention?.[type]; | ||
const title = TITLE_MAP[type]; | ||
|
||
const hasILM = logRetention !== null; |
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.
I know ILM is an Elastic acronym, but its weird that we refer to this as "Log Retention" everywhere except for a few boolean values. Worth dropping the acronym internally? hasLogRetention
hasLogRetentionDisabled
?
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.
I have no strong preference, I think my only hesitation is there are some instances where ILM does actually reference to separate Elasticsearch concept/architecture that can be disabled separately, whereas Enterprise Search can override ILM (mostly by disabling it), at which point there's the broader concept of "Log Retention" separate from ILM.
I think I'd slightly prefer to leave it as-is unless we can check with Chris/back-end engineers to make sure our understanding is correct?
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.
I ended up liking this way more over time and updated the tooltip & callout components to use your suggestion in a448f12 - thanks Byron!!
disabledAt?: string | null; | ||
minAgeDays?: number | null; |
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.
Raises an eyebrow to me that these can be both undefined and are nullable, two different ways of representing when a value is "missing". If these represent distinct states, we might be doing too much.
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.
🤷 | null
is the current definition in ent-search, I think we just copied it over. Looks like you originally defined this 6 months ago there? I have no strong feelings either way, this comes in from the server so it would basically just be confirming that the server can or cannot serve a null
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.
Oh if you're raising your eyebrow at the undefined / ?
, I mean that's because we're passing around optional props.
That's probably easily solvable by doing minAgeDays?: LogRetentionPolicy[minAgeDays]
. I can definitely make that change.
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.
export const DefaultPolicy: React.FC<Props> = ({ type, minAgeDays }) => ( | ||
<FormattedMessage | ||
id="xpack.enterpriseSearch.appSearch.logRetention.defaultPolicy" | ||
defaultMessage="Your {logsType} logs are being stored for at least {minAgeDays} days." |
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.
does 1 days
matter here?
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.
Ah great catch!! I'll add some i18n pluralization here
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.
@@ -7279,20 +7279,18 @@ | |||
"xpack.enterpriseSearch.appSearch.productName": "App Search", | |||
"xpack.enterpriseSearch.appSearch.result.hideAdditionalFields": "追加フィールドを非表示", | |||
"xpack.enterpriseSearch.appSearch.roleMappings.title": "ロールマッピング", | |||
"xpack.enterpriseSearch.appSearch.settings.logRetention.analytics.customPolicy": "カスタム分析保持ポリシーがあります。", | |||
"xpack.enterpriseSearch.appSearch.settings.logRetention.analytics.ilmDisabled": "App Search は分析保持を管理していません。", | |||
"xpack.enterpriseSearch.appSearch.logRetention.customPolicy": "カスタム {logsType} ログ保持ポリシーがあります。", |
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.
Just curious, where are these translations coming from?
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.
There's an i18n team+contractors that I think check for untranslated IDs every release? I'm not super clear myself lol, the #kibana-localization channel might know. Also https://github.com/elastic/kibana/tree/master/packages/kbn-i18n for reference
FYI - I'm adding another commit to this PR that has |
… log retention + change ILM to LogRetention per PR feedback
- e.g. if both LogRetentionTooltip and LogRetentionCallout are on the same page (which they will be)
@JasonStoltz If you have time today, do you mind taking another super quick glance at the 2 new commits and re-approving if they look sane? |
💚 Build SucceededMetrics [docs]Module Count
Async chunks
History
To update your PR or re-run it, just comment with: |
Looks fine to me @constancecchen |
Thanks a million! |
) (#88421) * Add remaining log retention components - Will shortly be used by Analytics view * [i18n] Change log retention date from moment to react-intl FormattedDate - this correctly localizes the dates when Kibana is in different languages, e.g. zh-CN, ja-JP * Refactor log_retention/messaging - Convert to all JSX/React vs plain strings (makes it easier to deal with FormattedDate/FormattedMessages) - Consolidate to single component that takes various log types (e.g. analytics, api) - This is important for adding future switches & toggles - there is *significantly* less complex strings to localize this way (2 short strings vs 5+ long sentences) * Update existing instances to use new LogRetentionMessage * Update translation strings - to account for new i18n logs type values & IDs * Attempt to fix test timezone shenanigans * [PR feedback] Types * [PR feedback] i18n pluralization * Update LogRetentionTooltip and LogRetentionCallout to manage fetching log retention + change ILM to LogRetention per PR feedback * Update LogRetentionLogic to prevent duplicate fetches - e.g. if both LogRetentionTooltip and LogRetentionCallout are on the same page (which they will be)
Summary
1. (blocking) 4991c8b
This commit migrates over
LogRetentionTooltip
andLogRetentionCallout
from ent-search's standalone UI. It will used by the Analytics and API logs views and is blocking for future Analytics PRs that I'll be opening here shortly:Heads up: I significantly changed how these components work compared to ent-search. Instead of having parent views/components handle passing in content, I wanted these components to manage their own visibility and content. Views calling these components should have APIs as simple as this:
That's it, no need to import/check logRetention from LogRetentionLogic. This greatly simplified my Analytics work views & allowed them to remain focused on Analytics-only logic.
@byronhulcher let me know if you're cool with this approach and change. :)
2. (i18n) 2fa5534
Because I'm very extra, I noticed that our log retention dates weren't being localized:
Switching from
moment
toFormattedDate
allows us to correctly localize dates according to the current i18n locale:This does however significantly mess up our typing, which was expecting strings instead of JSX/React components, which led me to the following commits...
3. (cleanup) c8a5a44, 00eb97a, 8e7fd56
These PRs streamline
log_retention/messaging
and simplifies our i18n handling of those messages.api
,analytics
,crawler
in the future)For the most part, this should behave as before with some minor copy changes/standardization (e.g., analytics collection -> analytics logging):
Checklist