From b2fbee16088769819b9c2faf8044a88932f7fa8e Mon Sep 17 00:00:00 2001 From: Harrison Healey Date: Wed, 16 Oct 2024 11:22:28 -0400 Subject: [PATCH] Remove localizeMessage from a bunch of components (#28340) * Remove localizeMessage usage for passing into LoadingSpinner or LoadingWrapper components * Allow Input widget to translate its placeholder and remove related usage of localizeMessage * Allow DropdownInputHybrid to translate its placeholder and remove localizeMessage from related files * Have Multiselect translate some of its props and remove localizeMessage from the components using it * Remove unused message prop from StartTrianBtn * Remove localizeMessage from a bunch of function components * Remove unused editingPost.title state * Remove usage of localizeMessage from some random components * Remove unused DataGrid searchPlaceholder prop * Add LocalizedPlaceholderInput and LocalizedPlaceholderTextarea I used these in a bunch of places where we used localizeMessage or in places where we only injected intl just for a placeholder. I didn't really need to remove injectIntl from all these places, but it's been a pet peeve of mine for a while * Have SearchableChannelList always use its injected intl * Added changes that VS Code didn't show me in the last commit... --- .../channels/src/actions/post_actions.test.ts | 14 +- webapp/channels/src/actions/post_actions.ts | 4 +- .../src/actions/views/create_comment.tsx | 1 - .../loading_image_preview.test.tsx.snap | 6 +- .../searchable_channel_list.test.tsx.snap | 1 + .../setting_picture.test.tsx.snap | 56 ++- .../components/device_icon.tsx | 11 +- .../add_groups_to_channel_modal.test.tsx.snap | 21 +- .../add_groups_to_channel_modal.tsx | 9 +- .../add_groups_to_team_modal.test.tsx.snap | 21 +- .../add_groups_to_team_modal.tsx | 10 +- ...dd_user_to_group_multiselect.test.tsx.snap | 49 +- .../add_user_to_group_multiselect.tsx | 19 +- .../add_users_to_group_modal.test.tsx.snap | 14 +- .../add_users_to_group_modal.tsx | 8 +- .../add_users_to_team_modal.test.tsx.snap | 42 +- .../add_users_to_team_modal.tsx | 10 +- .../custom_url_schemes_setting.test.tsx.snap | 455 +++++++++--------- .../billing/company_info_edit.tsx | 19 +- .../admin_console/cluster_table.tsx | 37 +- .../compliance_reports/compliance_reports.tsx | 29 +- .../custom_url_schemes_setting.test.tsx | 4 +- .../custom_url_schemes_setting.tsx | 34 +- .../__snapshots__/data_grid.test.tsx.snap | 4 - .../admin_console/data_grid/data_grid.tsx | 3 - .../data_grid/data_grid_search.tsx | 15 +- .../data_retention_settings.test.tsx.snap | 8 - .../__snapshots__/channel_list.test.tsx.snap | 2 - .../custom_policy_form.test.tsx.snap | 42 +- .../custom_policy_form/custom_policy_form.tsx | 64 ++- .../global_policy_form.test.tsx.snap | 33 +- .../global_policy_form/global_policy_form.tsx | 43 +- .../__snapshots__/team_list.test.tsx.snap | 57 ++- .../team_list/team_list.tsx | 5 +- .../feature_discovery/feature_discovery.tsx | 5 - .../__snapshots__/groups_list.test.tsx.snap | 99 +++- .../groups_list/groups_list.tsx | 8 +- .../modals/upload_license_modal.tsx | 6 +- .../manage_teams_dropdown.tsx | 22 +- .../member_list_group.test.tsx.snap | 2 - .../permission_schemes_settings.test.tsx | 15 +- .../permission_schemes_settings.tsx | 10 +- ...mission_team_scheme_settings.test.tsx.snap | 88 +++- .../permission_team_scheme_settings.test.tsx | 27 +- .../permission_team_scheme_settings.tsx | 23 +- .../permissions_scheme_summary.test.tsx.snap | 21 +- .../permissions_scheme_summary.tsx | 6 +- .../__snapshots__/system_roles.test.tsx.snap | 1 - .../add_users_to_role_modal.test.tsx.snap | 126 ++++- .../add_users_to_role_modal.tsx | 10 +- .../system_role_users.test.tsx.snap | 2 - .../__snapshots__/channel_list.test.tsx.snap | 3 - .../users_to_remove.test.tsx.snap | 4 - .../__snapshots__/team_list.test.tsx.snap | 2 - .../__snapshots__/user_grid.test.tsx.snap | 3 - .../apps_form_component.test.tsx.snap | 7 +- .../apps_form/apps_form_component.tsx | 5 +- .../backstage/components/backstage_list.tsx | 11 +- .../channel_groups_manage_modal.tsx | 14 +- .../channel_header_dropdown.tsx | 21 +- .../menu_items/toggle_info/toggle_info.tsx | 12 +- .../channel_info_button.tsx | 31 +- .../show_search_button/show_search_button.tsx | 7 +- .../channel_invite_modal.test.tsx.snap | 72 +++ .../channel_invite_modal.test.tsx | 1 - .../channel_invite_modal.tsx | 12 +- .../channel_members_dropdown.tsx | 13 +- .../channel_name_form_field.tsx | 11 +- .../channel_selector_modal.test.tsx.snap | 28 +- .../channel_selector_modal.tsx | 7 +- .../claim/components/ldap_to_email.tsx | 7 +- .../claim/components/oauth_to_email.tsx | 6 +- .../create_user_groups_modal.test.tsx.snap | 42 +- .../create_user_groups_modal.test.tsx | 16 +- .../create_user_groups_modal.tsx | 72 ++- .../dnd_custom_time_picker_modal.tsx | 4 +- .../src/components/dot_menu/dot_menu.tsx | 3 +- .../__snapshots__/emoji_page.test.tsx.snap | 2 +- .../__snapshots__/add_emoji.test.tsx.snap | 21 +- .../components/emoji/add_emoji/add_emoji.tsx | 5 +- .../emoji/emoji_list/emoji_list.tsx | 12 +- .../__snapshots__/error_title.test.tsx.snap | 7 +- .../src/components/error_page/error_title.tsx | 8 +- .../feature_restricted_modal.tsx | 1 - .../components/feedback_modal/feedback.tsx | 15 +- .../file_info_preview/file_info_preview.tsx | 7 +- .../file_preview_modal.test.tsx.snap | 21 +- .../file_preview_modal/file_preview_modal.tsx | 9 +- .../history_buttons/history_buttons.tsx | 7 +- .../abstract_command.test.tsx.snap | 170 +++++-- .../abstract_incoming_hook.test.tsx.snap | 42 +- .../abstract_oauth_app.test.tsx.snap | 14 +- .../abstract_outgoing_webhook.test.tsx.snap | 7 +- .../integrations/abstract_command.test.tsx | 23 +- .../integrations/abstract_command.tsx | 33 +- .../abstract_incoming_webhook.tsx | 4 +- .../integrations/abstract_oauth_app.tsx | 4 +- .../abstract_outgoing_webhook.tsx | 2 +- .../__snapshots__/add_command.test.tsx.snap | 2 +- .../__snapshots__/edit_command.test.tsx.snap | 2 +- .../installed_oauth_app.test.tsx.snap | 126 +++-- .../installed_oauth_app.tsx | 52 +- ...ed_outgoing_oauth_connection.test.tsx.snap | 13 +- ...th_connection_audience_input.test.tsx.snap | 140 +++++- .../installed_outgoing_oauth_connection.tsx | 19 +- .../oauth_connection_audience_input.test.tsx | 18 +- .../oauth_connection_audience_input.tsx | 6 +- .../learn_more_trial_modal.tsx | 3 - .../start_trial_btn.tsx | 1 - .../src/components/loading_image_preview.tsx | 5 +- .../localized_placeholder_input.tsx | 25 + .../localized_placeholder_textarea.tsx | 25 + .../src/components/mfa/setup/setup.tsx | 38 +- .../components/multiselect/multiselect.tsx | 41 +- ...nboarding_tasklist_completed.test.tsx.snap | 1 - .../onboarding_tasklist_completed.tsx | 5 +- .../password_reset_send_link.test.tsx.snap | 8 +- .../password_reset_send_link.test.tsx | 7 +- .../password_reset_send_link.tsx | 12 +- .../marketplace_item_app.test.tsx.snap | 63 ++- .../marketplace_item_app.tsx | 6 +- .../marketplace_item_plugin.test.tsx.snap | 63 ++- .../marketplace_item_plugin.tsx | 6 +- .../__snapshots__/show_more.test.tsx.snap | 25 +- .../post_view/show_more/show_more.tsx | 17 +- .../pricing_modal/self_hosted_content.tsx | 1 - .../search_results/search_results.tsx | 5 +- .../searchable_channel_list.test.tsx | 2 +- .../components/searchable_channel_list.tsx | 41 +- .../src/components/setting_picture.tsx | 4 +- .../src/components/spinner_button.tsx | 3 +- .../team_groups_manage_modal.tsx | 14 +- .../team_selector_modal.tsx | 8 +- .../toast_wrapper/toast_wrapper.tsx | 8 +- .../update_user_group_modal.test.tsx.snap | 5 +- .../update_user_group_modal.tsx | 26 +- .../group_member_list/group_member_list.tsx | 19 +- .../user_groups_modal.test.tsx.snap | 14 +- .../ad_ldap_upsell_banner.tsx | 1 - .../user_groups_modal/user_groups_modal.tsx | 4 +- .../general/user_settings_general.tsx | 4 +- .../manage_auto_responder.test.tsx.snap | 35 +- .../manage_auto_responder.test.tsx | 4 +- .../manage_auto_responder.tsx | 9 +- .../user_access_token_section.tsx | 33 +- .../view_user_group_modal.test.tsx.snap | 7 +- .../view_user_group_modal.tsx | 5 +- .../widgets/inputs/dropdown_input_hybrid.tsx | 13 +- .../components/widgets/inputs/input/input.tsx | 20 +- .../loading_spinner.test.tsx.snap | 28 -- .../loading_wrapper.test.tsx.snap | 4 +- .../widgets/loading/loading_spinner.test.tsx | 58 ++- .../widgets/loading/loading_spinner.tsx | 10 +- .../widgets/loading/loading_wrapper.tsx | 5 +- .../with_tooltip/create_tooltip.tsx | 7 +- .../src/components/with_tooltip/utils.tsx | 26 - webapp/channels/src/i18n/en.json | 14 +- webapp/channels/src/utils/i18n.tsx | 23 +- 158 files changed, 2442 insertions(+), 1196 deletions(-) create mode 100644 webapp/channels/src/components/localized_placeholder_input.tsx create mode 100644 webapp/channels/src/components/localized_placeholder_textarea.tsx delete mode 100644 webapp/channels/src/components/widgets/loading/__snapshots__/loading_spinner.test.tsx.snap delete mode 100644 webapp/channels/src/components/with_tooltip/utils.tsx diff --git a/webapp/channels/src/actions/post_actions.test.ts b/webapp/channels/src/actions/post_actions.test.ts index 394fd160d7..1cb5342b77 100644 --- a/webapp/channels/src/actions/post_actions.test.ts +++ b/webapp/channels/src/actions/post_actions.test.ts @@ -272,12 +272,12 @@ describe('Actions.Posts', () => { test('unsetEditingPost', async () => { // should allow to edit and should fire an action const testStore = mockStore({...initialState}); - const {data: dataSet} = await testStore.dispatch((Actions.setEditingPost as any)('latest_post_id', 'test', 'title')); + const {data: dataSet} = await testStore.dispatch((Actions.setEditingPost as any)('latest_post_id', 'test')); expect(dataSet).toEqual(true); // matches the action to set editingPost expect(testStore.getActions()).toEqual( - [{data: {isRHS: false, postId: 'latest_post_id', refocusId: 'test', title: 'title', show: true}, type: ActionTypes.TOGGLE_EDITING_POST}], + [{data: {isRHS: false, postId: 'latest_post_id', refocusId: 'test', show: true}, type: ActionTypes.TOGGLE_EDITING_POST}], ); // clear actions @@ -299,11 +299,11 @@ describe('Actions.Posts', () => { test('setEditingPost', async () => { // should allow to edit and should fire an action let testStore = mockStore({...initialState}); - const {data} = await testStore.dispatch(Actions.setEditingPost('latest_post_id', 'test', 'title')); + const {data} = await testStore.dispatch(Actions.setEditingPost('latest_post_id', 'test')); expect(data).toEqual(true); expect(testStore.getActions()).toEqual( - [{data: {isRHS: false, postId: 'latest_post_id', refocusId: 'test', title: 'title', show: true}, type: ActionTypes.TOGGLE_EDITING_POST}], + [{data: {isRHS: false, postId: 'latest_post_id', refocusId: 'test', show: true}, type: ActionTypes.TOGGLE_EDITING_POST}], ); const general = { @@ -319,10 +319,10 @@ describe('Actions.Posts', () => { testStore = mockStore(withLicenseState); - const {data: withLicenseData} = await testStore.dispatch(Actions.setEditingPost('latest_post_id', 'test', 'title')); + const {data: withLicenseData} = await testStore.dispatch(Actions.setEditingPost('latest_post_id', 'test')); expect(withLicenseData).toEqual(true); expect(testStore.getActions()).toEqual( - [{data: {isRHS: false, postId: 'latest_post_id', refocusId: 'test', title: 'title', show: true}, type: ActionTypes.TOGGLE_EDITING_POST}], + [{data: {isRHS: false, postId: 'latest_post_id', refocusId: 'test', show: true}, type: ActionTypes.TOGGLE_EDITING_POST}], ); // should not allow edit for pending post @@ -332,7 +332,7 @@ describe('Actions.Posts', () => { testStore = mockStore(withPendingPostState); - const {data: withPendingPostData} = await testStore.dispatch(Actions.setEditingPost('latest_post_id', 'test', 'title')); + const {data: withPendingPostData} = await testStore.dispatch(Actions.setEditingPost('latest_post_id', 'test')); expect(withPendingPostData).toEqual(false); expect(testStore.getActions()).toEqual([]); }); diff --git a/webapp/channels/src/actions/post_actions.ts b/webapp/channels/src/actions/post_actions.ts index 2effbef2fc..53e5ce9a3e 100644 --- a/webapp/channels/src/actions/post_actions.ts +++ b/webapp/channels/src/actions/post_actions.ts @@ -278,7 +278,7 @@ export function unpinPost(postId: string): ActionFuncAsync }; } -export function setEditingPost(postId = '', refocusId = '', title = '', isRHS = false): ActionFunc { +export function setEditingPost(postId = '', refocusId = '', isRHS = false): ActionFunc { return (dispatch, getState) => { const state = getState(); const post = PostSelectors.getPost(state, postId); @@ -300,7 +300,7 @@ export function setEditingPost(postId = '', refocusId = '', title = '', isRHS = if (canEditNow) { dispatch({ type: ActionTypes.TOGGLE_EDITING_POST, - data: {postId, refocusId, title, isRHS, show: true}, + data: {postId, refocusId, isRHS, show: true}, }); } diff --git a/webapp/channels/src/actions/views/create_comment.tsx b/webapp/channels/src/actions/views/create_comment.tsx index 787c4d5bbb..5bf9585d32 100644 --- a/webapp/channels/src/actions/views/create_comment.tsx +++ b/webapp/channels/src/actions/views/create_comment.tsx @@ -181,7 +181,6 @@ export function editLatestPost(channelId: string, rootId = ''): ActionFunc - Loading 50% + Loading + 50% `; @@ -21,7 +22,8 @@ exports[`components/LoadingImagePreview should match snapshot 2`] = ` - Loading 90% + Loading + 90% `; diff --git a/webapp/channels/src/components/__snapshots__/searchable_channel_list.test.tsx.snap b/webapp/channels/src/components/__snapshots__/searchable_channel_list.test.tsx.snap index 41b1a9b018..fa68f91cae 100644 --- a/webapp/channels/src/components/__snapshots__/searchable_channel_list.test.tsx.snap +++ b/webapp/channels/src/components/__snapshots__/searchable_channel_list.test.tsx.snap @@ -22,6 +22,7 @@ exports[`components/SearchableChannelList should match init snapshot 1`] = ` id="searchChannelsTextbox" onClear={[Function]} onInput={[Function]} + placeholder="Search channels" value="" /> diff --git a/webapp/channels/src/components/__snapshots__/setting_picture.test.tsx.snap b/webapp/channels/src/components/__snapshots__/setting_picture.test.tsx.snap index a2e3fcfbc2..6f0222a9a7 100644 --- a/webapp/channels/src/components/__snapshots__/setting_picture.test.tsx.snap +++ b/webapp/channels/src/components/__snapshots__/setting_picture.test.tsx.snap @@ -88,7 +88,12 @@ exports[`components/SettingItemMin should match snapshot with active Save button > ); } diff --git a/webapp/channels/src/components/add_groups_to_channel_modal/__snapshots__/add_groups_to_channel_modal.test.tsx.snap b/webapp/channels/src/components/add_groups_to_channel_modal/__snapshots__/add_groups_to_channel_modal.test.tsx.snap index 2ec52a9cf4..6db1132c5e 100644 --- a/webapp/channels/src/components/add_groups_to_channel_modal/__snapshots__/add_groups_to_channel_modal.test.tsx.snap +++ b/webapp/channels/src/components/add_groups_to_channel_modal/__snapshots__/add_groups_to_channel_modal.test.tsx.snap @@ -57,8 +57,18 @@ exports[`components/AddGroupsToChannelModal should match snapshot 1`] = ` > { ); - const buttonSubmitText = localizeMessage({id: 'multiselect.add', defaultMessage: 'Add'}); - const buttonSubmitLoadingText = localizeMessage({id: 'multiselect.adding', defaultMessage: 'Adding...'}); + const buttonSubmitText = defineMessage({id: 'multiselect.add', defaultMessage: 'Add'}); + const buttonSubmitLoadingText = defineMessage({id: 'multiselect.adding', defaultMessage: 'Adding...'}); let addError = null; if (this.state.addError) { @@ -305,7 +304,7 @@ export class AddGroupsToChannelModal extends React.PureComponent { buttonSubmitLoadingText={buttonSubmitLoadingText} saving={this.state.saving} loading={this.state.loadingGroups} - placeholderText={localizeMessage({id: 'multiselect.addGroupsPlaceholder', defaultMessage: 'Search and add groups'})} + placeholderText={defineMessage({id: 'multiselect.addGroupsPlaceholder', defaultMessage: 'Search and add groups'})} /> diff --git a/webapp/channels/src/components/add_groups_to_team_modal/__snapshots__/add_groups_to_team_modal.test.tsx.snap b/webapp/channels/src/components/add_groups_to_team_modal/__snapshots__/add_groups_to_team_modal.test.tsx.snap index fef0212081..239866a988 100644 --- a/webapp/channels/src/components/add_groups_to_team_modal/__snapshots__/add_groups_to_team_modal.test.tsx.snap +++ b/webapp/channels/src/components/add_groups_to_team_modal/__snapshots__/add_groups_to_team_modal.test.tsx.snap @@ -57,8 +57,18 @@ exports[`components/AddGroupsToTeamModal should match snapshot 1`] = ` > { ); - const buttonSubmitText = localizeMessage({id: 'multiselect.add', defaultMessage: 'Add'}); - const buttonSubmitLoadingText = localizeMessage({id: 'multiselect.adding', defaultMessage: 'Adding...'}); + const buttonSubmitText = defineMessage({id: 'multiselect.add', defaultMessage: 'Add'}); + const buttonSubmitLoadingText = defineMessage({id: 'multiselect.adding', defaultMessage: 'Adding...'}); let addError = null; if (this.state.addError) { @@ -319,11 +318,12 @@ export class AddGroupsToTeamModal extends React.PureComponent { buttonSubmitLoadingText={buttonSubmitLoadingText} saving={this.state.saving} loading={this.state.loadingGroups} - placeholderText={localizeMessage({id: 'multiselect.addGroupsPlaceholder', defaultMessage: 'Search and add groups'})} + placeholderText={defineMessage({id: 'multiselect.addGroupsPlaceholder', defaultMessage: 'Search and add groups'})} /> ); } } + export default injectIntl(AddGroupsToTeamModal); diff --git a/webapp/channels/src/components/add_user_to_group_multiselect/__snapshots__/add_user_to_group_multiselect.test.tsx.snap b/webapp/channels/src/components/add_user_to_group_multiselect/__snapshots__/add_user_to_group_multiselect.test.tsx.snap index 1d43451063..ca6da7b7ee 100644 --- a/webapp/channels/src/components/add_user_to_group_multiselect/__snapshots__/add_user_to_group_multiselect.test.tsx.snap +++ b/webapp/channels/src/components/add_user_to_group_multiselect/__snapshots__/add_user_to_group_multiselect.test.tsx.snap @@ -70,7 +70,12 @@ exports[`component/add_user_to_group_multiselect should match snapshot with diff ] } perPage={50} - placeholderText="Search for people" + placeholderText={ + Object { + "defaultMessage": "Search for people", + "id": "multiselect.placeholder", + } + } saveButtonPosition="bottom" saving={false} savingEnabled={false} @@ -87,8 +92,18 @@ exports[`component/add_user_to_group_multiselect should match snapshot with diff exports[`component/add_user_to_group_multiselect should match snapshot with profiles 1`] = ` void; backButtonClass?: string; - backButtonText?: string; + backButtonText?: string | MessageDescriptor; actions: { getProfiles: (page?: number, perPage?: number) => Promise; @@ -196,8 +195,8 @@ export class AddUserToGroupMultiSelect extends React.PureComponent }; public render = (): JSX.Element => { - const buttonSubmitText = this.props.buttonSubmitText || localizeMessage({id: 'multiselect.createGroup', defaultMessage: 'Create Group'}); - const buttonSubmitLoadingText = this.props.buttonSubmitLoadingText || localizeMessage({id: 'multiselect.creating', defaultMessage: 'Creating...'}); + const buttonSubmitText = this.props.buttonSubmitText || defineMessage({id: 'multiselect.createGroup', defaultMessage: 'Create Group'}); + const buttonSubmitLoadingText = this.props.buttonSubmitLoadingText || defineMessage({id: 'multiselect.creating', defaultMessage: 'Creating...'}); let users = filterProfilesStartingWithTerm(this.props.profiles, this.state.term).filter((user) => { return user.delete_at === 0 && @@ -214,7 +213,7 @@ export class AddUserToGroupMultiSelect extends React.PureComponent if (this.state.values.length >= MAX_SELECTABLE_VALUES) { maxValues = MAX_SELECTABLE_VALUES; - numRemainingText = localizeMessage({id: 'multiselect.maxGroupMembers', defaultMessage: 'No more than 256 members can be added to a group at once.'}); + numRemainingText = defineMessage({id: 'multiselect.maxGroupMembers', defaultMessage: 'No more than 256 members can be added to a group at once.'}); } return ( @@ -237,7 +236,7 @@ export class AddUserToGroupMultiSelect extends React.PureComponent buttonSubmitLoadingText={buttonSubmitLoadingText} saving={this.props.saving} loading={this.state.loadingUsers} - placeholderText={localizeMessage({id: 'multiselect.placeholder', defaultMessage: 'Search for people'})} + placeholderText={defineMessage({id: 'multiselect.placeholder', defaultMessage: 'Search for people'})} valueWithImage={true} focusOnLoad={this.props.focusOnLoad} savingEnabled={this.props.savingEnabled} diff --git a/webapp/channels/src/components/add_users_to_group_modal/__snapshots__/add_users_to_group_modal.test.tsx.snap b/webapp/channels/src/components/add_users_to_group_modal/__snapshots__/add_users_to_group_modal.test.tsx.snap index a44cfcaecc..99adbebb93 100644 --- a/webapp/channels/src/components/add_users_to_group_modal/__snapshots__/add_users_to_group_modal.test.tsx.snap +++ b/webapp/channels/src/components/add_users_to_group_modal/__snapshots__/add_users_to_group_modal.test.tsx.snap @@ -84,8 +84,18 @@ exports[`component/add_users_to_group_modal should match snapshot 1`] = ` addUserCallback={[Function]} backButtonClass="multiselect-back" backButtonClick={[Function]} - buttonSubmitLoadingText="Adding..." - buttonSubmitText="Add People" + buttonSubmitLoadingText={ + Object { + "defaultMessage": "Adding...", + "id": "multiselect.adding", + } + } + buttonSubmitText={ + Object { + "defaultMessage": "Add People", + "id": "multiselect.addPeopleToGroup", + } + } deleteUserCallback={[Function]} focusOnLoad={false} groupId="groupid123" diff --git a/webapp/channels/src/components/add_users_to_group_modal/add_users_to_group_modal.tsx b/webapp/channels/src/components/add_users_to_group_modal/add_users_to_group_modal.tsx index d4c2ecff4c..8f0cc0e8a7 100644 --- a/webapp/channels/src/components/add_users_to_group_modal/add_users_to_group_modal.tsx +++ b/webapp/channels/src/components/add_users_to_group_modal/add_users_to_group_modal.tsx @@ -3,7 +3,7 @@ import React, {useState, useCallback, useMemo} from 'react'; import {Modal} from 'react-bootstrap'; -import {FormattedMessage, useIntl} from 'react-intl'; +import {defineMessage, FormattedMessage, useIntl} from 'react-intl'; import type {Group} from '@mattermost/types/groups'; import type {UserProfile} from '@mattermost/types/users'; @@ -12,8 +12,6 @@ import type {ActionResult} from 'mattermost-redux/types/actions'; import AddUserToGroupMultiSelect from 'components/add_user_to_group_multiselect'; -import {localizeMessage} from 'utils/utils'; - import type {ModalData} from 'types/actions'; import 'components/user_groups_modal/user_groups_modal.scss'; @@ -136,8 +134,8 @@ const AddUsersToGroupModal = (props: Props) => { deleteUserCallback={deleteUserCallback} groupId={props.groupId} searchOptions={searchOptions} - buttonSubmitText={localizeMessage({id: 'multiselect.addPeopleToGroup', defaultMessage: 'Add People'})} - buttonSubmitLoadingText={localizeMessage({id: 'multiselect.adding', defaultMessage: 'Adding...'})} + buttonSubmitText={defineMessage({id: 'multiselect.addPeopleToGroup', defaultMessage: 'Add People'})} + buttonSubmitLoadingText={defineMessage({id: 'multiselect.adding', defaultMessage: 'Adding...'})} backButtonClick={goBack} backButtonClass={'multiselect-back'} saving={saving} diff --git a/webapp/channels/src/components/add_users_to_team_modal/__snapshots__/add_users_to_team_modal.test.tsx.snap b/webapp/channels/src/components/add_users_to_team_modal/__snapshots__/add_users_to_team_modal.test.tsx.snap index ac88890e2d..66ea8edec8 100644 --- a/webapp/channels/src/components/add_users_to_team_modal/__snapshots__/add_users_to_team_modal.test.tsx.snap +++ b/webapp/channels/src/components/add_users_to_team_modal/__snapshots__/add_users_to_team_modal.test.tsx.snap @@ -57,8 +57,18 @@ exports[`components/admin_console/add_users_to_team_modal/AddUsersToTeamModal sh > { ); - const buttonSubmitText = localizeMessage({id: 'multiselect.add', defaultMessage: 'Add'}); - const buttonSubmitLoadingText = localizeMessage({id: 'multiselect.adding', defaultMessage: 'Adding...'}); + const buttonSubmitText = defineMessage({id: 'multiselect.add', defaultMessage: 'Add'}); + const buttonSubmitLoadingText = defineMessage({id: 'multiselect.adding', defaultMessage: 'Adding...'}); let addError = null; if (this.state.addError) { @@ -259,7 +259,7 @@ export class AddUsersToTeamModal extends React.PureComponent { buttonSubmitLoadingText={buttonSubmitLoadingText} saving={this.state.saving} loading={this.state.loading} - placeholderText={localizeMessage({id: 'multiselect.placeholder', defaultMessage: 'Search and add members'})} + placeholderText={defineMessage({id: 'multiselect.placeholder', defaultMessage: 'Search and add members'})} /> diff --git a/webapp/channels/src/components/admin_console/__snapshots__/custom_url_schemes_setting.test.tsx.snap b/webapp/channels/src/components/admin_console/__snapshots__/custom_url_schemes_setting.test.tsx.snap index 1a7d736254..588abefed0 100644 --- a/webapp/channels/src/components/admin_console/__snapshots__/custom_url_schemes_setting.test.tsx.snap +++ b/webapp/channels/src/components/admin_console/__snapshots__/custom_url_schemes_setting.test.tsx.snap @@ -4,44 +4,6 @@ exports[`components/AdminConsole/CustomUrlSchemeSetting initial state with multi + } inputId="MySetting" - label="Custom URL Schemes:" + label={ + + } setByEnv={false} >
- Custom URL Schemes: + + + Custom URL Schemes: + +
- + > + +
- Allows message text to link if it begins with any of the comma-separated URL schemes listed. By default, the following schemes will create links: "http", "https", "ftp", "tel", and "mailto". + + + Allows message text to link if it begins with any of the comma-separated URL schemes listed. By default, the following schemes will create links: "http", "https", "ftp", "tel", and "mailto". + +
@@ -96,52 +97,24 @@ exports[`components/AdminConsole/CustomUrlSchemeSetting initial state with no it + } inputId="MySetting" - label="Custom URL Schemes:" + label={ + + } setByEnv={false} >
- Custom URL Schemes: + + + Custom URL Schemes: + +
- + > + +
- Allows message text to link if it begins with any of the comma-separated URL schemes listed. By default, the following schemes will create links: "http", "https", "ftp", "tel", and "mailto". + + + Allows message text to link if it begins with any of the comma-separated URL schemes listed. By default, the following schemes will create links: "http", "https", "ftp", "tel", and "mailto". + +
@@ -182,44 +184,6 @@ exports[`components/AdminConsole/CustomUrlSchemeSetting initial state with one i + } inputId="MySetting" - label="Custom URL Schemes:" + label={ + + } setByEnv={false} >
- Custom URL Schemes: + + + Custom URL Schemes: + +
- + > + +
- Allows message text to link if it begins with any of the comma-separated URL schemes listed. By default, the following schemes will create links: "http", "https", "ftp", "tel", and "mailto". + + + Allows message text to link if it begins with any of the comma-separated URL schemes listed. By default, the following schemes will create links: "http", "https", "ftp", "tel", and "mailto". + +
@@ -272,44 +275,6 @@ exports[`components/AdminConsole/CustomUrlSchemeSetting renders properly when di + } inputId="MySetting" - label="Custom URL Schemes:" + label={ + + } setByEnv={false} >
- Custom URL Schemes: + + + Custom URL Schemes: + +
- + > + +
- Allows message text to link if it begins with any of the comma-separated URL schemes listed. By default, the following schemes will create links: "http", "https", "ftp", "tel", and "mailto". + + + Allows message text to link if it begins with any of the comma-separated URL schemes listed. By default, the following schemes will create links: "http", "https", "ftp", "tel", and "mailto". + +
@@ -363,44 +367,6 @@ exports[`components/AdminConsole/CustomUrlSchemeSetting renders properly when se + } inputId="MySetting" - label="Custom URL Schemes:" + label={ + + } setByEnv={true} >
- Custom URL Schemes: + + + Custom URL Schemes: + +
- + > + +
- Allows message text to link if it begins with any of the comma-separated URL schemes listed. By default, the following schemes will create links: "http", "https", "ftp", "tel", and "mailto". + + + Allows message text to link if it begins with any of the comma-separated URL schemes listed. By default, the following schemes will create links: "http", "https", "ftp", "tel", and "mailto". + +
= () => { type='text' value={address} onChange={updateState(setAddress)} - placeholder={Utils.localizeMessage({id: 'admin.billing.company_info.address', defaultMessage: 'Address'})} + placeholder={defineMessage({id: 'admin.billing.company_info.address', defaultMessage: 'Address'})} required={true} />
@@ -160,7 +158,7 @@ const CompanyInfoEdit: React.FC = () => { type='text' value={address2} onChange={updateState(setAddress2)} - placeholder={Utils.localizeMessage({id: 'admin.billing.company_info.address_2', defaultMessage: 'Address 2'})} + placeholder={defineMessage({id: 'admin.billing.company_info.address_2', defaultMessage: 'Address 2'})} />
@@ -169,7 +167,7 @@ const CompanyInfoEdit: React.FC = () => { type='text' value={city} onChange={updateState(setCity)} - placeholder={Utils.localizeMessage({id: 'admin.billing.company_info.city', defaultMessage: 'City'})} + placeholder={defineMessage({id: 'admin.billing.company_info.city', defaultMessage: 'City'})} required={true} />
@@ -190,7 +188,10 @@ const CompanyInfoEdit: React.FC = () => { type='text' value={postalCode} onChange={updateState(setPostalCode)} - placeholder={Utils.localizeMessage({id: 'admin.billing.company_info.zipcode', defaultMessage: 'Zip/Postal Code'})} + placeholder={defineMessage({ + id: 'admin.billing.company_info.zipcode', + defaultMessage: 'Zip/Postal Code', + })} required={true} />
@@ -228,7 +229,7 @@ const CompanyInfoEdit: React.FC = () => { type='text' value={companyName} onChange={updateState(setCompanyName)} - placeholder={Utils.localizeMessage({id: 'admin.billing.company_info.companyName', defaultMessage: 'Company name'})} + placeholder={defineMessage({id: 'admin.billing.company_info.companyName', defaultMessage: 'Company name'})} required={true} /> @@ -238,7 +239,7 @@ const CompanyInfoEdit: React.FC = () => { type='number' value={numEmployees} onChange={updateNumEmployees} - placeholder={Utils.localizeMessage({id: 'admin.billing.company_info.numEmployees', defaultMessage: 'Number of employees (optional)'})} + placeholder={defineMessage({id: 'admin.billing.company_info.numEmployees', defaultMessage: 'Number of employees (optional)'})} />
diff --git a/webapp/channels/src/components/admin_console/cluster_table.tsx b/webapp/channels/src/components/admin_console/cluster_table.tsx index 107a5b28cf..9593b7dc23 100644 --- a/webapp/channels/src/components/admin_console/cluster_table.tsx +++ b/webapp/channels/src/components/admin_console/cluster_table.tsx @@ -10,7 +10,6 @@ import WarningIcon from 'components/widgets/icons/fa_warning_icon'; import statusGreen from 'images/status_green.png'; import statusYellow from 'images/status_yellow.png'; -import * as Utils from 'utils/utils'; type Props = { clusterInfos: Array<{ @@ -97,16 +96,34 @@ export default class ClusterTable extends PureComponent { const items = this.props.clusterInfos.map((clusterInfo) => { let status = null; - if (clusterInfo.hostname === '') { - clusterInfo.hostname = Utils.localizeMessage({id: 'admin.cluster.unknown', defaultMessage: 'unknown'}); + let hostname: React.ReactNode = clusterInfo.hostname; + if (hostname === '') { + hostname = ( + + ); } - if (clusterInfo.version === '') { - clusterInfo.version = Utils.localizeMessage({id: 'admin.cluster.unknown', defaultMessage: 'unknown'}); + let version: React.ReactNode = clusterInfo.version; + if (version === '') { + version = ( + + ); } - if (clusterInfo.config_hash === '') { - clusterInfo.config_hash = Utils.localizeMessage({id: 'admin.cluster.unknown', defaultMessage: 'unknown'}); + let configHash: React.ReactNode = clusterInfo.config_hash; + if (configHash === '') { + configHash = ( + + ); } if (singleItem) { @@ -130,9 +147,9 @@ export default class ClusterTable extends PureComponent { return ( {status} - {clusterInfo.hostname} - {versionMismatch} {clusterInfo.version} -
{configMismatch} {clusterInfo.config_hash}
+ {hostname} + {versionMismatch} {version} +
{configMismatch} {configHash}
{clusterInfo.ipaddress} {clusterInfo.schema_version} diff --git a/webapp/channels/src/components/admin_console/compliance_reports/compliance_reports.tsx b/webapp/channels/src/components/admin_console/compliance_reports/compliance_reports.tsx index 16b534c8a2..5f500b279c 100644 --- a/webapp/channels/src/components/admin_console/compliance_reports/compliance_reports.tsx +++ b/webapp/channels/src/components/admin_console/compliance_reports/compliance_reports.tsx @@ -2,7 +2,7 @@ // See LICENSE.txt for license information. import React from 'react'; -import {FormattedDate, FormattedMessage, FormattedTime, type IntlShape, injectIntl} from 'react-intl'; +import {FormattedDate, FormattedMessage, FormattedTime, defineMessage} from 'react-intl'; import type {Compliance} from '@mattermost/types/compliance'; import type {UserProfile} from '@mattermost/types/users'; @@ -11,6 +11,7 @@ import {Client4} from 'mattermost-redux/client'; import type {ActionResult} from 'mattermost-redux/types/actions'; import LoadingScreen from 'components/loading_screen'; +import LocalizedPlaceholderInput from 'components/localized_placeholder_input'; import ReloadIcon from 'components/widgets/icons/fa_reload_icon'; type Props = { @@ -38,8 +39,6 @@ type Props = { readOnly?: boolean; - intl: IntlShape; - actions: { /* @@ -59,7 +58,7 @@ type State = { runningReport?: boolean; } -class ComplianceReports extends React.PureComponent { +export default class ComplianceReports extends React.PureComponent { private descInput: React.RefObject; private emailsInput: React.RefObject; private fromInput: React.RefObject; @@ -345,12 +344,12 @@ class ComplianceReports extends React.PureComponent { defaultMessage='Job Name:' /> -
@@ -361,12 +360,12 @@ class ComplianceReports extends React.PureComponent { defaultMessage='From:' /> - @@ -377,12 +376,12 @@ class ComplianceReports extends React.PureComponent { defaultMessage='To:' /> - @@ -395,12 +394,12 @@ class ComplianceReports extends React.PureComponent { defaultMessage='Emails:' /> - @@ -411,12 +410,12 @@ class ComplianceReports extends React.PureComponent { defaultMessage='Keywords:' /> - @@ -466,5 +465,3 @@ const style: Record = { date: {whiteSpace: 'nowrap'}, serverError: {marginTop: '10px'}, }; - -export default injectIntl(ComplianceReports); diff --git a/webapp/channels/src/components/admin_console/custom_url_schemes_setting.test.tsx b/webapp/channels/src/components/admin_console/custom_url_schemes_setting.test.tsx index 7aaf8dcc20..314085d392 100644 --- a/webapp/channels/src/components/admin_console/custom_url_schemes_setting.test.tsx +++ b/webapp/channels/src/components/admin_console/custom_url_schemes_setting.test.tsx @@ -3,10 +3,10 @@ import React from 'react'; -import CustomURLSchemesSetting from 'components/admin_console/custom_url_schemes_setting'; - import {mountWithIntl} from 'tests/helpers/intl-test-helper'; +import CustomURLSchemesSetting from './custom_url_schemes_setting'; + describe('components/AdminConsole/CustomUrlSchemeSetting', () => { const baseProps = { id: 'MySetting', diff --git a/webapp/channels/src/components/admin_console/custom_url_schemes_setting.tsx b/webapp/channels/src/components/admin_console/custom_url_schemes_setting.tsx index fecd5f9ec9..154e3acf77 100644 --- a/webapp/channels/src/components/admin_console/custom_url_schemes_setting.tsx +++ b/webapp/channels/src/components/admin_console/custom_url_schemes_setting.tsx @@ -3,7 +3,9 @@ import React, {PureComponent} from 'react'; import type {ChangeEvent} from 'react'; -import {injectIntl, type IntlShape} from 'react-intl'; +import {defineMessage, FormattedMessage} from 'react-intl'; + +import LocalizedPlaceholderInput from 'components/localized_placeholder_input'; import Setting from './setting'; @@ -13,15 +15,13 @@ type Props = { onChange: (id: string, valueAsArray: string[]) => void; disabled: boolean; setByEnv: boolean; - intl: IntlShape; } type State = { value: string; } -class CustomURLSchemesSetting extends - PureComponent { +export default class CustomURLSchemesSetting extends PureComponent { constructor(props: Props) { super(props); @@ -51,22 +51,26 @@ class CustomURLSchemesSetting extends render() { return ( + } + helpText={ + + } inputId={this.props.id} setByEnv={this.props.setByEnv} > - void; term?: string; - searchPlaceholder?: string; extraComponent?: JSX.Element; filterProps?: { options: FilterOptions; @@ -82,7 +81,6 @@ class DataGrid extends React.PureComponent { static defaultProps = { term: '', - searchPlaceholder: '', }; public constructor(props: Props) { @@ -206,7 +204,6 @@ class DataGrid extends React.PureComponent { return ( void; - placeholder?: string; term: string; extraComponent?: JSX.Element; @@ -30,7 +29,6 @@ type State = { class DataGridSearch extends React.PureComponent { static defaultProps = { - placeholder: '', term: '', }; @@ -59,11 +57,6 @@ class DataGridSearch extends React.PureComponent { render() { const {filterProps} = this.props; - let {placeholder} = this.props; - if (!placeholder) { - placeholder = Utils.localizeMessage({id: 'search_bar.search', defaultMessage: 'Search'}); - } - let filter; if (filterProps) { filter = ; @@ -79,9 +72,9 @@ class DataGridSearch extends React.PureComponent { - @@ -89,7 +94,12 @@ exports[`components/admin_console/data_retention_settings/custom_policy_form sho inputId="message_retention_input" inputType="number" inputValue="" - legend="Channel & direct message retention" + legend={ + Object { + "defaultMessage": "Channel & direct message retention", + "id": "admin.data_retention.form.channelAndDirectMessageRetention", + } + } name="message_retention" onDropdownChange={[Function]} onInputChange={[Function]} @@ -126,7 +136,12 @@ exports[`components/admin_console/data_retention_settings/custom_policy_form sho }, ] } - placeholder="Channel & direct message retention" + placeholder={ + Object { + "defaultMessage": "Channel & direct message retention", + "id": "admin.data_retention.form.channelAndDirectMessageRetention", + } + } value={ Object { "label":
@@ -312,7 +327,12 @@ exports[`components/admin_console/data_retention_settings/custom_policy_form sho } name="policyName" onChange={[Function]} - placeholder="Policy name" + placeholder={ + Object { + "defaultMessage": "Policy name", + "id": "admin.data_retention.custom_policy.form.input", + } + } type="text" value="" /> @@ -341,7 +361,12 @@ exports[`components/admin_console/data_retention_settings/custom_policy_form sho inputId="message_retention_input" inputType="number" inputValue="22" - legend="Channel & direct message retention" + legend={ + Object { + "defaultMessage": "Channel & direct message retention", + "id": "admin.data_retention.form.channelAndDirectMessageRetention", + } + } name="message_retention" onDropdownChange={[Function]} onInputChange={[Function]} @@ -378,7 +403,12 @@ exports[`components/admin_console/data_retention_settings/custom_policy_form sho }, ] } - placeholder="Channel & direct message retention" + placeholder={ + Object { + "defaultMessage": "Channel & direct message retention", + "id": "admin.data_retention.form.channelAndDirectMessageRetention", + } + } value={ Object { "label": { @@ -235,7 +234,15 @@ export default class CustomPolicyForm extends React.PureComponent let postDuration = parseInt(messageRetentionInputValue, 10); if (postDuration <= 0) { - this.setState({formErrorText: Utils.localizeMessage({id: 'admin.data_retention.custom_policy.form.durationInput.error', defaultMessage: 'Error parsing message retention.'}), saving: false}); + this.setState({ + formErrorText: ( + + ), + saving: false, + }); return; } if (messageRetentionDropdownValue.value === FOREVER) { @@ -245,7 +252,15 @@ export default class CustomPolicyForm extends React.PureComponent } if (!policyName?.trim()) { - this.setState({inputErrorText: Utils.localizeMessage({id: 'admin.data_retention.custom_policy.form.input.error', defaultMessage: 'Policy name can\'t be blank.'}), saving: false}); + this.setState({ + inputErrorText: ( + + ), + saving: false, + }); return; } @@ -256,7 +271,15 @@ export default class CustomPolicyForm extends React.PureComponent }; if (((policy?.team_count + teamsToAdd.length) - teamsToRemove.length) === 0 && ((policy?.channel_count + channelsToAdd.length) - channelsToRemove.length) === 0) { - this.setState({formErrorText: Utils.localizeMessage({id: 'admin.data_retention.custom_policy.form.teamsError', defaultMessage: 'You must add a team or a channel to the policy.'}), saving: false}); + this.setState({ + formErrorText: ( + + ), + saving: false, + }); return; } @@ -282,7 +305,15 @@ export default class CustomPolicyForm extends React.PureComponent } } else { if (teamsToAdd.length < 1 && channelsToAdd.length < 1) { - this.setState({formErrorText: Utils.localizeMessage({id: 'admin.data_retention.custom_policy.form.teamsError', defaultMessage: 'You must add a team or a channel to the policy.'}), saving: false}); + this.setState({ + formErrorText: ( + + ), + saving: false, + }); return; } const newPolicy = { @@ -359,7 +390,7 @@ export default class CustomPolicyForm extends React.PureComponent this.setState({policyName: e.target.value, saveNeeded: true}); this.props.actions.setNavigationBlocked(true); }} - placeholder={Utils.localizeMessage({id: 'admin.data_retention.custom_policy.form.input', defaultMessage: 'Policy name'})} + placeholder={messages.policyName} customMessage={{type: ItemStatus.ERROR, value: this.state.inputErrorText}} /> exceptionToInput={[FOREVER]} defaultValue={keepForeverOption()} options={[daysOption(), yearsOption(), keepForeverOption()]} - legend={Utils.localizeMessage({id: 'admin.data_retention.form.channelAndDirectMessageRetention', defaultMessage: 'Channel & direct message retention'})} - placeholder={Utils.localizeMessage({id: 'admin.data_retention.form.channelAndDirectMessageRetention', defaultMessage: 'Channel & direct message retention'})} + legend={messages.channelAndDirectMessageRetention} + placeholder={messages.channelAndDirectMessageRetention} inputType={'number'} name={'message_retention'} dropdownClassNamePrefix={'message_retention'} @@ -535,3 +566,14 @@ export default class CustomPolicyForm extends React.PureComponent ); }; } + +const messages = defineMessages({ + channelAndDirectMessageRetention: { + id: 'admin.data_retention.form.channelAndDirectMessageRetention', + defaultMessage: 'Channel & direct message retention', + }, + policyName: { + id: 'admin.data_retention.custom_policy.form.input', + defaultMessage: 'Policy name', + }, +}); diff --git a/webapp/channels/src/components/admin_console/data_retention_settings/global_policy_form/__snapshots__/global_policy_form.test.tsx.snap b/webapp/channels/src/components/admin_console/data_retention_settings/global_policy_form/__snapshots__/global_policy_form.test.tsx.snap index 520cbd60ab..98e3661e88 100644 --- a/webapp/channels/src/components/admin_console/data_retention_settings/global_policy_form/__snapshots__/global_policy_form.test.tsx.snap +++ b/webapp/channels/src/components/admin_console/data_retention_settings/global_policy_form/__snapshots__/global_policy_form.test.tsx.snap @@ -33,7 +33,10 @@ exports[`components/PluginManagement should match snapshot 1`] = ` className="global_policy" >

- Applies to all teams and channels, but does not apply to custom retention policies. +

{ @@ -103,7 +102,15 @@ export default class GlobalPolicyForm extends React.PureComponent this.setState({saving: true}); if ((messageRetentionDropdownValue.value !== FOREVER && parseInt(messageRetentionInputValue, 10) < 1) || (fileRetentionDropdownValue.value !== FOREVER && parseInt(fileRetentionInputValue, 10) < 1)) { - this.setState({formErrorText: Utils.localizeMessage({id: 'admin.data_retention.global_policy.form.numberError', defaultMessage: 'You must add a number greater than or equal to 1.'}), saving: false}); + this.setState({ + formErrorText: ( + + ), + saving: false, + }); return; } @@ -185,7 +192,12 @@ export default class GlobalPolicyForm extends React.PureComponent
-

{Utils.localizeMessage({id: 'admin.data_retention.form.text', defaultMessage: 'Applies to all teams and channels, but does not apply to custom retention policies.'})}

+

+ +

{ @@ -205,8 +217,8 @@ export default class GlobalPolicyForm extends React.PureComponent disabled={this.isMessageRetentionSetByEnv()} defaultValue={keepForeverOption()} options={[hoursOption(), daysOption(), yearsOption(), keepForeverOption()]} - legend={Utils.localizeMessage({id: 'admin.data_retention.form.channelAndDirectMessageRetention', defaultMessage: 'Channel & direct message retention'})} - placeholder={Utils.localizeMessage({id: 'admin.data_retention.form.channelAndDirectMessageRetention', defaultMessage: 'Channel & direct message retention'})} + legend={messages.channelAndMessageRetention} + placeholder={messages.channelAndMessageRetention} name={'channel_message_retention'} inputType={'number'} dropdownClassNamePrefix={'channel_message_retention_dropdown'} @@ -233,8 +245,8 @@ export default class GlobalPolicyForm extends React.PureComponent disabled={this.isFileRetentionSetByEnv()} defaultValue={keepForeverOption()} options={[hoursOption(), daysOption(), yearsOption(), keepForeverOption()]} - legend={Utils.localizeMessage({id: 'admin.data_retention.form.fileRetention', defaultMessage: 'File retention'})} - placeholder={Utils.localizeMessage({id: 'admin.data_retention.form.fileRetention', defaultMessage: 'File retention'})} + legend={messages.fileRetention} + placeholder={messages.fileRetention} name={'file_retention'} inputType={'number'} dropdownClassNamePrefix={'file_retention_dropdown'} @@ -287,3 +299,14 @@ export default class GlobalPolicyForm extends React.PureComponent ); }; } + +const messages = defineMessages({ + channelAndMessageRetention: { + id: 'admin.data_retention.form.channelAndDirectMessageRetention', + defaultMessage: 'Channel & direct message retention', + }, + fileRetention: { + id: 'admin.data_retention.form.fileRetention', + defaultMessage: 'File retention', + }, +}); diff --git a/webapp/channels/src/components/admin_console/data_retention_settings/team_list/__snapshots__/team_list.test.tsx.snap b/webapp/channels/src/components/admin_console/data_retention_settings/team_list/__snapshots__/team_list.test.tsx.snap index 64fc627794..ac2dd2db98 100644 --- a/webapp/channels/src/components/admin_console/data_retention_settings/team_list/__snapshots__/team_list.test.tsx.snap +++ b/webapp/channels/src/components/admin_console/data_retention_settings/team_list/__snapshots__/team_list.test.tsx.snap @@ -65,13 +65,15 @@ exports[`components/admin_console/data_retention_settings/team_list should match id="remove-team-team-1" onClick={[Function]} > - Remove + , }, }, ] } - searchPlaceholder="" startCount={1} term="" total={1} @@ -144,7 +146,10 @@ exports[`components/admin_console/data_retention_settings/team_list should match id="remove-team-id0" onClick={[Function]} > - Remove + , }, }, @@ -180,7 +185,10 @@ exports[`components/admin_console/data_retention_settings/team_list should match id="remove-team-id1" onClick={[Function]} > - Remove + , }, }, @@ -216,7 +224,10 @@ exports[`components/admin_console/data_retention_settings/team_list should match id="remove-team-id2" onClick={[Function]} > - Remove + , }, }, @@ -252,7 +263,10 @@ exports[`components/admin_console/data_retention_settings/team_list should match id="remove-team-id3" onClick={[Function]} > - Remove + , }, }, @@ -288,7 +302,10 @@ exports[`components/admin_console/data_retention_settings/team_list should match id="remove-team-id4" onClick={[Function]} > - Remove + , }, }, @@ -324,7 +341,10 @@ exports[`components/admin_console/data_retention_settings/team_list should match id="remove-team-id5" onClick={[Function]} > - Remove + , }, }, @@ -360,7 +380,10 @@ exports[`components/admin_console/data_retention_settings/team_list should match id="remove-team-id6" onClick={[Function]} > - Remove + , }, }, @@ -396,7 +419,10 @@ exports[`components/admin_console/data_retention_settings/team_list should match id="remove-team-id7" onClick={[Function]} > - Remove + , }, }, @@ -432,7 +458,10 @@ exports[`components/admin_console/data_retention_settings/team_list should match id="remove-team-id8" onClick={[Function]} > - Remove + , }, }, @@ -468,13 +497,15 @@ exports[`components/admin_console/data_retention_settings/team_list should match id="remove-team-id9" onClick={[Function]} > - Remove + , }, }, ] } - searchPlaceholder="" startCount={1} term="" total={30} diff --git a/webapp/channels/src/components/admin_console/data_retention_settings/team_list/team_list.tsx b/webapp/channels/src/components/admin_console/data_retention_settings/team_list/team_list.tsx index 5b4793d7f1..12ee21f3a7 100644 --- a/webapp/channels/src/components/admin_console/data_retention_settings/team_list/team_list.tsx +++ b/webapp/channels/src/components/admin_console/data_retention_settings/team_list/team_list.tsx @@ -199,7 +199,10 @@ export default class TeamList extends React.PureComponent { }} href='#' > - {Utils.localizeMessage({id: 'admin.data_retention.custom_policy.teams.remove', defaultMessage: 'Remove'})} + ), }, diff --git a/webapp/channels/src/components/admin_console/feature_discovery/feature_discovery.tsx b/webapp/channels/src/components/admin_console/feature_discovery/feature_discovery.tsx index 505865ee37..59247a2b67 100644 --- a/webapp/channels/src/components/admin_console/feature_discovery/feature_discovery.tsx +++ b/webapp/channels/src/components/admin_console/feature_discovery/feature_discovery.tsx @@ -20,7 +20,6 @@ import LoadingSpinner from 'components/widgets/loading/loading_spinner'; import {TELEMETRY_CATEGORIES, AboutLinks, LicenseLinks, LicenseSkus} from 'utils/constants'; import {goToMattermostContactSalesForm} from 'utils/contact_support_sales'; -import * as Utils from 'utils/utils'; import type {ModalData} from 'types/actions'; @@ -146,10 +145,6 @@ export default class FeatureDiscovery extends React.PureComponent // by default we assume is not cloud, so the cta button is Start Trial (which will request a trial license) let ctaPrimaryButton = ( - @@ -72,10 +77,15 @@ exports[`components/admin_console/group_settings/GroupsList.tsx should match sna
- @@ -209,10 +219,15 @@ exports[`components/admin_console/group_settings/GroupsList.tsx should match sna
- @@ -334,10 +349,15 @@ exports[`components/admin_console/group_settings/GroupsList.tsx should match sna
- @@ -459,10 +479,15 @@ exports[`components/admin_console/group_settings/GroupsList.tsx should match sna
- @@ -584,10 +609,15 @@ exports[`components/admin_console/group_settings/GroupsList.tsx should match sna
- @@ -744,10 +774,15 @@ exports[`components/admin_console/group_settings/GroupsList.tsx should match sna
- @@ -995,10 +1030,15 @@ exports[`components/admin_console/group_settings/GroupsList.tsx should match sna
- @@ -1246,10 +1286,15 @@ exports[`components/admin_console/group_settings/GroupsList.tsx should match sna
- @@ -1406,10 +1451,15 @@ exports[`components/admin_console/group_settings/GroupsList.tsx should match sna
- @@ -1469,10 +1519,15 @@ exports[`components/admin_console/group_settings/GroupsList.tsx should match sna
- diff --git a/webapp/channels/src/components/admin_console/group_settings/groups_list/groups_list.tsx b/webapp/channels/src/components/admin_console/group_settings/groups_list/groups_list.tsx index 5d61eca174..b5a1d9f9cd 100644 --- a/webapp/channels/src/components/admin_console/group_settings/groups_list/groups_list.tsx +++ b/webapp/channels/src/components/admin_console/group_settings/groups_list/groups_list.tsx @@ -2,20 +2,20 @@ // See LICENSE.txt for license information. import React from 'react'; -import {FormattedMessage} from 'react-intl'; +import {defineMessage, FormattedMessage} from 'react-intl'; import type {GroupSearchOpts, MixedUnlinkedGroupRedux} from '@mattermost/types/groups'; import type {ActionResult} from 'mattermost-redux/types/actions'; import GroupRow from 'components/admin_console/group_settings/group_row'; +import LocalizedPlaceholderInput from 'components/localized_placeholder_input'; import CheckboxCheckedIcon from 'components/widgets/icons/checkbox_checked_icon'; import NextIcon from 'components/widgets/icons/fa_next_icon'; import PreviousIcon from 'components/widgets/icons/fa_previous_icon'; import SearchIcon from 'components/widgets/icons/search_icon'; import {Constants} from 'utils/constants'; -import * as Utils from 'utils/utils'; const LDAP_GROUPS_PAGE_SIZE = 200; @@ -469,9 +469,9 @@ export default class GroupsList extends React.PureComponent {
- this.handleGroupSearchKeyUp(e)} onChange={(e) => this.setState({searchString: e.target.value})} value={this.state.searchString} diff --git a/webapp/channels/src/components/admin_console/license_settings/modals/upload_license_modal.tsx b/webapp/channels/src/components/admin_console/license_settings/modals/upload_license_modal.tsx index 9697d060fc..01df29f8fe 100644 --- a/webapp/channels/src/components/admin_console/license_settings/modals/upload_license_modal.tsx +++ b/webapp/channels/src/components/admin_console/license_settings/modals/upload_license_modal.tsx @@ -3,7 +3,7 @@ import marked from 'marked'; import React, {useRef} from 'react'; -import {FormattedDate, FormattedMessage} from 'react-intl'; +import {defineMessage, FormattedDate, FormattedMessage} from 'react-intl'; import {useSelector, useDispatch} from 'react-redux'; import {GenericModal} from '@mattermost/components'; @@ -25,7 +25,7 @@ import LoadingWrapper from 'components/widgets/loading/loading_wrapper'; import {FileTypes, ModalIdentifiers} from 'utils/constants'; import {getMonthLong} from 'utils/i18n'; import {getSkuDisplayName} from 'utils/subscription'; -import {fileSizeToString, localizeMessage} from 'utils/utils'; +import {fileSizeToString} from 'utils/utils'; import type {GlobalState} from 'types/store'; @@ -205,7 +205,7 @@ const UploadLicenseModal = (props: Props): JSX.Element | null => { > { + const {formatMessage} = useIntl(); + const makeTeamAdmin = async () => { const {error} = await props.updateTeamMemberSchemeRoles(props.teamMember.team_id, props.user.id, true, true); if (error) { @@ -62,13 +62,13 @@ const ManageTeamsDropdown = (props: Props) => { const {team} = props; let title; if (isSysAdmin) { - title = localizeMessage({id: 'admin.user_item.sysAdmin', defaultMessage: 'System Admin'}); + title = formatMessage({id: 'admin.user_item.sysAdmin', defaultMessage: 'System Admin'}); } else if (isTeamAdmin) { - title = localizeMessage({id: 'admin.user_item.teamAdmin', defaultMessage: 'Team Admin'}); + title = formatMessage({id: 'admin.user_item.teamAdmin', defaultMessage: 'Team Admin'}); } else if (isGuestUser) { - title = localizeMessage({id: 'admin.user_item.guest', defaultMessage: 'Guest'}); + title = formatMessage({id: 'admin.user_item.guest', defaultMessage: 'Guest'}); } else { - title = localizeMessage({id: 'admin.user_item.teamMember', defaultMessage: 'Team Member'}); + title = formatMessage({id: 'admin.user_item.teamMember', defaultMessage: 'Team Member'}); } return ( @@ -79,22 +79,22 @@ const ManageTeamsDropdown = (props: Props) => { diff --git a/webapp/channels/src/components/admin_console/member_list_group/__snapshots__/member_list_group.test.tsx.snap b/webapp/channels/src/components/admin_console/member_list_group/__snapshots__/member_list_group.test.tsx.snap index 7acc8db1cb..ab99e47469 100644 --- a/webapp/channels/src/components/admin_console/member_list_group/__snapshots__/member_list_group.test.tsx.snap +++ b/webapp/channels/src/components/admin_console/member_list_group/__snapshots__/member_list_group.test.tsx.snap @@ -512,7 +512,6 @@ exports[`admin_console/team_channel_settings/group/GroupList should match snapsh }, ] } - searchPlaceholder="" startCount={1} term="" total={15} @@ -549,7 +548,6 @@ exports[`admin_console/team_channel_settings/group/GroupList should match snapsh } previousPage={[Function]} rows={Array []} - searchPlaceholder="" startCount={1} term="" total={0} diff --git a/webapp/channels/src/components/admin_console/permission_schemes_settings/permission_schemes_settings.test.tsx b/webapp/channels/src/components/admin_console/permission_schemes_settings/permission_schemes_settings.test.tsx index 59cbd0098b..1c0fa48d26 100644 --- a/webapp/channels/src/components/admin_console/permission_schemes_settings/permission_schemes_settings.test.tsx +++ b/webapp/channels/src/components/admin_console/permission_schemes_settings/permission_schemes_settings.test.tsx @@ -1,6 +1,7 @@ // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. +import {shallow} from 'enzyme'; import React from 'react'; import type {ComponentProps} from 'react'; import type {RouteComponentProps} from 'react-router-dom'; @@ -9,8 +10,6 @@ import type {Scheme} from '@mattermost/types/schemes'; import PermissionSchemesSettings from 'components/admin_console/permission_schemes_settings/permission_schemes_settings'; -import {shallowWithIntl} from 'tests/helpers/intl-test-helper'; - describe('components/admin_console/permission_schemes_settings/permission_schemes_settings', () => { const defaultProps: ComponentProps = { schemes: { @@ -32,14 +31,14 @@ describe('components/admin_console/permission_schemes_settings/permission_scheme }; test('should match snapshot loading', () => { - const wrapper = shallowWithIntl( + const wrapper = shallow( , ); expect(wrapper).toMatchSnapshot(); }); test('should match snapshot without schemes', () => { - const wrapper = shallowWithIntl( + const wrapper = shallow( { - const wrapper = shallowWithIntl( + const wrapper = shallow( , ); wrapper.setState({loading: false, phase2MigrationIsComplete: true}); @@ -58,7 +57,7 @@ describe('components/admin_console/permission_schemes_settings/permission_scheme }); test('should show migration in-progress view', () => { - const wrapper = shallowWithIntl( + const wrapper = shallow( , ); wrapper.setState({loading: false, phase2MigrationIsComplete: false}); @@ -68,7 +67,7 @@ describe('components/admin_console/permission_schemes_settings/permission_scheme test('should show migration on hold view', () => { const testProps = {...defaultProps}; testProps.jobsAreEnabled = false; - const wrapper = shallowWithIntl( + const wrapper = shallow( , ); wrapper.setState({loading: false, phase2MigrationIsComplete: false}); @@ -78,7 +77,7 @@ describe('components/admin_console/permission_schemes_settings/permission_scheme test('should show normal view (jobs disabled after migration)', () => { const testProps = {...defaultProps}; testProps.jobsAreEnabled = false; - const wrapper = shallowWithIntl( + const wrapper = shallow( , ); wrapper.setState({loading: false, phase2MigrationIsComplete: true}); diff --git a/webapp/channels/src/components/admin_console/permission_schemes_settings/permission_schemes_settings.tsx b/webapp/channels/src/components/admin_console/permission_schemes_settings/permission_schemes_settings.tsx index 112e6a25bd..11d7229d69 100644 --- a/webapp/channels/src/components/admin_console/permission_schemes_settings/permission_schemes_settings.tsx +++ b/webapp/channels/src/components/admin_console/permission_schemes_settings/permission_schemes_settings.tsx @@ -2,7 +2,7 @@ // See LICENSE.txt for license information. import React from 'react'; -import {injectIntl, type MessageDescriptor, type WrappedComponentProps} from 'react-intl'; +import {type MessageDescriptor} from 'react-intl'; import {FormattedMessage, defineMessage, defineMessages} from 'react-intl'; import type {RouteComponentProps} from 'react-router-dom'; @@ -36,7 +36,7 @@ export type Props = { loadSchemeTeams: (id: string) => Promise; }; isDisabled?: boolean; -} & WrappedComponentProps; +}; type State = { loading: boolean; @@ -69,7 +69,7 @@ export const searchableStrings = [ messages.teamOverrideSchemesNewButton, ]; -class PermissionSchemesSettings extends React.PureComponent { +export default class PermissionSchemesSettings extends React.PureComponent { constructor(props: Props & RouteComponentProps) { super(props); this.state = { @@ -213,7 +213,7 @@ class PermissionSchemesSettings extends React.PureComponent @@ -287,5 +287,3 @@ class PermissionSchemesSettings extends React.PureComponent - @@ -120,11 +126,17 @@ exports[`components/admin_console/permission_schemes_settings/permission_team_sc id="admin.permissions.teamScheme.schemeDescriptionLabel" /> -