From 8d6268acf9de1ae3e5edc7074687951c3c806250 Mon Sep 17 00:00:00 2001 From: Constance Date: Wed, 1 Sep 2021 08:39:20 -0700 Subject: [PATCH] Upgrade EUI to v37.3.1 (#109926) * Upgrade EUI to v37.3.1 * Update i18n token mappings * Skip i18n_eui_mapping defString checks for functions * Update snapshots * Update failing Security tests with extra nodes * Remove hook cleanup now that elastic/eui#5068 is merged * [i18n PR feedback] Prefer specific token skipping over all functions skipping * Revert "Remove hook cleanup now that elastic/eui#5068 is merged" This reverts commit e40ebfa92946662d401e169cfdfb97c664f92e92. Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> --- package.json | 2 +- .../__snapshots__/i18n_service.test.tsx.snap | 8 ++- src/core/public/i18n/i18n_eui_mapping.test.ts | 5 ++ src/core/public/i18n/i18n_eui_mapping.tsx | 30 +++++--- src/dev/license_checker/config.ts | 2 +- .../field/__snapshots__/field.test.tsx.snap | 28 ++++++-- .../__snapshots__/data_view.test.tsx.snap | 24 ++++--- .../List/__snapshots__/List.test.tsx.snap | 4 +- .../workpad_table.stories.storyshot | 4 +- .../api/__snapshots__/shareable.test.tsx.snap | 10 +-- .../__snapshots__/canvas.stories.storyshot | 8 +-- .../__snapshots__/footer.stories.storyshot | 6 +- .../page_controls.stories.storyshot | 6 +- .../upload_license.test.tsx.snap | 70 +++---------------- .../report_listing.test.tsx.snap | 18 +++-- .../security_solution/cypress/tasks/alerts.ts | 2 +- .../enrichment_range_picker.test.tsx | 1 + .../__snapshots__/index.test.tsx.snap | 6 +- .../translations/translations/ja-JP.json | 2 - .../translations/translations/zh-CN.json | 2 - .../location_status_tags.test.tsx.snap | 2 +- yarn.lock | 8 +-- 22 files changed, 125 insertions(+), 123 deletions(-) diff --git a/package.json b/package.json index 71a66d837f717..4824bcbb91071 100644 --- a/package.json +++ b/package.json @@ -97,7 +97,7 @@ "@elastic/datemath": "link:bazel-bin/packages/elastic-datemath", "@elastic/elasticsearch": "npm:@elastic/elasticsearch-canary@^7.16.0-canary.2", "@elastic/ems-client": "7.15.0", - "@elastic/eui": "37.3.0", + "@elastic/eui": "37.3.1", "@elastic/filesaver": "1.1.2", "@elastic/good": "^9.0.1-kibana3", "@elastic/maki": "6.3.0", diff --git a/src/core/public/i18n/__snapshots__/i18n_service.test.tsx.snap b/src/core/public/i18n/__snapshots__/i18n_service.test.tsx.snap index 4ef5eb8f56d2f..54e223cdc5d41 100644 --- a/src/core/public/i18n/__snapshots__/i18n_service.test.tsx.snap +++ b/src/core/public/i18n/__snapshots__/i18n_service.test.tsx.snap @@ -57,7 +57,7 @@ exports[`#start() returns \`Context\` component 1`] = ` "euiColumnSelector.searchcolumns": "Search columns", "euiColumnSelector.selectAll": "Show all", "euiColumnSorting.button": "Sort fields", - "euiColumnSorting.buttonActive": "fields sorted", + "euiColumnSorting.buttonActive": [Function], "euiColumnSorting.clearAll": "Clear sorting", "euiColumnSorting.emptySorting": "Currently no fields are sorted", "euiColumnSorting.pickFields": "Pick fields to sort by", @@ -104,9 +104,11 @@ exports[`#start() returns \`Context\` component 1`] = ` "euiFieldPassword.maskPassword": "Mask password", "euiFieldPassword.showPassword": "Show password as plain text. Note: this will visually expose your password on the screen.", "euiFilePicker.clearSelectedFiles": "Clear selected files", - "euiFilePicker.filesSelected": "files selected", + "euiFilePicker.filesSelected": [Function], + "euiFilePicker.promptText": "Select or drag and drop a file", "euiFilePicker.removeSelected": "Remove", - "euiFilterButton.filterBadge": [Function], + "euiFilterButton.filterBadgeActiveAriaLabel": [Function], + "euiFilterButton.filterBadgeAvailableAriaLabel": [Function], "euiFlyout.closeAriaLabel": "Close this dialog", "euiForm.addressFormErrors": "Please address the highlighted errors.", "euiFormControlLayoutClearButton.label": "Clear input", diff --git a/src/core/public/i18n/i18n_eui_mapping.test.ts b/src/core/public/i18n/i18n_eui_mapping.test.ts index 1b80257266d4c..d8d48a8e5f1d5 100644 --- a/src/core/public/i18n/i18n_eui_mapping.test.ts +++ b/src/core/public/i18n/i18n_eui_mapping.test.ts @@ -74,6 +74,11 @@ describe('@elastic/eui i18n tokens', () => { }); test('defaultMessage is in sync with defString', () => { + // Certain complex tokens (e.g. ones that have a function as a defaultMessage) + // need custom i18n handling, and can't be checked for basic defString equality + const tokensToSkip = ['euiColumnSorting.buttonActive']; + if (tokensToSkip.includes(token)) return; + // Clean up typical errors from the `@elastic/eui` extraction token tool const normalizedDefString = defString // Quoted words should use double-quotes diff --git a/src/core/public/i18n/i18n_eui_mapping.tsx b/src/core/public/i18n/i18n_eui_mapping.tsx index 133a2155f7430..4175dac712e82 100644 --- a/src/core/public/i18n/i18n_eui_mapping.tsx +++ b/src/core/public/i18n/i18n_eui_mapping.tsx @@ -272,9 +272,11 @@ export const getEuiContextMapping = (): EuiTokensObject => { 'euiColumnSorting.button': i18n.translate('core.euiColumnSorting.button', { defaultMessage: 'Sort fields', }), - 'euiColumnSorting.buttonActive': i18n.translate('core.euiColumnSorting.buttonActive', { - defaultMessage: 'fields sorted', - }), + 'euiColumnSorting.buttonActive': ({ numberOfSortedFields }: EuiValues) => + i18n.translate('core.euiColumnSorting.buttonActive', { + defaultMessage: '{numberOfSortedFields, plural, one {# field} other {# fields}} sorted', + values: { numberOfSortedFields }, + }), 'euiColumnSortingDraggable.activeSortLabel': ({ display }: EuiValues) => i18n.translate('core.euiColumnSortingDraggable.activeSortLabel', { defaultMessage: '{display} is sorting this data grid', @@ -514,16 +516,26 @@ export const getEuiContextMapping = (): EuiTokensObject => { 'euiFilePicker.clearSelectedFiles': i18n.translate('core.euiFilePicker.clearSelectedFiles', { defaultMessage: 'Clear selected files', }), - 'euiFilePicker.filesSelected': i18n.translate('core.euiFilePicker.filesSelected', { - defaultMessage: 'files selected', + 'euiFilePicker.filesSelected': ({ fileCount }: EuiValues) => + i18n.translate('core.euiFilePicker.filesSelected', { + defaultMessage: '{fileCount} files selected', + values: { fileCount }, + }), + 'euiFilePicker.promptText': i18n.translate('core.euiFilePicker.promptText', { + defaultMessage: 'Select or drag and drop a file', }), 'euiFilePicker.removeSelected': i18n.translate('core.euiFilePicker.removeSelected', { defaultMessage: 'Remove', }), - 'euiFilterButton.filterBadge': ({ count, hasActiveFilters }: EuiValues) => - i18n.translate('core.euiFilterButton.filterBadge', { - defaultMessage: '{count} {hasActiveFilters} filters', - values: { count, hasActiveFilters: hasActiveFilters ? 'active' : 'available' }, + 'euiFilterButton.filterBadgeActiveAriaLabel': ({ count }: EuiValues) => + i18n.translate('core.euiFilterButton.filterBadgeActiveAriaLabel', { + defaultMessage: '{count} active filters', + values: { count }, + }), + 'euiFilterButton.filterBadgeAvailableAriaLabel': ({ count }: EuiValues) => + i18n.translate('core.euiFilterButton.filterBadgeAvailableAriaLabel', { + defaultMessage: '{count} available filters', + values: { count }, }), 'euiFlyout.closeAriaLabel': i18n.translate('core.euiFlyout.closeAriaLabel', { defaultMessage: 'Close this dialog', diff --git a/src/dev/license_checker/config.ts b/src/dev/license_checker/config.ts index cb7e3781e2511..ee355d6a9811b 100644 --- a/src/dev/license_checker/config.ts +++ b/src/dev/license_checker/config.ts @@ -75,7 +75,7 @@ export const LICENSE_OVERRIDES = { '@mapbox/jsonlint-lines-primitives@2.0.2': ['MIT'], // license in readme https://github.com/tmcw/jsonlint 'node-sql-parser@3.6.1': ['(GPL-2.0 OR MIT)'], // GPL-2.0* https://github.com/taozhi8833998/node-sql-parser '@elastic/ems-client@7.15.0': ['Elastic License 2.0'], - '@elastic/eui@37.3.0': ['SSPL-1.0 OR Elastic License 2.0'], + '@elastic/eui@37.3.1': ['SSPL-1.0 OR Elastic License 2.0'], // TODO can be removed if the https://github.com/jindw/xmldom/issues/239 is released 'xmldom@0.1.27': ['MIT'], diff --git a/src/plugins/advanced_settings/public/management_app/components/field/__snapshots__/field.test.tsx.snap b/src/plugins/advanced_settings/public/management_app/components/field/__snapshots__/field.test.tsx.snap index be5163e89367c..9249f5f98e9c9 100644 --- a/src/plugins/advanced_settings/public/management_app/components/field/__snapshots__/field.test.tsx.snap +++ b/src/plugins/advanced_settings/public/management_app/components/field/__snapshots__/field.test.tsx.snap @@ -1326,7 +1326,12 @@ exports[`Field for image setting should render as read only if saving is disable disabled={true} display="large" fullWidth={true} - initialPromptText="Select or drag and drop a file" + initialPromptText={ + + } onChange={[Function]} /> @@ -1472,7 +1477,12 @@ exports[`Field for image setting should render custom setting icon if it is cust disabled={false} display="large" fullWidth={true} - initialPromptText="Select or drag and drop a file" + initialPromptText={ + + } onChange={[Function]} /> @@ -1526,7 +1536,12 @@ exports[`Field for image setting should render default value if there is no user disabled={false} display="large" fullWidth={true} - initialPromptText="Select or drag and drop a file" + initialPromptText={ + + } onChange={[Function]} /> @@ -1597,7 +1612,12 @@ exports[`Field for image setting should render unsaved value if there are unsave disabled={false} display="large" fullWidth={true} - initialPromptText="Select or drag and drop a file" + initialPromptText={ + + } onChange={[Function]} /> diff --git a/src/plugins/data/public/utils/table_inspector_view/components/__snapshots__/data_view.test.tsx.snap b/src/plugins/data/public/utils/table_inspector_view/components/__snapshots__/data_view.test.tsx.snap index 612ffdcf5029e..9cd0687a1074d 100644 --- a/src/plugins/data/public/utils/table_inspector_view/components/__snapshots__/data_view.test.tsx.snap +++ b/src/plugins/data/public/utils/table_inspector_view/components/__snapshots__/data_view.test.tsx.snap @@ -1403,7 +1403,7 @@ exports[`Inspector Data View component should render single table without select >
" +
markdown mock
My Canvas Workpad
" `; exports[`Canvas Shareable Workpad API Placed successfully with height specified 1`] = `"
"`; @@ -21,7 +21,7 @@ exports[`Canvas Shareable Workpad API Placed successfully with height specified
markdown mock
markdown mock
My Canvas Workpad
" +
markdown mock
My Canvas Workpad
" `; exports[`Canvas Shareable Workpad API Placed successfully with page specified 1`] = `"
"`; @@ -33,7 +33,7 @@ exports[`Canvas Shareable Workpad API Placed successfully with page specified 2`
markdown mock
markdown mock
My Canvas Workpad
" +
markdown mock
My Canvas Workpad
" `; exports[`Canvas Shareable Workpad API Placed successfully with width and height specified 1`] = `"
"`; @@ -45,7 +45,7 @@ exports[`Canvas Shareable Workpad API Placed successfully with width and height
markdown mock
markdown mock
My Canvas Workpad
" +
markdown mock
My Canvas Workpad
" `; exports[`Canvas Shareable Workpad API Placed successfully with width specified 1`] = `"
"`; @@ -57,5 +57,5 @@ exports[`Canvas Shareable Workpad API Placed successfully with width specified 2
markdown mock
markdown mock
My Canvas Workpad
" +
markdown mock
My Canvas Workpad
" `; diff --git a/x-pack/plugins/canvas/shareable_runtime/components/__stories__/__snapshots__/canvas.stories.storyshot b/x-pack/plugins/canvas/shareable_runtime/components/__stories__/__snapshots__/canvas.stories.storyshot index c5b6d768c89d8..a5eefde192371 100644 --- a/x-pack/plugins/canvas/shareable_runtime/components/__stories__/__snapshots__/canvas.stories.storyshot +++ b/x-pack/plugins/canvas/shareable_runtime/components/__stories__/__snapshots__/canvas.stories.storyshot @@ -1375,7 +1375,7 @@ exports[`Storyshots shareables/Canvas component 1`] = ` >