From 7a9bcc1e1e85a94e529f254fb4ee83633446e410 Mon Sep 17 00:00:00 2001 From: Alex Corey Date: Fri, 30 Apr 2021 08:48:11 -0400 Subject: [PATCH] Removes remaining I18n props, HOCs and mics objects --- awx/ui_next/CONTRIBUTING.md | 10 +- awx/ui_next/src/App.jsx | 4 +- awx/ui_next/src/components/About/About.jsx | 11 +- .../AdHocCommands/AdHocCommands.jsx | 28 +- .../AdHocCommands/AdHocCredentialStep.jsx | 26 +- .../AdHocCommands/AdHocDetailsStep.jsx | 102 +++---- .../AddDropDownButton/AddDropDownButton.jsx | 7 +- .../components/AddRole/AddResourceRole.jsx | 61 ++-- .../components/AddRole/SelectResourceStep.jsx | 8 +- .../src/components/AddRole/SelectRoleStep.jsx | 10 +- .../src/components/AlertModal/AlertModal.jsx | 8 +- .../AnsibleSelect/AnsibleSelect.jsx | 8 +- .../components/AppContainer/AppContainer.jsx | 26 +- .../AppContainer/PageHeaderToolbar.jsx | 27 +- .../AssociateModal/AssociateModal.jsx | 27 +- .../src/components/ChipGroup/ChipGroup.jsx | 13 +- .../src/components/CodeEditor/CodeEditor.jsx | 7 +- .../components/CodeEditor/VariablesDetail.jsx | 35 +-- .../components/CodeEditor/VariablesField.jsx | 25 +- .../components/ContentEmpty/ContentEmpty.jsx | 8 +- .../components/ContentError/ContentError.jsx | 18 +- .../src/components/CopyButton/CopyButton.jsx | 12 +- .../CredentialChip/CredentialChip.jsx | 10 +- .../DataListToolbar/DataListToolbar.jsx | 12 +- .../components/DeleteButton/DeleteButton.jsx | 26 +- .../components/DetailList/DeletedDetail.jsx | 8 +- .../DetailList/LaunchedByDetail.jsx | 4 +- .../DisassociateButton/DisassociateButton.jsx | 33 +-- .../components/ErrorDetail/ErrorDetail.jsx | 8 +- .../ExecutionEnvironmentDetail.jsx | 15 +- .../ExpandCollapse/ExpandCollapse.jsx | 10 +- .../FieldWithPrompt/FieldWithPrompt.jsx | 8 +- .../FormActionGroup/FormActionGroup.jsx | 14 +- .../components/FormField/PasswordInput.jsx | 20 +- .../src/components/HostForm/HostForm.jsx | 28 +- .../src/components/HostToggle/HostToggle.jsx | 21 +- .../InstanceToggle/InstanceToggle.jsx | 26 +- .../JobList/JobListCancelButton.jsx | 16 +- .../src/components/JobList/JobListItem.jsx | 59 ++-- .../components/LaunchButton/LaunchButton.jsx | 10 +- .../LaunchButton/ReLaunchDropDown.jsx | 24 +- .../components/LaunchPrompt/LaunchPrompt.jsx | 23 +- .../steps/CredentialPasswordsStep.jsx | 16 +- .../LaunchPrompt/steps/CredentialsStep.jsx | 21 +- .../LaunchPrompt/steps/InventoryStep.jsx | 16 +- .../LaunchPrompt/steps/OtherPromptsStep.jsx | 90 +++--- .../LaunchPrompt/steps/PreviewStep.jsx | 16 +- .../LaunchPrompt/steps/StepName.jsx | 8 +- .../LaunchPrompt/steps/SurveyStep.jsx | 33 +-- .../steps/credentialsValidator.jsx | 17 +- .../steps/useCredentialPasswordsStep.jsx | 10 +- .../LaunchPrompt/steps/useCredentialsStep.jsx | 10 +- .../LaunchPrompt/steps/useInventoryStep.jsx | 15 +- .../steps/useOtherPromptsStep.jsx | 10 +- .../LaunchPrompt/steps/usePreviewStep.jsx | 6 +- .../LaunchPrompt/steps/useSurveyStep.jsx | 21 +- .../components/LaunchPrompt/useLaunchSteps.js | 13 +- .../components/Lookup/ApplicationLookup.jsx | 22 +- .../components/Lookup/CredentialLookup.jsx | 14 +- .../Lookup/ExecutionEnvironmentLookup.jsx | 20 +- .../components/Lookup/HostFilterLookup.jsx | 57 ++-- .../src/components/Lookup/HostListItem.jsx | 10 +- .../Lookup/InstanceGroupsLookup.jsx | 26 +- .../src/components/Lookup/InventoryLookup.jsx | 36 +-- awx/ui_next/src/components/Lookup/Lookup.jsx | 18 +- .../Lookup/MultiCredentialsLookup.jsx | 26 +- .../components/Lookup/OrganizationLookup.jsx | 20 +- .../src/components/Lookup/ProjectLookup.jsx | 34 +-- .../Lookup/shared/LookupErrorMessage.jsx | 8 +- .../NotificationList/NotificationList.jsx | 50 ++-- .../NotificationList/NotificationListItem.jsx | 41 ++- .../components/OptionsList/OptionsList.jsx | 8 +- .../PaginatedDataList/PaginatedDataList.jsx | 18 +- .../PaginatedDataList/ToolbarAddButton.jsx | 8 +- .../PaginatedTable/PaginatedTable.jsx | 14 +- .../src/components/Pagination/Pagination.jsx | 26 +- .../src/components/Popover/Popover.jsx | 17 +- .../components/PromptDetail/PromptDetail.jsx | 64 ++--- .../PromptInventorySourceDetail.jsx | 56 ++-- .../PromptDetail/PromptJobTemplateDetail.jsx | 97 +++---- .../PromptDetail/PromptProjectDetail.jsx | 51 ++-- .../PromptWFJobTemplateDetail.jsx | 46 ++- .../DeleteRoleConfirmationModal.jsx | 36 +-- .../ResourceAccessList/ResourceAccessList.jsx | 31 +- .../ResourceAccessListItem.jsx | 14 +- .../src/components/Schedule/Schedule.jsx | 12 +- .../Schedule/ScheduleAdd/ScheduleAdd.jsx | 7 +- .../ScheduleDetail/ScheduleDetail.jsx | 90 +++--- .../Schedule/ScheduleEdit/ScheduleEdit.jsx | 7 +- .../Schedule/ScheduleList/ScheduleList.jsx | 34 +-- .../ScheduleList/ScheduleListItem.jsx | 31 +- .../ScheduleOccurrences.jsx | 10 +- .../ScheduleToggle/ScheduleToggle.jsx | 20 +- .../src/components/Schedule/Schedules.jsx | 4 +- .../shared/FrequencyDetailSubform.jsx | 132 ++++----- .../Schedule/shared/ScheduleForm.jsx | 72 +++-- .../shared/SchedulePromptableFields.jsx | 19 +- .../Schedule/shared/buildRuleObj.js | 10 +- .../Schedule/shared/useSchedulePromptSteps.js | 15 +- .../components/ScreenHeader/ScreenHeader.jsx | 10 +- .../src/components/Search/AdvancedSearch.jsx | 92 +++--- awx/ui_next/src/components/Search/Search.jsx | 18 +- awx/ui_next/src/components/Sort/Sort.jsx | 8 +- .../src/components/Sparkline/Sparkline.jsx | 14 +- .../TemplateList/TemplateListItem.jsx | 59 ++-- .../UserAndTeamAccessAdd.jsx | 34 +-- .../getResourceAccessConfig.js | 94 +++--- .../components/Workflow/WorkflowLegend.jsx | 26 +- .../components/Workflow/WorkflowLinkHelp.jsx | 14 +- .../components/Workflow/WorkflowNodeHelp.jsx | 56 ++-- .../components/Workflow/WorkflowStartNode.jsx | 9 +- .../src/components/Workflow/WorkflowTools.jsx | 23 +- .../components/Workflow/workflowReducer.js | 13 +- .../Workflow/workflowReducer.test.js | 6 +- awx/ui_next/src/contexts/Config.jsx | 10 +- .../src/{routeConfig.js => routeConfig.jsx} | 59 ++-- .../screens/ActivityStream/ActivityStream.jsx | 74 ++--- .../ActivityStreamDescription.jsx | 15 +- .../ActivityStreamDetailButton.jsx | 27 +- .../ActivityStream/ActivityStreamListItem.jsx | 20 +- .../Application/Application/Application.jsx | 18 +- .../ApplicationDetails/ApplicationDetails.jsx | 38 ++- .../ApplicationTokenList.jsx | 26 +- .../ApplicationTokenListItem.jsx | 22 +- .../src/screens/Application/Applications.jsx | 56 ++-- .../ApplicationsList/ApplicationListItem.jsx | 19 +- .../ApplicationsList/ApplicationsList.jsx | 26 +- .../Application/shared/ApplicationForm.jsx | 38 ++- .../src/screens/Credential/Credential.jsx | 22 +- .../CredentialDetail/CredentialDetail.jsx | 44 ++- .../CredentialList/CredentialListItem.jsx | 22 +- .../src/screens/Credential/Credentials.jsx | 39 ++- .../Credential/shared/CredentialForm.jsx | 47 ++- .../CredentialFormFields/CredentialField.jsx | 27 +- .../GceFileUploadField.jsx | 26 +- .../CredentialPluginField.jsx | 14 +- .../CredentialPluginPrompt.jsx | 32 +-- .../CredentialsStep.jsx | 14 +- .../CredentialPluginPrompt/MetadataStep.jsx | 10 +- .../CredentialPluginSelected.jsx | 9 +- .../CredentialPluginTestAlert.jsx | 13 +- .../Credential/shared/ExternalTestModal.jsx | 15 +- .../Credential/shared/TypeInputsSubForm.jsx | 13 +- .../screens/CredentialType/CredentialType.jsx | 14 +- .../CredentialTypeDetails.jsx | 36 ++- .../CredentialTypeListItem.jsx | 15 +- .../CredentialType/CredentialTypes.jsx | 39 ++- .../shared/CredentialTypeForm.jsx | 24 +- .../src/screens/Dashboard/Dashboard.jsx | 60 ++-- .../screens/Dashboard/shared/ChartTooltip.jsx | 10 +- .../screens/Dashboard/shared/LineChart.jsx | 11 +- .../ExecutionEnvironment.jsx | 16 +- .../ExecutionEnvironmentDetails.jsx | 44 ++- .../ExecutionEnvironmentListItem.jsx | 26 +- .../ExecutionEnvironmentTemplateList.jsx | 26 +- .../ExecutionEnvironmentTemplateListItem.jsx | 16 +- .../ExecutionEnvironments.jsx | 43 ++- .../shared/ExecutionEnvironmentForm.jsx | 39 +-- awx/ui_next/src/screens/Host/Host.jsx | 24 +- .../screens/Host/HostDetail/HostDetail.jsx | 38 ++- .../src/screens/Host/HostFacts/HostFacts.jsx | 8 +- .../screens/Host/HostGroups/HostGroupItem.jsx | 10 +- .../screens/Host/HostGroups/HostGroups.jsx | 4 +- .../Host/HostGroups/HostGroupsList.jsx | 34 +-- .../src/screens/Host/HostList/HostList.jsx | 28 +- .../screens/Host/HostList/HostListItem.jsx | 25 +- .../Host/HostList/SmartInventoryButton.jsx | 18 +- awx/ui_next/src/screens/Host/Hosts.jsx | 43 ++- .../screens/InstanceGroup/ContainerGroup.jsx | 18 +- .../ContainerGroupDetails.jsx | 34 ++- .../screens/InstanceGroup/InstanceGroup.jsx | 20 +- .../InstanceGroupDetails.jsx | 42 ++- .../InstanceGroupListItem.jsx | 33 ++- .../screens/InstanceGroup/InstanceGroups.jsx | 65 ++--- .../InstanceGroup/Instances/InstanceList.jsx | 28 +- .../Instances/InstanceListItem.jsx | 36 +-- .../shared/ContainerGroupForm.jsx | 31 +- .../shared/InstanceGroupForm.jsx | 30 +- .../src/screens/Inventory/Inventories.jsx | 96 +++---- .../src/screens/Inventory/Inventory.jsx | 28 +- .../InventoryDetail/InventoryDetail.jsx | 36 ++- .../InventoryGroup/InventoryGroup.jsx | 19 +- .../InventoryGroupAdd/InventoryGroupAdd.jsx | 4 +- .../InventoryGroupDetail.jsx | 32 +-- .../InventoryGroupEdit/InventoryGroupEdit.jsx | 4 +- .../InventoryGroupHostList.jsx | 38 +-- .../InventoryGroupHostListItem.jsx | 11 +- .../InventoryGroups/InventoryGroupItem.jsx | 18 +- .../InventoryGroups/InventoryGroups.jsx | 3 +- .../InventoryGroups/InventoryGroupsList.jsx | 28 +- .../Inventory/InventoryHost/InventoryHost.jsx | 24 +- .../InventoryHostDetail.jsx | 40 ++- .../InventoryHostFacts/InventoryHostFacts.jsx | 8 +- .../InventoryHostGroupItem.jsx | 16 +- .../InventoryHostGroups.jsx | 3 +- .../InventoryHostGroupsList.jsx | 30 +- .../InventoryHosts/InventoryHostItem.jsx | 10 +- .../InventoryHosts/InventoryHostList.jsx | 20 +- .../InventoryList/InventoryListItem.jsx | 44 ++- .../InventoryRelatedGroupList.jsx | 32 +-- .../InventoryRelatedGroupListItem.jsx | 11 +- .../InventorySource/InventorySource.jsx | 16 +- .../InventorySourceDetail.jsx | 102 +++---- .../InventorySourceListItem.jsx | 26 +- .../src/screens/Inventory/SmartInventory.jsx | 24 +- .../SmartInventoryDetail.jsx | 48 ++-- .../SmartInventoryHost/SmartInventoryHost.jsx | 12 +- .../SmartInventoryHostDetail.jsx | 33 +-- .../SmartInventoryHostList.jsx | 16 +- .../SmartInventoryHostListItem.jsx | 14 +- .../Inventory/shared/InventoryForm.jsx | 22 +- .../Inventory/shared/InventoryGroupForm.jsx | 20 +- .../shared/InventoryGroupsDeleteModal.jsx | 28 +- .../Inventory/shared/InventorySourceForm.jsx | 21 +- .../InventorySourceSubForms/AzureSubForm.jsx | 10 +- .../InventorySourceSubForms/EC2SubForm.jsx | 8 +- .../InventorySourceSubForms/GCESubForm.jsx | 10 +- .../OpenStackSubForm.jsx | 10 +- .../InventorySourceSubForms/SCMSubForm.jsx | 26 +- .../SatelliteSubForm.jsx | 10 +- .../InventorySourceSubForms/SharedFields.jsx | 271 +++++++++--------- .../InventorySourceSubForms/TowerSubForm.jsx | 10 +- .../InventorySourceSubForms/VMwareSubForm.jsx | 10 +- .../VirtualizationSubForm.jsx | 10 +- .../shared/InventorySourceSyncButton.jsx | 26 +- .../Inventory/shared/SmartInventoryForm.jsx | 30 +- awx/ui_next/src/screens/Job/Job.jsx | 18 +- .../src/screens/Job/JobDetail/JobDetail.jsx | 119 ++++---- .../screens/Job/JobOutput/HostEventModal.jsx | 48 ++-- .../src/screens/Job/JobOutput/JobOutput.jsx | 103 ++++--- .../screens/Job/JobOutput/PageControls.jsx | 15 +- .../Job/JobOutput/shared/HostStatusBar.jsx | 20 +- .../Job/JobOutput/shared/OutputToolbar.jsx | 53 ++-- .../src/screens/Job/JobTypeRedirect.jsx | 8 +- awx/ui_next/src/screens/Job/Jobs.jsx | 35 ++- .../Job/WorkflowOutput/WorkflowOutput.jsx | 9 +- .../Job/WorkflowOutput/WorkflowOutputNode.jsx | 10 +- .../WorkflowOutput/WorkflowOutputToolbar.jsx | 12 +- awx/ui_next/src/screens/Login/Login.jsx | 54 ++-- .../screens/ManagementJob/ManagementJob.jsx | 16 +- .../LaunchManagementPrompt.jsx | 25 +- .../ManagementJobList/ManagementJobList.jsx | 20 +- .../ManagementJobListItem.jsx | 27 +- .../screens/ManagementJob/ManagementJobs.jsx | 41 ++- awx/ui_next/src/screens/Metrics/Metrics.jsx | 18 +- .../NotificationTemplate.jsx | 14 +- .../NotificationTemplateAdd.jsx | 10 +- .../NotificationTemplateDetail.jsx | 169 +++++------ .../NotificationTemplateList.jsx | 58 ++-- .../NotificationTemplateListItem.jsx | 31 +- .../NotificationTemplates.jsx | 35 +-- .../shared/CustomMessagesSubForm.jsx | 46 +-- .../shared/NotificationTemplateForm.jsx | 22 +- .../shared/TypeInputsSubForm.jsx | 226 +++++++-------- .../src/screens/Organization/Organization.jsx | 26 +- .../OrganizationDetail/OrganizationDetail.jsx | 36 ++- .../OrganizationExecEnvList.jsx | 24 +- .../OrganizationExecEnvListItem.jsx | 17 +- .../OrganizationList/OrganizationListItem.jsx | 23 +- .../OrganizationTeamList.jsx | 16 +- .../OrganizationTeamListItem.jsx | 14 +- .../screens/Organization/Organizations.jsx | 51 ++-- .../Organization/shared/OrganizationForm.jsx | 31 +- awx/ui_next/src/screens/Project/Project.jsx | 24 +- .../Project/ProjectDetail/ProjectDetail.jsx | 91 +++--- .../ProjectJobTemplatesList.jsx | 32 +-- .../ProjectJobTemplatesListItem.jsx | 19 +- .../Project/ProjectList/ProjectListItem.jsx | 61 ++-- awx/ui_next/src/screens/Project/Projects.jsx | 57 ++-- .../screens/Project/shared/ProjectForm.jsx | 33 +-- .../shared/ProjectSubForms/ArchiveSubForm.jsx | 8 +- .../shared/ProjectSubForms/GitSubForm.jsx | 35 +-- .../ProjectSubForms/InsightsSubForm.jsx | 9 +- .../shared/ProjectSubForms/ManualSubForm.jsx | 31 +- .../shared/ProjectSubForms/SharedFields.jsx | 189 ++++++------ .../shared/ProjectSubForms/SvnSubForm.jsx | 10 +- .../Project/shared/ProjectSyncButton.jsx | 22 +- .../src/screens/Schedule/AllSchedules.jsx | 8 +- .../Setting/ActivityStream/ActivityStream.jsx | 8 +- .../ActivityStreamDetail.jsx | 14 +- .../src/screens/Setting/AzureAD/AzureAD.jsx | 10 +- .../AzureAD/AzureADDetail/AzureADDetail.jsx | 14 +- .../src/screens/Setting/GitHub/GitHub.jsx | 8 +- .../GitHub/GitHubDetail/GitHubDetail.jsx | 24 +- .../Setting/GoogleOAuth2/GoogleOAuth2.jsx | 8 +- .../GoogleOAuth2Detail/GoogleOAuth2Detail.jsx | 14 +- awx/ui_next/src/screens/Setting/Jobs/Jobs.jsx | 10 +- .../Setting/Jobs/JobsDetail/JobsDetail.jsx | 14 +- awx/ui_next/src/screens/Setting/LDAP/LDAP.jsx | 8 +- .../Setting/LDAP/LDAPDetail/LDAPDetail.jsx | 24 +- .../src/screens/Setting/Logging/Logging.jsx | 10 +- .../Logging/LoggingDetail/LoggingDetail.jsx | 14 +- .../Logging/LoggingEdit/LoggingEdit.jsx | 34 +-- .../screens/Setting/MiscSystem/MiscSystem.jsx | 8 +- .../MiscSystemDetail/MiscSystemDetail.jsx | 22 +- .../MiscSystemEdit/MiscSystemEdit.jsx | 18 +- .../src/screens/Setting/RADIUS/RADIUS.jsx | 10 +- .../RADIUS/RADIUSDetail/RADIUSDetail.jsx | 14 +- awx/ui_next/src/screens/Setting/SAML/SAML.jsx | 10 +- .../Setting/SAML/SAMLDetail/SAMLDetail.jsx | 14 +- .../src/screens/Setting/SettingList.jsx | 58 ++-- awx/ui_next/src/screens/Setting/Settings.jsx | 150 +++++----- .../Setting/Subscription/Subscription.jsx | 8 +- .../SubscriptionDetail/SubscriptionDetail.jsx | 44 +-- .../SubscriptionEdit/AnalyticsStep.jsx | 36 +-- .../SubscriptionEdit/EulaStep.jsx | 17 +- .../SubscriptionEdit/SubscriptionEdit.jsx | 26 +- .../SubscriptionEdit/SubscriptionModal.jsx | 40 ++- .../SubscriptionEdit/SubscriptionStep.jsx | 56 ++-- .../src/screens/Setting/TACACS/TACACS.jsx | 10 +- .../TACACS/TACACSDetail/TACACSDetail.jsx | 14 +- awx/ui_next/src/screens/Setting/UI/UI.jsx | 8 +- .../screens/Setting/UI/UIDetail/UIDetail.jsx | 14 +- .../Setting/shared/LoggingTestAlert.jsx | 18 +- .../screens/Setting/shared/RevertAllAlert.jsx | 20 +- .../screens/Setting/shared/RevertButton.jsx | 15 +- .../Setting/shared/RevertFormActionGroup.jsx | 24 +- .../screens/Setting/shared/SettingDetail.jsx | 224 +++++++-------- .../screens/Setting/shared/SharedFields.jsx | 37 +-- awx/ui_next/src/screens/Team/Team.jsx | 20 +- .../screens/Team/TeamDetail/TeamDetail.jsx | 35 +-- .../src/screens/Team/TeamList/TeamList.jsx | 30 +- .../screens/Team/TeamList/TeamListItem.jsx | 25 +- .../Team/TeamRoles/TeamRoleListItem.jsx | 16 +- .../screens/Team/TeamRoles/TeamRolesList.jsx | 39 ++- awx/ui_next/src/screens/Team/Teams.jsx | 43 ++- .../src/screens/Team/shared/TeamForm.jsx | 14 +- .../JobTemplateDetail/JobTemplateDetail.jsx | 132 ++++----- .../screens/Template/Survey/SurveyList.jsx | 31 +- .../Template/Survey/SurveyListItem.jsx | 24 +- .../Template/Survey/SurveyPreviewModal.jsx | 21 +- .../Template/Survey/SurveyQuestionForm.jsx | 89 +++--- .../screens/Template/Survey/SurveyToolbar.jsx | 16 +- awx/ui_next/src/screens/Template/Template.jsx | 26 +- .../src/screens/Template/TemplateSurvey.jsx | 10 +- .../src/screens/Template/Templates.jsx | 42 ++- .../screens/Template/WorkflowJobTemplate.jsx | 28 +- .../WorkflowJobTemplateDetail.jsx | 68 ++--- .../Modals/DeleteAllNodesModal.jsx | 20 +- .../Modals/LinkModals/LinkAddModal.jsx | 8 +- .../Modals/LinkModals/LinkDeleteModal.jsx | 22 +- .../Modals/LinkModals/LinkEditModal.jsx | 8 +- .../Modals/LinkModals/LinkModal.jsx | 26 +- .../Modals/NodeModals/NodeAddModal.jsx | 8 +- .../Modals/NodeModals/NodeDeleteModal.jsx | 20 +- .../Modals/NodeModals/NodeEditModal.jsx | 12 +- .../Modals/NodeModals/NodeModal.jsx | 34 ++- .../NodeTypeStep/InventorySourcesList.jsx | 32 +-- .../NodeTypeStep/JobTemplatesList.jsx | 16 +- .../NodeModals/NodeTypeStep/NodeTypeStep.jsx | 50 ++-- .../NodeModals/NodeTypeStep/ProjectsList.jsx | 28 +- .../NodeTypeStep/WorkflowJobTemplatesList.jsx | 22 +- .../NodeTypeStep/useNodeTypeStep.jsx | 12 +- .../Modals/NodeModals/NodeViewModal.jsx | 18 +- .../Modals/NodeModals/RunStep.jsx | 30 +- .../Modals/NodeModals/useRunTypeStep.jsx | 8 +- .../Modals/NodeModals/useWorkflowNodeSteps.js | 25 +- .../Modals/UnsavedChangesModal.jsx | 18 +- .../Visualizer.jsx | 15 +- .../VisualizerGraph.jsx | 10 +- .../VisualizerLink.jsx | 18 +- .../VisualizerNode.jsx | 35 +-- .../VisualizerStartScreen.jsx | 16 +- .../VisualizerToolbar.jsx | 39 ++- .../Template/shared/JobTemplateForm.jsx | 212 +++++++------- .../Template/shared/PlaybookSelect.jsx | 9 +- .../Template/shared/WebhookSubForm.jsx | 48 ++-- .../shared/WorkflowJobTemplateForm.jsx | 63 ++-- awx/ui_next/src/screens/User/User.jsx | 24 +- .../screens/User/UserDetail/UserDetail.jsx | 51 ++-- .../src/screens/User/UserEdit/UserEdit.jsx | 4 +- .../src/screens/User/UserList/UserList.jsx | 36 +-- .../screens/User/UserList/UserListItem.jsx | 43 ++- .../UserOrganizationsList.jsx | 8 +- .../screens/User/UserRoles/UserRolesList.jsx | 40 ++- .../User/UserRoles/UserRolesListItem.jsx | 18 +- .../screens/User/UserTeams/UserTeamList.jsx | 30 +- .../User/UserTeams/UserTeamListItem.jsx | 8 +- .../src/screens/User/UserToken/UserToken.jsx | 20 +- .../User/UserTokenDetail/UserTokenDetail.jsx | 26 +- .../User/UserTokenList/UserTokenList.jsx | 28 +- .../User/UserTokenList/UserTokenListItem.jsx | 24 +- .../screens/User/UserTokens/UserTokens.jsx | 20 +- awx/ui_next/src/screens/User/Users.jsx | 55 ++-- .../src/screens/User/shared/UserForm.jsx | 47 ++- .../src/screens/User/shared/UserTokenForm.jsx | 30 +- .../WorkflowApproval/WorkflowApproval.jsx | 16 +- .../WorkflowApprovalDetail.jsx | 60 ++-- .../WorkflowApprovalListApproveButton.jsx | 20 +- .../WorkflowApprovalListDenyButton.jsx | 20 +- .../WorkflowApprovalListItem.jsx | 27 +- .../WorkflowApproval/WorkflowApprovals.jsx | 33 +-- .../shared/WorkflowApprovalStatus.jsx | 38 +-- awx/ui_next/src/util/dates.jsx | 4 +- .../util/getRelatedResourceDeleteDetails.js | 61 ++-- awx/ui_next/src/util/validators.jsx | 44 ++- awx/ui_next/src/util/validators.test.js | 94 +++--- 397 files changed, 5383 insertions(+), 6511 deletions(-) rename awx/ui_next/src/{routeConfig.js => routeConfig.jsx} (70%) diff --git a/awx/ui_next/CONTRIBUTING.md b/awx/ui_next/CONTRIBUTING.md index f6207abd26..05ce336063 100644 --- a/awx/ui_next/CONTRIBUTING.md +++ b/awx/ui_next/CONTRIBUTING.md @@ -336,16 +336,14 @@ Internationalization leans on the [lingui](https://github.com/lingui/js-lingui) The lingui library provides various React helpers for dealing with both marking strings for translation, and replacing strings that have been translated. For consistency and ease of use, we have consolidated on one pattern for the codebase. To set strings to be translated in the UI: -- import the withI18n function and wrap the export of your component in it (i.e. `export default withI18n()(Foo)`) -- doing the above gives you access to the i18n object on props. Make sure to put it in the scope of the function that contains strings needed to be translated (i.e. `const { i18n } = this.props;`) - import the t template tag function from the @lingui/macro package. -- wrap your string using the following format: `` i18n._(t`String to be translated`) `` +- wrap your string using the following format: `` t`String to be translated` `` -**Note:** Variables that are put inside the t-marked template tag will not be translated. If you have a variable string with text that needs translating, you must wrap it in ` i18n._(t``) ` where it is defined. +**Note:** If you have a variable string with text that needs translating, you must wrap it in `` t`${variable} string` `` where it is defined. Then you must run `npm run extract-strings` to generate new `.po` files and submit those files along with your pull request. -**Note:** We try to avoid the `I18n` consumer, `i18nMark` function, or `` component lingui gives us access to in this repo. i18nMark does not actually replace the string in the UI (leading to the potential for untranslated bugs), and the other helpers are redundant. Settling on a consistent, single pattern helps us ease the mental overhead of the need to understand the ins and outs of the lingui API. +**Note:** We try to avoid the `I18n` consumer, or `i18nMark` function lingui gives us access to in this repo. i18nMark does not actually replace the string in the UI (leading to the potential for untranslated bugs), and the other helpers are redundant. Settling on a consistent, single pattern helps us ease the mental overhead of the need to understand the ins and outs of the lingui API. -**Note:** Pluralization can be complicated so it is best to allow lingui handle cases where we have a string that may need to be pluralized based on number of items, or count. In that case lingui provides a `` component, and a `plural()` function. See documentation [here](https://lingui.js.org/guides/plurals.html?highlight=pluralization). +**Note:** Pluralization can be complicated so it is best to allow lingui handle cases where we have a string that may need to be pluralized based on number of items, or count. In that case lingui provides a `` component, and a `plural()` function. When adding or updating strings in a `` tag you must run `npm run extra-strings` and submit the new `.po` files with your pull request. See documentation [here](https://lingui.js.org/guides/plurals.html?highlight=pluralization). You can learn more about the ways lingui and its React helpers at [this link](https://lingui.js.org/tutorials/react-patterns.html). diff --git a/awx/ui_next/src/App.jsx b/awx/ui_next/src/App.jsx index a6f1718a0e..2ae8adf284 100644 --- a/awx/ui_next/src/App.jsx +++ b/awx/ui_next/src/App.jsx @@ -105,8 +105,8 @@ function App() { - - + + diff --git a/awx/ui_next/src/components/About/About.jsx b/awx/ui_next/src/components/About/About.jsx index 2aebbfd6a5..f0730742e2 100644 --- a/awx/ui_next/src/components/About/About.jsx +++ b/awx/ui_next/src/components/About/About.jsx @@ -1,12 +1,11 @@ import React from 'react'; import PropTypes from 'prop-types'; -import { withI18n } from '@lingui/react'; import { t } from '@lingui/macro'; import { AboutModal } from '@patternfly/react-core'; import { BrandName } from '../../variables'; -function About({ version, isOpen, onClose, i18n }) { +function About({ version, isOpen, onClose }) { const createSpeechBubble = () => { let text = `${BrandName} ${version}`; let top = ''; @@ -25,8 +24,8 @@ function About({ version, isOpen, onClose, i18n }) { }; const speechBubble = createSpeechBubble(); - const copyright = i18n._(t`Copyright`); - const redHatInc = i18n._(t`Red Hat, Inc.`); + const copyright = t`Copyright`; + const redHatInc = t`Red Hat, Inc.`; return (
         {speechBubble}
@@ -63,4 +62,4 @@ About.defaultProps = {
   version: null,
 };
 
-export default withI18n()(About);
+export default About;
diff --git a/awx/ui_next/src/components/AdHocCommands/AdHocCommands.jsx b/awx/ui_next/src/components/AdHocCommands/AdHocCommands.jsx
index fb8ed89f84..f85120f8f7 100644
--- a/awx/ui_next/src/components/AdHocCommands/AdHocCommands.jsx
+++ b/awx/ui_next/src/components/AdHocCommands/AdHocCommands.jsx
@@ -1,6 +1,6 @@
 import React, { useCallback, useEffect, useState, useContext } from 'react';
 import { useHistory, useParams } from 'react-router-dom';
-import { withI18n } from '@lingui/react';
+
 import { t } from '@lingui/macro';
 import PropTypes from 'prop-types';
 import { Button, DropdownItem } from '@patternfly/react-core';
@@ -14,7 +14,7 @@ import AdHocCommandsWizard from './AdHocCommandsWizard';
 import { KebabifiedContext } from '../../contexts/Kebabified';
 import ContentError from '../ContentError';
 
-function AdHocCommands({ adHocItems, i18n, hasListItems, onLaunchLoading }) {
+function AdHocCommands({ adHocItems, hasListItems, onLaunchLoading }) {
   const history = useHistory();
   const { id } = useParams();
 
@@ -22,11 +22,11 @@ function AdHocCommands({ adHocItems, i18n, hasListItems, onLaunchLoading }) {
   const { isKebabified, onKebabModalChange } = useContext(KebabifiedContext);
 
   const verbosityOptions = [
-    { value: '0', key: '0', label: i18n._(t`0 (Normal)`) },
-    { value: '1', key: '1', label: i18n._(t`1 (Verbose)`) },
-    { value: '2', key: '2', label: i18n._(t`2 (More Verbose)`) },
-    { value: '3', key: '3', label: i18n._(t`3 (Debug)`) },
-    { value: '4', key: '4', label: i18n._(t`4 (Connection Debug)`) },
+    { value: '0', key: '0', label: t`0 (Normal)` },
+    { value: '1', key: '1', label: t`1 (Verbose)` },
+    { value: '2', key: '2', label: t`2 (More Verbose)` },
+    { value: '3', key: '3', label: t`3 (Debug)` },
+    { value: '4', key: '4', label: t`4 (Connection Debug)` },
   ];
   useEffect(() => {
     if (isKebabified) {
@@ -102,7 +102,7 @@ function AdHocCommands({ adHocItems, i18n, hasListItems, onLaunchLoading }) {
        {
           dismissError();
           setIsWizardOpen(false);
@@ -110,7 +110,7 @@ function AdHocCommands({ adHocItems, i18n, hasListItems, onLaunchLoading }) {
       >
         {launchError ? (
           <>
-            {i18n._(t`Failed to launch job.`)}
+            {t`Failed to launch job.`}
             
           
         ) : (
@@ -128,20 +128,20 @@ function AdHocCommands({ adHocItems, i18n, hasListItems, onLaunchLoading }) {
           key="cancel-job"
           isDisabled={isAdHocDisabled || !hasListItems}
           component="button"
-          aria-label={i18n._(t`Run Command`)}
+          aria-label={t`Run Command`}
           onClick={() => setIsWizardOpen(true)}
         >
-          {i18n._(t`Run Command`)}
+          {t`Run Command`}
         
       ) : (
         
       )}
 
@@ -166,4 +166,4 @@ AdHocCommands.propTypes = {
   hasListItems: PropTypes.bool.isRequired,
 };
 
-export default withI18n()(AdHocCommands);
+export default AdHocCommands;
diff --git a/awx/ui_next/src/components/AdHocCommands/AdHocCredentialStep.jsx b/awx/ui_next/src/components/AdHocCommands/AdHocCredentialStep.jsx
index e95f0b05cb..29ae4e6827 100644
--- a/awx/ui_next/src/components/AdHocCommands/AdHocCredentialStep.jsx
+++ b/awx/ui_next/src/components/AdHocCommands/AdHocCredentialStep.jsx
@@ -1,6 +1,6 @@
 import React, { useEffect, useCallback } from 'react';
 import { useHistory } from 'react-router-dom';
-import { withI18n } from '@lingui/react';
+
 import { t } from '@lingui/macro';
 import PropTypes from 'prop-types';
 import { useField } from 'formik';
@@ -21,7 +21,7 @@ const QS_CONFIG = getQSConfig('credentials', {
   order_by: 'name',
 });
 
-function AdHocCredentialStep({ i18n, credentialTypeId, onEnableLaunch }) {
+function AdHocCredentialStep({ credentialTypeId, onEnableLaunch }) {
   const history = useHistory();
   const {
     error,
@@ -52,7 +52,7 @@ function AdHocCredentialStep({ i18n, credentialTypeId, onEnableLaunch }) {
 
   const [credentialField, credentialMeta, credentialHelpers] = useField({
     name: 'credential',
-    validate: required(null, i18n),
+    validate: required(null),
   });
   if (error) {
     return ;
@@ -64,8 +64,8 @@ function AdHocCredentialStep({ i18n, credentialTypeId, onEnableLaunch }) {
     
} > @@ -83,27 +81,27 @@ function AdHocCredentialStep({ i18n, credentialTypeId, onEnableLaunch }) { value={credentialField.value || []} options={credentials} optionCount={credentialCount} - header={i18n._(t`Machine Credential`)} + header={t`Machine Credential`} readOnly qsConfig={QS_CONFIG} searchColumns={[ { - name: i18n._(t`Name`), + name: t`Name`, key: 'name', isDefault: true, }, { - name: i18n._(t`Created By (Username)`), + name: t`Created By (Username)`, key: 'created_by__username', }, { - name: i18n._(t`Modified By (Username)`), + name: t`Modified By (Username)`, key: 'modified_by__username', }, ]} sortColumns={[ { - name: i18n._(t`Name`), + name: t`Name`, key: 'name', }, ]} @@ -125,4 +123,4 @@ AdHocCredentialStep.propTypes = { credentialTypeId: PropTypes.number.isRequired, onEnableLaunch: PropTypes.func.isRequired, }; -export default withI18n()(AdHocCredentialStep); +export default AdHocCredentialStep; diff --git a/awx/ui_next/src/components/AdHocCommands/AdHocDetailsStep.jsx b/awx/ui_next/src/components/AdHocCommands/AdHocDetailsStep.jsx index 229024bfbe..4c5f6aad70 100644 --- a/awx/ui_next/src/components/AdHocCommands/AdHocDetailsStep.jsx +++ b/awx/ui_next/src/components/AdHocCommands/AdHocDetailsStep.jsx @@ -1,6 +1,6 @@ /* eslint-disable react/no-unescaped-entities */ import React from 'react'; -import { withI18n } from '@lingui/react'; + import { t } from '@lingui/macro'; import PropTypes from 'prop-types'; import { useField } from 'formik'; @@ -28,10 +28,10 @@ const TooltipWrapper = styled.div` // in failing tests. const brandName = BrandName; -function AdHocDetailsStep({ i18n, verbosityOptions, moduleOptions }) { +function AdHocDetailsStep({ verbosityOptions, moduleOptions }) { const [moduleNameField, moduleNameMeta, moduleNameHelpers] = useField({ name: 'module_name', - validate: required(null, i18n), + validate: required(null), }); const [variablesField] = useField('extra_vars'); @@ -41,14 +41,14 @@ function AdHocDetailsStep({ i18n, verbosityOptions, moduleOptions }) { ); const [verbosityField, verbosityMeta, verbosityHelpers] = useField({ name: 'verbosity', - validate: required(null, i18n), + validate: required(null), }); const argumentsRequired = moduleNameField.value === 'command' || moduleNameField.value === 'shell'; const [, argumentsMeta, argumentsHelpers] = useField({ name: 'module_args', - validate: argumentsRequired && required(null, i18n), + validate: argumentsRequired && required(null), }); const isValid = !argumentsMeta.error || !argumentsMeta.touched; @@ -59,8 +59,8 @@ function AdHocDetailsStep({ i18n, verbosityOptions, moduleOptions }) { } > ({ @@ -105,9 +103,9 @@ function AdHocDetailsStep({ i18n, verbosityOptions, moduleOptions }) { argumentsHelpers.setTouched(true)} isRequired={ @@ -117,27 +115,25 @@ function AdHocDetailsStep({ i18n, verbosityOptions, moduleOptions }) { tooltip={ moduleNameField.value ? ( <> - {i18n._( - t`These arguments are used with the specified module. You can find information about ${moduleNameField.value} by clicking ` - )} + {t`These arguments are used with the specified module. You can find information about ${moduleNameField.value} by clicking `} {' '} - {i18n._(t`here.`)} + {t`here.`} ) : ( - i18n._(t`These arguments are used with the specified module.`) + t`These arguments are used with the specified module.` ) } /> } > @@ -167,19 +161,17 @@ function AdHocDetailsStep({ i18n, verbosityOptions, moduleOptions }) { id="limit" name="limit" type="text" - label={i18n._(t`Limit`)} - aria-label={i18n._(t`Limit`)} + label={t`Limit`} + aria-label={t`Limit`} tooltip={ - {i18n._( - t`The pattern used to target hosts in the inventory. Leaving the field blank, all, and * will all target all hosts in the inventory. You can find more information about Ansible's host patterns` - )}{' '} + {t`The pattern used to target hosts in the inventory. Leaving the field blank, all, and * will all target all hosts in the inventory. You can find more information about Ansible's host patterns`}{' '} - {i18n._(t`here`)} + {t`here`} } @@ -189,67 +181,63 @@ function AdHocDetailsStep({ i18n, verbosityOptions, moduleOptions }) { name="forks" type="number" min="0" - label={i18n._(t`Forks`)} - aria-label={i18n._(t`Forks`)} + label={t`Forks`} + aria-label={t`Forks`} tooltip={ - {i18n._( - t`The number of parallel or simultaneous processes to use while executing the playbook. Inputting no value will use the default value from the ansible configuration file. You can find more information` - )}{' '} + {t`The number of parallel or simultaneous processes to use while executing the playbook. Inputting no value will use the default value from the ansible configuration file. You can find more information`}{' '} - {i18n._(t`here.`)} + {t`here.`} } /> } > { diffModeHelpers.setValue(!diffModeField.value); }} - aria-label={i18n._(t`toggle changes`)} + aria-label={t`toggle changes`} /> - {i18n._(t`Enable privilege escalation`)} + {t`Enable privilege escalation`}   - {i18n._(t`Enables creation of a provisioning + {t`Enables creation of a provisioning callback URL. Using the URL a host can contact ${brandName} and request a configuration update using this job - template`)} + template`}   --become - {i18n._(t`option to the`)}   + {t`option to the`}   ansible - {i18n._(t`command`)} + {t`command`}

} /> @@ -275,14 +263,12 @@ function AdHocDetailsStep({ i18n, verbosityOptions, moduleOptions }) { tooltip={

- {i18n._( - t`Pass extra command line changes. There are two ansible command line parameters: ` - )} + {t`Pass extra command line changes. There are two ansible command line parameters: `}
-e, --extra-vars
- {i18n._(t`Provide key/value pairs using either - YAML or JSON.`)} + {t`Provide key/value pairs using either + YAML or JSON.`}

JSON:
@@ -306,8 +292,8 @@ function AdHocDetailsStep({ i18n, verbosityOptions, moduleOptions }) {
} - label={i18n._(t`Extra variables`)} - aria-label={i18n._(t`Extra variables`)} + label={t`Extra variables`} + aria-label={t`Extra variables`} />
@@ -320,4 +306,4 @@ AdHocDetailsStep.propTypes = { verbosityOptions: PropTypes.arrayOf(PropTypes.object).isRequired, }; -export default withI18n()(AdHocDetailsStep); +export default AdHocDetailsStep; diff --git a/awx/ui_next/src/components/AddDropDownButton/AddDropDownButton.jsx b/awx/ui_next/src/components/AddDropDownButton/AddDropDownButton.jsx index c78bac17fb..8c2351110e 100644 --- a/awx/ui_next/src/components/AddDropDownButton/AddDropDownButton.jsx +++ b/awx/ui_next/src/components/AddDropDownButton/AddDropDownButton.jsx @@ -1,12 +1,11 @@ import React, { useState, useRef, useEffect, Fragment } from 'react'; -import { withI18n } from '@lingui/react'; import { t } from '@lingui/macro'; import PropTypes from 'prop-types'; import { Dropdown, DropdownPosition } from '@patternfly/react-core'; import { ToolbarAddButton } from '../PaginatedDataList'; import { useKebabifiedMenu } from '../../contexts/Kebabified'; -function AddDropDownButton({ dropdownItems, i18n }) { +function AddDropDownButton({ dropdownItems }) { const { isKebabified } = useKebabifiedMenu(); const [isOpen, setIsOpen] = useState(false); const element = useRef(null); @@ -36,7 +35,7 @@ function AddDropDownButton({ dropdownItems, i18n }) { position={DropdownPosition.right} toggle={ setIsOpen(!isOpen)} /> @@ -52,4 +51,4 @@ AddDropDownButton.propTypes = { }; export { AddDropDownButton as _AddDropDownButton }; -export default withI18n()(AddDropDownButton); +export default AddDropDownButton; diff --git a/awx/ui_next/src/components/AddRole/AddResourceRole.jsx b/awx/ui_next/src/components/AddRole/AddResourceRole.jsx index b07a1cd39c..b30f21b35f 100644 --- a/awx/ui_next/src/components/AddRole/AddResourceRole.jsx +++ b/awx/ui_next/src/components/AddRole/AddResourceRole.jsx @@ -1,7 +1,6 @@ import React, { Fragment, useState, useEffect } from 'react'; import PropTypes from 'prop-types'; import { useHistory } from 'react-router-dom'; -import { withI18n } from '@lingui/react'; import { t } from '@lingui/macro'; import SelectableCard from '../SelectableCard'; import Wizard from '../Wizard'; @@ -18,7 +17,7 @@ const readTeams = async queryParams => TeamsAPI.read(queryParams); const readTeamsOptions = async () => TeamsAPI.readOptions(); -function AddResourceRole({ onSave, onClose, roles, i18n, resource, onError }) { +function AddResourceRole({ onSave, onClose, roles, resource, onError }) { const history = useHistory(); const [selectedResource, setSelectedResource] = useState(null); @@ -122,52 +121,52 @@ function AddResourceRole({ onSave, onClose, roles, i18n, resource, onError }) { const userSearchColumns = [ { - name: i18n._(t`Username`), + name: t`Username`, key: 'username__icontains', isDefault: true, }, { - name: i18n._(t`First Name`), + name: t`First Name`, key: 'first_name__icontains', }, { - name: i18n._(t`Last Name`), + name: t`Last Name`, key: 'last_name__icontains', }, ]; const userSortColumns = [ { - name: i18n._(t`Username`), + name: t`Username`, key: 'username', }, { - name: i18n._(t`First Name`), + name: t`First Name`, key: 'first_name', }, { - name: i18n._(t`Last Name`), + name: t`Last Name`, key: 'last_name', }, ]; const teamSearchColumns = [ { - name: i18n._(t`Name`), + name: t`Name`, key: 'name', isDefault: true, }, { - name: i18n._(t`Created By (Username)`), + name: t`Created By (Username)`, key: 'created_by__username', }, { - name: i18n._(t`Modified By (Username)`), + name: t`Modified By (Username)`, key: 'modified_by__username', }, ]; const teamSortColumns = [ { - name: i18n._(t`Name`), + name: t`Name`, key: 'name', }, ]; @@ -176,30 +175,28 @@ function AddResourceRole({ onSave, onClose, roles, i18n, resource, onError }) { switch (selectedResource) { case 'users': - wizardTitle = i18n._(t`Add User Roles`); + wizardTitle = t`Add User Roles`; break; case 'teams': - wizardTitle = i18n._(t`Add Team Roles`); + wizardTitle = t`Add Team Roles`; break; default: - wizardTitle = i18n._(t`Add Roles`); + wizardTitle = t`Add Roles`; } const steps = [ { id: 1, - name: i18n._(t`Select a Resource Type`), + name: t`Select a Resource Type`, component: (
- {i18n._( - t`Choose the type of resource that will be receiving new roles. For example, if you'd like to add new roles to a set of users please choose Users and click Next. You'll be able to select the specific resources in the next step.` - )} + {t`Choose the type of resource that will be receiving new roles. For example, if you'd like to add new roles to a set of users please choose Users and click Next. You'll be able to select the specific resources in the next step.`}
handleResourceSelect('users')} /> @@ -208,8 +205,8 @@ function AddResourceRole({ onSave, onClose, roles, i18n, resource, onError }) { !resource?.organization) ? null : ( handleResourceSelect('teams')} /> @@ -220,7 +217,7 @@ function AddResourceRole({ onSave, onClose, roles, i18n, resource, onError }) { }, { id: 2, - name: i18n._(t`Select Items from List`), + name: t`Select Items from List`, component: ( {selectedResource === 'users' && ( @@ -231,7 +228,7 @@ function AddResourceRole({ onSave, onClose, roles, i18n, resource, onError }) { onRowClick={handleResourceCheckboxClick} fetchItems={readUsers} fetchOptions={readUsersOptions} - selectedLabel={i18n._(t`Selected`)} + selectedLabel={t`Selected`} selectedResourceRows={selectedResourceRows} sortedColumnKey="username" /> @@ -243,7 +240,7 @@ function AddResourceRole({ onSave, onClose, roles, i18n, resource, onError }) { onRowClick={handleResourceCheckboxClick} fetchItems={readTeams} fetchOptions={readTeamsOptions} - selectedLabel={i18n._(t`Selected`)} + selectedLabel={t`Selected`} selectedResourceRows={selectedResourceRows} /> )} @@ -254,18 +251,18 @@ function AddResourceRole({ onSave, onClose, roles, i18n, resource, onError }) { }, { id: 3, - name: i18n._(t`Select Roles to Apply`), + name: t`Select Roles to Apply`, component: ( ), - nextButtonText: i18n._(t`Save`), + nextButtonText: t`Save`, enableNext: selectedRoleRows.length > 0, canJumpTo: maxEnabledStep >= 3, }, @@ -285,8 +282,8 @@ function AddResourceRole({ onSave, onClose, roles, i18n, resource, onError }) { steps={steps} title={wizardTitle} nextButtonText={currentStep.nextButtonText || undefined} - backButtonText={i18n._(t`Back`)} - cancelButtonText={i18n._(t`Cancel`)} + backButtonText={t`Back`} + cancelButtonText={t`Cancel`} /> ); } @@ -304,4 +301,4 @@ AddResourceRole.defaultProps = { }; export { AddResourceRole as _AddResourceRole }; -export default withI18n()(AddResourceRole); +export default AddResourceRole; diff --git a/awx/ui_next/src/components/AddRole/SelectResourceStep.jsx b/awx/ui_next/src/components/AddRole/SelectResourceStep.jsx index f9a73d24ce..3a0ec2c5fe 100644 --- a/awx/ui_next/src/components/AddRole/SelectResourceStep.jsx +++ b/awx/ui_next/src/components/AddRole/SelectResourceStep.jsx @@ -1,7 +1,6 @@ import React, { Fragment, useCallback, useEffect } from 'react'; import PropTypes from 'prop-types'; import { withRouter, useLocation } from 'react-router-dom'; -import { withI18n } from '@lingui/react'; import { t } from '@lingui/macro'; import useRequest from '../../util/useRequest'; @@ -30,7 +29,6 @@ function SelectResourceStep({ selectedResourceRows, fetchItems, fetchOptions, - i18n, }) { const location = useLocation(); @@ -78,9 +76,7 @@ function SelectResourceStep({ return (
- {i18n._( - t`Choose the resources that will be receiving new roles. You'll be able to select the roles to apply in the next step. Note that the resources chosen here will receive all roles chosen in the next step.` - )} + {t`Choose the resources that will be receiving new roles. You'll be able to select the roles to apply in the next step. Note that the resources chosen here will receive all roles chosen in the next step.`}
{selectedResourceRows.length > 0 && (
- {i18n._( - t`Choose roles to apply to the selected resources. Note that all selected roles will be applied to all selected resources.` - )} + {t`Choose roles to apply to the selected resources. Note that all selected roles will be applied to all selected resources.`}
{selectedResourceRows.length > 0 && ( )} @@ -75,4 +71,4 @@ RolesStep.defaultProps = { selectedRoleRows: [], }; -export default withI18n()(RolesStep); +export default RolesStep; diff --git a/awx/ui_next/src/components/AlertModal/AlertModal.jsx b/awx/ui_next/src/components/AlertModal/AlertModal.jsx index 0c443300be..3d3c7394d3 100644 --- a/awx/ui_next/src/components/AlertModal/AlertModal.jsx +++ b/awx/ui_next/src/components/AlertModal/AlertModal.jsx @@ -8,7 +8,7 @@ import { InfoCircleIcon, TimesCircleIcon, } from '@patternfly/react-icons'; -import { withI18n } from '@lingui/react'; + import { t } from '@lingui/macro'; import styled from 'styled-components'; @@ -20,13 +20,11 @@ const Header = styled.div` `; function AlertModal({ - i18n, isOpen = null, title, label, variant, children, - i18nHash, ...props }) { const variantIcons = { @@ -74,7 +72,7 @@ function AlertModal({ return ( @@ -178,7 +178,7 @@ function AppContainer({ i18n, navRouteConfig = [], children }) { +
}> + {t`User`}
}> - {i18n._(t`User Details`)} + {t`User Details`} , - {i18n._(t`Logout`)} + {t`Logout`} , ]} /> @@ -191,4 +184,4 @@ PageHeaderToolbar.defaultProps = { isAboutDisabled: false, }; -export default withI18n()(PageHeaderToolbar); +export default PageHeaderToolbar; diff --git a/awx/ui_next/src/components/AssociateModal/AssociateModal.jsx b/awx/ui_next/src/components/AssociateModal/AssociateModal.jsx index c95d09ab06..a2f9663861 100644 --- a/awx/ui_next/src/components/AssociateModal/AssociateModal.jsx +++ b/awx/ui_next/src/components/AssociateModal/AssociateModal.jsx @@ -1,6 +1,6 @@ import React, { Fragment, useEffect, useCallback } from 'react'; import { useHistory } from 'react-router-dom'; -import { withI18n } from '@lingui/react'; + import { t } from '@lingui/macro'; import { Button, Modal } from '@patternfly/react-core'; import OptionsList from '../OptionsList'; @@ -17,9 +17,8 @@ const QS_CONFIG = (order_by = 'name') => { }; function AssociateModal({ - i18n, - header = i18n._(t`Items`), - title = i18n._(t`Select Items`), + header = t`Items`, + title = t`Select Items`, onClose, onAssociate, fetchRequest, @@ -96,28 +95,28 @@ function AssociateModal({ - {i18n._(t`Save`)} + {t`Save`} , , ]} > @@ -136,22 +135,22 @@ function AssociateModal({ value={selected} searchColumns={[ { - name: i18n._(t`Name`), + name: t`Name`, key: `${displayKey}__icontains`, isDefault: true, }, { - name: i18n._(t`Created By (Username)`), + name: t`Created By (Username)`, key: 'created_by__username__icontains', }, { - name: i18n._(t`Modified By (Username)`), + name: t`Modified By (Username)`, key: 'modified_by__username__icontains', }, ]} sortColumns={[ { - name: i18n._(t`Name`), + name: t`Name`, key: `${displayKey}`, }, ]} @@ -163,4 +162,4 @@ function AssociateModal({ ); } -export default withI18n()(AssociateModal); +export default AssociateModal; diff --git a/awx/ui_next/src/components/ChipGroup/ChipGroup.jsx b/awx/ui_next/src/components/ChipGroup/ChipGroup.jsx index c16ee052fe..a4ad262b89 100644 --- a/awx/ui_next/src/components/ChipGroup/ChipGroup.jsx +++ b/awx/ui_next/src/components/ChipGroup/ChipGroup.jsx @@ -1,16 +1,16 @@ import React from 'react'; -import { withI18n } from '@lingui/react'; + import { t } from '@lingui/macro'; import { ChipGroup as PFChipGroup } from '@patternfly/react-core'; -import { number, shape } from 'prop-types'; +import { number } from 'prop-types'; -function ChipGroup({ i18n, numChips, totalChips, i18nHash, ...props }) { +function ChipGroup({ numChips, totalChips, ...props }) { return ( ); } @@ -18,7 +18,6 @@ function ChipGroup({ i18n, numChips, totalChips, i18nHash, ...props }) { ChipGroup.propTypes = { numChips: number.isRequired, totalChips: number.isRequired, - i18n: shape({}).isRequired, }; -export default withI18n()(ChipGroup); +export default ChipGroup; diff --git a/awx/ui_next/src/components/CodeEditor/CodeEditor.jsx b/awx/ui_next/src/components/CodeEditor/CodeEditor.jsx index 501ece5bdb..23932b0056 100644 --- a/awx/ui_next/src/components/CodeEditor/CodeEditor.jsx +++ b/awx/ui_next/src/components/CodeEditor/CodeEditor.jsx @@ -8,7 +8,7 @@ import 'ace-builds/src-noconflict/mode-javascript'; import 'ace-builds/src-noconflict/mode-yaml'; import 'ace-builds/src-noconflict/mode-django'; import 'ace-builds/src-noconflict/theme-github'; -import { withI18n } from '@lingui/react'; + import { t } from '@lingui/macro'; import styled from 'styled-components'; import debounce from '../../util/debounce'; @@ -81,7 +81,6 @@ function CodeEditor({ rows, fullHeight, className, - i18n, }) { if (rows && typeof rows !== 'number' && rows !== 'auto') { // eslint-disable-next-line no-console @@ -185,7 +184,7 @@ function CodeEditor({ className="pf-c-form__helper-text keyboard-help-text" aria-live="polite" > - {i18n._(t`Press Enter to edit. Press ESC to stop editing.`)} + {t`Press Enter to edit. Press ESC to stop editing.`} )} @@ -210,4 +209,4 @@ CodeEditor.defaultProps = { className: '', }; -export default withI18n()(CodeEditor); +export default CodeEditor; diff --git a/awx/ui_next/src/components/CodeEditor/VariablesDetail.jsx b/awx/ui_next/src/components/CodeEditor/VariablesDetail.jsx index 3e8b08f69e..1f5e4c7231 100644 --- a/awx/ui_next/src/components/CodeEditor/VariablesDetail.jsx +++ b/awx/ui_next/src/components/CodeEditor/VariablesDetail.jsx @@ -1,7 +1,7 @@ import 'styled-components/macro'; import React, { useState } from 'react'; import { node, number, oneOfType, shape, string, arrayOf } from 'prop-types'; -import { withI18n } from '@lingui/react'; + import { t } from '@lingui/macro'; import { Split, @@ -23,15 +23,7 @@ import { import CodeEditor from './CodeEditor'; import { JSON_MODE, YAML_MODE } from './constants'; -function VariablesDetail({ - dataCy, - helpText, - value, - label, - rows, - fullHeight, - i18n, -}) { +function VariablesDetail({ dataCy, helpText, value, label, rows, fullHeight }) { const [mode, setMode] = useState( isJsonObject(value) || isJsonString(value) ? JSON_MODE : YAML_MODE ); @@ -84,7 +76,6 @@ function VariablesDetail({ setMode={setMode} currentValue={currentValue} onExpand={() => setIsExpanded(true)} - i18n={i18n} /> - {i18n._(t`Error:`)} {error.message} + {t`Error:`} {error.message} )} @@ -118,13 +109,13 @@ function VariablesDetail({ onClose={() => setIsExpanded(false)} actions={[ , ]} > @@ -137,7 +128,6 @@ function VariablesDetail({ mode={mode} setMode={setMode} currentValue={currentValue} - i18n={i18n} /> @@ -211,7 +192,7 @@ function ModeToggle({ , ]} >
)} {onExpand && ( {errorMessage} @@ -72,4 +72,4 @@ CopyButton.defaultProps = { ouiaId: null, }; -export default withI18n()(CopyButton); +export default CopyButton; diff --git a/awx/ui_next/src/components/CredentialChip/CredentialChip.jsx b/awx/ui_next/src/components/CredentialChip/CredentialChip.jsx index 7dd5b055b5..04f7894730 100644 --- a/awx/ui_next/src/components/CredentialChip/CredentialChip.jsx +++ b/awx/ui_next/src/components/CredentialChip/CredentialChip.jsx @@ -1,15 +1,14 @@ import React from 'react'; -import { shape } from 'prop-types'; -import { withI18n } from '@lingui/react'; + import { t } from '@lingui/macro'; import { Chip } from '@patternfly/react-core'; import { Credential } from '../../types'; import { toTitleCase } from '../../util/strings'; -function CredentialChip({ credential, i18n, i18nHash, ...props }) { +function CredentialChip({ credential, ...props }) { let type; if (credential.cloud) { - type = i18n._(t`Cloud`); + type = t`Cloud`; } else if (credential.kind === 'aws' || credential.kind === 'ssh') { type = credential.kind.toUpperCase(); } else { @@ -32,8 +31,7 @@ function CredentialChip({ credential, i18n, i18nHash, ...props }) { } CredentialChip.propTypes = { credential: Credential.isRequired, - i18n: shape({}).isRequired, }; export { CredentialChip as _CredentialChip }; -export default withI18n()(CredentialChip); +export default CredentialChip; diff --git a/awx/ui_next/src/components/DataListToolbar/DataListToolbar.jsx b/awx/ui_next/src/components/DataListToolbar/DataListToolbar.jsx index e52ae1c2cb..44351ebfd7 100644 --- a/awx/ui_next/src/components/DataListToolbar/DataListToolbar.jsx +++ b/awx/ui_next/src/components/DataListToolbar/DataListToolbar.jsx @@ -1,6 +1,6 @@ import React, { useEffect, useState } from 'react'; import PropTypes from 'prop-types'; -import { withI18n } from '@lingui/react'; + import { t } from '@lingui/macro'; import { Checkbox, @@ -37,7 +37,7 @@ function DataListToolbar({ onExpand, onSelectAll, additionalControls, - i18n, + qsConfig, pagination, }) { @@ -62,7 +62,7 @@ function DataListToolbar({ id={`${qsConfig.namespace}-list-toolbar`} clearAllFilters={clearAllFilters} collapseListedFiltersBreakpoint="lg" - clearFiltersButtonText={i18n._(t`Clear all filters`)} + clearFiltersButtonText={t`Clear all filters`} > {showSelectAll && ( @@ -71,7 +71,7 @@ function DataListToolbar({ @@ -83,7 +83,7 @@ function DataListToolbar({ qsConfig={qsConfig} columns={[ ...searchColumns, - { name: i18n._(t`Advanced`), key: 'advanced' }, + { name: t`Advanced`, key: 'advanced' }, ]} searchableKeys={searchableKeys} relatedSearchableKeys={relatedSearchableKeys} @@ -190,4 +190,4 @@ DataListToolbar.defaultProps = { additionalControls: [], }; -export default withI18n()(DataListToolbar); +export default DataListToolbar; diff --git a/awx/ui_next/src/components/DeleteButton/DeleteButton.jsx b/awx/ui_next/src/components/DeleteButton/DeleteButton.jsx index d2b236ad81..24a7f24fd5 100644 --- a/awx/ui_next/src/components/DeleteButton/DeleteButton.jsx +++ b/awx/ui_next/src/components/DeleteButton/DeleteButton.jsx @@ -1,6 +1,6 @@ import React, { useState } from 'react'; import PropTypes from 'prop-types'; -import { withI18n } from '@lingui/react'; + import { t } from '@lingui/macro'; import styled from 'styled-components'; import { Button, Badge, Alert, Tooltip } from '@patternfly/react-core'; @@ -20,7 +20,7 @@ function DeleteButton({ onConfirm, modalTitle, name, - i18n, + variant, children, isDisabled, @@ -54,7 +54,7 @@ function DeleteButton({ return ( { toggleModal(false); setDeleteMessageError(); @@ -73,12 +73,12 @@ function DeleteButton({ isLoading={isLoading} spinnerAriaValueText={isLoading ? 'Loading' : undefined} variant={variant || 'secondary'} - aria-label={i18n._(t`Delete`)} + aria-label={t`Delete`} isDisabled={isDisabled} onClick={() => toggleModal(true)} ouiaId={ouiaId} > - {children || i18n._(t`Delete`)} + {children || t`Delete`}
@@ -88,11 +88,11 @@ function DeleteButton({ isLoading={isLoading} spinnerAriaValueText={isLoading ? 'Loading' : undefined} variant={variant || 'secondary'} - aria-label={i18n._(t`Delete`)} + aria-label={t`Delete`} isDisabled={isDisabled} onClick={() => toggleModal(true)} > - {children || i18n._(t`Delete`)} + {children || t`Delete`} )} { onConfirm(); toggleModal(false); }} > - {i18n._(t`Delete`)} + {t`Delete`} , , ]} > - {i18n._(t`Are you sure you want to delete:`)} + {t`Are you sure you want to delete:`}
{name} {Object.values(deleteDetails).length > 0 && ( @@ -158,4 +158,4 @@ DeleteButton.defaultProps = { ouiaId: null, }; -export default withI18n()(DeleteButton); +export default DeleteButton; diff --git a/awx/ui_next/src/components/DetailList/DeletedDetail.jsx b/awx/ui_next/src/components/DetailList/DeletedDetail.jsx index e71fc183bd..60cf2f883c 100644 --- a/awx/ui_next/src/components/DetailList/DeletedDetail.jsx +++ b/awx/ui_next/src/components/DetailList/DeletedDetail.jsx @@ -1,5 +1,5 @@ import React from 'react'; -import { withI18n } from '@lingui/react'; + import { t } from '@lingui/macro'; import { node } from 'prop-types'; import styled from 'styled-components'; @@ -11,12 +11,12 @@ const Detail = styled(_Detail)` } `; -function DeletedDetail({ i18n, label }) { - return ; +function DeletedDetail({ label }) { + return ; } DeletedDetail.propTypes = { label: node.isRequired, }; -export default withI18n()(DeletedDetail); +export default DeletedDetail; diff --git a/awx/ui_next/src/components/DetailList/LaunchedByDetail.jsx b/awx/ui_next/src/components/DetailList/LaunchedByDetail.jsx index 6c451a3e51..7708feadc9 100644 --- a/awx/ui_next/src/components/DetailList/LaunchedByDetail.jsx +++ b/awx/ui_next/src/components/DetailList/LaunchedByDetail.jsx @@ -32,13 +32,13 @@ const getLaunchedByDetails = ({ summary_fields = {}, related = {} }) => { return { link, value }; }; -export default function LaunchedByDetail({ job, i18n }) { +export default function LaunchedByDetail({ job }) { const { value: launchedByValue, link: launchedByLink } = getLaunchedByDetails(job) || {}; return ( {launchedByValue} diff --git a/awx/ui_next/src/components/DisassociateButton/DisassociateButton.jsx b/awx/ui_next/src/components/DisassociateButton/DisassociateButton.jsx index 220a242c34..697dc6b304 100644 --- a/awx/ui_next/src/components/DisassociateButton/DisassociateButton.jsx +++ b/awx/ui_next/src/components/DisassociateButton/DisassociateButton.jsx @@ -1,6 +1,6 @@ import React, { useState, useEffect, useContext } from 'react'; import { arrayOf, func, shape, string, oneOfType, number } from 'prop-types'; -import { withI18n } from '@lingui/react'; + import { t } from '@lingui/macro'; import { Button, Tooltip, DropdownItem } from '@patternfly/react-core'; import styled from 'styled-components'; @@ -13,10 +13,9 @@ const ModalNote = styled.div` `; function DisassociateButton({ - i18n, itemsToDisassociate = [], modalNote = '', - modalTitle = i18n._(t`Disassociate?`), + modalTitle = t`Disassociate?`, onDisassociate, verifyCannotDisassociate = true, }) { @@ -48,18 +47,16 @@ function DisassociateButton({ if (itemsToDisassociate.some(cannotDisassociate)) { return (
- {i18n._( - t`You do not have permission to disassociate the following: ${itemsUnableToDisassociate}` - )} + {t`You do not have permission to disassociate the following: ${itemsUnableToDisassociate}`}
); } } if (itemsToDisassociate.length) { - return i18n._(t`Disassociate`); + return t`Disassociate`; } - return i18n._(t`Select a row to disassociate`); + return t`Select a row to disassociate`; } let isDisabled = false; @@ -79,12 +76,12 @@ function DisassociateButton({ {isKebabified ? ( setIsOpen(true)} > - {i18n._(t`Disassociate`)} + {t`Disassociate`} ) : ( @@ -92,11 +89,11 @@ function DisassociateButton({ @@ -113,25 +110,25 @@ function DisassociateButton({ ouiaId="disassociate-modal-confirm" key="disassociate" variant="danger" - aria-label={i18n._(t`confirm disassociate`)} + aria-label={t`confirm disassociate`} onClick={handleDisassociate} > - {i18n._(t`Disassociate`)} + {t`Disassociate`} , , ]} > {modalNote && {modalNote}} -
{i18n._(t`This action will disassociate the following:`)}
+
{t`This action will disassociate the following:`}
{itemsToDisassociate.map(item => ( @@ -171,4 +168,4 @@ DisassociateButton.propTypes = { onDisassociate: func.isRequired, }; -export default withI18n()(DisassociateButton); +export default DisassociateButton; diff --git a/awx/ui_next/src/components/ErrorDetail/ErrorDetail.jsx b/awx/ui_next/src/components/ErrorDetail/ErrorDetail.jsx index 3b05ba47d5..2118fdfc9e 100644 --- a/awx/ui_next/src/components/ErrorDetail/ErrorDetail.jsx +++ b/awx/ui_next/src/components/ErrorDetail/ErrorDetail.jsx @@ -1,7 +1,7 @@ import React, { useState, Fragment } from 'react'; import PropTypes from 'prop-types'; import styled from 'styled-components'; -import { withI18n } from '@lingui/react'; + import { t } from '@lingui/macro'; import { @@ -32,7 +32,7 @@ const Expandable = styled(PFExpandable)` } `; -function ErrorDetail({ error, i18n }) { +function ErrorDetail({ error }) { const { response } = error; const [isExpanded, setIsExpanded] = useState(false); @@ -70,7 +70,7 @@ function ErrorDetail({ error, i18n }) { return ( @@ -87,4 +87,4 @@ ErrorDetail.propTypes = { error: PropTypes.instanceOf(Error).isRequired, }; -export default withI18n()(ErrorDetail); +export default ErrorDetail; diff --git a/awx/ui_next/src/components/ExecutionEnvironmentDetail/ExecutionEnvironmentDetail.jsx b/awx/ui_next/src/components/ExecutionEnvironmentDetail/ExecutionEnvironmentDetail.jsx index 593812c2d5..415a855d9f 100644 --- a/awx/ui_next/src/components/ExecutionEnvironmentDetail/ExecutionEnvironmentDetail.jsx +++ b/awx/ui_next/src/components/ExecutionEnvironmentDetail/ExecutionEnvironmentDetail.jsx @@ -1,7 +1,7 @@ import React from 'react'; import { bool, string } from 'prop-types'; import { Link } from 'react-router-dom'; -import { withI18n } from '@lingui/react'; + import { t } from '@lingui/macro'; import { Tooltip } from '@patternfly/react-core'; import styled from 'styled-components'; @@ -20,11 +20,10 @@ function ExecutionEnvironmentDetail({ virtualEnvironment, executionEnvironment, isDefaultEnvironment, - i18n, }) { const label = isDefaultEnvironment - ? i18n._(t`Default Execution Environment`) - : i18n._(t`Execution Environment`); + ? t`Default Execution Environment` + : t`Execution Environment`; if (executionEnvironment) { return ( @@ -47,12 +46,10 @@ function ExecutionEnvironmentDetail({ label={label} value={ <> - {i18n._(t`Missing resource`)} + {t`Missing resource`} @@ -79,4 +76,4 @@ ExecutionEnvironmentDetail.defaultProps = { virtualEnvironment: '', }; -export default withI18n()(ExecutionEnvironmentDetail); +export default ExecutionEnvironmentDetail; diff --git a/awx/ui_next/src/components/ExpandCollapse/ExpandCollapse.jsx b/awx/ui_next/src/components/ExpandCollapse/ExpandCollapse.jsx index 251ad86354..d1ee17dac4 100644 --- a/awx/ui_next/src/components/ExpandCollapse/ExpandCollapse.jsx +++ b/awx/ui_next/src/components/ExpandCollapse/ExpandCollapse.jsx @@ -1,6 +1,6 @@ import React, { Fragment } from 'react'; import PropTypes from 'prop-types'; -import { withI18n } from '@lingui/react'; + import { t } from '@lingui/macro'; import { Button as PFButton, @@ -31,14 +31,14 @@ const ToolbarItem = styled(PFToolbarItem)` // TODO: Recommend renaming this component to avoid confusion // with ExpandingContainer -function ExpandCollapse({ isCompact, onCompact, onExpand, i18n }) { +function ExpandCollapse({ isCompact, onCompact, onExpand }) { return ( @@ -43,4 +43,4 @@ FormActionGroup.defaultProps = { submitDisabled: false, }; -export default withI18n()(FormActionGroup); +export default FormActionGroup; diff --git a/awx/ui_next/src/components/FormField/PasswordInput.jsx b/awx/ui_next/src/components/FormField/PasswordInput.jsx index 3c406dcba0..4747ef1319 100644 --- a/awx/ui_next/src/components/FormField/PasswordInput.jsx +++ b/awx/ui_next/src/components/FormField/PasswordInput.jsx @@ -1,6 +1,6 @@ import React, { useState } from 'react'; import PropTypes from 'prop-types'; -import { withI18n } from '@lingui/react'; + import { t } from '@lingui/macro'; import { useField } from 'formik'; import { @@ -12,15 +12,7 @@ import { import { EyeIcon, EyeSlashIcon } from '@patternfly/react-icons'; function PasswordInput(props) { - const { - autocomplete, - id, - name, - validate, - isRequired, - isDisabled, - i18n, - } = props; + const { autocomplete, id, name, validate, isRequired, isDisabled } = props; const [inputType, setInputType] = useState('password'); const [field, meta] = useField({ name, validate }); @@ -32,13 +24,11 @@ function PasswordInput(props) { return ( <> - + , ]} > @@ -192,4 +192,4 @@ JobListCancelButton.defaultProps = { onCancel: () => {}, }; -export default withI18n()(JobListCancelButton); +export default JobListCancelButton; diff --git a/awx/ui_next/src/components/JobList/JobListItem.jsx b/awx/ui_next/src/components/JobList/JobListItem.jsx index 0a248b93d5..ad1215f8c6 100644 --- a/awx/ui_next/src/components/JobList/JobListItem.jsx +++ b/awx/ui_next/src/components/JobList/JobListItem.jsx @@ -1,6 +1,6 @@ import React, { useState } from 'react'; import { Link } from 'react-router-dom'; -import { withI18n } from '@lingui/react'; + import { t } from '@lingui/macro'; import { Button, Chip } from '@patternfly/react-core'; import { Tr, Td, ExpandableRowContent } from '@patternfly/react-table'; @@ -18,7 +18,6 @@ import { JOB_TYPE_URL_SEGMENTS } from '../../constants'; const Dash = styled.span``; function JobListItem({ - i18n, job, rowIndex, isSelected, @@ -29,12 +28,12 @@ function JobListItem({ const [isExpanded, setIsExpanded] = useState(false); const jobTypes = { - project_update: i18n._(t`Source Control Update`), - inventory_update: i18n._(t`Inventory Sync`), - job: i18n._(t`Playbook Run`), - ad_hoc_command: i18n._(t`Command`), - system_job: i18n._(t`Management Job`), - workflow_job: i18n._(t`Workflow Job`), + project_update: t`Source Control Update`, + inventory_update: t`Inventory Sync`, + job: t`Playbook Run`, + ad_hoc_command: t`Command`, + system_job: t`Management Job`, + workflow_job: t`Workflow Job`, }; const { @@ -64,9 +63,9 @@ function JobListItem({ isSelected, onSelect, }} - dataLabel={i18n._(t`Select`)} + dataLabel={t`Select`} /> - + @@ -75,19 +74,15 @@ function JobListItem({ - + {job.status && } - {showTypeColumn && ( - {jobTypes[job.type]} - )} - - {formatDateString(job.started)} - - + {showTypeColumn && {jobTypes[job.type]}} + {formatDateString(job.started)} + {job.finished ? formatDateString(job.finished) : ''} - + {job.status === 'failed' && job.type === 'job' ? ( @@ -115,7 +110,7 @@ function JobListItem({ ouiaId={`${job.id}-relaunch-button`} variant="plain" onClick={handleRelaunch} - aria-label={i18n._(t`Relaunch`)} + aria-label={t`Relaunch`} isDisabled={isLaunching} > @@ -131,10 +126,10 @@ function JobListItem({ - + {job_template && ( {job_template.name} @@ -144,7 +139,7 @@ function JobListItem({ )} {workflow_job_template && ( {source_workflow_job.id} - {source_workflow_job.name} @@ -166,7 +161,7 @@ function JobListItem({ )} {inventory && ( {project.name} @@ -198,7 +193,7 @@ function JobListItem({ {credentials && credentials.length > 0 && ( {credentials.map(c => ( @@ -211,7 +206,7 @@ function JobListItem({ {labels && labels.count > 0 && ( {labels.results.map(l => ( @@ -226,7 +221,7 @@ function JobListItem({ {job.job_explanation && ( )} @@ -239,4 +234,4 @@ function JobListItem({ } export { JobListItem as _JobListItem }; -export default withI18n()(JobListItem); +export default JobListItem; diff --git a/awx/ui_next/src/components/LaunchButton/LaunchButton.jsx b/awx/ui_next/src/components/LaunchButton/LaunchButton.jsx index ab292ee976..7424c8d35a 100644 --- a/awx/ui_next/src/components/LaunchButton/LaunchButton.jsx +++ b/awx/ui_next/src/components/LaunchButton/LaunchButton.jsx @@ -1,7 +1,7 @@ import React, { Fragment, useState } from 'react'; import { withRouter } from 'react-router-dom'; import { number, shape } from 'prop-types'; -import { withI18n } from '@lingui/react'; + import { t } from '@lingui/macro'; import AlertModal from '../AlertModal'; @@ -32,7 +32,7 @@ function canLaunchWithoutPrompt(launchData) { ); } -function LaunchButton({ resource, i18n, children, history }) { +function LaunchButton({ resource, children, history }) { const [showLaunchPrompt, setShowLaunchPrompt] = useState(false); const [launchConfig, setLaunchConfig] = useState(null); const [surveyConfig, setSurveyConfig] = useState(null); @@ -168,10 +168,10 @@ function LaunchButton({ resource, i18n, children, history }) { setError(null)} > - {i18n._(t`Failed to launch job.`)} + {t`Failed to launch job.`} )} @@ -195,4 +195,4 @@ LaunchButton.propTypes = { }).isRequired, }; -export default withI18n()(withRouter(LaunchButton)); +export default withRouter(LaunchButton); diff --git a/awx/ui_next/src/components/LaunchButton/ReLaunchDropDown.jsx b/awx/ui_next/src/components/LaunchButton/ReLaunchDropDown.jsx index 1dfca545f7..a215fa5246 100644 --- a/awx/ui_next/src/components/LaunchButton/ReLaunchDropDown.jsx +++ b/awx/ui_next/src/components/LaunchButton/ReLaunchDropDown.jsx @@ -1,5 +1,5 @@ import React, { useState } from 'react'; -import { withI18n } from '@lingui/react'; + import { t } from '@lingui/macro'; import { Dropdown, @@ -15,7 +15,7 @@ function ReLaunchDropDown({ isPrimary = false, handleRelaunch, isLaunching, - i18n, + ouiaId, }) { const [isOpen, setIsOpen] = useState(false); @@ -27,38 +27,38 @@ function ReLaunchDropDown({ const dropdownItems = [ - {i18n._(t`Relaunch on`)} + {t`Relaunch on`} , , { handleRelaunch({ hosts: 'all' }); }} isDisabled={isLaunching} > - {i18n._(t`All`)} + {t`All`} , { handleRelaunch({ hosts: 'failed' }); }} isDisabled={isLaunching} > - {i18n._(t`Failed hosts`)} + {t`Failed hosts`} , ]; @@ -74,11 +74,11 @@ function ReLaunchDropDown({ - {i18n._(t`Relaunch`)} + {t`Relaunch`} } /> @@ -96,7 +96,7 @@ function ReLaunchDropDown({ @@ -106,4 +106,4 @@ function ReLaunchDropDown({ ); } -export default withI18n()(ReLaunchDropDown); +export default ReLaunchDropDown; diff --git a/awx/ui_next/src/components/LaunchPrompt/LaunchPrompt.jsx b/awx/ui_next/src/components/LaunchPrompt/LaunchPrompt.jsx index 69716edab7..614fde426a 100644 --- a/awx/ui_next/src/components/LaunchPrompt/LaunchPrompt.jsx +++ b/awx/ui_next/src/components/LaunchPrompt/LaunchPrompt.jsx @@ -1,6 +1,6 @@ import React from 'react'; import { Wizard } from '@patternfly/react-core'; -import { withI18n } from '@lingui/react'; + import { t } from '@lingui/macro'; import { Formik, useFormikContext } from 'formik'; import ContentError from '../ContentError'; @@ -13,7 +13,7 @@ import AlertModal from '../AlertModal'; function PromptModalForm({ launchConfig, - i18n, + onCancel, onSubmit, resource, @@ -33,7 +33,7 @@ function PromptModalForm({ launchConfig, surveyConfig, resource, - i18n, + resourceDefaultCredentials ); @@ -70,7 +70,7 @@ function PromptModalForm({ { dismissError(); }} @@ -104,27 +104,27 @@ function PromptModalForm({ validateStep(nextStep.id); } }} - title={i18n._(t`Prompts`)} + title={t`Prompts`} steps={ isReady ? steps : [ { - name: i18n._(t`Content Loading`), + name: t`Content Loading`, component: , }, ] } - backButtonText={i18n._(t`Back`)} - cancelButtonText={i18n._(t`Cancel`)} - nextButtonText={i18n._(t`Next`)} + backButtonText={t`Back`} + cancelButtonText={t`Cancel`} + nextButtonText={t`Next`} /> ); } function LaunchPrompt({ launchConfig, - i18n, + onCancel, onLaunch, resource = {}, @@ -136,7 +136,6 @@ function LaunchPrompt({ onLaunch(values)} onCancel={onCancel} - i18n={i18n} launchConfig={launchConfig} surveyConfig={surveyConfig} resource={resource} @@ -147,4 +146,4 @@ function LaunchPrompt({ } export { LaunchPrompt as _LaunchPrompt }; -export default withI18n()(LaunchPrompt); +export default LaunchPrompt; diff --git a/awx/ui_next/src/components/LaunchPrompt/steps/CredentialPasswordsStep.jsx b/awx/ui_next/src/components/LaunchPrompt/steps/CredentialPasswordsStep.jsx index 675a6a8477..f57c7c15e3 100644 --- a/awx/ui_next/src/components/LaunchPrompt/steps/CredentialPasswordsStep.jsx +++ b/awx/ui_next/src/components/LaunchPrompt/steps/CredentialPasswordsStep.jsx @@ -1,11 +1,11 @@ import React from 'react'; -import { withI18n } from '@lingui/react'; + import { t } from '@lingui/macro'; import { Form } from '@patternfly/react-core'; import { useFormikContext } from 'formik'; import { PasswordField } from '../../FormField'; -function CredentialPasswordsStep({ launchConfig, i18n }) { +function CredentialPasswordsStep({ launchConfig }) { const { values: { credentials }, } = useFormikContext(); @@ -92,7 +92,7 @@ function CredentialPasswordsStep({ launchConfig, i18n }) { {showcredentialPasswordSsh && ( @@ -100,7 +100,7 @@ function CredentialPasswordsStep({ launchConfig, i18n }) { {showcredentialPasswordPrivateKeyPassphrase && ( @@ -108,7 +108,7 @@ function CredentialPasswordsStep({ launchConfig, i18n }) { {showcredentialPasswordPrivilegeEscalation && ( @@ -118,9 +118,7 @@ function CredentialPasswordsStep({ launchConfig, i18n }) { id={`launch-vault-password-${credId}`} key={credId} label={ - credId === '' - ? i18n._(t`Vault password`) - : i18n._(t`Vault password | ${credId}`) + credId === '' ? t`Vault password` : t`Vault password | ${credId}` } name={`credential_passwords['vault_password${ credId !== '' ? `.${credId}` : '' @@ -132,4 +130,4 @@ function CredentialPasswordsStep({ launchConfig, i18n }) { ); } -export default withI18n()(CredentialPasswordsStep); +export default CredentialPasswordsStep; diff --git a/awx/ui_next/src/components/LaunchPrompt/steps/CredentialsStep.jsx b/awx/ui_next/src/components/LaunchPrompt/steps/CredentialsStep.jsx index a127aaf19a..dd6ebefc9c 100644 --- a/awx/ui_next/src/components/LaunchPrompt/steps/CredentialsStep.jsx +++ b/awx/ui_next/src/components/LaunchPrompt/steps/CredentialsStep.jsx @@ -1,7 +1,7 @@ import 'styled-components/macro'; import React, { useState, useCallback, useEffect } from 'react'; import { useHistory } from 'react-router-dom'; -import { withI18n } from '@lingui/react'; + import { t } from '@lingui/macro'; import { useField } from 'formik'; import styled from 'styled-components'; @@ -27,7 +27,6 @@ const QS_CONFIG = getQSConfig('credential', { }); function CredentialsStep({ - i18n, allowCredentialsWithPasswords, defaultCredentials = [], }) { @@ -35,7 +34,6 @@ function CredentialsStep({ name: 'credentials', validate: val => { return credentialsValidator( - i18n, defaultCredentials, allowCredentialsWithPasswords, val @@ -106,7 +104,6 @@ function CredentialsStep({ useEffect(() => { helpers.setError( credentialsValidator( - i18n, defaultCredentials, allowCredentialsWithPasswords, field.value @@ -145,12 +142,12 @@ function CredentialsStep({ {types && types.length > 0 && (
- {i18n._(t`Selected Category`)} + {t`Selected Category`}
({ key: type.id, value: type.id, @@ -171,29 +168,29 @@ function CredentialsStep({ optionCount={count} searchColumns={[ { - name: i18n._(t`Name`), + name: t`Name`, key: 'name__icontains', isDefault: true, }, { - name: i18n._(t`Created By (Username)`), + name: t`Created By (Username)`, key: 'created_by__username__icontains', }, { - name: i18n._(t`Modified By (Username)`), + name: t`Modified By (Username)`, key: 'modified_by__username__icontains', }, ]} sortColumns={[ { - name: i18n._(t`Name`), + name: t`Name`, key: 'name', }, ]} searchableKeys={searchableKeys} relatedSearchableKeys={relatedSearchableKeys} multiple={isVault} - header={i18n._(t`Credentials`)} + header={t`Credentials`} name="credentials" qsConfig={QS_CONFIG} readOnly={false} @@ -218,4 +215,4 @@ function CredentialsStep({ ); } -export default withI18n()(CredentialsStep); +export default CredentialsStep; diff --git a/awx/ui_next/src/components/LaunchPrompt/steps/InventoryStep.jsx b/awx/ui_next/src/components/LaunchPrompt/steps/InventoryStep.jsx index 80c5b87bd2..0b92cd3906 100644 --- a/awx/ui_next/src/components/LaunchPrompt/steps/InventoryStep.jsx +++ b/awx/ui_next/src/components/LaunchPrompt/steps/InventoryStep.jsx @@ -1,6 +1,6 @@ import React, { useCallback, useEffect } from 'react'; import { useHistory } from 'react-router-dom'; -import { withI18n } from '@lingui/react'; + import { t } from '@lingui/macro'; import { useField } from 'formik'; import styled from 'styled-components'; @@ -22,7 +22,7 @@ const QS_CONFIG = getQSConfig('inventory', { order_by: 'name', }); -function InventoryStep({ i18n, warningMessage = null }) { +function InventoryStep({ warningMessage = null }) { const [field, meta, helpers] = useField({ name: 'inventory', }); @@ -83,28 +83,28 @@ function InventoryStep({ i18n, warningMessage = null }) { optionCount={count} searchColumns={[ { - name: i18n._(t`Name`), + name: t`Name`, key: 'name__icontains', isDefault: true, }, { - name: i18n._(t`Created By (Username)`), + name: t`Created By (Username)`, key: 'created_by__username__icontains', }, { - name: i18n._(t`Modified By (Username)`), + name: t`Modified By (Username)`, key: 'modified_by__username__icontains', }, ]} sortColumns={[ { - name: i18n._(t`Name`), + name: t`Name`, key: 'name', }, ]} searchableKeys={searchableKeys} relatedSearchableKeys={relatedSearchableKeys} - header={i18n._(t`Inventory`)} + header={t`Inventory`} name="inventory" qsConfig={QS_CONFIG} readOnly @@ -115,4 +115,4 @@ function InventoryStep({ i18n, warningMessage = null }) { ); } -export default withI18n()(InventoryStep); +export default InventoryStep; diff --git a/awx/ui_next/src/components/LaunchPrompt/steps/OtherPromptsStep.jsx b/awx/ui_next/src/components/LaunchPrompt/steps/OtherPromptsStep.jsx index 6b1aea73d5..e938cb541d 100644 --- a/awx/ui_next/src/components/LaunchPrompt/steps/OtherPromptsStep.jsx +++ b/awx/ui_next/src/components/LaunchPrompt/steps/OtherPromptsStep.jsx @@ -1,5 +1,5 @@ import React from 'react'; -import { withI18n } from '@lingui/react'; + import { t } from '@lingui/macro'; import { useField } from 'formik'; import { Form, FormGroup, Switch } from '@patternfly/react-core'; @@ -20,88 +20,84 @@ const FieldHeader = styled.div` } `; -function OtherPromptsStep({ launchConfig, i18n }) { +function OtherPromptsStep({ launchConfig }) { return ( { e.preventDefault(); }} > - {launchConfig.ask_job_type_on_launch && } + {launchConfig.ask_job_type_on_launch && } {launchConfig.ask_limit_on_launch && ( )} {launchConfig.ask_scm_branch_on_launch && ( )} - {launchConfig.ask_verbosity_on_launch && } - {launchConfig.ask_diff_mode_on_launch && ( - - )} + {launchConfig.ask_verbosity_on_launch && } + {launchConfig.ask_diff_mode_on_launch && } {launchConfig.ask_tags_on_launch && ( )} {launchConfig.ask_skip_tags_on_launch && ( )} {launchConfig.ask_variables_on_launch && ( )} ); } -function JobTypeField({ i18n }) { +function JobTypeField() { const [field, meta, helpers] = useField('job_type'); const options = [ { value: '', key: '', - label: i18n._(t`Choose a job type`), + label: t`Choose a job type`, isDisabled: true, }, - { value: 'run', key: 'run', label: i18n._(t`Run`), isDisabled: false }, + { value: 'run', key: 'run', label: t`Run`, isDisabled: false }, { value: 'check', key: 'check', - label: i18n._(t`Check`), + label: t`Check`, isDisabled: false, }, ]; @@ -109,12 +105,12 @@ function JobTypeField({ i18n }) { return ( } isRequired @@ -130,14 +126,14 @@ function JobTypeField({ i18n }) { ); } -function VerbosityField({ i18n }) { +function VerbosityField() { const [field, meta, helpers] = useField('verbosity'); const options = [ - { value: '0', key: '0', label: i18n._(t`0 (Normal)`) }, - { value: '1', key: '1', label: i18n._(t`1 (Verbose)`) }, - { value: '2', key: '2', label: i18n._(t`2 (More Verbose)`) }, - { value: '3', key: '3', label: i18n._(t`3 (Debug)`) }, - { value: '4', key: '4', label: i18n._(t`4 (Connection Debug)`) }, + { value: '0', key: '0', label: t`0 (Normal)` }, + { value: '1', key: '1', label: t`1 (Verbose)` }, + { value: '2', key: '2', label: t`2 (More Verbose)` }, + { value: '3', key: '3', label: t`3 (Debug)` }, + { value: '4', key: '4', label: t`4 (Connection Debug)` }, ]; const isValid = !(meta.touched && meta.error); @@ -146,11 +142,11 @@ function VerbosityField({ i18n }) { } > @@ -164,7 +160,7 @@ function VerbosityField({ i18n }) { ); } -function ShowChangesToggle({ i18n }) { +function ShowChangesToggle() { const [field, , helpers] = useField('diff_mode'); return ( @@ -172,20 +168,20 @@ function ShowChangesToggle({ i18n }) { {' '} @@ -206,4 +202,4 @@ function TagField({ id, name, label, tooltip }) { ); } -export default withI18n()(OtherPromptsStep); +export default OtherPromptsStep; diff --git a/awx/ui_next/src/components/LaunchPrompt/steps/PreviewStep.jsx b/awx/ui_next/src/components/LaunchPrompt/steps/PreviewStep.jsx index c2242b44fa..e5e9e90bdd 100644 --- a/awx/ui_next/src/components/LaunchPrompt/steps/PreviewStep.jsx +++ b/awx/ui_next/src/components/LaunchPrompt/steps/PreviewStep.jsx @@ -4,7 +4,7 @@ import { ExclamationCircleIcon as PFExclamationCircleIcon } from '@patternfly/re import { Tooltip } from '@patternfly/react-core'; import { t } from '@lingui/macro'; import { useFormikContext } from 'formik'; -import { withI18n } from '@lingui/react'; + import yaml from 'js-yaml'; import mergeExtraVars, { maskPasswords, @@ -25,13 +25,7 @@ const ErrorMessageWrapper = styled.div` margin-bottom: 10px; `; -function PreviewStep({ - resource, - launchConfig, - surveyConfig, - formErrors, - i18n, -}) { +function PreviewStep({ resource, launchConfig, surveyConfig, formErrors }) { const { values } = useFormikContext(); const surveyValues = getSurveyValues(values); @@ -61,10 +55,10 @@ function PreviewStep({ {formErrors && ( - {i18n._(t`Some of the previous step(s) have errors`)} + {t`Some of the previous step(s) have errors`} @@ -80,4 +74,4 @@ function PreviewStep({ ); } -export default withI18n()(PreviewStep); +export default PreviewStep; diff --git a/awx/ui_next/src/components/LaunchPrompt/steps/StepName.jsx b/awx/ui_next/src/components/LaunchPrompt/steps/StepName.jsx index d7d37989cd..6c3ee2f609 100644 --- a/awx/ui_next/src/components/LaunchPrompt/steps/StepName.jsx +++ b/awx/ui_next/src/components/LaunchPrompt/steps/StepName.jsx @@ -1,6 +1,6 @@ import React from 'react'; import styled from 'styled-components'; -import { withI18n } from '@lingui/react'; + import { t } from '@lingui/macro'; import { Tooltip } from '@patternfly/react-core'; import { ExclamationCircleIcon as PFExclamationCircleIcon } from '@patternfly/react-icons'; @@ -14,7 +14,7 @@ const ExclamationCircleIcon = styled(PFExclamationCircleIcon)` margin-left: 10px; `; -function StepName({ hasErrors, children, i18n, id }) { +function StepName({ hasErrors, children, id }) { if (!hasErrors) { return
{children}
; } @@ -24,7 +24,7 @@ function StepName({ hasErrors, children, i18n, id }) { {children} @@ -34,4 +34,4 @@ function StepName({ hasErrors, children, i18n, id }) { ); } -export default withI18n()(StepName); +export default StepName; diff --git a/awx/ui_next/src/components/LaunchPrompt/steps/SurveyStep.jsx b/awx/ui_next/src/components/LaunchPrompt/steps/SurveyStep.jsx index cbe0d62fd2..0c84e829be 100644 --- a/awx/ui_next/src/components/LaunchPrompt/steps/SurveyStep.jsx +++ b/awx/ui_next/src/components/LaunchPrompt/steps/SurveyStep.jsx @@ -1,5 +1,5 @@ import React, { useState } from 'react'; -import { withI18n } from '@lingui/react'; + import { t } from '@lingui/macro'; import { useField } from 'formik'; import { @@ -22,7 +22,7 @@ import { } from '../../../util/validators'; import { Survey } from '../../../types'; -function SurveyStep({ surveyConfig, i18n }) { +function SurveyStep({ surveyConfig }) { const fieldTypes = { text: TextField, textarea: TextField, @@ -40,9 +40,7 @@ function SurveyStep({ surveyConfig, i18n }) { > {surveyConfig.spec.map(question => { const Field = fieldTypes[question.type]; - return ( - - ); + return ; })} ); @@ -51,11 +49,11 @@ SurveyStep.propTypes = { surveyConfig: Survey.isRequired, }; -function TextField({ question, i18n }) { +function TextField({ question }) { const validators = [ - question.required ? required(null, i18n) : null, - question.required && question.min ? minLength(question.min, i18n) : null, - question.required && question.max ? maxLength(question.max, i18n) : null, + question.required ? required(null) : null, + question.required && question.min ? minLength(question.min) : null, + question.required && question.max ? maxLength(question.max) : null, ]; return ( 0; @@ -134,8 +132,7 @@ function MultiSelectField({ question, i18n }) { credential?.inputs?.vault_password === 'ASK'; export default function credentialsValidator( - i18n, defaultCredentials = [], allowCredentialsWithPasswords, selectedCredentials @@ -38,11 +37,9 @@ export default function credentialsValidator( }); if (missingCredentialTypes.length > 0) { - return i18n._( - t`Job Template default credentials must be replaced with one of the same type. Please select a credential for the following types in order to proceed: ${missingCredentialTypes.join( - ', ' - )}` - ); + return t`Job Template default credentials must be replaced with one of the same type. Please select a credential for the following types in order to proceed: ${missingCredentialTypes.join( + ', ' + )}`; } } @@ -54,11 +51,9 @@ export default function credentialsValidator( } }); if (credentialsThatPrompt.length > 0) { - return i18n._( - t`Credentials that require passwords on launch are not permitted. Please remove or replace the following credentials with a credential of the same type in order to proceed: ${credentialsThatPrompt.join( - ', ' - )}` - ); + return t`Credentials that require passwords on launch are not permitted. Please remove or replace the following credentials with a credential of the same type in order to proceed: ${credentialsThatPrompt.join( + ', ' + )}`; } } diff --git a/awx/ui_next/src/components/LaunchPrompt/steps/useCredentialPasswordsStep.jsx b/awx/ui_next/src/components/LaunchPrompt/steps/useCredentialPasswordsStep.jsx index dfdf72c5a5..c3b281083e 100644 --- a/awx/ui_next/src/components/LaunchPrompt/steps/useCredentialPasswordsStep.jsx +++ b/awx/ui_next/src/components/LaunchPrompt/steps/useCredentialPasswordsStep.jsx @@ -12,7 +12,7 @@ const isValueMissing = val => { export default function useCredentialPasswordsStep( launchConfig, - i18n, + showStep, visitedSteps ) { @@ -27,12 +27,10 @@ export default function useCredentialPasswordsStep( id: STEP_ID, name: ( - {i18n._(t`Credential passwords`)} + {t`Credential passwords`} ), - component: ( - - ), + component: , enableNext: true, } : null, @@ -51,7 +49,7 @@ export default function useCredentialPasswordsStep( }, validate: () => { const setPasswordFieldError = fieldName => { - setFieldError(fieldName, i18n._(t`This field may not be blank`)); + setFieldError(fieldName, t`This field may not be blank`); }; if ( diff --git a/awx/ui_next/src/components/LaunchPrompt/steps/useCredentialsStep.jsx b/awx/ui_next/src/components/LaunchPrompt/steps/useCredentialsStep.jsx index c390f5dde2..6b05b27b78 100644 --- a/awx/ui_next/src/components/LaunchPrompt/steps/useCredentialsStep.jsx +++ b/awx/ui_next/src/components/LaunchPrompt/steps/useCredentialsStep.jsx @@ -11,7 +11,7 @@ export default function useCredentialsStep( launchConfig, resource, resourceDefaultCredentials, - i18n, + allowCredentialsWithPasswords = false ) { const [field, meta, helpers] = useField('credentials'); @@ -22,7 +22,7 @@ export default function useCredentialsStep( return { step: getStep( launchConfig, - i18n, + allowCredentialsWithPasswords, formError, resourceDefaultCredentials @@ -37,7 +37,6 @@ export default function useCredentialsStep( validate: () => { helpers.setError( credentialsValidator( - i18n, resourceDefaultCredentials, allowCredentialsWithPasswords, field.value @@ -49,7 +48,7 @@ export default function useCredentialsStep( function getStep( launchConfig, - i18n, + allowCredentialsWithPasswords, formError, resourceDefaultCredentials @@ -62,12 +61,11 @@ function getStep( key: 4, name: ( - {i18n._(t`Credentials`)} + {t`Credentials`} ), component: ( diff --git a/awx/ui_next/src/components/LaunchPrompt/steps/useInventoryStep.jsx b/awx/ui_next/src/components/LaunchPrompt/steps/useInventoryStep.jsx index 83d60bfa00..0e69e0877c 100644 --- a/awx/ui_next/src/components/LaunchPrompt/steps/useInventoryStep.jsx +++ b/awx/ui_next/src/components/LaunchPrompt/steps/useInventoryStep.jsx @@ -15,7 +15,7 @@ const STEP_ID = 'inventory'; export default function useInventoryStep( launchConfig, resource, - i18n, + visitedSteps ) { const [, meta, helpers] = useField('inventory'); @@ -27,7 +27,7 @@ export default function useInventoryStep( !meta.value; return { - step: getStep(launchConfig, i18n, formError, resource), + step: getStep(launchConfig, formError, resource), initialValues: getInitialValues(launchConfig, resource), isReady: true, contentError: null, @@ -37,12 +37,12 @@ export default function useInventoryStep( }, validate: () => { if (meta.touched && !meta.value && resource.type === 'job_template') { - helpers.setError(i18n._(t`An inventory must be selected`)); + helpers.setError(t`An inventory must be selected`); } }, }; } -function getStep(launchConfig, i18n, formError, resource) { +function getStep(launchConfig, formError, resource) { if (!launchConfig.ask_inventory_on_launch) { return null; } @@ -50,21 +50,18 @@ function getStep(launchConfig, i18n, formError, resource) { id: STEP_ID, name: ( - {i18n._(t`Inventory`)} + {t`Inventory`} ), component: ( ) : null } diff --git a/awx/ui_next/src/components/LaunchPrompt/steps/useOtherPromptsStep.jsx b/awx/ui_next/src/components/LaunchPrompt/steps/useOtherPromptsStep.jsx index c38f23f665..f1581812e2 100644 --- a/awx/ui_next/src/components/LaunchPrompt/steps/useOtherPromptsStep.jsx +++ b/awx/ui_next/src/components/LaunchPrompt/steps/useOtherPromptsStep.jsx @@ -16,9 +16,9 @@ const getVariablesData = resource => { return '---'; }; -export default function useOtherPromptsStep(launchConfig, resource, i18n) { +export default function useOtherPromptsStep(launchConfig, resource) { return { - step: getStep(launchConfig, i18n), + step: getStep(launchConfig), initialValues: getInitialValues(launchConfig, resource), isReady: true, contentError: null, @@ -38,7 +38,7 @@ export default function useOtherPromptsStep(launchConfig, resource, i18n) { }; } -function getStep(launchConfig, i18n) { +function getStep(launchConfig) { if (!shouldShowPrompt(launchConfig)) { return null; } @@ -47,10 +47,10 @@ function getStep(launchConfig, i18n) { key: 5, name: ( - {i18n._(t`Other prompts`)} + {t`Other prompts`} ), - component: , + component: , enableNext: true, }; } diff --git a/awx/ui_next/src/components/LaunchPrompt/steps/usePreviewStep.jsx b/awx/ui_next/src/components/LaunchPrompt/steps/usePreviewStep.jsx index a53c6d6a6c..bc6e1c9e72 100644 --- a/awx/ui_next/src/components/LaunchPrompt/steps/usePreviewStep.jsx +++ b/awx/ui_next/src/components/LaunchPrompt/steps/usePreviewStep.jsx @@ -7,7 +7,7 @@ const STEP_ID = 'preview'; export default function usePreviewStep( launchConfig, - i18n, + resource, surveyConfig, hasErrors, @@ -20,7 +20,7 @@ export default function usePreviewStep( id: STEP_ID, name: ( - {i18n._(t`Preview`)} + {t`Preview`} ), component: ( @@ -32,7 +32,7 @@ export default function usePreviewStep( /> ), enableNext: !hasErrors, - nextButtonText: nextButtonText || i18n._(t`Launch`), + nextButtonText: nextButtonText || t`Launch`, } : null, initialValues: {}, diff --git a/awx/ui_next/src/components/LaunchPrompt/steps/useSurveyStep.jsx b/awx/ui_next/src/components/LaunchPrompt/steps/useSurveyStep.jsx index 6069878dd6..b02d7524aa 100644 --- a/awx/ui_next/src/components/LaunchPrompt/steps/useSurveyStep.jsx +++ b/awx/ui_next/src/components/LaunchPrompt/steps/useSurveyStep.jsx @@ -10,7 +10,7 @@ export default function useSurveyStep( launchConfig, surveyConfig, resource, - i18n, + visitedSteps ) { const { setFieldError, values } = useFormikContext(); @@ -24,10 +24,10 @@ export default function useSurveyStep( id: STEP_ID, name: ( - {i18n._(t`Survey`)} + {t`Survey`} ), - component: , + component: , enableNext: true, } : null, @@ -49,8 +49,7 @@ export default function useSurveyStep( surveyConfig.spec.forEach(question => { const errMessage = validateSurveyField( question, - values[`survey_${question.variable}`], - i18n + values[`survey_${question.variable}`] ); if (errMessage) { setFieldError(`survey_${question.variable}`, errMessage); @@ -96,26 +95,24 @@ function getInitialValues(launchConfig, surveyConfig, resource) { return values; } -function validateSurveyField(question, value, i18n) { +function validateSurveyField(question, value) { const isTextField = ['text', 'textarea'].includes(question.type); const isNumeric = ['integer', 'float'].includes(question.type); if (isTextField && (value || value === 0)) { if (question.min && value.length < question.min) { - return i18n._(t`This field must be at least ${question.min} characters`); + return t`This field must be at least ${question.min} characters`; } if (question.max && value.length > question.max) { - return i18n._(t`This field must not exceed ${question.max} characters`); + return t`This field must not exceed ${question.max} characters`; } } if (isNumeric && (value || value === 0)) { if (value < question.min || value > question.max) { - return i18n._( - t`This field must be a number and have a value between ${question.min} and ${question.max}` - ); + return t`This field must be a number and have a value between ${question.min} and ${question.max}`; } } if (question.required && !value && value !== 0) { - return i18n._(t`This field must not be blank`); + return t`This field must not be blank`; } return null; } diff --git a/awx/ui_next/src/components/LaunchPrompt/useLaunchSteps.js b/awx/ui_next/src/components/LaunchPrompt/useLaunchSteps.js index f1d0f65f59..74b962c0e1 100644 --- a/awx/ui_next/src/components/LaunchPrompt/useLaunchSteps.js +++ b/awx/ui_next/src/components/LaunchPrompt/useLaunchSteps.js @@ -43,35 +43,34 @@ export default function useLaunchSteps( launchConfig, surveyConfig, resource, - i18n, resourceDefaultCredentials ) { const [visited, setVisited] = useState({}); const [isReady, setIsReady] = useState(false); const { touched, values: formikValues } = useFormikContext(); const steps = [ - useInventoryStep(launchConfig, resource, i18n, visited), + useInventoryStep(launchConfig, resource, visited), useCredentialsStep( launchConfig, resource, resourceDefaultCredentials, - i18n, + true ), useCredentialPasswordsStep( launchConfig, - i18n, + showCredentialPasswordsStep(formikValues.credentials, launchConfig), visited ), - useOtherPromptsStep(launchConfig, resource, i18n), - useSurveyStep(launchConfig, surveyConfig, resource, i18n, visited), + useOtherPromptsStep(launchConfig, resource), + useSurveyStep(launchConfig, surveyConfig, resource, visited), ]; const { resetForm } = useFormikContext(); const hasErrors = steps.some(step => step.hasError); steps.push( - usePreviewStep(launchConfig, i18n, resource, surveyConfig, hasErrors, true) + usePreviewStep(launchConfig, resource, surveyConfig, hasErrors, true) ); const pfSteps = steps.map(s => s.step).filter(s => s != null); diff --git a/awx/ui_next/src/components/Lookup/ApplicationLookup.jsx b/awx/ui_next/src/components/Lookup/ApplicationLookup.jsx index ca5871c2cc..412e6f77ca 100644 --- a/awx/ui_next/src/components/Lookup/ApplicationLookup.jsx +++ b/awx/ui_next/src/components/Lookup/ApplicationLookup.jsx @@ -1,7 +1,7 @@ import React, { useCallback, useEffect } from 'react'; import { func, node } from 'prop-types'; import { withRouter, useLocation } from 'react-router-dom'; -import { withI18n } from '@lingui/react'; + import { t } from '@lingui/macro'; import { FormGroup } from '@patternfly/react-core'; import { ApplicationsAPI } from '../../api'; @@ -18,7 +18,7 @@ const QS_CONFIG = getQSConfig('applications', { order_by: 'name', }); -function ApplicationLookup({ i18n, onChange, value, label }) { +function ApplicationLookup({ onChange, value, label }) { const location = useLocation(); const { error, @@ -62,7 +62,7 @@ function ApplicationLookup({ i18n, onChange, value, label }) { { if (globalDefaultEnvironment) { - return i18n._(t`Global Default Execution Environment`); + return t`Global Default Execution Environment`; } if (defaultExecutionEnvironment) { - return i18n._(t`Default Execution Environment`); + return t`Default Execution Environment`; } - return i18n._(t`Execution Environment`); + return t`Execution Environment`; }; return ( @@ -210,4 +210,4 @@ ExecutionEnvironmentLookup.defaultProps = { organizationId: null, }; -export default withI18n()(ExecutionEnvironmentLookup); +export default ExecutionEnvironmentLookup; diff --git a/awx/ui_next/src/components/Lookup/HostFilterLookup.jsx b/awx/ui_next/src/components/Lookup/HostFilterLookup.jsx index 5cd1c2d598..bdbb0342cc 100644 --- a/awx/ui_next/src/components/Lookup/HostFilterLookup.jsx +++ b/awx/ui_next/src/components/Lookup/HostFilterLookup.jsx @@ -1,7 +1,7 @@ import React, { useState, useEffect, useCallback } from 'react'; import { withRouter, useHistory, useLocation } from 'react-router-dom'; import { number, func, bool, string } from 'prop-types'; -import { withI18n } from '@lingui/react'; + import styled from 'styled-components'; import { t } from '@lingui/macro'; import { SearchIcon } from '@patternfly/react-icons'; @@ -72,46 +72,46 @@ const QS_CONFIG = getQSConfig( ['id', 'page', 'page_size', 'inventory'] ); -const buildSearchColumns = i18n => [ +const buildSearchColumns = () => [ { - name: i18n._(t`Name`), + name: t`Name`, key: 'name__icontains', isDefault: true, }, { - name: i18n._(t`ID`), + name: t`ID`, key: 'id', }, { - name: i18n._(t`Group`), + name: t`Group`, key: 'groups__name__icontains', }, { - name: i18n._(t`Inventory ID`), + name: t`Inventory ID`, key: 'inventory', }, { - name: i18n._(t`Enabled`), + name: t`Enabled`, key: 'enabled', isBoolean: true, }, { - name: i18n._(t`Instance ID`), + name: t`Instance ID`, key: 'instance_id', }, { - name: i18n._(t`Last job`), + name: t`Last job`, key: 'last_job', }, { - name: i18n._(t`Insights system ID`), + name: t`Insights system ID`, key: 'insights_system_id', }, ]; function HostFilterLookup({ helperTextInvalid, - i18n, + isValid, isDisabled, onBlur, @@ -124,7 +124,7 @@ function HostFilterLookup({ const [chips, setChips] = useState({}); const [queryString, setQueryString] = useState(''); const { isModalOpen, toggleModal, closeModal } = useModal(); - const searchColumns = buildSearchColumns(i18n); + const searchColumns = buildSearchColumns(); const { result: { count, hosts, relatedSearchableKeys, searchableKeys }, @@ -248,7 +248,7 @@ function HostFilterLookup({ , , ]} > @@ -337,7 +334,7 @@ function HostFilterLookup({ itemCount={count} items={hosts} onRowClick={() => {}} - pluralizedItemName={i18n._(t`hosts`)} + pluralizedItemName={t`hosts`} qsConfig={QS_CONFIG} renderItem={item => ( + {item.name} , - + {item.summary_fields.inventory.name} , ]} @@ -37,4 +37,4 @@ function HostListItem({ item, i18n }) { ); } -export default withI18n()(HostListItem); +export default HostListItem; diff --git a/awx/ui_next/src/components/Lookup/InstanceGroupsLookup.jsx b/awx/ui_next/src/components/Lookup/InstanceGroupsLookup.jsx index 1b4bfb5e59..3f21abccd8 100644 --- a/awx/ui_next/src/components/Lookup/InstanceGroupsLookup.jsx +++ b/awx/ui_next/src/components/Lookup/InstanceGroupsLookup.jsx @@ -1,7 +1,7 @@ import React, { useCallback, useEffect } from 'react'; import { arrayOf, string, func, bool } from 'prop-types'; import { withRouter } from 'react-router-dom'; -import { withI18n } from '@lingui/react'; + import { t } from '@lingui/macro'; import { FormGroup } from '@patternfly/react-core'; import { InstanceGroupsAPI } from '../../api'; @@ -20,15 +20,7 @@ const QS_CONFIG = getQSConfig('instance-groups', { }); function InstanceGroupsLookup(props) { - const { - value, - onChange, - tooltip, - className, - required, - history, - i18n, - } = props; + const { value, onChange, tooltip, className, required, history } = props; const { result: { instanceGroups, count, relatedSearchableKeys, searchableKeys }, @@ -68,13 +60,13 @@ function InstanceGroupsLookup(props) { return ( } fieldId="org-instance-groups" > , , ]} > @@ -197,4 +197,4 @@ Lookup.defaultProps = { }; export { Lookup as _Lookup }; -export default withI18n()(withRouter(Lookup)); +export default withRouter(Lookup); diff --git a/awx/ui_next/src/components/Lookup/MultiCredentialsLookup.jsx b/awx/ui_next/src/components/Lookup/MultiCredentialsLookup.jsx index d2b4e3fb1e..771a880738 100644 --- a/awx/ui_next/src/components/Lookup/MultiCredentialsLookup.jsx +++ b/awx/ui_next/src/components/Lookup/MultiCredentialsLookup.jsx @@ -2,7 +2,7 @@ import 'styled-components/macro'; import React, { Fragment, useState, useCallback, useEffect } from 'react'; import { withRouter } from 'react-router-dom'; import PropTypes from 'prop-types'; -import { withI18n } from '@lingui/react'; + import { t } from '@lingui/macro'; import { ToolbarItem, Alert } from '@patternfly/react-core'; import { CredentialsAPI, CredentialTypesAPI } from '../../api'; @@ -27,7 +27,7 @@ async function loadCredentials(params, selectedCredentialTypeId) { } function MultiCredentialsLookup(props) { - const { value, onChange, onError, history, i18n } = props; + const { value, onChange, onError, history } = props; const [selectedType, setSelectedType] = useState(null); const isMounted = useIsMounted(); @@ -128,7 +128,7 @@ function MultiCredentialsLookup(props) { return ( )} {credentialTypes && credentialTypes.length > 0 && (
- {i18n._(t`Selected Category`)} + {t`Selected Category`}
({ key: type.id, value: type.id, @@ -178,29 +176,29 @@ function MultiCredentialsLookup(props) { optionCount={credentialsCount} searchColumns={[ { - name: i18n._(t`Name`), + name: t`Name`, key: 'name__icontains', isDefault: true, }, { - name: i18n._(t`Created By (Username)`), + name: t`Created By (Username)`, key: 'created_by__username__icontains', }, { - name: i18n._(t`Modified By (Username)`), + name: t`Modified By (Username)`, key: 'modified_by__username__icontains', }, ]} sortColumns={[ { - name: i18n._(t`Name`), + name: t`Name`, key: 'name', }, ]} searchableKeys={searchableKeys} relatedSearchableKeys={relatedSearchableKeys} multiple={isVault} - header={i18n._(t`Credentials`)} + header={t`Credentials`} displayKey={isVault ? 'label' : 'name'} name="credentials" qsConfig={QS_CONFIG} @@ -249,4 +247,4 @@ MultiCredentialsLookup.defaultProps = { }; export { MultiCredentialsLookup as _MultiCredentialsLookup }; -export default withI18n()(withRouter(MultiCredentialsLookup)); +export default withRouter(MultiCredentialsLookup); diff --git a/awx/ui_next/src/components/Lookup/OrganizationLookup.jsx b/awx/ui_next/src/components/Lookup/OrganizationLookup.jsx index 8252c9035c..b3fa6ee194 100644 --- a/awx/ui_next/src/components/Lookup/OrganizationLookup.jsx +++ b/awx/ui_next/src/components/Lookup/OrganizationLookup.jsx @@ -1,7 +1,7 @@ import React, { useCallback, useEffect } from 'react'; import { node, func, bool } from 'prop-types'; import { withRouter } from 'react-router-dom'; -import { withI18n } from '@lingui/react'; + import { t } from '@lingui/macro'; import { FormGroup } from '@patternfly/react-core'; import { OrganizationsAPI } from '../../api'; @@ -21,7 +21,7 @@ const QS_CONFIG = getQSConfig('organizations', { function OrganizationLookup({ helperTextInvalid, - i18n, + isValid, onBlur, onChange, @@ -79,13 +79,13 @@ function OrganizationLookup({ helperTextInvalid={helperTextInvalid} isRequired={required} validated={isValid ? 'default' : 'error'} - label={i18n._(t`Organization`)} + label={t`Organization`} helperText={helperText} > } > - {error.message || i18n._(t`An error occurred`)} + {error.message || t`An error occurred`} ); } -export default withI18n()(LookupErrorMessage); +export default LookupErrorMessage; diff --git a/awx/ui_next/src/components/NotificationList/NotificationList.jsx b/awx/ui_next/src/components/NotificationList/NotificationList.jsx index 4422dc8c01..aca57d8c94 100644 --- a/awx/ui_next/src/components/NotificationList/NotificationList.jsx +++ b/awx/ui_next/src/components/NotificationList/NotificationList.jsx @@ -1,7 +1,7 @@ import React, { useEffect, useCallback, useState } from 'react'; import { useLocation } from 'react-router-dom'; import { number, shape, bool } from 'prop-types'; -import { withI18n } from '@lingui/react'; + import { t } from '@lingui/macro'; import AlertModal from '../AlertModal'; import ErrorDetail from '../ErrorDetail'; @@ -21,7 +21,7 @@ function NotificationList({ apiModel, canToggleNotifications, id, - i18n, + showApprovalsToggle, }) { const location = useLocation(); @@ -174,40 +174,40 @@ function NotificationList({ hasContentLoading={isLoading} items={notifications} itemCount={itemCount} - pluralizedItemName={i18n._(t`Notifications`)} + pluralizedItemName={t`Notifications`} qsConfig={QS_CONFIG} toolbarSearchColumns={[ { - name: i18n._(t`Name`), + name: t`Name`, key: 'name__icontains', isDefault: true, }, { - name: i18n._(t`Description`), + name: t`Description`, key: 'description__icontains', }, { - name: i18n._(t`Notification type`), + name: t`Notification type`, key: 'or__notification_type', options: [ - ['email', i18n._(t`Email`)], - ['grafana', i18n._(t`Grafana`)], - ['hipchat', i18n._(t`Hipchat`)], - ['irc', i18n._(t`IRC`)], - ['mattermost', i18n._(t`Mattermost`)], - ['pagerduty', i18n._(t`Pagerduty`)], - ['rocketchat', i18n._(t`Rocket.Chat`)], - ['slack', i18n._(t`Slack`)], - ['twilio', i18n._(t`Twilio`)], - ['webhook', i18n._(t`Webhook`)], + ['email', t`Email`], + ['grafana', t`Grafana`], + ['hipchat', t`Hipchat`], + ['irc', t`IRC`], + ['mattermost', t`Mattermost`], + ['pagerduty', t`Pagerduty`], + ['rocketchat', t`Rocket.Chat`], + ['slack', t`Slack`], + ['twilio', t`Twilio`], + ['webhook', t`Webhook`], ], }, { - name: i18n._(t`Created By (Username)`), + name: t`Created By (Username)`, key: 'created_by__username__icontains', }, { - name: i18n._(t`Modified By (Username)`), + name: t`Modified By (Username)`, key: 'modified_by__username__icontains', }, ]} @@ -215,11 +215,9 @@ function NotificationList({ toolbarRelatedSearchableKeys={relatedSearchableKeys} headerRow={ - {i18n._(t`Name`)} - - {i18n._(t`Type`)} - - {i18n._(t`Options`)} + {t`Name`} + {t`Type`} + {t`Options`} } renderRow={(notification, index) => ( @@ -245,11 +243,11 @@ function NotificationList({ {toggleError && ( setToggleError(null)} > - {i18n._(t`Failed to toggle notification.`)} + {t`Failed to toggle notification.`} )} @@ -268,4 +266,4 @@ NotificationList.defaultProps = { showApprovalsToggle: false, }; -export default withI18n()(NotificationList); +export default NotificationList; diff --git a/awx/ui_next/src/components/NotificationList/NotificationListItem.jsx b/awx/ui_next/src/components/NotificationList/NotificationListItem.jsx index 5b0fc2fad7..faf88aae29 100644 --- a/awx/ui_next/src/components/NotificationList/NotificationListItem.jsx +++ b/awx/ui_next/src/components/NotificationList/NotificationListItem.jsx @@ -1,6 +1,6 @@ import React from 'react'; import { shape, number, string, bool, func } from 'prop-types'; -import { withI18n } from '@lingui/react'; + import { t } from '@lingui/macro'; import { Link } from 'react-router-dom'; import { Switch } from '@patternfly/react-core'; @@ -16,29 +16,24 @@ function NotificationListItem({ successTurnedOn, errorTurnedOn, toggleNotification, - i18n, + typeLabels, showApprovalsToggle, }) { return ( - + {notification.name} - - {typeLabels[notification.notification_type]} - - + {typeLabels[notification.notification_type]} + @@ -48,46 +43,46 @@ function NotificationListItem({ 'approvals' ) } - aria-label={i18n._(t`Toggle notification approvals`)} + aria-label={t`Toggle notification approvals`} /> toggleNotification(notification.id, startedTurnedOn, 'started') } - aria-label={i18n._(t`Toggle notification start`)} + aria-label={t`Toggle notification start`} /> toggleNotification(notification.id, successTurnedOn, 'success') } - aria-label={i18n._(t`Toggle notification success`)} + aria-label={t`Toggle notification success`} /> toggleNotification(notification.id, errorTurnedOn, 'error') } - aria-label={i18n._(t`Toggle notification failure`)} + aria-label={t`Toggle notification failure`} /> @@ -120,4 +115,4 @@ NotificationListItem.defaultProps = { showApprovalsToggle: false, }; -export default withI18n()(NotificationListItem); +export default NotificationListItem; diff --git a/awx/ui_next/src/components/OptionsList/OptionsList.jsx b/awx/ui_next/src/components/OptionsList/OptionsList.jsx index 86abce0001..ef6f23da75 100644 --- a/awx/ui_next/src/components/OptionsList/OptionsList.jsx +++ b/awx/ui_next/src/components/OptionsList/OptionsList.jsx @@ -9,7 +9,7 @@ import { oneOfType, } from 'prop-types'; import styled from 'styled-components'; -import { withI18n } from '@lingui/react'; + import { t } from '@lingui/macro'; import SelectedList from '../SelectedList'; import PaginatedDataList from '../PaginatedDataList'; @@ -41,14 +41,14 @@ function OptionsList({ deselectItem, renderItemChip, isLoading, - i18n, + displayKey, }) { return ( {value.length > 0 && ( deselectItem(item)} isReadOnly={readOnly} @@ -113,4 +113,4 @@ OptionsList.defaultProps = { displayKey: 'name', }; -export default withI18n()(OptionsList); +export default OptionsList; diff --git a/awx/ui_next/src/components/PaginatedDataList/PaginatedDataList.jsx b/awx/ui_next/src/components/PaginatedDataList/PaginatedDataList.jsx index 60412ae0d5..aaeed5455b 100644 --- a/awx/ui_next/src/components/PaginatedDataList/PaginatedDataList.jsx +++ b/awx/ui_next/src/components/PaginatedDataList/PaginatedDataList.jsx @@ -2,7 +2,7 @@ import React, { Fragment } from 'react'; import PropTypes from 'prop-types'; import { DataList } from '@patternfly/react-core'; -import { withI18n } from '@lingui/react'; + import { t } from '@lingui/macro'; import { withRouter, useHistory, useLocation } from 'react-router-dom'; @@ -40,7 +40,7 @@ function PaginatedDataList({ pluralizedItemName, showPageSizeOptions, location, - i18n, + renderToolbar, }) { const { search, pathname } = useLocation(); @@ -74,7 +74,7 @@ function PaginatedDataList({ ? toolbarSearchColumns : [ { - name: i18n._(t`Name`), + name: t`Name`, key: 'name', isDefault: true, }, @@ -83,17 +83,15 @@ function PaginatedDataList({ ? toolbarSortColumns : [ { - name: i18n._(t`Name`), + name: t`Name`, key: 'name', }, ]; const queryParams = parseQueryString(qsConfig, location.search); - const dataListLabel = i18n._(t`${pluralizedItemName} List`); - const emptyContentMessage = i18n._( - t`Please add ${pluralizedItemName} to populate this list ` - ); - const emptyContentTitle = i18n._(t`No ${pluralizedItemName} Found `); + const dataListLabel = t`${pluralizedItemName} List`; + const emptyContentMessage = t`Please add ${pluralizedItemName} to populate this list `; + const emptyContentTitle = t`No ${pluralizedItemName} Found `; let Content; if (hasContentLoading && items.length <= 0) { @@ -218,4 +216,4 @@ PaginatedDataList.defaultProps = { }; export { PaginatedDataList as _PaginatedDataList }; -export default withI18n()(withRouter(PaginatedDataList)); +export default withRouter(PaginatedDataList); diff --git a/awx/ui_next/src/components/PaginatedDataList/ToolbarAddButton.jsx b/awx/ui_next/src/components/PaginatedDataList/ToolbarAddButton.jsx index 3190bfbc27..846942b168 100644 --- a/awx/ui_next/src/components/PaginatedDataList/ToolbarAddButton.jsx +++ b/awx/ui_next/src/components/PaginatedDataList/ToolbarAddButton.jsx @@ -3,16 +3,16 @@ import { string, func } from 'prop-types'; import { Link } from 'react-router-dom'; import { Button, DropdownItem, Tooltip } from '@patternfly/react-core'; import CaretDownIcon from '@patternfly/react-icons/dist/js/icons/caret-down-icon'; -import { withI18n } from '@lingui/react'; + import { t } from '@lingui/macro'; import { useKebabifiedMenu } from '../../contexts/Kebabified'; function ToolbarAddButton({ linkTo, onClick, - i18n, + isDisabled, - defaultLabel = i18n._(t`Add`), + defaultLabel = t`Add`, showToggleIndicator, }) { const { isKebabified } = useKebabifiedMenu(); @@ -72,4 +72,4 @@ ToolbarAddButton.defaultProps = { onClick: null, }; -export default withI18n()(ToolbarAddButton); +export default ToolbarAddButton; diff --git a/awx/ui_next/src/components/PaginatedTable/PaginatedTable.jsx b/awx/ui_next/src/components/PaginatedTable/PaginatedTable.jsx index ffd9878d60..33dc4c70af 100644 --- a/awx/ui_next/src/components/PaginatedTable/PaginatedTable.jsx +++ b/awx/ui_next/src/components/PaginatedTable/PaginatedTable.jsx @@ -2,7 +2,7 @@ import 'styled-components/macro'; import React, { Fragment } from 'react'; import PropTypes from 'prop-types'; import { TableComposable, Tbody } from '@patternfly/react-table'; -import { withI18n } from '@lingui/react'; + import { t } from '@lingui/macro'; import { useHistory } from 'react-router-dom'; @@ -35,7 +35,7 @@ function PaginatedTable({ toolbarRelatedSearchableKeys, pluralizedItemName, showPageSizeOptions, - i18n, + renderToolbar, emptyContentMessage, ouiaId, @@ -67,15 +67,15 @@ function PaginatedTable({ ? toolbarSearchColumns : [ { - name: i18n._(t`Name`), + name: t`Name`, key: 'name', isDefault: true, }, ]; const queryParams = parseQueryString(qsConfig, history.location.search); - const dataListLabel = i18n._(t`${pluralizedItemName} List`); - const emptyContentTitle = i18n._(t`No ${pluralizedItemName} Found `); + const dataListLabel = t`${pluralizedItemName} List`; + const emptyContentTitle = t`No ${pluralizedItemName} Found `; let Content; if (hasContentLoading && items.length <= 0) { @@ -88,7 +88,7 @@ function PaginatedTable({ title={emptyContentTitle} message={ emptyContentMessage || - i18n._(t`Please add ${pluralizedItemName} to populate this list `) + t`Please add ${pluralizedItemName} to populate this list ` } /> ); @@ -201,4 +201,4 @@ PaginatedTable.defaultProps = { }; export { PaginatedTable as _PaginatedTable }; -export default withI18n()(PaginatedTable); +export default PaginatedTable; diff --git a/awx/ui_next/src/components/Pagination/Pagination.jsx b/awx/ui_next/src/components/Pagination/Pagination.jsx index 88384be7f3..139cda4ad4 100644 --- a/awx/ui_next/src/components/Pagination/Pagination.jsx +++ b/awx/ui_next/src/components/Pagination/Pagination.jsx @@ -4,7 +4,7 @@ import { Pagination as PFPagination, DropdownDirection, } from '@patternfly/react-core'; -import { i18n } from '@lingui/core'; +import {} from '@lingui/core'; import { t } from '@lingui/macro'; const AWXPagination = styled(PFPagination)` @@ -21,18 +21,18 @@ const AWXPagination = styled(PFPagination)` export default props => ( e.preventDefault()} @@ -63,4 +54,4 @@ Popover.defaultProps = { maxWidth: '', }; -export default withI18n()(Popover); +export default Popover; diff --git a/awx/ui_next/src/components/PromptDetail/PromptDetail.jsx b/awx/ui_next/src/components/PromptDetail/PromptDetail.jsx index 61eede896d..4069f67270 100644 --- a/awx/ui_next/src/components/PromptDetail/PromptDetail.jsx +++ b/awx/ui_next/src/components/PromptDetail/PromptDetail.jsx @@ -1,7 +1,7 @@ import 'styled-components/macro'; import React from 'react'; import { shape } from 'prop-types'; -import { withI18n } from '@lingui/react'; + import { t, Trans } from '@lingui/macro'; import { Link } from 'react-router-dom'; import styled from 'styled-components'; @@ -90,13 +90,13 @@ function omitOverrides(resource, overrides, defaultConfig) { return clonedResource; } -function PromptDetail({ i18n, resource, launchConfig = {}, overrides = {} }) { +function PromptDetail({ resource, launchConfig = {}, overrides = {} }) { const VERBOSITY = { - 0: i18n._(t`0 (Normal)`), - 1: i18n._(t`1 (Verbose)`), - 2: i18n._(t`2 (More Verbose)`), - 3: i18n._(t`3 (Debug)`), - 4: i18n._(t`4 (Connection Debug)`), + 0: t`0 (Normal)`, + 1: t`1 (Verbose)`, + 2: t`2 (More Verbose)`, + 3: t`3 (Debug)`, + 4: t`4 (Connection Debug)`, }; const details = omitOverrides(resource, overrides, launchConfig.defaults); @@ -106,16 +106,13 @@ function PromptDetail({ i18n, resource, launchConfig = {}, overrides = {} }) { return ( <> - - + + - + {details?.type === 'project' && ( )} @@ -130,14 +127,14 @@ function PromptDetail({ i18n, resource, launchConfig = {}, overrides = {} }) { )} {details?.created && ( )} {details?.modified && ( @@ -146,21 +143,19 @@ function PromptDetail({ i18n, resource, launchConfig = {}, overrides = {} }) { {hasPromptData(launchConfig) && hasOverrides && ( <> - - {i18n._(t`Prompted Values`)} - + {t`Prompted Values`} - + {launchConfig.ask_job_type_on_launch && ( )} {launchConfig.ask_credential_on_launch && ( )} {launchConfig.ask_inventory_on_launch && ( - + )} {launchConfig.ask_scm_branch_on_launch && ( )} {launchConfig.ask_limit_on_launch && ( - + )} {Object.prototype.hasOwnProperty.call(overrides, 'verbosity') && launchConfig.ask_verbosity_on_launch ? ( ) : null} {launchConfig.ask_tags_on_launch && ( )} {(launchConfig.survey_enabled || launchConfig.ask_variables_on_launch) && ( @@ -278,4 +268,4 @@ PromptDetail.propTypes = { launchConfig: shape({}), }; -export default withI18n()(PromptDetail); +export default PromptDetail; diff --git a/awx/ui_next/src/components/PromptDetail/PromptInventorySourceDetail.jsx b/awx/ui_next/src/components/PromptDetail/PromptInventorySourceDetail.jsx index 587c399a1e..11869d150a 100644 --- a/awx/ui_next/src/components/PromptDetail/PromptInventorySourceDetail.jsx +++ b/awx/ui_next/src/components/PromptDetail/PromptInventorySourceDetail.jsx @@ -1,5 +1,5 @@ import React from 'react'; -import { withI18n } from '@lingui/react'; + import { t } from '@lingui/macro'; import { Link } from 'react-router-dom'; @@ -10,7 +10,7 @@ import CredentialChip from '../CredentialChip'; import ChipGroup from '../ChipGroup'; import ExecutionEnvironmentDetail from '../ExecutionEnvironmentDetail'; -function PromptInventorySourceDetail({ i18n, resource }) { +function PromptInventorySourceDetail({ resource }) { const { custom_virtualenv, group_by, @@ -29,11 +29,11 @@ function PromptInventorySourceDetail({ i18n, resource }) { } = resource; const VERBOSITY = { - 0: i18n._(t`0 (Normal)`), - 1: i18n._(t`1 (Verbose)`), - 2: i18n._(t`2 (More Verbose)`), - 3: i18n._(t`3 (Debug)`), - 4: i18n._(t`4 (Connection Debug)`), + 0: t`0 (Normal)`, + 1: t`1 (Verbose)`, + 2: t`2 (More Verbose)`, + 3: t`3 (Debug)`, + 4: t`4 (Connection Debug)`, }; let optionsList = ''; @@ -45,13 +45,11 @@ function PromptInventorySourceDetail({ i18n, resource }) { ) { optionsList = ( - {overwrite && {i18n._(t`Overwrite`)}} - {overwrite_vars && ( - {i18n._(t`Overwrite Variables`)} - )} - {update_on_launch && {i18n._(t`Update on Launch`)}} + {overwrite && {t`Overwrite`}} + {overwrite_vars && {t`Overwrite Variables`}} + {update_on_launch && {t`Update on Launch`}} {update_on_project_update && ( - {i18n._(t`Update on Project Update`)} + {t`Update on Project Update`} )} ); @@ -61,7 +59,7 @@ function PromptInventorySourceDetail({ i18n, resource }) { <> {summary_fields?.organization ? ( ) : ( - + )} {summary_fields?.inventory && ( {summary_fields?.inventory?.name} @@ -83,10 +81,10 @@ function PromptInventorySourceDetail({ i18n, resource }) { } /> )} - + {summary_fields?.source_project && ( {summary_fields.source_project?.name} @@ -98,16 +96,16 @@ function PromptInventorySourceDetail({ i18n, resource }) { virtualEnvironment={custom_virtualenv} executionEnvironment={summary_fields?.execution_environment} /> - - + + {summary_fields?.credentials?.length > 0 && ( ( ))} @@ -116,7 +114,7 @@ function PromptInventorySourceDetail({ i18n, resource }) { {source_regions && ( {group_by.split(',').map(group => ( @@ -164,10 +162,10 @@ function PromptInventorySourceDetail({ i18n, resource }) { } /> )} - {optionsList && } + {optionsList && } {source_vars && ( @@ -176,4 +174,4 @@ function PromptInventorySourceDetail({ i18n, resource }) { ); } -export default withI18n()(PromptInventorySourceDetail); +export default PromptInventorySourceDetail; diff --git a/awx/ui_next/src/components/PromptDetail/PromptJobTemplateDetail.jsx b/awx/ui_next/src/components/PromptDetail/PromptJobTemplateDetail.jsx index 0442a2d4de..b0763d8717 100644 --- a/awx/ui_next/src/components/PromptDetail/PromptJobTemplateDetail.jsx +++ b/awx/ui_next/src/components/PromptDetail/PromptJobTemplateDetail.jsx @@ -1,5 +1,5 @@ import React from 'react'; -import { withI18n } from '@lingui/react'; + import { t } from '@lingui/macro'; import { Link } from 'react-router-dom'; @@ -12,7 +12,7 @@ import { VariablesDetail } from '../CodeEditor'; import ExecutionEnvironmentDetail from '../ExecutionEnvironmentDetail'; import { toTitleCase } from '../../util/strings'; -function PromptJobTemplateDetail({ i18n, resource }) { +function PromptJobTemplateDetail({ resource }) { const { allow_simultaneous, ask_inventory_on_launch, @@ -39,11 +39,11 @@ function PromptJobTemplateDetail({ i18n, resource }) { } = resource; const VERBOSITY = { - 0: i18n._(t`0 (Normal)`), - 1: i18n._(t`1 (Verbose)`), - 2: i18n._(t`2 (More Verbose)`), - 3: i18n._(t`3 (Debug)`), - 4: i18n._(t`4 (Connection Debug)`), + 0: t`0 (Normal)`, + 1: t`1 (Verbose)`, + 2: t`2 (More Verbose)`, + 3: t`3 (Debug)`, + 4: t`4 (Connection Debug)`, }; let optionsList = ''; @@ -56,15 +56,13 @@ function PromptJobTemplateDetail({ i18n, resource }) { optionsList = ( {become_enabled && ( - {i18n._(t`Enable Privilege Escalation`)} + {t`Enable Privilege Escalation`} )} {host_config_key && ( - {i18n._(t`Allow Provisioning Callbacks`)} + {t`Allow Provisioning Callbacks`} )} - {allow_simultaneous && ( - {i18n._(t`Enable Concurrent Jobs`)} - )} - {use_fact_cache && {i18n._(t`Use Fact Storage`)}} + {allow_simultaneous && {t`Enable Concurrent Jobs`}} + {use_fact_cache && {t`Use Fact Storage`}} ); } @@ -82,15 +80,12 @@ function PromptJobTemplateDetail({ i18n, resource }) { return ( <> {summary_fields.recent_jobs?.length > 0 && ( - } - label={i18n._(t`Activity`)} - /> + } label={t`Activity`} /> )} - + {summary_fields?.organization ? ( ) : ( - + )} {summary_fields?.inventory ? ( ) : ( - !ask_inventory_on_launch && ( - - ) + !ask_inventory_on_launch && )} {summary_fields?.project ? ( {summary_fields.project?.name} @@ -128,46 +121,40 @@ function PromptJobTemplateDetail({ i18n, resource }) { } /> ) : ( - + )} - - - - - + + + + + {typeof diff_mode === 'boolean' && ( - + )} - - + + {related?.callback && ( )} - + {related?.webhook_receiver && ( )} - + {summary_fields?.webhook_credential && ( )} - {optionsList && } + {optionsList && } {summary_fields?.credentials?.length > 0 && ( 0 && ( 0 && ( {instance_groups.map(ig => ( @@ -230,7 +217,7 @@ function PromptJobTemplateDetail({ i18n, resource }) { {job_tags?.length > 0 && ( {job_tags.split(',').map(jobTag => ( @@ -245,7 +232,7 @@ function PromptJobTemplateDetail({ i18n, resource }) { {skip_tags?.length > 0 && ( {skip_tags.split(',').map(skipTag => ( @@ -258,14 +245,10 @@ function PromptJobTemplateDetail({ i18n, resource }) { /> )} {extra_vars && ( - + )} ); } -export default withI18n()(PromptJobTemplateDetail); +export default PromptJobTemplateDetail; diff --git a/awx/ui_next/src/components/PromptDetail/PromptProjectDetail.jsx b/awx/ui_next/src/components/PromptDetail/PromptProjectDetail.jsx index f47045aee3..dd2fe8b5a9 100644 --- a/awx/ui_next/src/components/PromptDetail/PromptProjectDetail.jsx +++ b/awx/ui_next/src/components/PromptDetail/PromptProjectDetail.jsx @@ -1,5 +1,5 @@ import React from 'react'; -import { withI18n } from '@lingui/react'; + import { t } from '@lingui/macro'; import { List, ListItem } from '@patternfly/react-core'; import { Link } from 'react-router-dom'; @@ -10,7 +10,7 @@ import CredentialChip from '../CredentialChip'; import { toTitleCase } from '../../util/strings'; import ExecutionEnvironmentDetail from '../ExecutionEnvironmentDetail'; -function PromptProjectDetail({ i18n, resource }) { +function PromptProjectDetail({ resource }) { const { allow_override, custom_virtualenv, @@ -37,21 +37,15 @@ function PromptProjectDetail({ i18n, resource }) { ) { optionsList = ( - {scm_clean && {i18n._(t`Clean`)}} - {scm_delete_on_update && ( - {i18n._(t`Delete on Update`)} - )} + {scm_clean && {t`Clean`}} + {scm_delete_on_update && {t`Delete on Update`}} {scm_track_submodules && ( - - {i18n._(t`Track submodules latest commit on branch`)} - + {t`Track submodules latest commit on branch`} )} {scm_update_on_launch && ( - {i18n._(t`Update Revision on Launch`)} - )} - {allow_override && ( - {i18n._(t`Allow Branch Override`)} + {t`Update Revision on Launch`} )} + {allow_override && {t`Allow Branch Override`}} ); } @@ -60,7 +54,7 @@ function PromptProjectDetail({ i18n, resource }) { <> {summary_fields?.organization ? ( ) : ( - + )} - - - + + + {summary_fields?.credential?.id && ( )} - {optionsList && } + {optionsList && } {({ project_base_dir }) => ( - + )} - + ); } -export default withI18n()(PromptProjectDetail); +export default PromptProjectDetail; diff --git a/awx/ui_next/src/components/PromptDetail/PromptWFJobTemplateDetail.jsx b/awx/ui_next/src/components/PromptDetail/PromptWFJobTemplateDetail.jsx index 0778bbc649..72e10660b8 100644 --- a/awx/ui_next/src/components/PromptDetail/PromptWFJobTemplateDetail.jsx +++ b/awx/ui_next/src/components/PromptDetail/PromptWFJobTemplateDetail.jsx @@ -1,5 +1,5 @@ import React from 'react'; -import { withI18n } from '@lingui/react'; + import { t } from '@lingui/macro'; import { Link } from 'react-router-dom'; @@ -11,7 +11,7 @@ import { VariablesDetail } from '../CodeEditor'; import Sparkline from '../Sparkline'; import { toTitleCase } from '../../util/strings'; -function PromptWFJobTemplateDetail({ i18n, resource }) { +function PromptWFJobTemplateDetail({ resource }) { const { allow_simultaneous, extra_vars, @@ -27,10 +27,8 @@ function PromptWFJobTemplateDetail({ i18n, resource }) { if (allow_simultaneous || webhook_service) { optionsList = ( - {allow_simultaneous && ( - {i18n._(t`Enable Concurrent Jobs`)} - )} - {webhook_service && {i18n._(t`Enable Webhooks`)}} + {allow_simultaneous && {t`Enable Concurrent Jobs`}} + {webhook_service && {t`Enable Webhooks`}} ); } @@ -48,14 +46,11 @@ function PromptWFJobTemplateDetail({ i18n, resource }) { return ( <> {summary_fields?.recent_jobs?.length > 0 && ( - } - label={i18n._(t`Activity`)} - /> + } label={t`Activity`} /> )} {summary_fields?.organization && ( )} - - - - + + + + {related?.webhook_receiver && ( )} - {optionsList && } + {optionsList && } {summary_fields?.webhook_credential && ( 0 && ( )} {extra_vars && ( - + )} ); } -export default withI18n()(PromptWFJobTemplateDetail); +export default PromptWFJobTemplateDetail; diff --git a/awx/ui_next/src/components/ResourceAccessList/DeleteRoleConfirmationModal.jsx b/awx/ui_next/src/components/ResourceAccessList/DeleteRoleConfirmationModal.jsx index ef959fb53d..be9e52fda1 100644 --- a/awx/ui_next/src/components/ResourceAccessList/DeleteRoleConfirmationModal.jsx +++ b/awx/ui_next/src/components/ResourceAccessList/DeleteRoleConfirmationModal.jsx @@ -1,26 +1,18 @@ import React, { Fragment } from 'react'; import { func, string } from 'prop-types'; import { Button } from '@patternfly/react-core'; -import { withI18n } from '@lingui/react'; + import { t } from '@lingui/macro'; import AlertModal from '../AlertModal'; import { Role } from '../../types'; -function DeleteRoleConfirmationModal({ - role, - username, - onCancel, - onConfirm, - i18n, -}) { +function DeleteRoleConfirmationModal({ role, username, onCancel, onConfirm }) { const isTeamRole = () => { - return typeof role.team_id !== 'undefined' - ? i18n._(t`Team`) - : i18n._(t`User`); + return typeof role.team_id !== 'undefined' ? t`Team` : t`User`; }; - const title = i18n._(t`Remove ${isTeamRole()} Access`); + const title = t`Remove ${isTeamRole()} Access`; return ( - {i18n._(t`Delete`)} + {t`Delete`} , , ]} > {isTeamRole() ? ( - {i18n._( - t`Are you sure you want to remove ${role.name} access from ${role.team_name}? Doing so affects all members of the team.` - )} + {t`Are you sure you want to remove ${role.name} access from ${role.team_name}? Doing so affects all members of the team.`}

- {i18n._( - t`If you only want to remove access for this particular user, please remove them from the team.` - )} + {t`If you only want to remove access for this particular user, please remove them from the team.`}
) : ( - {i18n._( - t`Are you sure you want to remove ${role.name} access from ${username}?` - )} + {t`Are you sure you want to remove ${role.name} access from ${username}?`} )}
@@ -80,4 +66,4 @@ DeleteRoleConfirmationModal.defaultProps = { username: '', }; -export default withI18n()(DeleteRoleConfirmationModal); +export default DeleteRoleConfirmationModal; diff --git a/awx/ui_next/src/components/ResourceAccessList/ResourceAccessList.jsx b/awx/ui_next/src/components/ResourceAccessList/ResourceAccessList.jsx index f43a7fa8de..7c304627e2 100644 --- a/awx/ui_next/src/components/ResourceAccessList/ResourceAccessList.jsx +++ b/awx/ui_next/src/components/ResourceAccessList/ResourceAccessList.jsx @@ -1,6 +1,6 @@ import React, { useCallback, useEffect, useState } from 'react'; import { useLocation } from 'react-router-dom'; -import { withI18n } from '@lingui/react'; + import { t } from '@lingui/macro'; import { RolesAPI, TeamsAPI, UsersAPI } from '../../api'; import AddResourceRole from '../AddRole/AddResourceRole'; @@ -19,7 +19,7 @@ const QS_CONFIG = getQSConfig('access', { order_by: 'first_name', }); -function ResourceAccessList({ i18n, apiModel, resource }) { +function ResourceAccessList({ apiModel, resource }) { const [submitError, setSubmitError] = useState(null); const [deletionRecord, setDeletionRecord] = useState(null); const [deletionRole, setDeletionRole] = useState(null); @@ -124,23 +124,23 @@ function ResourceAccessList({ i18n, apiModel, resource }) { ); const toolbarSearchColumns = [ { - name: i18n._(t`Username`), + name: t`Username`, key: 'username__icontains', isDefault: true, }, { - name: i18n._(t`First Name`), + name: t`First Name`, key: 'first_name__icontains', }, { - name: i18n._(t`Last Name`), + name: t`Last Name`, key: 'last_name__icontains', }, ]; if (organizationRoles?.length > 0) { toolbarSearchColumns.push({ - name: i18n._(t`Roles`), + name: t`Roles`, key: `or__roles__in`, options: organizationRoles, }); @@ -153,20 +153,20 @@ function ResourceAccessList({ i18n, apiModel, resource }) { hasContentLoading={isLoading || isDeleteLoading} items={accessRecords} itemCount={itemCount} - pluralizedItemName={i18n._(t`Roles`)} + pluralizedItemName={t`Roles`} qsConfig={QS_CONFIG} toolbarSearchColumns={toolbarSearchColumns} toolbarSortColumns={[ { - name: i18n._(t`Username`), + name: t`Username`, key: 'username', }, { - name: i18n._(t`First Name`), + name: t`First Name`, key: 'first_name', }, { - name: i18n._(t`Last Name`), + name: t`Last Name`, key: 'last_name', }, ]} @@ -197,7 +197,6 @@ function ResourceAccessList({ i18n, apiModel, resource }) { setDeletionRole(role); setShowDeleteModal(true); }} - i18n={i18n} /> )} /> @@ -233,11 +232,11 @@ function ResourceAccessList({ i18n, apiModel, resource }) { {submitError && ( setSubmitError(null)} > - {i18n._(t`Failed to assign roles properly`)} + {t`Failed to assign roles properly`} )} @@ -245,13 +244,13 @@ function ResourceAccessList({ i18n, apiModel, resource }) { - {i18n._(t`Failed to delete role`)} + {t`Failed to delete role`} )} ); } -export default withI18n()(ResourceAccessList); +export default ResourceAccessList; diff --git a/awx/ui_next/src/components/ResourceAccessList/ResourceAccessListItem.jsx b/awx/ui_next/src/components/ResourceAccessList/ResourceAccessListItem.jsx index 669c5223ab..24b9f11fd4 100644 --- a/awx/ui_next/src/components/ResourceAccessList/ResourceAccessListItem.jsx +++ b/awx/ui_next/src/components/ResourceAccessList/ResourceAccessListItem.jsx @@ -1,7 +1,7 @@ import 'styled-components/macro'; import React from 'react'; import { func } from 'prop-types'; -import { withI18n } from '@lingui/react'; + import { t } from '@lingui/macro'; import { Chip, @@ -24,7 +24,7 @@ const DataListItemCells = styled(PFDataListItemCells)` align-items: start; `; -function ResourceAccessListItem({ accessRecord, onRoleDelete, i18n }) { +function ResourceAccessListItem({ accessRecord, onRoleDelete }) { ResourceAccessListItem.propTypes = { accessRecord: AccessRecord.isRequired, onRoleDelete: func.isRequired, @@ -57,7 +57,7 @@ function ResourceAccessListItem({ accessRecord, onRoleDelete, i18n }) { }} isReadOnly={!role.user_capabilities.unattach} ouiaId={`${role.name}-${role.id}`} - closeBtnAriaLabel={i18n._(t`Remove ${role.name} chip`)} + closeBtnAriaLabel={t`Remove ${role.name} chip`} > {role.name} @@ -97,7 +97,7 @@ function ResourceAccessListItem({ accessRecord, onRoleDelete, i18n }) { {accessRecord.first_name || accessRecord.last_name ? ( @@ -107,7 +107,7 @@ function ResourceAccessListItem({ accessRecord, onRoleDelete, i18n }) { {userRoles.length > 0 && ( {userRoles.map(renderChip)} @@ -117,7 +117,7 @@ function ResourceAccessListItem({ accessRecord, onRoleDelete, i18n }) { )} {teamRoles.length > 0 && ( {teamRoles.map(renderChip)} @@ -134,4 +134,4 @@ function ResourceAccessListItem({ accessRecord, onRoleDelete, i18n }) { ); } -export default withI18n()(ResourceAccessListItem); +export default ResourceAccessListItem; diff --git a/awx/ui_next/src/components/Schedule/Schedule.jsx b/awx/ui_next/src/components/Schedule/Schedule.jsx index 93fd657a9b..1ebd4210d2 100644 --- a/awx/ui_next/src/components/Schedule/Schedule.jsx +++ b/awx/ui_next/src/components/Schedule/Schedule.jsx @@ -1,6 +1,5 @@ import React, { useEffect, useCallback } from 'react'; import { t } from '@lingui/macro'; -import { withI18n } from '@lingui/react'; import { Switch, @@ -20,7 +19,6 @@ import { SchedulesAPI } from '../../api'; import useRequest from '../../util/useRequest'; function Schedule({ - i18n, setBreadcrumb, resource, launchConfig, @@ -58,14 +56,14 @@ function Schedule({ name: ( <> - {i18n._(t`Back to Schedules`)} + {t`Back to Schedules`} ), link: `${pathRoot}schedules`, id: 99, }, { - name: i18n._(t`Details`), + name: t`Details`, link: `${pathRoot}schedules/${schedule && schedule.id}/details`, id: 0, }, @@ -82,7 +80,7 @@ function Schedule({ return ( {schedule && ( - {i18n._(t`View Schedules`)} + {t`View Schedules`} )} ); @@ -132,7 +130,7 @@ function Schedule({ {resource && ( - {i18n._(t`View Details`)} + {t`View Details`} )} @@ -142,4 +140,4 @@ function Schedule({ } export { Schedule as _Schedule }; -export default withI18n()(Schedule); +export default Schedule; diff --git a/awx/ui_next/src/components/Schedule/ScheduleAdd/ScheduleAdd.jsx b/awx/ui_next/src/components/Schedule/ScheduleAdd/ScheduleAdd.jsx index 9023f1a50f..f935425082 100644 --- a/awx/ui_next/src/components/Schedule/ScheduleAdd/ScheduleAdd.jsx +++ b/awx/ui_next/src/components/Schedule/ScheduleAdd/ScheduleAdd.jsx @@ -1,6 +1,6 @@ import React, { useState } from 'react'; import { func, shape } from 'prop-types'; -import { withI18n } from '@lingui/react'; + import { useHistory, useLocation } from 'react-router-dom'; import { RRule } from 'rrule'; import { Card } from '@patternfly/react-core'; @@ -16,7 +16,6 @@ import getSurveyValues from '../../../util/prompt/getSurveyValues'; import { getAddedAndRemoved } from '../../../util/lists'; function ScheduleAdd({ - i18n, resource, apiModel, launchConfig, @@ -77,7 +76,7 @@ function ScheduleAdd({ } try { - const rule = new RRule(buildRuleObj(values, i18n)); + const rule = new RRule(buildRuleObj(values)); const requestData = { ...submitValues, rrule: rule.toString().replace(/\n/g, ' '), @@ -131,4 +130,4 @@ ScheduleAdd.propTypes = { ScheduleAdd.defaultProps = {}; -export default withI18n()(ScheduleAdd); +export default ScheduleAdd; diff --git a/awx/ui_next/src/components/Schedule/ScheduleDetail/ScheduleDetail.jsx b/awx/ui_next/src/components/Schedule/ScheduleDetail/ScheduleDetail.jsx index 8cf47b14a6..69d2a933f7 100644 --- a/awx/ui_next/src/components/Schedule/ScheduleDetail/ScheduleDetail.jsx +++ b/awx/ui_next/src/components/Schedule/ScheduleDetail/ScheduleDetail.jsx @@ -3,7 +3,7 @@ import React, { useCallback, useEffect } from 'react'; import { Link, useHistory, useLocation } from 'react-router-dom'; import { RRule, rrulestr } from 'rrule'; import styled from 'styled-components'; -import { withI18n } from '@lingui/react'; + import { t } from '@lingui/macro'; import { Chip, Divider, Title, Button } from '@patternfly/react-core'; import { Schedule } from '../../../types'; @@ -43,7 +43,7 @@ const PromptDetailList = styled(DetailList)` padding: 0px 20px; `; -function ScheduleDetail({ hasDaysToKeepField, schedule, i18n, surveyConfig }) { +function ScheduleDetail({ hasDaysToKeepField, schedule, surveyConfig }) { const { id, created, @@ -72,11 +72,11 @@ function ScheduleDetail({ hasDaysToKeepField, schedule, i18n, surveyConfig }) { const pathRoot = pathname.substr(0, pathname.indexOf('schedules')); const VERBOSITY = { - 0: i18n._(t`0 (Normal)`), - 1: i18n._(t`1 (Verbose)`), - 2: i18n._(t`2 (More Verbose)`), - 3: i18n._(t`3 (Debug)`), - 4: i18n._(t`4 (Connection Debug)`), + 0: t`0 (Normal)`, + 1: t`1 (Verbose)`, + 2: t`2 (More Verbose)`, + 3: t`3 (Debug)`, + 4: t`4 (Connection Debug)`, }; const { @@ -144,7 +144,7 @@ function ScheduleDetail({ hasDaysToKeepField, schedule, i18n, surveyConfig }) { const rule = rrulestr(rrule); const repeatFrequency = rule.options.freq === RRule.MINUTELY && dtstart === dtend - ? i18n._(t`None (Run Once)`) + ? t`None (Run Once)` : rule.toText().replace(/^\w/, c => c.toUpperCase()); const { @@ -252,47 +252,39 @@ function ScheduleDetail({ hasDaysToKeepField, schedule, i18n, surveyConfig }) { isDisabled={isDisabled} /> - - - - - - - + + + + + + + {hasDaysToKeepField ? ( - + ) : null} {showPromptedFields && ( <> - - {i18n._(t`Prompted Values`)} - + {t`Prompted Values`} {ask_job_type_on_launch && ( - + )} {showInventoryDetail && ( )} {ask_verbosity_on_launch && ( - + )} {ask_scm_branch_on_launch && ( - - )} - {ask_limit_on_launch && ( - + )} + {ask_limit_on_launch && } {showDiffModeDetail && ( )} {showCredentialsDetail && ( {credentials.map(c => ( @@ -347,7 +331,7 @@ function ScheduleDetail({ hasDaysToKeepField, schedule, i18n, surveyConfig }) { {showTagsDetail && ( )} @@ -394,21 +378,21 @@ function ScheduleDetail({ hasDaysToKeepField, schedule, i18n, surveyConfig }) { {summary_fields?.user_capabilities?.edit && ( )} {summary_fields?.user_capabilities?.delete && ( - {i18n._(t`Delete`)} + {t`Delete`} )} @@ -416,10 +400,10 @@ function ScheduleDetail({ hasDaysToKeepField, schedule, i18n, surveyConfig }) { - {i18n._(t`Failed to delete schedule.`)} + {t`Failed to delete schedule.`} )} @@ -431,4 +415,4 @@ ScheduleDetail.propTypes = { schedule: Schedule.isRequired, }; -export default withI18n()(ScheduleDetail); +export default ScheduleDetail; diff --git a/awx/ui_next/src/components/Schedule/ScheduleEdit/ScheduleEdit.jsx b/awx/ui_next/src/components/Schedule/ScheduleEdit/ScheduleEdit.jsx index 3d7276cdea..477af4a483 100644 --- a/awx/ui_next/src/components/Schedule/ScheduleEdit/ScheduleEdit.jsx +++ b/awx/ui_next/src/components/Schedule/ScheduleEdit/ScheduleEdit.jsx @@ -1,5 +1,5 @@ import React, { useState } from 'react'; -import { withI18n } from '@lingui/react'; + import { useHistory, useLocation } from 'react-router-dom'; import { RRule } from 'rrule'; import { shape } from 'prop-types'; @@ -16,7 +16,6 @@ import mergeExtraVars from '../../../util/prompt/mergeExtraVars'; import getSurveyValues from '../../../util/prompt/getSurveyValues'; function ScheduleEdit({ - i18n, hasDaysToKeepField, schedule, resource, @@ -84,7 +83,7 @@ function ScheduleEdit({ } try { - const rule = new RRule(buildRuleObj(values, i18n)); + const rule = new RRule(buildRuleObj(values)); const requestData = { ...submitValues, rrule: rule.toString().replace(/\n/g, ' '), @@ -145,4 +144,4 @@ ScheduleEdit.propTypes = { ScheduleEdit.defaultProps = {}; -export default withI18n()(ScheduleEdit); +export default ScheduleEdit; diff --git a/awx/ui_next/src/components/Schedule/ScheduleList/ScheduleList.jsx b/awx/ui_next/src/components/Schedule/ScheduleList/ScheduleList.jsx index 7e5f7d9805..69805328e6 100644 --- a/awx/ui_next/src/components/Schedule/ScheduleList/ScheduleList.jsx +++ b/awx/ui_next/src/components/Schedule/ScheduleList/ScheduleList.jsx @@ -1,7 +1,7 @@ import React, { useState, useEffect, useCallback } from 'react'; import { useLocation } from 'react-router-dom'; import { bool, func } from 'prop-types'; -import { withI18n } from '@lingui/react'; + import { t } from '@lingui/macro'; import { SchedulesAPI } from '../../../api'; import AlertModal from '../../AlertModal'; @@ -20,7 +20,6 @@ const QS_CONFIG = getQSConfig('schedule', { }); function ScheduleList({ - i18n, loadSchedules, loadScheduleOptions, hideAddButton, @@ -128,7 +127,7 @@ function ScheduleList({ ) { return null; } - return i18n._(t`This schedule is missing an Inventory`); + return t`This schedule is missing an Inventory`; }; const hasMissingSurveyValue = schedule => { @@ -153,10 +152,7 @@ function ScheduleList({ } }); } - return ( - missingValues && - i18n._(t`This schedule is missing required survey values`) - ); + return missingValues && t`This schedule is missing required survey values`; }; return ( @@ -170,10 +166,10 @@ function ScheduleList({ onRowClick={handleSelect} headerRow={ - {i18n._(t`Name`)} - {i18n._(t`Type`)} - {i18n._(t`Next Run`)} - {i18n._(t`Actions`)} + {t`Name`} + {t`Type`} + {t`Next Run`} + {t`Actions`} } renderRow={(item, index) => ( @@ -189,20 +185,20 @@ function ScheduleList({ )} toolbarSearchColumns={[ { - name: i18n._(t`Name`), + name: t`Name`, key: 'name__icontains', isDefault: true, }, { - name: i18n._(t`Description`), + name: t`Description`, key: 'description__icontains', }, { - name: i18n._(t`Created By (Username)`), + name: t`Created By (Username)`, key: 'created_by__username__icontains', }, { - name: i18n._(t`Modified By (Username)`), + name: t`Modified By (Username)`, key: 'modified_by__username__icontains', }, ]} @@ -228,7 +224,7 @@ function ScheduleList({ key="delete" onDelete={handleDelete} itemsToDelete={selected} - pluralizedItemName={i18n._(t`Schedules`)} + pluralizedItemName={t`Schedules`} />, ]} /> @@ -238,10 +234,10 @@ function ScheduleList({ - {i18n._(t`Failed to delete one or more schedules.`)} + {t`Failed to delete one or more schedules.`} )} @@ -258,4 +254,4 @@ ScheduleList.defaultProps = { hideAddButton: false, }; -export default withI18n()(ScheduleList); +export default ScheduleList; diff --git a/awx/ui_next/src/components/Schedule/ScheduleList/ScheduleListItem.jsx b/awx/ui_next/src/components/Schedule/ScheduleList/ScheduleListItem.jsx index 1e6bd30f1e..277b8991fe 100644 --- a/awx/ui_next/src/components/Schedule/ScheduleList/ScheduleListItem.jsx +++ b/awx/ui_next/src/components/Schedule/ScheduleList/ScheduleListItem.jsx @@ -1,7 +1,7 @@ import 'styled-components/macro'; import React from 'react'; import { bool, func } from 'prop-types'; -import { withI18n } from '@lingui/react'; + import { t } from '@lingui/macro'; import { Link } from 'react-router-dom'; import { Button, Tooltip } from '@patternfly/react-core'; @@ -23,7 +23,6 @@ const ExclamationTriangleIcon = styled(PFExclamationTriangleIcon)` `; function ScheduleListItem({ - i18n, rowIndex, isSelected, onSelect, @@ -34,11 +33,11 @@ function ScheduleListItem({ const labelId = `check-action-${schedule.id}`; const jobTypeLabels = { - inventory_update: i18n._(t`Inventory Sync`), - job: i18n._(t`Playbook Run`), - project_update: i18n._(t`Source Control Update`), - system_job: i18n._(t`Management Job`), - workflow_job: i18n._(t`Workflow Job`), + inventory_update: t`Inventory Sync`, + job: t`Playbook Run`, + project_update: t`Source Control Update`, + system_job: t`Management Job`, + workflow_job: t`Workflow Job`, }; let scheduleBaseUrl; @@ -73,9 +72,9 @@ function ScheduleListItem({ onSelect, disable: false, }} - dataLabel={i18n._(t`Selected`)} + dataLabel={t`Selected`} /> - + {schedule.name} @@ -92,32 +91,32 @@ function ScheduleListItem({
)} - + { jobTypeLabels[ schedule.summary_fields.unified_job_template.unified_job_type ] } - + {schedule.next_run && ( )} - + {isTemplate && showPromptButton && ( @@ -630,20 +622,20 @@ function ScheduleForm({ ouiaId="schedule-form-prompt-button" variant="secondary" type="button" - aria-label={i18n._(t`Prompt`)} + aria-label={t`Prompt`} onClick={() => setIsWizardOpen(true)} > - {i18n._(t`Prompt`)} + {t`Prompt`} )} @@ -669,4 +661,4 @@ ScheduleForm.defaultProps = { submitError: null, }; -export default withI18n()(ScheduleForm); +export default ScheduleForm; diff --git a/awx/ui_next/src/components/Schedule/shared/SchedulePromptableFields.jsx b/awx/ui_next/src/components/Schedule/shared/SchedulePromptableFields.jsx index e86485d6b3..72cac061e8 100644 --- a/awx/ui_next/src/components/Schedule/shared/SchedulePromptableFields.jsx +++ b/awx/ui_next/src/components/Schedule/shared/SchedulePromptableFields.jsx @@ -1,6 +1,6 @@ import React from 'react'; import { Wizard } from '@patternfly/react-core'; -import { withI18n } from '@lingui/react'; + import { t } from '@lingui/macro'; import { useFormikContext } from 'formik'; import AlertModal from '../../AlertModal'; @@ -18,7 +18,6 @@ function SchedulePromptableFields({ credentials, resource, resourceDefaultCredentials, - i18n, }) { const { setFieldTouched, @@ -38,7 +37,7 @@ function SchedulePromptableFields({ launchConfig, schedule, resource, - i18n, + credentials, resourceDefaultCredentials ); @@ -74,7 +73,7 @@ function SchedulePromptableFields({ { dismissError(); onCloseWizard(); @@ -108,22 +107,22 @@ function SchedulePromptableFields({ validateStep(nextStep.id); } }} - title={i18n._(t`Prompts`)} + title={t`Prompts`} steps={ isReady ? steps : [ { - name: i18n._(t`Content Loading`), + name: t`Content Loading`, component: , }, ] } - backButtonText={i18n._(t`Back`)} - cancelButtonText={i18n._(t`Cancel`)} - nextButtonText={i18n._(t`Next`)} + backButtonText={t`Back`} + cancelButtonText={t`Cancel`} + nextButtonText={t`Next`} /> ); } -export default withI18n()(SchedulePromptableFields); +export default SchedulePromptableFields; diff --git a/awx/ui_next/src/components/Schedule/shared/buildRuleObj.js b/awx/ui_next/src/components/Schedule/shared/buildRuleObj.js index 701fc65080..b2c145a868 100644 --- a/awx/ui_next/src/components/Schedule/shared/buildRuleObj.js +++ b/awx/ui_next/src/components/Schedule/shared/buildRuleObj.js @@ -2,7 +2,7 @@ import { t } from '@lingui/macro'; import { RRule } from 'rrule'; import { getRRuleDayConstants } from '../../../util/dates'; -export default function buildRuleObj(values, i18n) { +export default function buildRuleObj(values) { const [startDate, startTime] = values.startDateTime.split('T'); // Dates are formatted like "YYYY-MM-DD" const [startYear, startMonth, startDay] = startDate.split('-'); @@ -51,7 +51,7 @@ export default function buildRuleObj(values, i18n) { ruleObj.bymonthday = values.runOnDayNumber; } else if (values.runOn === 'the') { ruleObj.bysetpos = parseInt(values.runOnTheOccurrence, 10); - ruleObj.byweekday = getRRuleDayConstants(values.runOnTheDay, i18n); + ruleObj.byweekday = getRRuleDayConstants(values.runOnTheDay); } break; case 'year': @@ -61,12 +61,12 @@ export default function buildRuleObj(values, i18n) { ruleObj.bymonthday = values.runOnDayNumber; } else if (values.runOn === 'the') { ruleObj.bysetpos = parseInt(values.runOnTheOccurrence, 10); - ruleObj.byweekday = getRRuleDayConstants(values.runOnTheDay, i18n); + ruleObj.byweekday = getRRuleDayConstants(values.runOnTheDay); ruleObj.bymonth = parseInt(values.runOnTheMonth, 10); } break; default: - throw new Error(i18n._(t`Frequency did not match an expected value`)); + throw new Error(t`Frequency did not match an expected value`); } if (values.frequency !== 'none') { @@ -93,7 +93,7 @@ export default function buildRuleObj(values, i18n) { break; } default: - throw new Error(i18n._(t`End did not match an expected value`)); + throw new Error(t`End did not match an expected value`); } } diff --git a/awx/ui_next/src/components/Schedule/shared/useSchedulePromptSteps.js b/awx/ui_next/src/components/Schedule/shared/useSchedulePromptSteps.js index 6bc0c35291..5c28f35ed5 100644 --- a/awx/ui_next/src/components/Schedule/shared/useSchedulePromptSteps.js +++ b/awx/ui_next/src/components/Schedule/shared/useSchedulePromptSteps.js @@ -12,7 +12,7 @@ export default function useSchedulePromptSteps( launchConfig, schedule, resource, - i18n, + scheduleCredentials, resourceDefaultCredentials ) { @@ -22,15 +22,14 @@ export default function useSchedulePromptSteps( const [visited, setVisited] = useState({}); const steps = [ - useInventoryStep(launchConfig, sourceOfValues, i18n, visited), + useInventoryStep(launchConfig, sourceOfValues, visited), useCredentialsStep( launchConfig, sourceOfValues, - resourceDefaultCredentials, - i18n + resourceDefaultCredentials ), - useOtherPromptsStep(launchConfig, sourceOfValues, i18n), - useSurveyStep(launchConfig, surveyConfig, sourceOfValues, i18n, visited), + useOtherPromptsStep(launchConfig, sourceOfValues), + useSurveyStep(launchConfig, surveyConfig, sourceOfValues, visited), ]; const hasErrors = steps.some(step => step.hasError); @@ -38,12 +37,12 @@ export default function useSchedulePromptSteps( steps.push( usePreviewStep( launchConfig, - i18n, + resource, surveyConfig, hasErrors, true, - i18n._(t`Save`) + t`Save` ) ); diff --git a/awx/ui_next/src/components/ScreenHeader/ScreenHeader.jsx b/awx/ui_next/src/components/ScreenHeader/ScreenHeader.jsx index 8446540392..f12a3cdd09 100644 --- a/awx/ui_next/src/components/ScreenHeader/ScreenHeader.jsx +++ b/awx/ui_next/src/components/ScreenHeader/ScreenHeader.jsx @@ -1,6 +1,6 @@ import React, { Fragment } from 'react'; import PropTypes from 'prop-types'; -import { withI18n } from '@lingui/react'; + import { t } from '@lingui/macro'; import { Button, @@ -14,7 +14,7 @@ import { import { HistoryIcon } from '@patternfly/react-icons'; import { Link, Route, useRouteMatch } from 'react-router-dom'; -const ScreenHeader = ({ breadcrumbConfig, i18n, streamType }) => { +const ScreenHeader = ({ breadcrumbConfig, streamType }) => { const { light } = PageSectionVariants; const oneCrumbMatch = useRouteMatch({ path: Object.keys(breadcrumbConfig)[0], @@ -51,10 +51,10 @@ const ScreenHeader = ({ breadcrumbConfig, i18n, streamType }) => { {streamType !== 'none' && (
- +
- + )} {isWizardOpen && ( @@ -181,4 +181,4 @@ function UserAndTeamAccessAdd({ i18n, title, onFetchData, apiModel }) { ); } -export default withI18n()(UserAndTeamAccessAdd); +export default UserAndTeamAccessAdd; diff --git a/awx/ui_next/src/components/UserAndTeamAccessAdd/getResourceAccessConfig.js b/awx/ui_next/src/components/UserAndTeamAccessAdd/getResourceAccessConfig.js index 9333d1770c..e54bbe2cf6 100644 --- a/awx/ui_next/src/components/UserAndTeamAccessAdd/getResourceAccessConfig.js +++ b/awx/ui_next/src/components/UserAndTeamAccessAdd/getResourceAccessConfig.js @@ -8,33 +8,33 @@ import { OrganizationsAPI, } from '../../api'; -export default function getResourceAccessConfig(i18n) { +export default function getResourceAccessConfig() { return [ { selectedResource: 'jobTemplate', - label: i18n._(t`Job templates`), + label: t`Job templates`, searchColumns: [ { - name: i18n._(t`Name`), + name: t`Name`, key: 'name__icontains', isDefault: true, }, { - name: i18n._(t`Playbook name`), + name: t`Playbook name`, key: 'playbook__icontains', }, { - name: i18n._(t`Created By (Username)`), + name: t`Created By (Username)`, key: 'created_by__username__icontains', }, { - name: i18n._(t`Modified By (Username)`), + name: t`Modified By (Username)`, key: 'modified_by__username__icontains', }, ], sortColumns: [ { - name: i18n._(t`Name`), + name: t`Name`, key: 'name', }, ], @@ -43,29 +43,29 @@ export default function getResourceAccessConfig(i18n) { }, { selectedResource: 'workflowJobTemplate', - label: i18n._(t`Workflow job templates`), + label: t`Workflow job templates`, searchColumns: [ { - name: i18n._(t`Name`), + name: t`Name`, key: 'name__icontains', isDefault: true, }, { - name: i18n._(t`Playbook name`), + name: t`Playbook name`, key: 'playbook__icontains', }, { - name: i18n._(t`Created By (Username)`), + name: t`Created By (Username)`, key: 'created_by__username__icontains', }, { - name: i18n._(t`Modified By (Username)`), + name: t`Modified By (Username)`, key: 'modified_by__username__icontains', }, ], sortColumns: [ { - name: i18n._(t`Name`), + name: t`Name`, key: 'name', }, ], @@ -74,40 +74,40 @@ export default function getResourceAccessConfig(i18n) { }, { selectedResource: 'credential', - label: i18n._(t`Credentials`), + label: t`Credentials`, searchColumns: [ { - name: i18n._(t`Name`), + name: t`Name`, key: 'name__icontains', isDefault: true, }, { - name: i18n._(t`Type`), + name: t`Type`, key: 'or__scm_type', options: [ - [``, i18n._(t`Manual`)], - [`git`, i18n._(t`Git`)], - [`svn`, i18n._(t`Subversion`)], - [`archive`, i18n._(t`Remote Archive`)], - [`insights`, i18n._(t`Red Hat Insights`)], + [``, t`Manual`], + [`git`, t`Git`], + [`svn`, t`Subversion`], + [`archive`, t`Remote Archive`], + [`insights`, t`Red Hat Insights`], ], }, { - name: i18n._(t`Source Control URL`), + name: t`Source Control URL`, key: 'scm_url__icontains', }, { - name: i18n._(t`Modified By (Username)`), + name: t`Modified By (Username)`, key: 'modified_by__username__icontains', }, { - name: i18n._(t`Created By (Username)`), + name: t`Created By (Username)`, key: 'created_by__username__icontains', }, ], sortColumns: [ { - name: i18n._(t`Name`), + name: t`Name`, key: 'name', }, ], @@ -116,25 +116,25 @@ export default function getResourceAccessConfig(i18n) { }, { selectedResource: 'inventory', - label: i18n._(t`Inventories`), + label: t`Inventories`, searchColumns: [ { - name: i18n._(t`Name`), + name: t`Name`, key: 'name__icontains', isDefault: true, }, { - name: i18n._(t`Created By (Username)`), + name: t`Created By (Username)`, key: 'created_by__username__icontains', }, { - name: i18n._(t`Modified By (Username)`), + name: t`Modified By (Username)`, key: 'modified_by__username__icontains', }, ], sortColumns: [ { - name: i18n._(t`Name`), + name: t`Name`, key: 'name', }, ], @@ -143,40 +143,40 @@ export default function getResourceAccessConfig(i18n) { }, { selectedResource: 'project', - label: i18n._(t`Projects`), + label: t`Projects`, searchColumns: [ { - name: i18n._(t`Name`), + name: t`Name`, key: 'name__icontains', isDefault: true, }, { - name: i18n._(t`Type`), + name: t`Type`, key: 'or__scm_type', options: [ - [``, i18n._(t`Manual`)], - [`git`, i18n._(t`Git`)], - [`svn`, i18n._(t`Subversion`)], - [`archive`, i18n._(t`Remote Archive`)], - [`insights`, i18n._(t`Red Hat Insights`)], + [``, t`Manual`], + [`git`, t`Git`], + [`svn`, t`Subversion`], + [`archive`, t`Remote Archive`], + [`insights`, t`Red Hat Insights`], ], }, { - name: i18n._(t`Source Control URL`), + name: t`Source Control URL`, key: 'scm_url__icontains', }, { - name: i18n._(t`Modified By (Username)`), + name: t`Modified By (Username)`, key: 'modified_by__username__icontains', }, { - name: i18n._(t`Created By (Username)`), + name: t`Created By (Username)`, key: 'created_by__username__icontains', }, ], sortColumns: [ { - name: i18n._(t`Name`), + name: t`Name`, key: 'name', }, ], @@ -185,25 +185,25 @@ export default function getResourceAccessConfig(i18n) { }, { selectedResource: 'organization', - label: i18n._(t`Organizations`), + label: t`Organizations`, searchColumns: [ { - name: i18n._(t`Name`), + name: t`Name`, key: 'name__icontains', isDefault: true, }, { - name: i18n._(t`Created By (Username)`), + name: t`Created By (Username)`, key: 'created_by__username__icontains', }, { - name: i18n._(t`Modified By (Username)`), + name: t`Modified By (Username)`, key: 'modified_by__username__icontains', }, ], sortColumns: [ { - name: i18n._(t`Name`), + name: t`Name`, key: 'name', }, ], diff --git a/awx/ui_next/src/components/Workflow/WorkflowLegend.jsx b/awx/ui_next/src/components/Workflow/WorkflowLegend.jsx index c571d0c9b4..bf2bcc3ffc 100644 --- a/awx/ui_next/src/components/Workflow/WorkflowLegend.jsx +++ b/awx/ui_next/src/components/Workflow/WorkflowLegend.jsx @@ -1,5 +1,5 @@ import React, { useContext } from 'react'; -import { withI18n } from '@lingui/react'; + import { t } from '@lingui/macro'; import styled from 'styled-components'; import { @@ -77,57 +77,57 @@ const Close = styled(TimesIcon)` top: 15px; `; -function WorkflowLegend({ i18n }) { +function WorkflowLegend() { const dispatch = useContext(WorkflowDispatchContext); return (
- {i18n._(t`Legend`)} + {t`Legend`} dispatch({ type: 'TOGGLE_LEGEND' })} />
  • JT - {i18n._(t`Job Template`)} + {t`Job Template`}
  • W - {i18n._(t`Workflow`)} + {t`Workflow`}
  • I - {i18n._(t`Inventory Sync`)} + {t`Inventory Sync`}
  • P - {i18n._(t`Project Sync`)} + {t`Project Sync`}
  • - {i18n._(t`Approval`)} + {t`Approval`}
  • - {i18n._(t`Warning`)} + {t`Warning`}
  • - {i18n._(t`On Success`)} + {t`On Success`}
  • - {i18n._(t`On Failure`)} + {t`On Failure`}
  • - {i18n._(t`Always`)} + {t`Always`}
  • ); } -export default withI18n()(WorkflowLegend); +export default WorkflowLegend; diff --git a/awx/ui_next/src/components/Workflow/WorkflowLinkHelp.jsx b/awx/ui_next/src/components/Workflow/WorkflowLinkHelp.jsx index 5180ab3bba..756eb5022f 100644 --- a/awx/ui_next/src/components/Workflow/WorkflowLinkHelp.jsx +++ b/awx/ui_next/src/components/Workflow/WorkflowLinkHelp.jsx @@ -1,5 +1,5 @@ import React from 'react'; -import { withI18n } from '@lingui/react'; + import { t } from '@lingui/macro'; import styled from 'styled-components'; import { shape } from 'prop-types'; @@ -17,17 +17,17 @@ const GridDL = styled.dl` } `; -function WorkflowLinkHelp({ link, i18n }) { +function WorkflowLinkHelp({ link }) { let linkType; switch (link.linkType) { case 'always': - linkType = i18n._(t`Always`); + linkType = t`Always`; break; case 'success': - linkType = i18n._(t`On Success`); + linkType = t`On Success`; break; case 'failure': - linkType = i18n._(t`On Failure`); + linkType = t`On Failure`; break; default: linkType = ''; @@ -36,7 +36,7 @@ function WorkflowLinkHelp({ link, i18n }) { return (
    - {i18n._(t`Run`)} + {t`Run`}
    @@ -47,4 +47,4 @@ WorkflowLinkHelp.propTypes = { link: shape().isRequired, }; -export default withI18n()(WorkflowLinkHelp); +export default WorkflowLinkHelp; diff --git a/awx/ui_next/src/components/Workflow/WorkflowNodeHelp.jsx b/awx/ui_next/src/components/Workflow/WorkflowNodeHelp.jsx index 909a7c3d6e..088cad8232 100644 --- a/awx/ui_next/src/components/Workflow/WorkflowNodeHelp.jsx +++ b/awx/ui_next/src/components/Workflow/WorkflowNodeHelp.jsx @@ -1,6 +1,6 @@ import 'styled-components/macro'; import React from 'react'; -import { withI18n } from '@lingui/react'; + import { t, Trans } from '@lingui/macro'; import styled from 'styled-components'; import { ExclamationTriangleIcon } from '@patternfly/react-icons'; @@ -31,7 +31,7 @@ const StyledExclamationTriangleIcon = styled(ExclamationTriangleIcon)` width: 20px; `; -function WorkflowNodeHelp({ node, i18n }) { +function WorkflowNodeHelp({ node }) { let nodeType; const job = node?.originalNodeObject?.summary_fields?.job; const unifiedJobTemplate = @@ -44,23 +44,23 @@ function WorkflowNodeHelp({ node, i18n }) { switch (type) { case 'job_template': case 'job': - nodeType = i18n._(t`Job Template`); + nodeType = t`Job Template`; break; case 'workflow_job_template': case 'workflow_job': - nodeType = i18n._(t`Workflow Job Template`); + nodeType = t`Workflow Job Template`; break; case 'project': case 'project_update': - nodeType = i18n._(t`Project Update`); + nodeType = t`Project Update`; break; case 'inventory_source': case 'inventory_update': - nodeType = i18n._(t`Inventory Update`); + nodeType = t`Inventory Update`; break; case 'workflow_approval_template': case 'workflow_approval': - nodeType = i18n._(t`Workflow Approval`); + nodeType = t`Workflow Approval`; break; default: nodeType = ''; @@ -71,43 +71,43 @@ function WorkflowNodeHelp({ node, i18n }) { if (job) { switch (job.status) { case 'new': - jobStatus = i18n._(t`New`); + jobStatus = t`New`; break; case 'pending': - jobStatus = i18n._(t`Pending`); + jobStatus = t`Pending`; break; case 'waiting': - jobStatus = i18n._(t`Waiting`); + jobStatus = t`Waiting`; break; case 'running': - jobStatus = i18n._(t`Running`); + jobStatus = t`Running`; break; case 'successful': - jobStatus = i18n._(t`Successful`); + jobStatus = t`Successful`; break; case 'failed': - jobStatus = i18n._(t`Failed`); + jobStatus = t`Failed`; break; case 'error': - jobStatus = i18n._(t`Error`); + jobStatus = t`Error`; break; case 'canceled': - jobStatus = i18n._(t`Canceled`); + jobStatus = t`Canceled`; break; case 'never updated': - jobStatus = i18n._(t`Never Updated`); + jobStatus = t`Never Updated`; break; case 'ok': - jobStatus = i18n._(t`OK`); + jobStatus = t`OK`; break; case 'missing': - jobStatus = i18n._(t`Missing`); + jobStatus = t`Missing`; break; case 'none': - jobStatus = i18n._(t`None`); + jobStatus = t`None`; break; case 'updating': - jobStatus = i18n._(t`Updating`); + jobStatus = t`Updating`; break; default: jobStatus = ''; @@ -129,21 +129,21 @@ function WorkflowNodeHelp({ node, i18n }) { {job && (
    - {i18n._(t`Name`)} + {t`Name`}
    {job.name}
    - {i18n._(t`Type`)} + {t`Type`}
    {nodeType}
    - {i18n._(t`Job Status`)} + {t`Job Status`}
    {jobStatus}
    {typeof job.elapsed === 'number' && ( <>
    - {i18n._(t`Elapsed`)} + {t`Elapsed`}
    {secondsToHHMMSS(job.elapsed)} @@ -155,17 +155,17 @@ function WorkflowNodeHelp({ node, i18n }) { {unifiedJobTemplate && !job && (
    - {i18n._(t`Name`)} + {t`Name`}
    {unifiedJobTemplate.name}
    - {i18n._(t`Type`)} + {t`Type`}
    {nodeType}
    )} {job && job.type !== 'workflow_approval' && ( -

    {i18n._(t`Click to view job details`)}

    +

    {t`Click to view job details`}

    )} ); @@ -175,4 +175,4 @@ WorkflowNodeHelp.propTypes = { node: shape().isRequired, }; -export default withI18n()(WorkflowNodeHelp); +export default WorkflowNodeHelp; diff --git a/awx/ui_next/src/components/Workflow/WorkflowStartNode.jsx b/awx/ui_next/src/components/Workflow/WorkflowStartNode.jsx index 23dbc06481..8f4c17d79c 100644 --- a/awx/ui_next/src/components/Workflow/WorkflowStartNode.jsx +++ b/awx/ui_next/src/components/Workflow/WorkflowStartNode.jsx @@ -1,6 +1,5 @@ import React, { useContext, useRef, useState } from 'react'; import styled from 'styled-components'; -import { withI18n } from '@lingui/react'; import { t } from '@lingui/macro'; import { bool, func } from 'prop-types'; import { PlusIcon } from '@patternfly/react-icons'; @@ -31,7 +30,7 @@ const StartDiv = styled.div` padding: 0px 10px; `; -function WorkflowStartNode({ i18n, onUpdateHelpText, showActionTooltip }) { +function WorkflowStartNode({ onUpdateHelpText, showActionTooltip }) { const ref = useRef(null); const startNodeRef = useRef(null); const [hovering, setHovering] = useState(false); @@ -58,7 +57,7 @@ function WorkflowStartNode({ i18n, onUpdateHelpText, showActionTooltip }) { y="10" style={{ overflow: 'visible' }} > - {i18n._(t`START`)} + {t`START`} {showActionTooltip && hovering && ( onUpdateHelpText(i18n._(t`Add a new node`))} + onMouseEnter={() => onUpdateHelpText(t`Add a new node`)} onMouseLeave={() => onUpdateHelpText(null)} onClick={() => { onUpdateHelpText(null); @@ -94,4 +93,4 @@ WorkflowStartNode.defaultProps = { onUpdateHelpText: () => {}, }; -export default withI18n()(WorkflowStartNode); +export default WorkflowStartNode; diff --git a/awx/ui_next/src/components/Workflow/WorkflowTools.jsx b/awx/ui_next/src/components/Workflow/WorkflowTools.jsx index 7fa6a13621..499857abe1 100644 --- a/awx/ui_next/src/components/Workflow/WorkflowTools.jsx +++ b/awx/ui_next/src/components/Workflow/WorkflowTools.jsx @@ -1,6 +1,6 @@ import 'styled-components/macro'; import React, { useContext } from 'react'; -import { withI18n } from '@lingui/react'; + import { t } from '@lingui/macro'; import styled from 'styled-components'; import { func, number } from 'prop-types'; @@ -54,7 +54,6 @@ const Close = styled(TimesIcon)` `; function WorkflowTools({ - i18n, onFitGraph, onPan, onPanToMiddle, @@ -81,12 +80,12 @@ function WorkflowTools({ return (
    - {i18n._(t`Tools`)} + {t`Tools`} dispatch({ type: 'TOGGLE_TOOLS' })} />
    - + - + )} {application.summary_fields.user_capabilities && application.summary_fields.user_capabilities.delete && ( - {i18n._(t`Delete`)} + {t`Delete`} )} @@ -136,14 +132,14 @@ function ApplicationDetails({ - {i18n._(t`Failed to delete application.`)} + {t`Failed to delete application.`} )} ); } -export default withI18n()(ApplicationDetails); +export default ApplicationDetails; diff --git a/awx/ui_next/src/screens/Application/ApplicationTokens/ApplicationTokenList.jsx b/awx/ui_next/src/screens/Application/ApplicationTokens/ApplicationTokenList.jsx index 018829623d..02f17863a4 100644 --- a/awx/ui_next/src/screens/Application/ApplicationTokens/ApplicationTokenList.jsx +++ b/awx/ui_next/src/screens/Application/ApplicationTokens/ApplicationTokenList.jsx @@ -1,7 +1,7 @@ import React, { useCallback, useEffect } from 'react'; import { useParams, useLocation } from 'react-router-dom'; import { t } from '@lingui/macro'; -import { withI18n } from '@lingui/react'; + import PaginatedDataList, { ToolbarDeleteButton, } from '../../../components/PaginatedDataList'; @@ -20,7 +20,7 @@ const QS_CONFIG = getQSConfig('applications', { order_by: 'user__username', }); -function ApplicationTokenList({ i18n }) { +function ApplicationTokenList() { const { id } = useParams(); const location = useLocation(); const { @@ -100,35 +100,35 @@ function ApplicationTokenList({ i18n }) { hasContentLoading={isLoading || deleteLoading} items={tokens} itemCount={itemCount} - pluralizedItemName={i18n._(t`Tokens`)} + pluralizedItemName={t`Tokens`} qsConfig={QS_CONFIG} onRowClick={handleSelect} toolbarSearchColumns={[ { - name: i18n._(t`Name`), + name: t`Name`, key: 'user__username__icontains', isDefault: true, }, ]} toolbarSortColumns={[ { - name: i18n._(t`Name`), + name: t`Name`, key: 'user__username', }, { - name: i18n._(t`Scope`), + name: t`Scope`, key: 'scope', }, { - name: i18n._(t`Expiration`), + name: t`Expiration`, key: 'expires', }, { - name: i18n._(t`Created`), + name: t`Created`, key: 'created', }, { - name: i18n._(t`Modified`), + name: t`Modified`, key: 'modified', }, ]} @@ -148,7 +148,7 @@ function ApplicationTokenList({ i18n }) { key="delete" onDelete={handleDelete} itemsToDelete={selected} - pluralizedItemName={i18n._(t`Tokens`)} + pluralizedItemName={t`Tokens`} />, ]} /> @@ -167,14 +167,14 @@ function ApplicationTokenList({ i18n }) { - {i18n._(t`Failed to delete one or more tokens.`)} + {t`Failed to delete one or more tokens.`} ); } -export default withI18n()(ApplicationTokenList); +export default ApplicationTokenList; diff --git a/awx/ui_next/src/screens/Application/ApplicationTokens/ApplicationTokenListItem.jsx b/awx/ui_next/src/screens/Application/ApplicationTokens/ApplicationTokenListItem.jsx index 142561ea7e..7a32738f83 100644 --- a/awx/ui_next/src/screens/Application/ApplicationTokens/ApplicationTokenListItem.jsx +++ b/awx/ui_next/src/screens/Application/ApplicationTokens/ApplicationTokenListItem.jsx @@ -1,6 +1,6 @@ import React from 'react'; import { string, bool, func } from 'prop-types'; -import { withI18n } from '@lingui/react'; + import { t } from '@lingui/macro'; import { Link } from 'react-router-dom'; import { @@ -20,13 +20,7 @@ const Label = styled.b` margin-right: 20px; `; -function ApplicationTokenListItem({ - token, - isSelected, - onSelect, - detailUrl, - i18n, -}) { +function ApplicationTokenListItem({ token, isSelected, onSelect, detailUrl }) { const labelId = `check-action-${token.id}`; return ( @@ -39,17 +33,17 @@ function ApplicationTokenListItem({ /> + {token.summary_fields.user.username} , - - + + {toTitleCase(token.scope)} , - - + + {formatDateString(token.expires)} , ]} @@ -66,4 +60,4 @@ ApplicationTokenListItem.propTypes = { onSelect: func.isRequired, }; -export default withI18n()(ApplicationTokenListItem); +export default ApplicationTokenListItem; diff --git a/awx/ui_next/src/screens/Application/Applications.jsx b/awx/ui_next/src/screens/Application/Applications.jsx index ae6fa94af1..dbffa80f1c 100644 --- a/awx/ui_next/src/screens/Application/Applications.jsx +++ b/awx/ui_next/src/screens/Application/Applications.jsx @@ -1,5 +1,5 @@ import React, { useState, useCallback } from 'react'; -import { withI18n } from '@lingui/react'; + import { t } from '@lingui/macro'; import styled from 'styled-components'; import { Route, Switch } from 'react-router-dom'; @@ -19,29 +19,26 @@ const ApplicationAlert = styled(Alert)` margin-bottom: 20px; `; -function Applications({ i18n }) { +function Applications() { const [applicationModalSource, setApplicationModalSource] = useState(null); const [breadcrumbConfig, setBreadcrumbConfig] = useState({ - '/applications': i18n._(t`Applications`), - '/applications/add': i18n._(t`Create New Application`), + '/applications': t`Applications`, + '/applications/add': t`Create New Application`, }); - const buildBreadcrumbConfig = useCallback( - application => { - if (!application) { - return; - } - setBreadcrumbConfig({ - '/applications': i18n._(t`Applications`), - '/applications/add': i18n._(t`Create New Application`), - [`/applications/${application.id}`]: `${application.name}`, - [`/applications/${application.id}/edit`]: i18n._(t`Edit Details`), - [`/applications/${application.id}/details`]: i18n._(t`Details`), - [`/applications/${application.id}/tokens`]: i18n._(t`Tokens`), - }); - }, - [i18n] - ); + const buildBreadcrumbConfig = useCallback(application => { + if (!application) { + return; + } + setBreadcrumbConfig({ + '/applications': t`Applications`, + '/applications/add': t`Create New Application`, + [`/applications/${application.id}`]: `${application.name}`, + [`/applications/${application.id}/edit`]: t`Edit Details`, + [`/applications/${application.id}/details`]: t`Details`, + [`/applications/${application.id}/tokens`]: t`Tokens`, + }); + }, []); return ( <> @@ -64,29 +61,24 @@ function Applications({ i18n }) { {applicationModalSource && ( setApplicationModalSource(null)} > {applicationModalSource.client_secret && ( )} - + {applicationModalSource.client_id && ( - + {application.name} - + {application.summary_fields.organization.name} - + {formatDateString(application.modified)} - + )} {user_capabilities.delete && ( - {i18n._(t`Delete`)} + {t`Delete`} )} @@ -292,10 +287,10 @@ function CredentialDetail({ i18n, credential }) { - {i18n._(t`Failed to delete credential.`)} + {t`Failed to delete credential.`} )} @@ -305,7 +300,6 @@ function CredentialDetail({ i18n, credential }) { CredentialDetail.propTypes = { credential: Credential.isRequired, - i18n: shape({}).isRequired, }; -export default withI18n()(CredentialDetail); +export default CredentialDetail; diff --git a/awx/ui_next/src/screens/Credential/CredentialList/CredentialListItem.jsx b/awx/ui_next/src/screens/Credential/CredentialList/CredentialListItem.jsx index 78bc9b74e4..547ac51cf2 100644 --- a/awx/ui_next/src/screens/Credential/CredentialList/CredentialListItem.jsx +++ b/awx/ui_next/src/screens/Credential/CredentialList/CredentialListItem.jsx @@ -1,6 +1,6 @@ import React, { useState, useCallback } from 'react'; import { string, bool, func } from 'prop-types'; -import { withI18n } from '@lingui/react'; + import { t } from '@lingui/macro'; import { Link } from 'react-router-dom'; import { Button } from '@patternfly/react-core'; @@ -18,7 +18,7 @@ function CredentialListItem({ detailUrl, isSelected, onSelect, - i18n, + fetchCredentials, rowIndex, }) { @@ -50,22 +50,22 @@ function CredentialListItem({ isSelected, onSelect, }} - dataLabel={i18n._(t`Selected`)} + dataLabel={t`Selected`} /> - + {credential.name} - + {credential.summary_fields.credential_type.name} - - + + )} {summary_fields.user_capabilities?.delete && ( - {i18n._(t`Delete`)} + {t`Delete`} )} @@ -147,7 +145,7 @@ function ExecutionEnvironmentDetails({ executionEnvironment, i18n }) { )} @@ -155,4 +153,4 @@ function ExecutionEnvironmentDetails({ executionEnvironment, i18n }) { ); } -export default withI18n()(ExecutionEnvironmentDetails); +export default ExecutionEnvironmentDetails; diff --git a/awx/ui_next/src/screens/ExecutionEnvironment/ExecutionEnvironmentList/ExecutionEnvironmentListItem.jsx b/awx/ui_next/src/screens/ExecutionEnvironment/ExecutionEnvironmentList/ExecutionEnvironmentListItem.jsx index 05655925f4..2f1c816e4e 100644 --- a/awx/ui_next/src/screens/ExecutionEnvironment/ExecutionEnvironmentList/ExecutionEnvironmentListItem.jsx +++ b/awx/ui_next/src/screens/ExecutionEnvironment/ExecutionEnvironmentList/ExecutionEnvironmentListItem.jsx @@ -1,6 +1,6 @@ import React, { useState, useCallback } from 'react'; import { string, bool, func } from 'prop-types'; -import { withI18n } from '@lingui/react'; + import { t } from '@lingui/macro'; import { Link } from 'react-router-dom'; import { Button } from '@patternfly/react-core'; @@ -18,7 +18,7 @@ function ExecutionEnvironmentListItem({ detailUrl, isSelected, onSelect, - i18n, + rowIndex, fetchExecutionEnvironments, }) { @@ -52,15 +52,15 @@ function ExecutionEnvironmentListItem({ onSelect, disable: false, }} - dataLabel={i18n._(t`Selected`)} + dataLabel={t`Selected`} /> - + {executionEnvironment.name} - {executionEnvironment.image} - + {executionEnvironment.image} + {executionEnvironment.organization ? ( {executionEnvironment?.summary_fields?.organization?.name}
    ) : ( - i18n._(t`Globally Available`) + t`Globally Available` )} - + )} {user_capabilities?.delete && ( handleHostDelete()} - modalTitle={i18n._(t`Delete Host`)} + modalTitle={t`Delete Host`} name={name} /> )} @@ -129,10 +125,10 @@ function HostDetail({ i18n, host }) { setDeletionError(null)} > - {i18n._(t`Failed to delete host.`)} + {t`Failed to delete host.`} )} @@ -144,4 +140,4 @@ HostDetail.propTypes = { host: Host.isRequired, }; -export default withI18n()(HostDetail); +export default HostDetail; diff --git a/awx/ui_next/src/screens/Host/HostFacts/HostFacts.jsx b/awx/ui_next/src/screens/Host/HostFacts/HostFacts.jsx index 08b447a991..ac62cddf42 100644 --- a/awx/ui_next/src/screens/Host/HostFacts/HostFacts.jsx +++ b/awx/ui_next/src/screens/Host/HostFacts/HostFacts.jsx @@ -1,5 +1,5 @@ import React, { useCallback, useEffect } from 'react'; -import { withI18n } from '@lingui/react'; + import { t } from '@lingui/macro'; import { Host } from '../../../types'; import { CardBody } from '../../../components/Card'; @@ -10,7 +10,7 @@ import ContentLoading from '../../../components/ContentLoading'; import useRequest from '../../../util/useRequest'; import { HostsAPI } from '../../../api'; -function HostFacts({ i18n, host }) { +function HostFacts({ host }) { const { result: facts, isLoading, error, request: fetchFacts } = useRequest( useCallback(async () => { const [{ data: factsObj }] = await Promise.all([ @@ -36,7 +36,7 @@ function HostFacts({ i18n, host }) { return ( - + ); @@ -46,4 +46,4 @@ HostFacts.propTypes = { host: Host.isRequired, }; -export default withI18n()(HostFacts); +export default HostFacts; diff --git a/awx/ui_next/src/screens/Host/HostGroups/HostGroupItem.jsx b/awx/ui_next/src/screens/Host/HostGroups/HostGroupItem.jsx index 9f26cc3bc4..ca1bb97f21 100644 --- a/awx/ui_next/src/screens/Host/HostGroups/HostGroupItem.jsx +++ b/awx/ui_next/src/screens/Host/HostGroups/HostGroupItem.jsx @@ -1,6 +1,6 @@ import React from 'react'; import { bool, func, number, oneOfType, string } from 'prop-types'; -import { withI18n } from '@lingui/react'; + import { t } from '@lingui/macro'; import { @@ -18,7 +18,7 @@ import { PencilAltIcon } from '@patternfly/react-icons'; import DataListCell from '../../../components/DataListCell'; import { Group } from '../../../types'; -function HostGroupItem({ i18n, group, inventoryId, isSelected, onSelect }) { +function HostGroupItem({ group, inventoryId, isSelected, onSelect }) { const labelId = `check-action-${group.id}`; const detailUrl = `/inventories/inventory/${inventoryId}/groups/${group.id}/details`; const editUrl = `/inventories/inventory/${inventoryId}/groups/${group.id}/edit`; @@ -42,12 +42,12 @@ function HostGroupItem({ i18n, group, inventoryId, isSelected, onSelect }) { ]} /> {group.summary_fields.user_capabilities.edit && ( - + @@ -51,4 +49,4 @@ SmartInventoryButton.propTypes = { onClick: func.isRequired, }; -export default withI18n()(SmartInventoryButton); +export default SmartInventoryButton; diff --git a/awx/ui_next/src/screens/Host/Hosts.jsx b/awx/ui_next/src/screens/Host/Hosts.jsx index d8769b071e..da48d99e90 100644 --- a/awx/ui_next/src/screens/Host/Hosts.jsx +++ b/awx/ui_next/src/screens/Host/Hosts.jsx @@ -1,6 +1,6 @@ import React, { useState, useCallback } from 'react'; import { Route, Switch } from 'react-router-dom'; -import { withI18n } from '@lingui/react'; + import { t } from '@lingui/macro'; import { Config } from '../../contexts/Config'; @@ -10,30 +10,27 @@ import HostList from './HostList'; import HostAdd from './HostAdd'; import Host from './Host'; -function Hosts({ i18n }) { +function Hosts() { const [breadcrumbConfig, setBreadcrumbConfig] = useState({ - '/hosts': i18n._(t`Hosts`), - '/hosts/add': i18n._(t`Create New Host`), + '/hosts': t`Hosts`, + '/hosts/add': t`Create New Host`, }); - const buildBreadcrumbConfig = useCallback( - host => { - if (!host) { - return; - } - setBreadcrumbConfig({ - '/hosts': i18n._(t`Hosts`), - '/hosts/add': i18n._(t`Create New Host`), - [`/hosts/${host.id}`]: `${host.name}`, - [`/hosts/${host.id}/edit`]: i18n._(t`Edit Details`), - [`/hosts/${host.id}/details`]: i18n._(t`Details`), - [`/hosts/${host.id}/facts`]: i18n._(t`Facts`), - [`/hosts/${host.id}/groups`]: i18n._(t`Groups`), - [`/hosts/${host.id}/jobs`]: i18n._(t`Jobs`), - }); - }, - [i18n] - ); + const buildBreadcrumbConfig = useCallback(host => { + if (!host) { + return; + } + setBreadcrumbConfig({ + '/hosts': t`Hosts`, + '/hosts/add': t`Create New Host`, + [`/hosts/${host.id}`]: `${host.name}`, + [`/hosts/${host.id}/edit`]: t`Edit Details`, + [`/hosts/${host.id}/details`]: t`Details`, + [`/hosts/${host.id}/facts`]: t`Facts`, + [`/hosts/${host.id}/groups`]: t`Groups`, + [`/hosts/${host.id}/jobs`]: t`Jobs`, + }); + }, []); return ( <> @@ -58,4 +55,4 @@ function Hosts({ i18n }) { } export { Hosts as _Hosts }; -export default withI18n()(Hosts); +export default Hosts; diff --git a/awx/ui_next/src/screens/InstanceGroup/ContainerGroup.jsx b/awx/ui_next/src/screens/InstanceGroup/ContainerGroup.jsx index b806e999f7..640380b983 100644 --- a/awx/ui_next/src/screens/InstanceGroup/ContainerGroup.jsx +++ b/awx/ui_next/src/screens/InstanceGroup/ContainerGroup.jsx @@ -7,7 +7,7 @@ import { useLocation, useParams, } from 'react-router-dom'; -import { withI18n } from '@lingui/react'; + import { t } from '@lingui/macro'; import { CaretLeftIcon } from '@patternfly/react-icons'; import { Card, PageSection } from '@patternfly/react-core'; @@ -22,7 +22,7 @@ import JobList from '../../components/JobList'; import ContainerGroupDetails from './ContainerGroupDetails'; import ContainerGroupEdit from './ContainerGroupEdit'; -function ContainerGroup({ i18n, setBreadcrumb }) { +function ContainerGroup({ setBreadcrumb }) { const { id } = useParams(); const { pathname } = useLocation(); @@ -53,19 +53,19 @@ function ContainerGroup({ i18n, setBreadcrumb }) { name: ( <> - {i18n._(t`Back to instance groups`)} + {t`Back to instance groups`} ), link: '/instance_groups', id: 99, }, { - name: i18n._(t`Details`), + name: t`Details`, link: `/instance_groups/container_group/${id}/details`, id: 0, }, { - name: i18n._(t`Jobs`), + name: t`Jobs`, link: `/instance_groups/container_group/${id}/jobs`, id: 1, }, @@ -78,11 +78,9 @@ function ContainerGroup({ i18n, setBreadcrumb }) { {contentError.response?.status === 404 && ( - {i18n._(t`Container group not found.`)} + {t`Container group not found.`} {''} - - {i18n._(t`View all instance groups`)} - + {t`View all instance groups`} )} @@ -131,4 +129,4 @@ function ContainerGroup({ i18n, setBreadcrumb }) { ); } -export default withI18n()(ContainerGroup); +export default ContainerGroup; diff --git a/awx/ui_next/src/screens/InstanceGroup/ContainerGroupDetails/ContainerGroupDetails.jsx b/awx/ui_next/src/screens/InstanceGroup/ContainerGroupDetails/ContainerGroupDetails.jsx index 77b2b31bfb..da25393c0c 100644 --- a/awx/ui_next/src/screens/InstanceGroup/ContainerGroupDetails/ContainerGroupDetails.jsx +++ b/awx/ui_next/src/screens/InstanceGroup/ContainerGroupDetails/ContainerGroupDetails.jsx @@ -1,5 +1,5 @@ import React, { useCallback } from 'react'; -import { withI18n } from '@lingui/react'; + import { t } from '@lingui/macro'; import { Link, useHistory } from 'react-router-dom'; import { Button, Label } from '@patternfly/react-core'; @@ -18,7 +18,7 @@ import { jsonToYaml, isJsonString } from '../../../util/yaml'; import { InstanceGroupsAPI } from '../../../api'; import { relatedResourceDeleteRequests } from '../../../util/getRelatedResourceDeleteDetails'; -function ContainerGroupDetails({ instanceGroup, i18n }) { +function ContainerGroupDetails({ instanceGroup }) { const { id, name } = instanceGroup; const history = useHistory(); @@ -42,18 +42,18 @@ function ContainerGroupDetails({ instanceGroup, i18n }) { {instanceGroup.summary_fields.credential && ( {instanceGroup.summary_fields.credential?.name} @@ -63,18 +63,18 @@ function ContainerGroupDetails({ instanceGroup, i18n }) { /> )} {instanceGroup.pod_spec_override && ( - {i18n._(t`Edit`)} + {t`Edit`} )} {instanceGroup.summary_fields.user_capabilities && instanceGroup.summary_fields.user_capabilities.delete && ( - {i18n._(t`Delete`)} + {t`Delete`} )} @@ -117,7 +115,7 @@ function ContainerGroupDetails({ instanceGroup, i18n }) { )} @@ -125,4 +123,4 @@ function ContainerGroupDetails({ instanceGroup, i18n }) { ); } -export default withI18n()(ContainerGroupDetails); +export default ContainerGroupDetails; diff --git a/awx/ui_next/src/screens/InstanceGroup/InstanceGroup.jsx b/awx/ui_next/src/screens/InstanceGroup/InstanceGroup.jsx index 06c348a8b9..5d13650c3f 100644 --- a/awx/ui_next/src/screens/InstanceGroup/InstanceGroup.jsx +++ b/awx/ui_next/src/screens/InstanceGroup/InstanceGroup.jsx @@ -7,7 +7,7 @@ import { useLocation, useParams, } from 'react-router-dom'; -import { withI18n } from '@lingui/react'; + import { t } from '@lingui/macro'; import { CaretLeftIcon } from '@patternfly/react-icons'; import { Card, PageSection } from '@patternfly/react-core'; @@ -23,7 +23,7 @@ import InstanceGroupDetails from './InstanceGroupDetails'; import InstanceGroupEdit from './InstanceGroupEdit'; import InstanceList from './Instances/InstanceList'; -function InstanceGroup({ i18n, setBreadcrumb }) { +function InstanceGroup({ setBreadcrumb }) { const { id } = useParams(); const { pathname } = useLocation(); @@ -54,24 +54,24 @@ function InstanceGroup({ i18n, setBreadcrumb }) { name: ( <> - {i18n._(t`Back to instance groups`)} + {t`Back to instance groups`} ), link: '/instance_groups', id: 99, }, { - name: i18n._(t`Details`), + name: t`Details`, link: `/instance_groups/${id}/details`, id: 0, }, { - name: i18n._(t`Instances`), + name: t`Instances`, link: `/instance_groups/${id}/instances`, id: 1, }, { - name: i18n._(t`Jobs`), + name: t`Jobs`, link: `/instance_groups/${id}/jobs`, id: 2, }, @@ -84,11 +84,9 @@ function InstanceGroup({ i18n, setBreadcrumb }) { {contentError.response?.status === 404 && ( - {i18n._(t`Instance group not found.`)} + {t`Instance group not found.`} {''} - - {i18n._(t`View all instance groups`)} - + {t`View all instance groups`} )} @@ -140,4 +138,4 @@ function InstanceGroup({ i18n, setBreadcrumb }) { ); } -export default withI18n()(InstanceGroup); +export default InstanceGroup; diff --git a/awx/ui_next/src/screens/InstanceGroup/InstanceGroupDetails/InstanceGroupDetails.jsx b/awx/ui_next/src/screens/InstanceGroup/InstanceGroupDetails/InstanceGroupDetails.jsx index 414c2effd8..1e9b1bb8c5 100644 --- a/awx/ui_next/src/screens/InstanceGroup/InstanceGroupDetails/InstanceGroupDetails.jsx +++ b/awx/ui_next/src/screens/InstanceGroup/InstanceGroupDetails/InstanceGroupDetails.jsx @@ -1,5 +1,5 @@ import React, { useCallback } from 'react'; -import { withI18n } from '@lingui/react'; + import { t } from '@lingui/macro'; import { Link, useHistory } from 'react-router-dom'; import styled from 'styled-components'; @@ -22,7 +22,7 @@ const Unavailable = styled.span` color: var(--pf-global--danger-color--200); `; -function InstanceGroupDetails({ instanceGroup, i18n }) { +function InstanceGroupDetails({ instanceGroup }) { const { id, name } = instanceGroup; const history = useHistory(); @@ -47,32 +47,32 @@ function InstanceGroupDetails({ instanceGroup, i18n }) { {instanceGroup.capacity ? ( ) : ( {i18n._(t`Unavailable`)}} + label={t`Used capacity`} + value={{t`Unavailable`}} dataCy="instance-group-used-capacity" /> )} @@ -103,11 +103,11 @@ function InstanceGroupDetails({ instanceGroup, i18n }) { instanceGroup.summary_fields.user_capabilities.edit && ( )} {name !== 'tower' && @@ -115,15 +115,13 @@ function InstanceGroupDetails({ instanceGroup, i18n }) { instanceGroup.summary_fields.user_capabilities.delete && ( - {i18n._(t`Delete`)} + {t`Delete`} )} @@ -131,7 +129,7 @@ function InstanceGroupDetails({ instanceGroup, i18n }) { )} @@ -139,4 +137,4 @@ function InstanceGroupDetails({ instanceGroup, i18n }) { ); } -export default withI18n()(InstanceGroupDetails); +export default InstanceGroupDetails; diff --git a/awx/ui_next/src/screens/InstanceGroup/InstanceGroupList/InstanceGroupListItem.jsx b/awx/ui_next/src/screens/InstanceGroup/InstanceGroupList/InstanceGroupListItem.jsx index f6d7556a20..8c9ba76eaa 100644 --- a/awx/ui_next/src/screens/InstanceGroup/InstanceGroupList/InstanceGroupListItem.jsx +++ b/awx/ui_next/src/screens/InstanceGroup/InstanceGroupList/InstanceGroupListItem.jsx @@ -1,6 +1,6 @@ import React from 'react'; import { string, bool, func } from 'prop-types'; -import { withI18n } from '@lingui/react'; + import { t } from '@lingui/macro'; import { Link } from 'react-router-dom'; import 'styled-components/macro'; @@ -26,7 +26,6 @@ function InstanceGroupListItem({ isSelected, onSelect, rowIndex, - i18n, }) { const labelId = `check-action-${instanceGroup.id}`; @@ -42,11 +41,11 @@ function InstanceGroupListItem({ value={Math.round(100 - item.percent_capacity_remaining)} measureLocation={ProgressMeasureLocation.top} size={ProgressSize.sm} - title={i18n._(t`Used capacity`)} + title={t`Used capacity`} /> ); } - return {i18n._(t`Unavailable`)}; + return {t`Unavailable`}; } return null; } @@ -59,30 +58,30 @@ function InstanceGroupListItem({ isSelected, onSelect, }} - dataLabel={i18n._(t`Selected`)} + dataLabel={t`Selected`} /> - + {instanceGroup.name} - + {isContainerGroup(instanceGroup) - ? i18n._(t`Container group`) - : i18n._(t`Instance group`)} + ? t`Container group` + : t`Instance group`} - {instanceGroup.jobs_running} - {instanceGroup.jobs_total} - {instanceGroup.instances} - {usedCapacity(instanceGroup)} - + {instanceGroup.jobs_running} + {instanceGroup.jobs_total} + {instanceGroup.instances} + {usedCapacity(instanceGroup)} + )} {userCapabilities.delete && ( - {i18n._(t`Delete`)} + {t`Delete`} )} @@ -145,10 +143,10 @@ function InventoryDetail({ inventory, i18n }) { - {i18n._(t`Failed to delete inventory.`)} + {t`Failed to delete inventory.`} )} @@ -159,4 +157,4 @@ InventoryDetail.propTypes = { inventory: Inventory.isRequired, }; -export default withI18n()(InventoryDetail); +export default InventoryDetail; diff --git a/awx/ui_next/src/screens/Inventory/InventoryGroup/InventoryGroup.jsx b/awx/ui_next/src/screens/Inventory/InventoryGroup/InventoryGroup.jsx index 0221d3afe7..2d7ed3ecc5 100644 --- a/awx/ui_next/src/screens/Inventory/InventoryGroup/InventoryGroup.jsx +++ b/awx/ui_next/src/screens/Inventory/InventoryGroup/InventoryGroup.jsx @@ -1,6 +1,5 @@ import React, { useEffect, useState } from 'react'; import { t } from '@lingui/macro'; -import { withI18n } from '@lingui/react'; import { Switch, @@ -21,7 +20,7 @@ import InventoryRelatedGroups from '../InventoryRelatedGroups'; import { GroupsAPI } from '../../../api'; -function InventoryGroup({ i18n, setBreadcrumb, inventory }) { +function InventoryGroup({ setBreadcrumb, inventory }) { const [inventoryGroup, setInventoryGroup] = useState(null); const [contentLoading, setContentLoading] = useState(true); const [contentError, setContentError] = useState(null); @@ -48,25 +47,25 @@ function InventoryGroup({ i18n, setBreadcrumb, inventory }) { { name: ( <> - - {i18n._(t`Back to Groups`)} + + {t`Back to Groups`} ), link: `/inventories/inventory/${inventory.id}/groups`, id: 99, }, { - name: i18n._(t`Details`), + name: t`Details`, link: `/inventories/inventory/${inventory.id}/groups/${inventoryGroup?.id}/details`, id: 0, }, { - name: i18n._(t`Related Groups`), + name: t`Related Groups`, link: `/inventories/inventory/${inventory.id}/groups/${inventoryGroup?.id}/nested_groups`, id: 1, }, { - name: i18n._(t`Hosts`), + name: t`Hosts`, link: `/inventories/inventory/${inventory.id}/groups/${inventoryGroup?.id}/nested_hosts`, id: 2, }, @@ -91,7 +90,7 @@ function InventoryGroup({ i18n, setBreadcrumb, inventory }) { return ( - {i18n._(t`View Inventory Groups`)} + {t`View Inventory Groups`} ); @@ -141,7 +140,7 @@ function InventoryGroup({ i18n, setBreadcrumb, inventory }) { {inventory && ( - {i18n._(t`View Inventory Details`)} + {t`View Inventory Details`} )} @@ -152,4 +151,4 @@ function InventoryGroup({ i18n, setBreadcrumb, inventory }) { } export { InventoryGroup as _InventoryGroup }; -export default withI18n()(InventoryGroup); +export default InventoryGroup; diff --git a/awx/ui_next/src/screens/Inventory/InventoryGroupAdd/InventoryGroupAdd.jsx b/awx/ui_next/src/screens/Inventory/InventoryGroupAdd/InventoryGroupAdd.jsx index 29bfb016dd..7f7f37f106 100644 --- a/awx/ui_next/src/screens/Inventory/InventoryGroupAdd/InventoryGroupAdd.jsx +++ b/awx/ui_next/src/screens/Inventory/InventoryGroupAdd/InventoryGroupAdd.jsx @@ -1,5 +1,5 @@ import React, { useState } from 'react'; -import { withI18n } from '@lingui/react'; + import { useHistory, useParams } from 'react-router-dom'; import { Card } from '@patternfly/react-core'; import { GroupsAPI } from '../../../api'; @@ -35,5 +35,5 @@ function InventoryGroupsAdd() { ); } -export default withI18n()(InventoryGroupsAdd); +export default InventoryGroupsAdd; export { InventoryGroupsAdd as _InventoryGroupsAdd }; diff --git a/awx/ui_next/src/screens/Inventory/InventoryGroupDetail/InventoryGroupDetail.jsx b/awx/ui_next/src/screens/Inventory/InventoryGroupDetail/InventoryGroupDetail.jsx index ed891f3c53..a6ed796e09 100644 --- a/awx/ui_next/src/screens/Inventory/InventoryGroupDetail/InventoryGroupDetail.jsx +++ b/awx/ui_next/src/screens/Inventory/InventoryGroupDetail/InventoryGroupDetail.jsx @@ -2,7 +2,7 @@ import React, { useState } from 'react'; import { t } from '@lingui/macro'; import { Button } from '@patternfly/react-core'; -import { withI18n } from '@lingui/react'; + import { useHistory, useParams } from 'react-router-dom'; import { VariablesDetail } from '../../../components/CodeEditor'; import { CardBody, CardActionsRow } from '../../../components/Card'; @@ -15,7 +15,7 @@ import { } from '../../../components/DetailList'; import InventoryGroupsDeleteModal from '../shared/InventoryGroupsDeleteModal'; -function InventoryGroupDetail({ i18n, inventoryGroup }) { +function InventoryGroupDetail({ inventoryGroup }) { const { summary_fields: { created_by, modified_by, user_capabilities }, created, @@ -32,23 +32,15 @@ function InventoryGroupDetail({ i18n, inventoryGroup }) { - - + + + - @@ -58,14 +50,14 @@ function InventoryGroupDetail({ i18n, inventoryGroup }) { )} {user_capabilities?.delete && ( @@ -81,15 +73,15 @@ function InventoryGroupDetail({ i18n, inventoryGroup }) { {error && ( setError(false)} > - {i18n._(t`Failed to delete group ${inventoryGroup.name}.`)} + {t`Failed to delete group ${inventoryGroup.name}.`} )} ); } -export default withI18n()(InventoryGroupDetail); +export default InventoryGroupDetail; diff --git a/awx/ui_next/src/screens/Inventory/InventoryGroupEdit/InventoryGroupEdit.jsx b/awx/ui_next/src/screens/Inventory/InventoryGroupEdit/InventoryGroupEdit.jsx index 1e88b12795..842583d65f 100644 --- a/awx/ui_next/src/screens/Inventory/InventoryGroupEdit/InventoryGroupEdit.jsx +++ b/awx/ui_next/src/screens/Inventory/InventoryGroupEdit/InventoryGroupEdit.jsx @@ -1,5 +1,5 @@ import React, { useState } from 'react'; -import { withI18n } from '@lingui/react'; + import { useParams, useHistory } from 'react-router-dom'; import { GroupsAPI } from '../../../api'; @@ -32,5 +32,5 @@ function InventoryGroupEdit({ inventoryGroup }) { /> ); } -export default withI18n()(InventoryGroupEdit); +export default InventoryGroupEdit; export { InventoryGroupEdit as _InventoryGroupEdit }; diff --git a/awx/ui_next/src/screens/Inventory/InventoryGroupHosts/InventoryGroupHostList.jsx b/awx/ui_next/src/screens/Inventory/InventoryGroupHosts/InventoryGroupHostList.jsx index 682883f907..f0528e7926 100644 --- a/awx/ui_next/src/screens/Inventory/InventoryGroupHosts/InventoryGroupHostList.jsx +++ b/awx/ui_next/src/screens/Inventory/InventoryGroupHosts/InventoryGroupHostList.jsx @@ -1,6 +1,6 @@ import React, { useEffect, useCallback, useState } from 'react'; import { useLocation, useParams, Link } from 'react-router-dom'; -import { withI18n } from '@lingui/react'; + import { t } from '@lingui/macro'; import { DropdownItem } from '@patternfly/react-core'; import { getQSConfig, mergeParams, parseQueryString } from '../../../util/qs'; @@ -27,7 +27,7 @@ const QS_CONFIG = getQSConfig('host', { order_by: 'name', }); -function InventoryGroupHostList({ i18n }) { +function InventoryGroupHostList() { const [isAdHocLaunchLoading, setIsAdHocLaunchLoading] = useState(false); const [isModalOpen, setIsModalOpen] = useState(false); const { id: inventoryId, groupId } = useParams(); @@ -144,8 +144,8 @@ function InventoryGroupHostList({ i18n }) { const canAdd = actions && Object.prototype.hasOwnProperty.call(actions, 'POST'); const addFormUrl = `/inventories/inventory/${inventoryId}/groups/${groupId}/nested_hosts/add`; - const addExistingHost = i18n._(t`Add existing host`); - const addNewHost = i18n._(t`Add new host`); + const addExistingHost = t`Add existing host`; + const addNewHost = t`Add new host`; const addButton = ( , ]} /> @@ -248,23 +248,23 @@ function InventoryGroupHostList({ i18n }) { /> {isModalOpen && ( setIsModalOpen(false)} - title={i18n._(t`Select Hosts`)} + title={t`Select Hosts`} /> )} {associateError && ( - {i18n._(t`Failed to associate.`)} + {t`Failed to associate.`} )} @@ -272,10 +272,10 @@ function InventoryGroupHostList({ i18n }) { - {i18n._(t`Failed to disassociate one or more hosts.`)} + {t`Failed to disassociate one or more hosts.`} )} @@ -283,4 +283,4 @@ function InventoryGroupHostList({ i18n }) { ); } -export default withI18n()(InventoryGroupHostList); +export default InventoryGroupHostList; diff --git a/awx/ui_next/src/screens/Inventory/InventoryGroupHosts/InventoryGroupHostListItem.jsx b/awx/ui_next/src/screens/Inventory/InventoryGroupHosts/InventoryGroupHostListItem.jsx index 643b5ae140..e68da5542c 100644 --- a/awx/ui_next/src/screens/Inventory/InventoryGroupHosts/InventoryGroupHostListItem.jsx +++ b/awx/ui_next/src/screens/Inventory/InventoryGroupHosts/InventoryGroupHostListItem.jsx @@ -2,7 +2,7 @@ import 'styled-components/macro'; import React from 'react'; import { Link } from 'react-router-dom'; import { string, bool, func } from 'prop-types'; -import { withI18n } from '@lingui/react'; + import { t } from '@lingui/macro'; import { @@ -30,7 +30,6 @@ const DataListAction = styled(_DataListAction)` `; function InventoryGroupHostListItem({ - i18n, detailUrl, editUrl, host, @@ -66,16 +65,16 @@ function InventoryGroupHostListItem({ ]} /> {host.summary_fields.user_capabilities?.edit && ( - + )} {user_capabilities?.delete && ( handleHostDelete()} /> )} @@ -119,10 +111,10 @@ function InventoryHostDetail({ i18n, host }) { setDeletionError(null)} > - {i18n._(t`Failed to delete host.`)} + {t`Failed to delete host.`} )} @@ -134,4 +126,4 @@ InventoryHostDetail.propTypes = { host: Host.isRequired, }; -export default withI18n()(InventoryHostDetail); +export default InventoryHostDetail; diff --git a/awx/ui_next/src/screens/Inventory/InventoryHostFacts/InventoryHostFacts.jsx b/awx/ui_next/src/screens/Inventory/InventoryHostFacts/InventoryHostFacts.jsx index 4d93ce58c3..2bbc96f55f 100644 --- a/awx/ui_next/src/screens/Inventory/InventoryHostFacts/InventoryHostFacts.jsx +++ b/awx/ui_next/src/screens/Inventory/InventoryHostFacts/InventoryHostFacts.jsx @@ -1,5 +1,5 @@ import React, { useCallback, useEffect } from 'react'; -import { withI18n } from '@lingui/react'; + import { t } from '@lingui/macro'; import { Host } from '../../../types'; import { CardBody } from '../../../components/Card'; @@ -10,7 +10,7 @@ import ContentLoading from '../../../components/ContentLoading'; import useRequest from '../../../util/useRequest'; import { HostsAPI } from '../../../api'; -function InventoryHostFacts({ i18n, host }) { +function InventoryHostFacts({ host }) { const { request, isLoading, error, result } = useRequest( useCallback(async () => { const { data } = await HostsAPI.readFacts(host.id); @@ -35,7 +35,7 @@ function InventoryHostFacts({ i18n, host }) { return ( - + ); @@ -45,4 +45,4 @@ InventoryHostFacts.propTypes = { host: Host.isRequired, }; -export default withI18n()(InventoryHostFacts); +export default InventoryHostFacts; diff --git a/awx/ui_next/src/screens/Inventory/InventoryHostGroups/InventoryHostGroupItem.jsx b/awx/ui_next/src/screens/Inventory/InventoryHostGroups/InventoryHostGroupItem.jsx index fa3ed0e12c..b87ab23da0 100644 --- a/awx/ui_next/src/screens/Inventory/InventoryHostGroups/InventoryHostGroupItem.jsx +++ b/awx/ui_next/src/screens/Inventory/InventoryHostGroups/InventoryHostGroupItem.jsx @@ -1,6 +1,6 @@ import React from 'react'; import { bool, func, number, oneOfType, string } from 'prop-types'; -import { withI18n } from '@lingui/react'; + import { t } from '@lingui/macro'; import { @@ -18,13 +18,7 @@ import { PencilAltIcon } from '@patternfly/react-icons'; import DataListCell from '../../../components/DataListCell'; import { Group } from '../../../types'; -function InventoryHostGroupItem({ - i18n, - group, - inventoryId, - isSelected, - onSelect, -}) { +function InventoryHostGroupItem({ group, inventoryId, isSelected, onSelect }) { const labelId = `check-action-${group.id}`; const detailUrl = `/inventories/inventory/${inventoryId}/groups/${group.id}/details`; const editUrl = `/inventories/inventory/${inventoryId}/groups/${group.id}/edit`; @@ -48,12 +42,12 @@ function InventoryHostGroupItem({ ]} /> {group.summary_fields.user_capabilities.edit && ( - + )} {user_capabilities?.start && ( @@ -281,29 +275,27 @@ function InventorySourceDetail({ inventorySource, i18n }) { {user_capabilities?.delete && ( - {i18n._(t`Delete`)} + {t`Delete`} )} {deletionError && ( setDeletionError(false)} > - {i18n._(t`Failed to delete inventory source ${name}.`)} + {t`Failed to delete inventory source ${name}.`} )} ); } -export default withI18n()(InventorySourceDetail); +export default InventorySourceDetail; diff --git a/awx/ui_next/src/screens/Inventory/InventorySources/InventorySourceListItem.jsx b/awx/ui_next/src/screens/Inventory/InventorySources/InventorySourceListItem.jsx index a09320db3e..2ac1f21fc3 100644 --- a/awx/ui_next/src/screens/Inventory/InventorySources/InventorySourceListItem.jsx +++ b/awx/ui_next/src/screens/Inventory/InventorySources/InventorySourceListItem.jsx @@ -1,5 +1,5 @@ import React from 'react'; -import { withI18n } from '@lingui/react'; + import { Link } from 'react-router-dom'; import { t } from '@lingui/macro'; import { @@ -30,23 +30,23 @@ function InventorySourceListItem({ source, isSelected, onSelect, - i18n, + detailUrl, label, }) { const generateLastJobTooltip = job => { return ( <> -
    {i18n._(t`MOST RECENT SYNC`)}
    +
    {t`MOST RECENT SYNC`}
    - {i18n._(t`JOB ID:`)} {job.id} + {t`JOB ID:`} {job.id}
    - {i18n._(t`STATUS:`)} {job.status.toUpperCase()} + {t`STATUS:`} {job.status.toUpperCase()}
    {job.finished && (
    - {i18n._(t`FINISHED:`)} {job.finished} + {t`FINISHED:`} {job.finished}
    )} @@ -87,7 +87,7 @@ function InventorySourceListItem({
    )} , - + {source.name} @@ -97,9 +97,7 @@ function InventorySourceListItem({ @@ -107,7 +105,7 @@ function InventorySourceListItem({ )} , - + {label} , ]} @@ -115,7 +113,7 @@ function InventorySourceListItem({ {source.summary_fields.user_capabilities.start && ( @@ -123,7 +121,7 @@ function InventorySourceListItem({ {source.summary_fields.user_capabilities.edit && ( )} {user_capabilities?.delete && ( - {i18n._(t`Delete`)} + {t`Delete`} )} @@ -175,10 +166,10 @@ function SmartInventoryDetail({ inventory, i18n }) { - {i18n._(t`Failed to delete smart inventory.`)} + {t`Failed to delete smart inventory.`} )} @@ -188,7 +179,6 @@ function SmartInventoryDetail({ inventory, i18n }) { SmartInventoryDetail.propTypes = { inventory: Inventory.isRequired, - i18n: shape({}).isRequired, }; -export default withI18n()(SmartInventoryDetail); +export default SmartInventoryDetail; diff --git a/awx/ui_next/src/screens/Inventory/SmartInventoryHost/SmartInventoryHost.jsx b/awx/ui_next/src/screens/Inventory/SmartInventoryHost/SmartInventoryHost.jsx index 048bf88419..4775321c46 100644 --- a/awx/ui_next/src/screens/Inventory/SmartInventoryHost/SmartInventoryHost.jsx +++ b/awx/ui_next/src/screens/Inventory/SmartInventoryHost/SmartInventoryHost.jsx @@ -1,5 +1,5 @@ import React, { useEffect, useCallback } from 'react'; -import { withI18n } from '@lingui/react'; + import { t } from '@lingui/macro'; import { Link, Redirect, Route, Switch, useRouteMatch } from 'react-router-dom'; import { CaretLeftIcon } from '@patternfly/react-icons'; @@ -10,7 +10,7 @@ import SmartInventoryHostDetail from '../SmartInventoryHostDetail'; import useRequest from '../../../util/useRequest'; import { InventoriesAPI } from '../../../api'; -function SmartInventoryHost({ i18n, inventory, setBreadcrumb }) { +function SmartInventoryHost({ inventory, setBreadcrumb }) { const { params, path, url } = useRouteMatch( '/inventories/smart_inventory/:id/hosts/:hostId' ); @@ -45,14 +45,14 @@ function SmartInventoryHost({ i18n, inventory, setBreadcrumb }) { name: ( <> - {i18n._(t`Back to Hosts`)} + {t`Back to Hosts`} ), link: `/inventories/smart_inventory/${inventory.id}/hosts`, id: 0, }, { - name: i18n._(t`Details`), + name: t`Details`, link: `${url}/details`, id: 1, }, @@ -77,7 +77,7 @@ function SmartInventoryHost({ i18n, inventory, setBreadcrumb }) { - {i18n._(t`View smart inventory host details`)} + {t`View smart inventory host details`} @@ -87,4 +87,4 @@ function SmartInventoryHost({ i18n, inventory, setBreadcrumb }) { ); } -export default withI18n()(SmartInventoryHost); +export default SmartInventoryHost; diff --git a/awx/ui_next/src/screens/Inventory/SmartInventoryHostDetail/SmartInventoryHostDetail.jsx b/awx/ui_next/src/screens/Inventory/SmartInventoryHostDetail/SmartInventoryHostDetail.jsx index 3abb48d0ca..7f8e78d9c1 100644 --- a/awx/ui_next/src/screens/Inventory/SmartInventoryHostDetail/SmartInventoryHostDetail.jsx +++ b/awx/ui_next/src/screens/Inventory/SmartInventoryHostDetail/SmartInventoryHostDetail.jsx @@ -1,6 +1,6 @@ import React from 'react'; import { Link } from 'react-router-dom'; -import { withI18n } from '@lingui/react'; + import { t } from '@lingui/macro'; import { Host } from '../../../types'; import { CardBody } from '../../../components/Card'; @@ -12,7 +12,7 @@ import { import Sparkline from '../../../components/Sparkline'; import { VariablesDetail } from '../../../components/CodeEditor'; -function SmartInventoryHostDetail({ host, i18n }) { +function SmartInventoryHostDetail({ host }) { const { created, description, @@ -28,41 +28,30 @@ function SmartInventoryHostDetail({ host, i18n }) { return ( - + {recentPlaybookJobs?.length > 0 && ( } /> )} - + {inventory?.name} } /> - - + + - + ); @@ -72,4 +61,4 @@ SmartInventoryHostDetail.propTypes = { host: Host.isRequired, }; -export default withI18n()(SmartInventoryHostDetail); +export default SmartInventoryHostDetail; diff --git a/awx/ui_next/src/screens/Inventory/SmartInventoryHosts/SmartInventoryHostList.jsx b/awx/ui_next/src/screens/Inventory/SmartInventoryHosts/SmartInventoryHostList.jsx index aa9477326b..eb50309366 100644 --- a/awx/ui_next/src/screens/Inventory/SmartInventoryHosts/SmartInventoryHostList.jsx +++ b/awx/ui_next/src/screens/Inventory/SmartInventoryHosts/SmartInventoryHostList.jsx @@ -1,6 +1,6 @@ import React, { useEffect, useCallback, useState } from 'react'; import { useLocation } from 'react-router-dom'; -import { withI18n } from '@lingui/react'; + import { t } from '@lingui/macro'; import DataListToolbar from '../../../components/DataListToolbar'; import PaginatedDataList from '../../../components/PaginatedDataList'; @@ -18,7 +18,7 @@ const QS_CONFIG = getQSConfig('host', { order_by: 'name', }); -function SmartInventoryHostList({ i18n, inventory }) { +function SmartInventoryHostList({ inventory }) { const location = useLocation(); const [isAdHocLaunchLoading, setIsAdHocLaunchLoading] = useState(false); const { @@ -59,27 +59,27 @@ function SmartInventoryHostList({ i18n, inventory }) { hasContentLoading={isLoading || isAdHocLaunchLoading} items={hosts} itemCount={count} - pluralizedItemName={i18n._(t`Hosts`)} + pluralizedItemName={t`Hosts`} qsConfig={QS_CONFIG} onRowClick={handleSelect} toolbarSearchColumns={[ { - name: i18n._(t`Name`), + name: t`Name`, key: 'name', isDefault: true, }, { - name: i18n._(t`Created by (username)`), + name: t`Created by (username)`, key: 'created_by__username', }, { - name: i18n._(t`Modified by (username)`), + name: t`Modified by (username)`, key: 'modified_by__username', }, ]} toolbarSortColumns={[ { - name: i18n._(t`Name`), + name: t`Name`, key: 'name', }, ]} @@ -123,4 +123,4 @@ SmartInventoryHostList.propTypes = { inventory: Inventory.isRequired, }; -export default withI18n()(SmartInventoryHostList); +export default SmartInventoryHostList; diff --git a/awx/ui_next/src/screens/Inventory/SmartInventoryHosts/SmartInventoryHostListItem.jsx b/awx/ui_next/src/screens/Inventory/SmartInventoryHosts/SmartInventoryHostListItem.jsx index 30a807c459..66ce6aeefd 100644 --- a/awx/ui_next/src/screens/Inventory/SmartInventoryHosts/SmartInventoryHostListItem.jsx +++ b/awx/ui_next/src/screens/Inventory/SmartInventoryHosts/SmartInventoryHostListItem.jsx @@ -1,7 +1,7 @@ import React from 'react'; import { Link } from 'react-router-dom'; import { string, bool, func } from 'prop-types'; -import { withI18n } from '@lingui/react'; + import { t } from '@lingui/macro'; import 'styled-components/macro'; @@ -15,13 +15,7 @@ import DataListCell from '../../../components/DataListCell'; import Sparkline from '../../../components/Sparkline'; import { Host } from '../../../types'; -function SmartInventoryHostListItem({ - i18n, - detailUrl, - host, - isSelected, - onSelect, -}) { +function SmartInventoryHostListItem({ detailUrl, host, isSelected, onSelect }) { const recentPlaybookJobs = host.summary_fields.recent_jobs.map(job => ({ ...job, type: 'job', @@ -50,7 +44,7 @@ function SmartInventoryHostListItem({ , <> - {i18n._(t`Inventory`)} + {t`Inventory`} @@ -72,4 +66,4 @@ SmartInventoryHostListItem.propTypes = { onSelect: func.isRequired, }; -export default withI18n()(SmartInventoryHostListItem); +export default SmartInventoryHostListItem; diff --git a/awx/ui_next/src/screens/Inventory/shared/InventoryForm.jsx b/awx/ui_next/src/screens/Inventory/shared/InventoryForm.jsx index ac79968a05..b7922841df 100644 --- a/awx/ui_next/src/screens/Inventory/shared/InventoryForm.jsx +++ b/awx/ui_next/src/screens/Inventory/shared/InventoryForm.jsx @@ -1,6 +1,6 @@ import React, { useCallback } from 'react'; import { Formik, useField, useFormikContext } from 'formik'; -import { withI18n } from '@lingui/react'; + import { t } from '@lingui/macro'; import { func, number, shape } from 'prop-types'; @@ -17,11 +17,11 @@ import { FormFullWidthLayout, } from '../../../components/FormLayout'; -function InventoryFormFields({ i18n, credentialTypeId, inventory }) { +function InventoryFormFields({ credentialTypeId, inventory }) { const { setFieldValue } = useFormikContext(); const [organizationField, organizationMeta, organizationHelpers] = useField({ name: 'organization', - validate: required(i18n._(t`Select a value for this field`), i18n), + validate: required(t`Select a value for this field`), }); const [instanceGroupsField, , instanceGroupsHelpers] = useField( 'instanceGroups' @@ -44,15 +44,15 @@ function InventoryFormFields({ i18n, credentialTypeId, inventory }) { <> @@ -68,7 +68,7 @@ function InventoryFormFields({ i18n, credentialTypeId, inventory }) { autoPopulate={!inventory?.id} /> @@ -153,4 +151,4 @@ InventoryForm.defaultProps = { submitError: null, }; -export default withI18n()(InventoryForm); +export default InventoryForm; diff --git a/awx/ui_next/src/screens/Inventory/shared/InventoryGroupForm.jsx b/awx/ui_next/src/screens/Inventory/shared/InventoryGroupForm.jsx index ac894d918b..899a2d3c80 100644 --- a/awx/ui_next/src/screens/Inventory/shared/InventoryGroupForm.jsx +++ b/awx/ui_next/src/screens/Inventory/shared/InventoryGroupForm.jsx @@ -1,5 +1,5 @@ import React from 'react'; -import { withI18n } from '@lingui/react'; + import { Formik } from 'formik'; import { Form, Card } from '@patternfly/react-core'; import { t } from '@lingui/macro'; @@ -14,13 +14,7 @@ import { FormFullWidthLayout, } from '../../../components/FormLayout'; -function InventoryGroupForm({ - i18n, - error, - group = {}, - handleSubmit, - handleCancel, -}) { +function InventoryGroupForm({ error, group = {}, handleSubmit, handleCancel }) { const initialValues = { name: group.name || '', description: group.description || '', @@ -38,21 +32,21 @@ function InventoryGroupForm({ id="inventoryGroup-name" name="name" type="text" - label={i18n._(t`Name`)} - validate={required(null, i18n)} + label={t`Name`} + validate={required(null)} isRequired /> { - const { i18n } = useLingui(); const [radioOption, setRadioOption] = useState(null); const [isModalOpen, setIsModalOpen] = useState(false); const [isDeleteLoading, setIsDeleteLoading] = useState(false); @@ -63,19 +61,19 @@ const InventoryGroupsDeleteModal = ({ onAfterDelete, isDisabled, groups }) => { key="delete" isDisabled={isDisabled || isDeleteLoading} component="button" - aria-label={i18n._(t`Delete`)} + aria-label={t`Delete`} onClick={() => setIsModalOpen(true)} > - {i18n._(t`Delete`)} + {t`Delete`} ) : ( )} {isModalOpen && ( @@ -92,21 +90,21 @@ const InventoryGroupsDeleteModal = ({ onAfterDelete, isDisabled, groups }) => { onClose={() => setIsModalOpen(false)} actions={[ , , ]} > @@ -125,7 +123,7 @@ const InventoryGroupsDeleteModal = ({ onAfterDelete, isDisabled, groups }) => { setRadioOption('delete')} /> @@ -133,7 +131,7 @@ const InventoryGroupsDeleteModal = ({ onAfterDelete, isDisabled, groups }) => { css="margin-top: 5px;" id="radio-promote" key="radio-promote" - label={i18n._(t`Promote Child Groups and Hosts`)} + label={t`Promote Child Groups and Hosts`} name="option" onChange={() => setRadioOption('promote')} /> @@ -144,11 +142,11 @@ const InventoryGroupsDeleteModal = ({ onAfterDelete, isDisabled, groups }) => { setDeletionError(null)} > - {i18n._(t`Failed to delete one or more groups.`)} + {t`Failed to delete one or more groups.`} )} diff --git a/awx/ui_next/src/screens/Inventory/shared/InventorySourceForm.jsx b/awx/ui_next/src/screens/Inventory/shared/InventorySourceForm.jsx index 3049d2ccb4..a0f33a6a12 100644 --- a/awx/ui_next/src/screens/Inventory/shared/InventorySourceForm.jsx +++ b/awx/ui_next/src/screens/Inventory/shared/InventorySourceForm.jsx @@ -1,7 +1,7 @@ import React, { useEffect, useCallback } from 'react'; import { Formik, useField, useFormikContext } from 'formik'; import { func, shape } from 'prop-types'; -import { withI18n } from '@lingui/react'; + import { t } from '@lingui/macro'; import { Form, FormGroup, Title } from '@patternfly/react-core'; import { InventorySourcesAPI } from '../../../api'; @@ -42,7 +42,6 @@ const InventorySourceFormFields = ({ source, sourceOptions, organizationId, - i18n, }) => { const { values, @@ -53,7 +52,7 @@ const InventorySourceFormFields = ({ } = useFormikContext(); const [sourceField, sourceMeta] = useField({ name: 'source', - validate: required(i18n._(t`Set a value for this field`), i18n), + validate: required(t`Set a value for this field`), }); const [ executionEnvironmentField, @@ -102,15 +101,15 @@ const InventorySourceFormFields = ({ <> @@ -132,7 +131,7 @@ const InventorySourceFormFields = ({ validated={ !sourceMeta.touched || !sourceMeta.error ? 'default' : 'error' } - label={i18n._(t`Source`)} + label={t`Source`} > - {i18n._(t`Source details`)} + {t`Source details`} { @@ -229,7 +228,6 @@ const InventorySourceFormFields = ({ }; const InventorySourceForm = ({ - i18n, onCancel, onSubmit, source, @@ -295,7 +293,6 @@ const InventorySourceForm = ({ { +const AzureSubForm = ({ autoPopulateCredential }) => { const { setFieldValue } = useFormikContext(); const [credentialField, credentialMeta, credentialHelpers] = useField({ name: 'credential', - validate: required(i18n._(t`Select a value for this field`), i18n), + validate: required(t`Select a value for this field`), }); const config = useConfig(); @@ -40,7 +40,7 @@ const AzureSubForm = ({ autoPopulateCredential, i18n }) => { <> credentialHelpers.setTouched()} @@ -78,4 +78,4 @@ const AzureSubForm = ({ autoPopulateCredential, i18n }) => { ); }; -export default withI18n()(AzureSubForm); +export default AzureSubForm; diff --git a/awx/ui_next/src/screens/Inventory/shared/InventorySourceSubForms/EC2SubForm.jsx b/awx/ui_next/src/screens/Inventory/shared/InventorySourceSubForms/EC2SubForm.jsx index c5a988fa3d..e28abc6ef8 100644 --- a/awx/ui_next/src/screens/Inventory/shared/InventorySourceSubForms/EC2SubForm.jsx +++ b/awx/ui_next/src/screens/Inventory/shared/InventorySourceSubForms/EC2SubForm.jsx @@ -1,6 +1,6 @@ import React, { useCallback } from 'react'; import { useField, useFormikContext } from 'formik'; -import { withI18n } from '@lingui/react'; + import { t, Trans } from '@lingui/macro'; import CredentialLookup from '../../../../components/Lookup/CredentialLookup'; import { @@ -14,7 +14,7 @@ import { import getDocsBaseUrl from '../../../../util/getDocsBaseUrl'; import { useConfig } from '../../../../contexts/Config'; -const EC2SubForm = ({ i18n }) => { +const EC2SubForm = () => { const { setFieldValue } = useFormikContext(); const [credentialField] = useField('credential'); const config = useConfig(); @@ -36,7 +36,7 @@ const EC2SubForm = ({ i18n }) => { <> @@ -69,4 +69,4 @@ const EC2SubForm = ({ i18n }) => { ); }; -export default withI18n()(EC2SubForm); +export default EC2SubForm; diff --git a/awx/ui_next/src/screens/Inventory/shared/InventorySourceSubForms/GCESubForm.jsx b/awx/ui_next/src/screens/Inventory/shared/InventorySourceSubForms/GCESubForm.jsx index 793211107a..813ace1e8e 100644 --- a/awx/ui_next/src/screens/Inventory/shared/InventorySourceSubForms/GCESubForm.jsx +++ b/awx/ui_next/src/screens/Inventory/shared/InventorySourceSubForms/GCESubForm.jsx @@ -1,6 +1,6 @@ import React, { useCallback } from 'react'; import { useField, useFormikContext } from 'formik'; -import { withI18n } from '@lingui/react'; + import { t, Trans } from '@lingui/macro'; import CredentialLookup from '../../../../components/Lookup/CredentialLookup'; import { @@ -15,11 +15,11 @@ import { required } from '../../../../util/validators'; import getDocsBaseUrl from '../../../../util/getDocsBaseUrl'; import { useConfig } from '../../../../contexts/Config'; -const GCESubForm = ({ autoPopulateCredential, i18n }) => { +const GCESubForm = ({ autoPopulateCredential }) => { const { setFieldValue } = useFormikContext(); const [credentialField, credentialMeta, credentialHelpers] = useField({ name: 'credential', - validate: required(i18n._(t`Select a value for this field`), i18n), + validate: required(t`Select a value for this field`), }); const config = useConfig(); @@ -40,7 +40,7 @@ const GCESubForm = ({ autoPopulateCredential, i18n }) => { <> credentialHelpers.setTouched()} @@ -78,4 +78,4 @@ const GCESubForm = ({ autoPopulateCredential, i18n }) => { ); }; -export default withI18n()(GCESubForm); +export default GCESubForm; diff --git a/awx/ui_next/src/screens/Inventory/shared/InventorySourceSubForms/OpenStackSubForm.jsx b/awx/ui_next/src/screens/Inventory/shared/InventorySourceSubForms/OpenStackSubForm.jsx index 3d85189b10..f52f50ffa0 100644 --- a/awx/ui_next/src/screens/Inventory/shared/InventorySourceSubForms/OpenStackSubForm.jsx +++ b/awx/ui_next/src/screens/Inventory/shared/InventorySourceSubForms/OpenStackSubForm.jsx @@ -1,6 +1,6 @@ import React, { useCallback } from 'react'; import { useField, useFormikContext } from 'formik'; -import { withI18n } from '@lingui/react'; + import { t, Trans } from '@lingui/macro'; import CredentialLookup from '../../../../components/Lookup/CredentialLookup'; import { @@ -15,11 +15,11 @@ import { required } from '../../../../util/validators'; import getDocsBaseUrl from '../../../../util/getDocsBaseUrl'; import { useConfig } from '../../../../contexts/Config'; -const OpenStackSubForm = ({ autoPopulateCredential, i18n }) => { +const OpenStackSubForm = ({ autoPopulateCredential }) => { const { setFieldValue } = useFormikContext(); const [credentialField, credentialMeta, credentialHelpers] = useField({ name: 'credential', - validate: required(i18n._(t`Select a value for this field`), i18n), + validate: required(t`Select a value for this field`), }); const config = useConfig(); @@ -40,7 +40,7 @@ const OpenStackSubForm = ({ autoPopulateCredential, i18n }) => { <> credentialHelpers.setTouched()} @@ -78,4 +78,4 @@ const OpenStackSubForm = ({ autoPopulateCredential, i18n }) => { ); }; -export default withI18n()(OpenStackSubForm); +export default OpenStackSubForm; diff --git a/awx/ui_next/src/screens/Inventory/shared/InventorySourceSubForms/SCMSubForm.jsx b/awx/ui_next/src/screens/Inventory/shared/InventorySourceSubForms/SCMSubForm.jsx index c04f471f32..d3be7a3fcb 100644 --- a/awx/ui_next/src/screens/Inventory/shared/InventorySourceSubForms/SCMSubForm.jsx +++ b/awx/ui_next/src/screens/Inventory/shared/InventorySourceSubForms/SCMSubForm.jsx @@ -1,6 +1,6 @@ import React, { useCallback, useEffect, useState } from 'react'; import { useField, useFormikContext } from 'formik'; -import { withI18n } from '@lingui/react'; + import { t } from '@lingui/macro'; import { FormGroup, @@ -24,18 +24,18 @@ import { HostFilterField, } from './SharedFields'; -const SCMSubForm = ({ autoPopulateProject, i18n }) => { +const SCMSubForm = ({ autoPopulateProject }) => { const [isOpen, setIsOpen] = useState(false); const [sourcePath, setSourcePath] = useState([]); const { setFieldValue, setFieldTouched } = useFormikContext(); const [credentialField] = useField('credential'); const [projectField, projectMeta, projectHelpers] = useField({ name: 'source_project', - validate: required(i18n._(t`Select a value for this field`), i18n), + validate: required(t`Select a value for this field`), }); const [sourcePathField, sourcePathMeta, sourcePathHelpers] = useField({ name: 'source_path', - validate: required(i18n._(t`Select a value for this field`), i18n), + validate: required(t`Select a value for this field`), }); const { error: sourcePathError, request: fetchSourcePath } = useRequest( @@ -76,7 +76,7 @@ const SCMSubForm = ({ autoPopulateProject, i18n }) => { <> @@ -99,12 +99,12 @@ const SCMSubForm = ({ autoPopulateProject, i18n }) => { : 'error' } isRequired - label={i18n._(t`Inventory file`)} + label={t`Inventory file`} labelIcon={ } > @@ -124,10 +124,10 @@ const SCMSubForm = ({ autoPopulateProject, i18n }) => { value = value.trim(); sourcePathHelpers.setValue(value); }} - aria-label={i18n._(t`Select source path`)} - typeAheadAriaLabel={i18n._(t`Select source path`)} - placeholder={i18n._(t`Select source path`)} - createText={i18n._(t`Set source path to`)} + aria-label={t`Select source path`} + typeAheadAriaLabel={t`Select source path`} + placeholder={t`Select source path`} + createText={t`Set source path to`} isCreatable onCreateOption={value => { value.trim(); @@ -149,4 +149,4 @@ const SCMSubForm = ({ autoPopulateProject, i18n }) => { ); }; -export default withI18n()(SCMSubForm); +export default SCMSubForm; diff --git a/awx/ui_next/src/screens/Inventory/shared/InventorySourceSubForms/SatelliteSubForm.jsx b/awx/ui_next/src/screens/Inventory/shared/InventorySourceSubForms/SatelliteSubForm.jsx index 0d27c3b298..6df0d3b9c2 100644 --- a/awx/ui_next/src/screens/Inventory/shared/InventorySourceSubForms/SatelliteSubForm.jsx +++ b/awx/ui_next/src/screens/Inventory/shared/InventorySourceSubForms/SatelliteSubForm.jsx @@ -1,6 +1,6 @@ import React, { useCallback } from 'react'; import { useField, useFormikContext } from 'formik'; -import { withI18n } from '@lingui/react'; + import { t, Trans } from '@lingui/macro'; import CredentialLookup from '../../../../components/Lookup/CredentialLookup'; import { @@ -15,11 +15,11 @@ import { required } from '../../../../util/validators'; import getDocsBaseUrl from '../../../../util/getDocsBaseUrl'; import { useConfig } from '../../../../contexts/Config'; -const SatelliteSubForm = ({ autoPopulateCredential, i18n }) => { +const SatelliteSubForm = ({ autoPopulateCredential }) => { const { setFieldValue } = useFormikContext(); const [credentialField, credentialMeta, credentialHelpers] = useField({ name: 'credential', - validate: required(i18n._(t`Select a value for this field`), i18n), + validate: required(t`Select a value for this field`), }); const config = useConfig(); @@ -40,7 +40,7 @@ const SatelliteSubForm = ({ autoPopulateCredential, i18n }) => { <> credentialHelpers.setTouched()} @@ -78,4 +78,4 @@ const SatelliteSubForm = ({ autoPopulateCredential, i18n }) => { ); }; -export default withI18n()(SatelliteSubForm); +export default SatelliteSubForm; diff --git a/awx/ui_next/src/screens/Inventory/shared/InventorySourceSubForms/SharedFields.jsx b/awx/ui_next/src/screens/Inventory/shared/InventorySourceSubForms/SharedFields.jsx index cb03c36af0..a0063a2fc7 100644 --- a/awx/ui_next/src/screens/Inventory/shared/InventorySourceSubForms/SharedFields.jsx +++ b/awx/ui_next/src/screens/Inventory/shared/InventorySourceSubForms/SharedFields.jsx @@ -1,5 +1,5 @@ import React, { useEffect } from 'react'; -import { withI18n } from '@lingui/react'; + import { t, Trans } from '@lingui/macro'; import { useField } from 'formik'; import { Link } from 'react-router-dom'; @@ -14,7 +14,7 @@ import { } from '../../../../components/FormLayout'; import Popover from '../../../../components/Popover'; -export const SourceVarsField = withI18n()(({ i18n, popoverContent }) => { +export const SourceVarsField = ({ popoverContent }) => { const jsonExample = ` { "somevar": "somevalue" @@ -31,7 +31,7 @@ export const SourceVarsField = withI18n()(({ i18n, popoverContent }) => { {popoverContent} @@ -73,25 +73,25 @@ export const SourceVarsField = withI18n()(({ i18n, popoverContent }) => { /> ); -}); +}; -export const VerbosityField = withI18n()(({ i18n }) => { +export const VerbosityField = () => { const [field, meta, helpers] = useField('verbosity'); const isValid = !(meta.touched && meta.error); const options = [ - { value: '0', key: '0', label: i18n._(t`0 (Warning)`) }, - { value: '1', key: '1', label: i18n._(t`1 (Info)`) }, - { value: '2', key: '2', label: i18n._(t`2 (Debug)`) }, + { value: '0', key: '0', label: t`0 (Warning)` }, + { value: '1', key: '1', label: t`1 (Info)` }, + { value: '2', key: '2', label: t`2 (Debug)` }, ]; return ( } > @@ -103,188 +103,177 @@ export const VerbosityField = withI18n()(({ i18n }) => { /> ); -}); +}; -export const OptionsField = withI18n()( - ({ i18n, showProjectUpdate = false }) => { - const [updateOnLaunchField] = useField('update_on_launch'); - const [, , updateCacheTimeoutHelper] = useField('update_cache_timeout'); - const [updatedOnProjectUpdateField] = useField('update_on_project_update'); - const [projectField] = useField('source_project'); +export const OptionsField = ({ showProjectUpdate = false }) => { + const [updateOnLaunchField] = useField('update_on_launch'); + const [, , updateCacheTimeoutHelper] = useField('update_cache_timeout'); + const [updatedOnProjectUpdateField] = useField('update_on_project_update'); + const [projectField] = useField('source_project'); - useEffect(() => { - if (!updateOnLaunchField.value) { - updateCacheTimeoutHelper.setValue(0); - } - }, [updateOnLaunchField.value]); // eslint-disable-line react-hooks/exhaustive-deps + useEffect(() => { + if (!updateOnLaunchField.value) { + updateCacheTimeoutHelper.setValue(0); + } + }, [updateOnLaunchField.value]); // eslint-disable-line react-hooks/exhaustive-deps - return ( - <> - - - - - {i18n._(t`If checked, any hosts and groups that were + return ( + <> + + + + + {t`If checked, any hosts and groups that were previously present on the external source but are now removed will be removed from the inventory. Hosts and groups that were not managed by the inventory source will be promoted to the next manually created group or if there is no manually created group to promote them into, they will be left in the "all" - default group for the inventory.`)} -
    -
    - {i18n._(t`When not checked, local child + default group for the inventory.`} +
    +
    + {t`When not checked, local child hosts and groups not found on the external source will remain - untouched by the inventory update process.`)} - - } - /> - - {i18n._(t`If checked, all variables for child groups + untouched by the inventory update process.`} + + } + /> + + {t`If checked, all variables for child groups and hosts will be removed and replaced by those found - on the external source.`)} -
    -
    - {i18n._(t`When not checked, a merge will be performed, + on the external source.`} +
    +
    + {t`When not checked, a merge will be performed, combining local variables with those found on the - external source.`)} - - } - /> + external source.`} + + } + /> + +
    + {t`Each time a job runs using this inventory, + refresh the inventory from the selected source before + executing job tasks.`} +
    +
    + {projectField?.value && ( +
    + {t`If you want the Inventory Source to update on + launch and on project update, click on Update on launch, and also go to`} + + {' '} + {projectField.value.name}{' '} + + {t`and click on Update Revision on Launch`} +
    + )} + + } + /> + {showProjectUpdate && (
    - {i18n._(t`Each time a job runs using this inventory, - refresh the inventory from the selected source before - executing job tasks.`)} + {t`After every project update where the SCM revision + changes, refresh the inventory from the selected source + before executing job tasks. This is intended for static content, + like the Ansible inventory .ini file format.`}

    {projectField?.value && (
    - {i18n._(t`If you want the Inventory Source to update on - launch and on project update, click on Update on launch, and also go to`)} + {t`If you want the Inventory Source to update on + launch and on project update, click on Update on launch, and also go to`} {' '} {projectField.value.name}{' '} - {i18n._(t`and click on Update Revision on Launch`)} + {t`and click on Update Revision on Launch`}
    )} } /> - {showProjectUpdate && ( - -
    - {i18n._(t`After every project update where the SCM revision - changes, refresh the inventory from the selected source - before executing job tasks. This is intended for static content, - like the Ansible inventory .ini file format.`)} -
    -
    - {projectField?.value && ( -
    - {i18n._(t`If you want the Inventory Source to update on - launch and on project update, click on Update on launch, and also go to`)} - - {' '} - {projectField.value.name}{' '} - - {i18n._(t`and click on Update Revision on Launch`)} -
    - )} - - } - /> - )} -
    -
    -
    - {updateOnLaunchField.value && ( - +
    +
    + {updateOnLaunchField.value && ( + - )} - - ); - } -); + inventory sync will be performed.`} + /> + )} + + ); +}; -export const EnabledVarField = withI18n()(({ i18n }) => { +export const EnabledVarField = () => { return ( ); -}); +}; -export const EnabledValueField = withI18n()(({ i18n }) => { +export const EnabledValueField = () => { return ( ); -}); +}; -export const HostFilterField = withI18n()(({ i18n }) => { +export const HostFilterField = () => { return ( ); -}); +}; diff --git a/awx/ui_next/src/screens/Inventory/shared/InventorySourceSubForms/TowerSubForm.jsx b/awx/ui_next/src/screens/Inventory/shared/InventorySourceSubForms/TowerSubForm.jsx index dd3f57df41..a6f92ad81c 100644 --- a/awx/ui_next/src/screens/Inventory/shared/InventorySourceSubForms/TowerSubForm.jsx +++ b/awx/ui_next/src/screens/Inventory/shared/InventorySourceSubForms/TowerSubForm.jsx @@ -1,6 +1,6 @@ import React, { useCallback } from 'react'; import { useField, useFormikContext } from 'formik'; -import { withI18n } from '@lingui/react'; + import { t, Trans } from '@lingui/macro'; import CredentialLookup from '../../../../components/Lookup/CredentialLookup'; import { @@ -15,11 +15,11 @@ import { required } from '../../../../util/validators'; import getDocsBaseUrl from '../../../../util/getDocsBaseUrl'; import { useConfig } from '../../../../contexts/Config'; -const TowerSubForm = ({ autoPopulateCredential, i18n }) => { +const TowerSubForm = ({ autoPopulateCredential }) => { const { setFieldValue } = useFormikContext(); const [credentialField, credentialMeta, credentialHelpers] = useField({ name: 'credential', - validate: required(i18n._(t`Select a value for this field`), i18n), + validate: required(t`Select a value for this field`), }); const config = useConfig(); @@ -40,7 +40,7 @@ const TowerSubForm = ({ autoPopulateCredential, i18n }) => { <> credentialHelpers.setTouched()} @@ -78,4 +78,4 @@ const TowerSubForm = ({ autoPopulateCredential, i18n }) => { ); }; -export default withI18n()(TowerSubForm); +export default TowerSubForm; diff --git a/awx/ui_next/src/screens/Inventory/shared/InventorySourceSubForms/VMwareSubForm.jsx b/awx/ui_next/src/screens/Inventory/shared/InventorySourceSubForms/VMwareSubForm.jsx index f9b0b16eb4..349c36ccf3 100644 --- a/awx/ui_next/src/screens/Inventory/shared/InventorySourceSubForms/VMwareSubForm.jsx +++ b/awx/ui_next/src/screens/Inventory/shared/InventorySourceSubForms/VMwareSubForm.jsx @@ -1,6 +1,6 @@ import React, { useCallback } from 'react'; import { useField, useFormikContext } from 'formik'; -import { withI18n } from '@lingui/react'; + import { t, Trans } from '@lingui/macro'; import CredentialLookup from '../../../../components/Lookup/CredentialLookup'; import { @@ -15,11 +15,11 @@ import { required } from '../../../../util/validators'; import getDocsBaseUrl from '../../../../util/getDocsBaseUrl'; import { useConfig } from '../../../../contexts/Config'; -const VMwareSubForm = ({ autoPopulateCredential, i18n }) => { +const VMwareSubForm = ({ autoPopulateCredential }) => { const { setFieldValue } = useFormikContext(); const [credentialField, credentialMeta, credentialHelpers] = useField({ name: 'credential', - validate: required(i18n._(t`Select a value for this field`), i18n), + validate: required(t`Select a value for this field`), }); const config = useConfig(); @@ -40,7 +40,7 @@ const VMwareSubForm = ({ autoPopulateCredential, i18n }) => { <> credentialHelpers.setTouched()} @@ -78,4 +78,4 @@ const VMwareSubForm = ({ autoPopulateCredential, i18n }) => { ); }; -export default withI18n()(VMwareSubForm); +export default VMwareSubForm; diff --git a/awx/ui_next/src/screens/Inventory/shared/InventorySourceSubForms/VirtualizationSubForm.jsx b/awx/ui_next/src/screens/Inventory/shared/InventorySourceSubForms/VirtualizationSubForm.jsx index e081d9f629..b507101d17 100644 --- a/awx/ui_next/src/screens/Inventory/shared/InventorySourceSubForms/VirtualizationSubForm.jsx +++ b/awx/ui_next/src/screens/Inventory/shared/InventorySourceSubForms/VirtualizationSubForm.jsx @@ -1,6 +1,6 @@ import React, { useCallback } from 'react'; import { useField, useFormikContext } from 'formik'; -import { withI18n } from '@lingui/react'; + import { t, Trans } from '@lingui/macro'; import CredentialLookup from '../../../../components/Lookup/CredentialLookup'; import { @@ -15,11 +15,11 @@ import { required } from '../../../../util/validators'; import getDocsBaseUrl from '../../../../util/getDocsBaseUrl'; import { useConfig } from '../../../../contexts/Config'; -const VirtualizationSubForm = ({ autoPopulateCredential, i18n }) => { +const VirtualizationSubForm = ({ autoPopulateCredential }) => { const { setFieldValue } = useFormikContext(); const [credentialField, credentialMeta, credentialHelpers] = useField({ name: 'credential', - validate: required(i18n._(t`Select a value for this field`), i18n), + validate: required(t`Select a value for this field`), }); const config = useConfig(); @@ -40,7 +40,7 @@ const VirtualizationSubForm = ({ autoPopulateCredential, i18n }) => { <> credentialHelpers.setTouched()} @@ -78,4 +78,4 @@ const VirtualizationSubForm = ({ autoPopulateCredential, i18n }) => { ); }; -export default withI18n()(VirtualizationSubForm); +export default VirtualizationSubForm; diff --git a/awx/ui_next/src/screens/Inventory/shared/InventorySourceSyncButton.jsx b/awx/ui_next/src/screens/Inventory/shared/InventorySourceSyncButton.jsx index d6b8f02058..07272a5d7a 100644 --- a/awx/ui_next/src/screens/Inventory/shared/InventorySourceSyncButton.jsx +++ b/awx/ui_next/src/screens/Inventory/shared/InventorySourceSyncButton.jsx @@ -1,5 +1,5 @@ import React, { useCallback } from 'react'; -import { withI18n } from '@lingui/react'; + import { t } from '@lingui/macro'; import PropTypes from 'prop-types'; import { Button, Tooltip } from '@patternfly/react-core'; @@ -9,7 +9,7 @@ import AlertModal from '../../../components/AlertModal/AlertModal'; import ErrorDetail from '../../../components/ErrorDetail/ErrorDetail'; import { InventoryUpdatesAPI, InventorySourcesAPI } from '../../../api'; -function InventorySourceSyncButton({ source, icon, i18n }) { +function InventorySourceSyncButton({ source, icon }) { const { isLoading: startSyncLoading, error: startSyncError, @@ -55,27 +55,27 @@ function InventorySourceSyncButton({ source, icon, i18n }) { return ( <> {['running', 'pending', 'updating'].includes(source.status) ? ( - + ) : ( - + )} @@ -83,10 +83,10 @@ function InventorySourceSyncButton({ source, icon, i18n }) { - {i18n._(t`Failed to sync inventory source.`)} + {t`Failed to sync inventory source.`} )} @@ -94,10 +94,10 @@ function InventorySourceSyncButton({ source, icon, i18n }) { - {i18n._(t`Failed to cancel inventory source sync.`)} + {t`Failed to cancel inventory source sync.`} )} @@ -115,4 +115,4 @@ InventorySourceSyncButton.propTypes = { icon: PropTypes.bool, }; -export default withI18n()(InventorySourceSyncButton); +export default InventorySourceSyncButton; diff --git a/awx/ui_next/src/screens/Inventory/shared/SmartInventoryForm.jsx b/awx/ui_next/src/screens/Inventory/shared/SmartInventoryForm.jsx index 71a54592a7..f4182086fe 100644 --- a/awx/ui_next/src/screens/Inventory/shared/SmartInventoryForm.jsx +++ b/awx/ui_next/src/screens/Inventory/shared/SmartInventoryForm.jsx @@ -1,6 +1,6 @@ import React, { useEffect, useCallback } from 'react'; import { Formik, useField, useFormikContext } from 'formik'; -import { withI18n } from '@lingui/react'; + import { t } from '@lingui/macro'; import { useLocation } from 'react-router-dom'; import { func, shape, arrayOf } from 'prop-types'; @@ -26,18 +26,18 @@ import useRequest from '../../../util/useRequest'; import { required } from '../../../util/validators'; import { InventoriesAPI } from '../../../api'; -const SmartInventoryFormFields = withI18n()(({ i18n, inventory }) => { +const SmartInventoryFormFields = ({ inventory }) => { const { setFieldValue } = useFormikContext(); const [organizationField, organizationMeta, organizationHelpers] = useField({ name: 'organization', - validate: required(i18n._(t`Select a value for this field`), i18n), + validate: required(t`Select a value for this field`), }); const [instanceGroupsField, , instanceGroupsHelpers] = useField({ name: 'instance_groups', }); const [hostFilterField, hostFilterMeta, hostFilterHelpers] = useField({ name: 'host_filter', - validate: required(null, i18n), + validate: required(null), }); const onOrganizationChange = useCallback( value => { @@ -50,15 +50,15 @@ const SmartInventoryFormFields = withI18n()(({ i18n, inventory }) => { <> @@ -87,25 +87,21 @@ const SmartInventoryFormFields = withI18n()(({ i18n, inventory }) => { onChange={value => { instanceGroupsHelpers.setValue(value); }} - tooltip={i18n._( - t`Select the Instance Groups for this Inventory to run on.` - )} + tooltip={t`Select the Instance Groups for this Inventory to run on.`} /> ); -}); +}; function SmartInventoryForm({ inventory, @@ -195,4 +191,4 @@ SmartInventoryForm.defaultProps = { submitError: null, }; -export default withI18n()(SmartInventoryForm); +export default SmartInventoryForm; diff --git a/awx/ui_next/src/screens/Job/Job.jsx b/awx/ui_next/src/screens/Job/Job.jsx index a46315c397..056f71a72f 100644 --- a/awx/ui_next/src/screens/Job/Job.jsx +++ b/awx/ui_next/src/screens/Job/Job.jsx @@ -8,7 +8,7 @@ import { useParams, useRouteMatch, } from 'react-router-dom'; -import { withI18n } from '@lingui/react'; + import { t } from '@lingui/macro'; import { CaretLeftIcon } from '@patternfly/react-icons'; import { Card, PageSection } from '@patternfly/react-core'; @@ -32,7 +32,7 @@ export const JOB_URL_SEGMENT_MAP = { workflow: 'workflow_job', }; -function Job({ i18n, setBreadcrumb }) { +function Job({ setBreadcrumb }) { const { id, typeSegment } = useParams(); const match = useRouteMatch(); @@ -94,14 +94,14 @@ function Job({ i18n, setBreadcrumb }) { name: ( <> - {i18n._(t`Back to Jobs`)} + {t`Back to Jobs`} ), link: `/jobs`, id: 99, }, - { name: i18n._(t`Details`), link: `${match.url}/details`, id: 0 }, - { name: i18n._(t`Output`), link: `${match.url}/output`, id: 1 }, + { name: t`Details`, link: `${match.url}/details`, id: 0 }, + { name: t`Output`, link: `${match.url}/output`, id: 1 }, ]; if (isLoading) { @@ -121,8 +121,8 @@ function Job({ i18n, setBreadcrumb }) { {error.response.status === 404 && ( - {i18n._(t`The page you requested could not be found.`)}{' '} - {i18n._(t`View all Jobs.`)} + {t`The page you requested could not be found.`}{' '} + {t`View all Jobs.`} )} @@ -162,7 +162,7 @@ function Job({ i18n, setBreadcrumb }) { - {i18n._(t`View Job Details`)} + {t`View Job Details`} , @@ -173,5 +173,5 @@ function Job({ i18n, setBreadcrumb }) { ); } -export default withI18n()(withRouter(Job)); +export default withRouter(Job); export { Job as _Job }; diff --git a/awx/ui_next/src/screens/Job/JobDetail/JobDetail.jsx b/awx/ui_next/src/screens/Job/JobDetail/JobDetail.jsx index aa471f407b..768aa135d4 100644 --- a/awx/ui_next/src/screens/Job/JobDetail/JobDetail.jsx +++ b/awx/ui_next/src/screens/Job/JobDetail/JobDetail.jsx @@ -1,7 +1,7 @@ import 'styled-components/macro'; import React, { useCallback, useState } from 'react'; import { Link, useHistory } from 'react-router-dom'; -import { withI18n } from '@lingui/react'; + import { t } from '@lingui/macro'; import { Button, Chip } from '@patternfly/react-core'; import styled from 'styled-components'; @@ -52,7 +52,7 @@ const VERBOSITY = { 4: '4 (Connection Debug)', }; -function JobDetail({ job, i18n }) { +function JobDetail({ job }) { const { created_by, credential, @@ -90,15 +90,12 @@ function JobDetail({ job, i18n }) { } = useDismissableError(cancelError); const jobTypes = { - project_update: i18n._(t`Source Control Update`), - inventory_update: i18n._(t`Inventory Sync`), - job: - job.job_type === 'check' - ? i18n._(t`Playbook Check`) - : i18n._(t`Playbook Run`), - ad_hoc_command: i18n._(t`Command`), - management_job: i18n._(t`Management Job`), - workflow_job: i18n._(t`Workflow Job`), + project_update: t`Source Control Update`, + inventory_update: t`Inventory Sync`, + job: job.job_type === 'check' ? t`Playbook Check` : t`Playbook Run`, + ad_hoc_command: t`Command`, + management_job: t`Management Job`, + workflow_job: t`Workflow Job`, }; const deleteJob = async () => { @@ -127,7 +124,7 @@ function JobDetail({ job, i18n }) { {job.status && } @@ -137,17 +134,11 @@ function JobDetail({ job, i18n }) { } /> - - + + {jobTemplate && ( {jobTemplate.name} @@ -157,7 +148,7 @@ function JobDetail({ job, i18n }) { )} {workflowJobTemplate && ( {source_workflow_job.id} - {source_workflow_job.name} @@ -177,11 +168,11 @@ function JobDetail({ job, i18n }) { } /> )} - - + + {inventory && ( {source_project.status && ( @@ -224,7 +215,7 @@ function JobDetail({ job, i18n }) { )} {project && ( {project.status && } @@ -233,37 +224,37 @@ function JobDetail({ job, i18n }) { } /> )} - - - - + + + + - + {instanceGroup && !instanceGroup?.is_container_group && ( )} {instanceGroup && instanceGroup?.is_container_group && ( )} {typeof job.job_slice_number === 'number' && typeof job.job_slice_count === 'number' && ( )} {credential && ( 0 && ( {credentials.map(c => ( @@ -291,7 +282,7 @@ function JobDetail({ job, i18n }) { {labels && labels.count > 0 && ( {labels.results.map(l => ( @@ -306,7 +297,7 @@ function JobDetail({ job, i18n }) { {job.job_tags && job.job_tags.length > 0 && ( 0 && ( )} - + {job.extra_vars && ( )} {job.artifacts && ( @@ -363,7 +354,7 @@ function JobDetail({ job, i18n }) { readOnly value={JSON.stringify(job.artifacts)} rows={4} - label={i18n._(t`Artifacts`)} + label={t`Artifacts`} /> )} @@ -381,7 +372,7 @@ function JobDetail({ job, i18n }) { )} ) : ( - + {({ handleRelaunch, isLaunching }) => ( )} @@ -398,23 +389,23 @@ function JobDetail({ job, i18n }) { job?.summary_fields?.user_capabilities?.start && ( )} {!isJobRunning(job.status) && job?.summary_fields?.user_capabilities?.delete && ( - {i18n._(t`Delete`)} + {t`Delete`} )} @@ -423,33 +414,31 @@ function JobDetail({ job, i18n }) { isOpen={showCancelModal} variant="danger" onClose={() => setShowCancelModal(false)} - title={i18n._(t`Cancel Job`)} - label={i18n._(t`Cancel Job`)} + title={t`Cancel Job`} + label={t`Cancel Job`} actions={[ , , ]} > - {i18n._( - t`Are you sure you want to submit the request to cancel this job?` - )} + {t`Are you sure you want to submit the request to cancel this job?`}
    )} {dismissableCancelError && ( @@ -457,8 +446,8 @@ function JobDetail({ job, i18n }) { isOpen={dismissableCancelError} variant="danger" onClose={dismissCancelError} - title={i18n._(t`Job Cancel Error`)} - label={i18n._(t`Job Cancel Error`)} + title={t`Job Cancel Error`} + label={t`Job Cancel Error`} >
    @@ -468,7 +457,7 @@ function JobDetail({ job, i18n }) { isOpen={errorMsg} variant="error" onClose={() => setErrorMsg()} - title={i18n._(t`Job Delete Error`)} + title={t`Job Delete Error`} > @@ -480,4 +469,4 @@ JobDetail.propTypes = { job: Job.isRequired, }; -export default withI18n()(JobDetail); +export default JobDetail; diff --git a/awx/ui_next/src/screens/Job/JobOutput/HostEventModal.jsx b/awx/ui_next/src/screens/Job/JobOutput/HostEventModal.jsx index 20f363a849..5994e63827 100644 --- a/awx/ui_next/src/screens/Job/JobOutput/HostEventModal.jsx +++ b/awx/ui_next/src/screens/Job/JobOutput/HostEventModal.jsx @@ -1,7 +1,7 @@ import React, { useEffect, useState } from 'react'; import { Modal, Tab, Tabs, TabTitleText } from '@patternfly/react-core'; import PropTypes from 'prop-types'; -import { withI18n } from '@lingui/react'; + import { t } from '@lingui/macro'; import styled from 'styled-components'; import { AllHtmlEntities } from 'html-entities'; @@ -78,7 +78,7 @@ const processStdOutValue = hostEvent => { return stdOut; }; -function HostEventModal({ onClose, hostEvent = {}, isOpen = false, i18n }) { +function HostEventModal({ onClose, hostEvent = {}, isOpen = false }) { const [hostStatus, setHostStatus] = useState(null); const [activeTabKey, setActiveTabKey] = useState(0); @@ -98,26 +98,26 @@ function HostEventModal({ onClose, hostEvent = {}, isOpen = false, i18n }) { {i18n._(t`Details`)}} + title={{t`Details`}} > {hostStatus ? : null} @@ -125,24 +125,22 @@ function HostEventModal({ onClose, hostEvent = {}, isOpen = false, i18n }) { } /> - - + + {i18n._(t`JSON`)}} - aria-label={i18n._(t`JSON tab`)} + title={{t`JSON`}} + aria-label={t`JSON tab`} > {activeTabKey === 1 && jsonObj ? ( ) : ( - + )} {i18n._(t`Standard Out`)}} - aria-label={i18n._(t`Standard out tab`)} + title={{t`Standard Out`}} + aria-label={t`Standard out tab`} > {activeTabKey === 2 && stdOut ? ( ) : ( - + )} {i18n._(t`Standard Error`)}} - aria-label={i18n._(t`Standard error tab`)} + title={{t`Standard Error`}} + aria-label={t`Standard error tab`} > {activeTabKey === 3 && stdErr ? ( ) : ( - + )} @@ -198,7 +196,7 @@ function HostEventModal({ onClose, hostEvent = {}, isOpen = false, i18n }) { ); } -export default withI18n()(HostEventModal); +export default HostEventModal; HostEventModal.propTypes = { onClose: PropTypes.func.isRequired, diff --git a/awx/ui_next/src/screens/Job/JobOutput/JobOutput.jsx b/awx/ui_next/src/screens/Job/JobOutput/JobOutput.jsx index 9a58be1055..19f1b0f751 100644 --- a/awx/ui_next/src/screens/Job/JobOutput/JobOutput.jsx +++ b/awx/ui_next/src/screens/Job/JobOutput/JobOutput.jsx @@ -1,6 +1,5 @@ import React, { useCallback, useEffect, useRef, useState } from 'react'; import { useHistory, useLocation, withRouter } from 'react-router-dom'; -import { i18n } from '@lingui/core'; import { t } from '@lingui/macro'; import styled from 'styled-components'; import { @@ -626,48 +625,48 @@ function JobOutput({ job, eventRelatedSearchableKeys, eventSearchableKeys }) { qsConfig={QS_CONFIG} columns={[ { - name: i18n._(t`Stdout`), + name: t`Stdout`, key: 'stdout__icontains', isDefault: true, }, { - name: i18n._(t`Event`), + name: t`Event`, key: 'event', options: [ - ['runner_on_failed', i18n._(t`Host Failed`)], - ['runner_on_start', i18n._(t`Host Started`)], - ['runner_on_ok', i18n._(t`Host OK`)], - ['runner_on_error', i18n._(t`Host Failure`)], - ['runner_on_skipped', i18n._(t`Host Skipped`)], - ['runner_on_unreachable', i18n._(t`Host Unreachable`)], - ['runner_on_no_hosts', i18n._(t`No Hosts Remaining`)], - ['runner_on_async_poll', i18n._(t`Host Polling`)], - ['runner_on_async_ok', i18n._(t`Host Async OK`)], - ['runner_on_async_failed', i18n._(t`Host Async Failure`)], - ['runner_item_on_ok', i18n._(t`Item OK`)], - ['runner_item_on_failed', i18n._(t`Item Failed`)], - ['runner_item_on_skipped', i18n._(t`Item Skipped`)], - ['runner_retry', i18n._(t`Host Retry`)], - ['runner_on_file_diff', i18n._(t`File Difference`)], - ['playbook_on_start', i18n._(t`Playbook Started`)], - ['playbook_on_notify', i18n._(t`Running Handlers`)], - ['playbook_on_include', i18n._(t`Including File`)], - ['playbook_on_no_hosts_matched', i18n._(t`No Hosts Matched`)], - ['playbook_on_no_hosts_remaining', i18n._(t`No Hosts Remaining`)], - ['playbook_on_task_start', i18n._(t`Task Started`)], - ['playbook_on_vars_prompt', i18n._(t`Variables Prompted`)], - ['playbook_on_setup', i18n._(t`Gathering Facts`)], - ['playbook_on_play_start', i18n._(t`Play Started`)], - ['playbook_on_stats', i18n._(t`Playbook Complete`)], - ['debug', i18n._(t`Debug`)], - ['verbose', i18n._(t`Verbose`)], - ['deprecated', i18n._(t`Deprecated`)], - ['warning', i18n._(t`Warning`)], - ['system_warning', i18n._(t`System Warning`)], - ['error', i18n._(t`Error`)], + ['runner_on_failed', t`Host Failed`], + ['runner_on_start', t`Host Started`], + ['runner_on_ok', t`Host OK`], + ['runner_on_error', t`Host Failure`], + ['runner_on_skipped', t`Host Skipped`], + ['runner_on_unreachable', t`Host Unreachable`], + ['runner_on_no_hosts', t`No Hosts Remaining`], + ['runner_on_async_poll', t`Host Polling`], + ['runner_on_async_ok', t`Host Async OK`], + ['runner_on_async_failed', t`Host Async Failure`], + ['runner_item_on_ok', t`Item OK`], + ['runner_item_on_failed', t`Item Failed`], + ['runner_item_on_skipped', t`Item Skipped`], + ['runner_retry', t`Host Retry`], + ['runner_on_file_diff', t`File Difference`], + ['playbook_on_start', t`Playbook Started`], + ['playbook_on_notify', t`Running Handlers`], + ['playbook_on_include', t`Including File`], + ['playbook_on_no_hosts_matched', t`No Hosts Matched`], + ['playbook_on_no_hosts_remaining', t`No Hosts Remaining`], + ['playbook_on_task_start', t`Task Started`], + ['playbook_on_vars_prompt', t`Variables Prompted`], + ['playbook_on_setup', t`Gathering Facts`], + ['playbook_on_play_start', t`Play Started`], + ['playbook_on_stats', t`Playbook Complete`], + ['debug', t`Debug`], + ['verbose', t`Verbose`], + ['deprecated', t`Deprecated`], + ['warning', t`Warning`], + ['system_warning', t`System Warning`], + ['error', t`Error`], ], }, - { name: i18n._(t`Advanced`), key: 'advanced' }, + { name: t`Advanced`, key: 'advanced' }, ]} searchableKeys={eventSearchableKeys} relatedSearchableKeys={eventRelatedSearchableKeys} @@ -711,21 +710,19 @@ function JobOutput({ job, eventRelatedSearchableKeys, eventSearchableKeys }) { id="job_output-toolbar" clearAllFilters={handleRemoveAllSearchTerms} collapseListedFiltersBreakpoint="lg" - clearFiltersButtonText={i18n._(t`Clear all filters`)} + clearFiltersButtonText={t`Clear all filters`} > } breakpoint="lg"> {isJobRunning(job.status) ? ( - {renderSearchComponent(i18n)} + {renderSearchComponent()} ) : ( - renderSearchComponent(i18n) + renderSearchComponent() )} @@ -783,33 +780,31 @@ function JobOutput({ job, eventRelatedSearchableKeys, eventSearchableKeys }) { isOpen={showCancelModal} variant="danger" onClose={() => setShowCancelModal(false)} - title={i18n._(t`Cancel Job`)} - label={i18n._(t`Cancel Job`)} + title={t`Cancel Job`} + label={t`Cancel Job`} actions={[ , , ]} > - {i18n._( - t`Are you sure you want to submit the request to cancel this job?` - )} + {t`Are you sure you want to submit the request to cancel this job?`} )} {dismissableDeleteError && ( @@ -817,8 +812,8 @@ function JobOutput({ job, eventRelatedSearchableKeys, eventSearchableKeys }) { isOpen={dismissableDeleteError} variant="danger" onClose={dismissDeleteError} - title={i18n._(t`Job Delete Error`)} - label={i18n._(t`Job Delete Error`)} + title={t`Job Delete Error`} + label={t`Job Delete Error`} > @@ -828,8 +823,8 @@ function JobOutput({ job, eventRelatedSearchableKeys, eventSearchableKeys }) { isOpen={dismissableCancelError} variant="danger" onClose={dismissCancelError} - title={i18n._(t`Job Cancel Error`)} - label={i18n._(t`Job Cancel Error`)} + title={t`Job Cancel Error`} + label={t`Job Cancel Error`} > diff --git a/awx/ui_next/src/screens/Job/JobOutput/PageControls.jsx b/awx/ui_next/src/screens/Job/JobOutput/PageControls.jsx index a7d8e6fd86..9749e83748 100644 --- a/awx/ui_next/src/screens/Job/JobOutput/PageControls.jsx +++ b/awx/ui_next/src/screens/Job/JobOutput/PageControls.jsx @@ -1,6 +1,6 @@ import 'styled-components/macro'; import React from 'react'; -import { withI18n } from '@lingui/react'; + import { t } from '@lingui/macro'; import { Button as PFButton } from '@patternfly/react-core'; import { @@ -25,7 +25,6 @@ const Button = styled(PFButton)` `; const PageControls = ({ - i18n, onScrollFirst, onScrollLast, onScrollNext, @@ -34,7 +33,7 @@ const PageControls = ({ @@ -185,11 +184,11 @@ const OutputToolbar = ({ )} {job.summary_fields.user_capabilities.start && ['pending', 'waiting', 'running'].includes(jobStatus) && ( - + , , ]} > - {i18n._(t`Set how many days of data should be retained.`)} + {t`Set how many days of data should be retained.`} setDataRetention(clamp(value, 0, MAX_RETENTION))} - aria-label={i18n._(t`Data retention period`)} + aria-label={t`Data retention period`} /> ); } -export default withI18n()(LaunchManagementPrompt); +export default LaunchManagementPrompt; diff --git a/awx/ui_next/src/screens/ManagementJob/ManagementJobList/ManagementJobList.jsx b/awx/ui_next/src/screens/ManagementJob/ManagementJobList/ManagementJobList.jsx index 89c7200a57..569310a390 100644 --- a/awx/ui_next/src/screens/ManagementJob/ManagementJobList/ManagementJobList.jsx +++ b/awx/ui_next/src/screens/ManagementJob/ManagementJobList/ManagementJobList.jsx @@ -1,6 +1,6 @@ import React, { useCallback, useEffect, useState } from 'react'; import { t } from '@lingui/macro'; -import { withI18n } from '@lingui/react'; + import { useLocation } from 'react-router-dom'; import { Card, PageSection } from '@patternfly/react-core'; @@ -48,7 +48,7 @@ const loadManagementJobs = async search => { return { items, count, options }; }; -function ManagementJobList({ i18n }) { +function ManagementJobList() { const { search } = useLocation(); const { me } = useConfig(); const [launchError, setLaunchError] = useState(null); @@ -79,13 +79,13 @@ function ManagementJobList({ i18n }) { hasContentLoading={isLoading} items={items} itemCount={count} - pluralizedItemName={i18n._(t`Management Jobs`)} + pluralizedItemName={t`Management Jobs`} emptyContentMessage={' '} toolbarSearchableKeys={searchableKeys} toolbarRelatedSearchableKeys={relatedSearchableKeys} toolbarSearchColumns={[ { - name: i18n._(t`Name`), + name: t`Name`, key: 'name__icontains', isDefault: true, }, @@ -99,9 +99,9 @@ function ManagementJobList({ i18n }) { )} headerRow={ - {i18n._(t`Name`)} - {i18n._(t`Description`)} - {i18n._(t`Actions`)} + {t`Name`} + {t`Description`} + {t`Actions`} } renderRow={({ id, name, description, job_type }) => ( @@ -124,14 +124,14 @@ function ManagementJobList({ i18n }) { setLaunchError(null)} > - {i18n._(t`Failed to launch job.`)} + {t`Failed to launch job.`} ); } -export default withI18n()(ManagementJobList); +export default ManagementJobList; diff --git a/awx/ui_next/src/screens/ManagementJob/ManagementJobList/ManagementJobListItem.jsx b/awx/ui_next/src/screens/ManagementJob/ManagementJobList/ManagementJobListItem.jsx index 0347cfa47a..152028aafe 100644 --- a/awx/ui_next/src/screens/ManagementJob/ManagementJobList/ManagementJobListItem.jsx +++ b/awx/ui_next/src/screens/ManagementJob/ManagementJobList/ManagementJobListItem.jsx @@ -1,5 +1,5 @@ import React, { useState } from 'react'; -import { withI18n } from '@lingui/react'; + import { t } from '@lingui/macro'; import { Link, useHistory } from 'react-router-dom'; import { Button, Tooltip } from '@patternfly/react-core'; @@ -13,7 +13,6 @@ import { ActionsTd, ActionItem } from '../../../components/PaginatedTable'; import LaunchManagementPrompt from './LaunchManagementPrompt'; function ManagementJobListItem({ - i18n, onLaunchError, isPrompted, isSuperUser, @@ -65,17 +64,14 @@ function ManagementJobListItem({ <> - + {name} - {description} - - + {description} + + {isSuperUser ? ( <> {isPrompted ? ( @@ -90,13 +86,10 @@ function ManagementJobListItem({ /> ) : ( - + @@ -79,4 +79,4 @@ function SurveyToolbar({ ); } -export default withI18n()(SurveyToolbar); +export default SurveyToolbar; diff --git a/awx/ui_next/src/screens/Template/Template.jsx b/awx/ui_next/src/screens/Template/Template.jsx index dddd151170..277d8eb925 100644 --- a/awx/ui_next/src/screens/Template/Template.jsx +++ b/awx/ui_next/src/screens/Template/Template.jsx @@ -1,6 +1,6 @@ import React, { useEffect, useCallback } from 'react'; import { t } from '@lingui/macro'; -import { withI18n } from '@lingui/react'; + import { CaretLeftIcon } from '@patternfly/react-icons'; import { Card, PageSection } from '@patternfly/react-core'; import { @@ -25,7 +25,7 @@ import JobTemplateEdit from './JobTemplateEdit'; import { JobTemplatesAPI, OrganizationsAPI } from '../../api'; import TemplateSurvey from './TemplateSurvey'; -function Template({ i18n, setBreadcrumb }) { +function Template({ setBreadcrumb }) { const match = useRouteMatch(); const location = useLocation(); const { id: templateId } = useParams(); @@ -135,37 +135,37 @@ function Template({ i18n, setBreadcrumb }) { name: ( <> - {i18n._(t`Back to Templates`)} + {t`Back to Templates`} ), link: `/templates`, id: 99, }, - { name: i18n._(t`Details`), link: `${match.url}/details` }, - { name: i18n._(t`Access`), link: `${match.url}/access` }, + { name: t`Details`, link: `${match.url}/details` }, + { name: t`Access`, link: `${match.url}/access` }, ]; if (canSeeNotificationsTab) { tabsArray.push({ - name: i18n._(t`Notifications`), + name: t`Notifications`, link: `${match.url}/notifications`, }); } if (template) { tabsArray.push({ - name: i18n._(t`Schedules`), + name: t`Schedules`, link: `${match.url}/schedules`, }); } tabsArray.push( { - name: i18n._(t`Jobs`), + name: t`Jobs`, link: `${match.url}/jobs`, }, { - name: canAddAndEditSurvey ? i18n._(t`Survey`) : i18n._(t`View Survey`), + name: canAddAndEditSurvey ? t`Survey` : t`View Survey`, link: `${match.url}/survey`, } ); @@ -181,8 +181,8 @@ function Template({ i18n, setBreadcrumb }) { {contentError.response?.status === 404 && ( - {i18n._(t`Template not found.`)}{' '} - {i18n._(t`View all Templates.`)} + {t`Template not found.`}{' '} + {t`View all Templates.`} )} @@ -262,7 +262,7 @@ function Template({ i18n, setBreadcrumb }) { - {i18n._(t`View Template Details`)} + {t`View Template Details`} )} @@ -276,4 +276,4 @@ function Template({ i18n, setBreadcrumb }) { } export { Template as _Template }; -export default withI18n()(Template); +export default Template; diff --git a/awx/ui_next/src/screens/Template/TemplateSurvey.jsx b/awx/ui_next/src/screens/Template/TemplateSurvey.jsx index c3701baa33..60531837b9 100644 --- a/awx/ui_next/src/screens/Template/TemplateSurvey.jsx +++ b/awx/ui_next/src/screens/Template/TemplateSurvey.jsx @@ -1,6 +1,6 @@ import React, { useState, useEffect, useCallback } from 'react'; import { Switch, Route, useParams } from 'react-router-dom'; -import { withI18n } from '@lingui/react'; + import { t } from '@lingui/macro'; import { JobTemplatesAPI, WorkflowJobTemplatesAPI } from '../../api'; import ContentError from '../../components/ContentError'; @@ -9,7 +9,7 @@ import ErrorDetail from '../../components/ErrorDetail'; import useRequest, { useDismissableError } from '../../util/useRequest'; import { SurveyList, SurveyQuestionAdd, SurveyQuestionEdit } from './Survey'; -function TemplateSurvey({ template, canEdit, i18n }) { +function TemplateSurvey({ template, canEdit }) { const [surveyEnabled, setSurveyEnabled] = useState(template.survey_enabled); const { templateType, id: templateId } = useParams(); @@ -127,10 +127,10 @@ function TemplateSurvey({ template, canEdit, i18n }) { - {i18n._(t`Failed to update survey.`)} + {t`Failed to update survey.`} )} @@ -138,4 +138,4 @@ function TemplateSurvey({ template, canEdit, i18n }) { ); } -export default withI18n()(TemplateSurvey); +export default TemplateSurvey; diff --git a/awx/ui_next/src/screens/Template/Templates.jsx b/awx/ui_next/src/screens/Template/Templates.jsx index 4deeeb32b3..d58e3a9e54 100644 --- a/awx/ui_next/src/screens/Template/Templates.jsx +++ b/awx/ui_next/src/screens/Template/Templates.jsx @@ -1,5 +1,5 @@ import React, { useState, useCallback, useRef } from 'react'; -import { withI18n } from '@lingui/react'; + import { t } from '@lingui/macro'; import { Route, withRouter, Switch } from 'react-router-dom'; import { PageSection } from '@patternfly/react-core'; @@ -11,13 +11,11 @@ import WorkflowJobTemplate from './WorkflowJobTemplate'; import JobTemplateAdd from './JobTemplateAdd'; import WorkflowJobTemplateAdd from './WorkflowJobTemplateAdd'; -function Templates({ i18n }) { +function Templates() { const initScreenHeader = useRef({ - '/templates': i18n._(t`Templates`), - '/templates/job_template/add': i18n._(t`Create New Job Template`), - '/templates/workflow_job_template/add': i18n._( - t`Create New Workflow Template` - ), + '/templates': t`Templates`, + '/templates/job_template/add': t`Create New Job Template`, + '/templates/workflow_job_template/add': t`Create New Workflow Template`, }); const [breadcrumbConfig, setScreenHeader] = useState( initScreenHeader.current @@ -41,24 +39,22 @@ function Templates({ i18n }) { setScreenHeader({ ...initScreenHeader.current, [templatePath]: `${template.name}`, - [`${templatePath}/details`]: i18n._(t`Details`), - [`${templatePath}/edit`]: i18n._(t`Edit Details`), - [`${templatePath}/access`]: i18n._(t`Access`), - [`${templatePath}/notifications`]: i18n._(t`Notifications`), - [`${templatePath}/jobs`]: i18n._(t`Jobs`), - [surveyPath]: i18n._(t`Survey`), - [`${surveyPath}/add`]: i18n._(t`Add Question`), - [`${surveyPath}/edit`]: i18n._(t`Edit Question`), - [schedulesPath]: i18n._(t`Schedules`), - [`${schedulesPath}/add`]: i18n._(t`Create New Schedule`), + [`${templatePath}/details`]: t`Details`, + [`${templatePath}/edit`]: t`Edit Details`, + [`${templatePath}/access`]: t`Access`, + [`${templatePath}/notifications`]: t`Notifications`, + [`${templatePath}/jobs`]: t`Jobs`, + [surveyPath]: t`Survey`, + [`${surveyPath}/add`]: t`Add Question`, + [`${surveyPath}/edit`]: t`Edit Question`, + [schedulesPath]: t`Schedules`, + [`${schedulesPath}/add`]: t`Create New Schedule`, [`${schedulesPath}/${schedule?.id}`]: `${schedule?.name}`, - [`${schedulesPath}/${schedule?.id}/details`]: i18n._( - t`Schedule Details` - ), - [`${schedulesPath}/${schedule?.id}/edit`]: i18n._(t`Edit Schedule`), + [`${schedulesPath}/${schedule?.id}/details`]: t`Schedule Details`, + [`${schedulesPath}/${schedule?.id}/edit`]: t`Edit Schedule`, }); }, - [i18n, template, schedule] + [template, schedule] ); return ( @@ -91,4 +87,4 @@ function Templates({ i18n }) { } export { Templates as _Templates }; -export default withI18n()(withRouter(Templates)); +export default withRouter(Templates); diff --git a/awx/ui_next/src/screens/Template/WorkflowJobTemplate.jsx b/awx/ui_next/src/screens/Template/WorkflowJobTemplate.jsx index 237ea084bb..b080c8f768 100644 --- a/awx/ui_next/src/screens/Template/WorkflowJobTemplate.jsx +++ b/awx/ui_next/src/screens/Template/WorkflowJobTemplate.jsx @@ -1,6 +1,6 @@ import React, { useEffect, useCallback } from 'react'; import { t } from '@lingui/macro'; -import { withI18n } from '@lingui/react'; + import { CaretLeftIcon } from '@patternfly/react-icons'; import { Card, PageSection } from '@patternfly/react-core'; import { @@ -29,7 +29,7 @@ import TemplateSurvey from './TemplateSurvey'; import { Visualizer } from './WorkflowJobTemplateVisualizer'; import ContentLoading from '../../components/ContentLoading'; -function WorkflowJobTemplate({ i18n, setBreadcrumb }) { +function WorkflowJobTemplate({ setBreadcrumb }) { const location = useLocation(); const match = useRouteMatch(); const { id: templateId } = useParams(); @@ -112,41 +112,41 @@ function WorkflowJobTemplate({ i18n, setBreadcrumb }) { name: ( <> - {i18n._(t`Back to Templates`)} + {t`Back to Templates`} ), link: `/templates`, id: 99, }, - { name: i18n._(t`Details`), link: `${match.url}/details` }, - { name: i18n._(t`Access`), link: `${match.url}/access` }, + { name: t`Details`, link: `${match.url}/details` }, + { name: t`Access`, link: `${match.url}/access` }, ]; if (canSeeNotificationsTab) { tabsArray.push({ - name: i18n._(t`Notifications`), + name: t`Notifications`, link: `${match.url}/notifications`, }); } if (template) { tabsArray.push({ - name: i18n._(t`Schedules`), + name: t`Schedules`, link: `${match.url}/schedules`, }); } tabsArray.push( { - name: i18n._(t`Visualizer`), + name: t`Visualizer`, link: `${match.url}/visualizer`, }, { - name: i18n._(t`Jobs`), + name: t`Jobs`, link: `${match.url}/jobs`, }, { - name: canAddAndEditSurvey ? i18n._(t`Survey`) : i18n._(t`View Survey`), + name: canAddAndEditSurvey ? t`Survey` : t`View Survey`, link: `${match.url}/survey`, } ); @@ -176,8 +176,8 @@ function WorkflowJobTemplate({ i18n, setBreadcrumb }) { {contentError.response.status === 404 && ( - {i18n._(t`Template not found.`)}{' '} - {i18n._(t`View all Templates.`)} + {t`Template not found.`}{' '} + {t`View all Templates.`} )} @@ -276,7 +276,7 @@ function WorkflowJobTemplate({ i18n, setBreadcrumb }) { - {i18n._(t`View Template Details`)} + {t`View Template Details`} )} @@ -289,4 +289,4 @@ function WorkflowJobTemplate({ i18n, setBreadcrumb }) { } export { WorkflowJobTemplate as _WorkflowJobTemplate }; -export default withI18n()(WorkflowJobTemplate); +export default WorkflowJobTemplate; diff --git a/awx/ui_next/src/screens/Template/WorkflowJobTemplateDetail/WorkflowJobTemplateDetail.jsx b/awx/ui_next/src/screens/Template/WorkflowJobTemplateDetail/WorkflowJobTemplateDetail.jsx index f9cc6961a8..ed781f09c8 100644 --- a/awx/ui_next/src/screens/Template/WorkflowJobTemplateDetail/WorkflowJobTemplateDetail.jsx +++ b/awx/ui_next/src/screens/Template/WorkflowJobTemplateDetail/WorkflowJobTemplateDetail.jsx @@ -1,6 +1,6 @@ import React, { useCallback } from 'react'; import { Link, useHistory } from 'react-router-dom'; -import { withI18n } from '@lingui/react'; + import { t } from '@lingui/macro'; import { Chip, @@ -30,7 +30,7 @@ import { toTitleCase } from '../../../util/strings'; import { relatedResourceDeleteRequests } from '../../../util/getRelatedResourceDeleteDetails'; import useRequest, { useDismissableError } from '../../../util/useRequest'; -function WorkflowJobTemplateDetail({ template, i18n }) { +function WorkflowJobTemplateDetail({ template }) { const { id, ask_inventory_on_launch, @@ -56,12 +56,12 @@ function WorkflowJobTemplateDetail({ template, i18n }) { {template.allow_simultaneous && ( - {i18n._(t`- Enable Concurrent Jobs`)} + {t`- Enable Concurrent Jobs`} )} {template.webhook_service && ( - {i18n._(t`- Enable Webhooks`)} + {t`- Enable Webhooks`} )} @@ -88,7 +88,7 @@ function WorkflowJobTemplateDetail({ template, i18n }) { - {i18n._(t`(Prompt on launch)`)} + {t`(Prompt on launch)`} ) : ( @@ -110,17 +110,17 @@ function WorkflowJobTemplateDetail({ template, i18n }) { return ( - - + + {summary_fields.recent_jobs?.length > 0 && ( } - label={i18n._(t`Activity`)} + label={t`Activity`} /> )} {summary_fields.organization && ( )} - + {summary_fields.inventory && ( )} {related.webhook_receiver && ( )} - + {webhook_credential && ( )} {renderOptionsField && ( - + )} {summary_fields.labels?.results?.length > 0 && ( )} - + {summary_fields.user_capabilities && @@ -220,13 +216,13 @@ function WorkflowJobTemplateDetail({ template, i18n }) { ouiaId="workflow-job-template-detail-edit-button" component={Link} to={`/templates/workflow_job_template/${id}/edit`} - aria-label={i18n._(t`Edit`)} + aria-label={t`Edit`} > - {i18n._(t`Edit`)} + {t`Edit`} )} {canLaunch && ( - + {({ handleLaunch, isLaunching }) => ( )} @@ -244,15 +240,13 @@ function WorkflowJobTemplateDetail({ template, i18n }) { summary_fields.user_capabilities.delete && ( - {i18n._(t`Delete`)} + {t`Delete`} )} @@ -260,10 +254,10 @@ function WorkflowJobTemplateDetail({ template, i18n }) { - {i18n._(t`Failed to delete workflow job template.`)} + {t`Failed to delete workflow job template.`} )} @@ -271,4 +265,4 @@ function WorkflowJobTemplateDetail({ template, i18n }) { ); } export { WorkflowJobTemplateDetail as _WorkflowJobTemplateDetail }; -export default withI18n()(WorkflowJobTemplateDetail); +export default WorkflowJobTemplateDetail; diff --git a/awx/ui_next/src/screens/Template/WorkflowJobTemplateVisualizer/Modals/DeleteAllNodesModal.jsx b/awx/ui_next/src/screens/Template/WorkflowJobTemplateVisualizer/Modals/DeleteAllNodesModal.jsx index 99fc39810f..0a22801ead 100644 --- a/awx/ui_next/src/screens/Template/WorkflowJobTemplateVisualizer/Modals/DeleteAllNodesModal.jsx +++ b/awx/ui_next/src/screens/Template/WorkflowJobTemplateVisualizer/Modals/DeleteAllNodesModal.jsx @@ -1,11 +1,11 @@ import React, { useContext } from 'react'; import { Button } from '@patternfly/react-core'; -import { withI18n } from '@lingui/react'; + import { t } from '@lingui/macro'; import { WorkflowDispatchContext } from '../../../../contexts/Workflow'; import AlertModal from '../../../../components/AlertModal'; -function DeleteAllNodesModal({ i18n }) { +function DeleteAllNodesModal() { const dispatch = useContext(WorkflowDispatchContext); return ( dispatch({ type: 'DELETE_ALL_NODES' })} > - {i18n._(t`Remove`)} + {t`Remove`} , , ]} isOpen onClose={() => dispatch({ type: 'TOGGLE_DELETE_ALL_NODES_MODAL' })} - title={i18n._(t`Remove All Nodes`)} + title={t`Remove All Nodes`} variant="danger" >

    - {i18n._( - t`Are you sure you want to remove all the nodes in this workflow?` - )} + {t`Are you sure you want to remove all the nodes in this workflow?`}

    ); } -export default withI18n()(DeleteAllNodesModal); +export default DeleteAllNodesModal; diff --git a/awx/ui_next/src/screens/Template/WorkflowJobTemplateVisualizer/Modals/LinkModals/LinkAddModal.jsx b/awx/ui_next/src/screens/Template/WorkflowJobTemplateVisualizer/Modals/LinkModals/LinkAddModal.jsx index 5d7baf4099..fe2d85c1f1 100644 --- a/awx/ui_next/src/screens/Template/WorkflowJobTemplateVisualizer/Modals/LinkModals/LinkAddModal.jsx +++ b/awx/ui_next/src/screens/Template/WorkflowJobTemplateVisualizer/Modals/LinkModals/LinkAddModal.jsx @@ -1,17 +1,17 @@ import React, { useContext } from 'react'; import { Title } from '@patternfly/react-core'; -import { withI18n } from '@lingui/react'; + import { t } from '@lingui/macro'; import { WorkflowDispatchContext } from '../../../../../contexts/Workflow'; import LinkModal from './LinkModal'; -function LinkAddModal({ i18n }) { +function LinkAddModal() { const dispatch = useContext(WorkflowDispatchContext); return ( - {i18n._(t`Add Link`)} + {t`Add Link`} } onConfirm={linkType => dispatch({ type: 'CREATE_LINK', linkType })} @@ -19,4 +19,4 @@ function LinkAddModal({ i18n }) { ); } -export default withI18n()(LinkAddModal); +export default LinkAddModal; diff --git a/awx/ui_next/src/screens/Template/WorkflowJobTemplateVisualizer/Modals/LinkModals/LinkDeleteModal.jsx b/awx/ui_next/src/screens/Template/WorkflowJobTemplateVisualizer/Modals/LinkModals/LinkDeleteModal.jsx index d0863a76fa..b350b92ce8 100644 --- a/awx/ui_next/src/screens/Template/WorkflowJobTemplateVisualizer/Modals/LinkModals/LinkDeleteModal.jsx +++ b/awx/ui_next/src/screens/Template/WorkflowJobTemplateVisualizer/Modals/LinkModals/LinkDeleteModal.jsx @@ -1,6 +1,6 @@ import React, { Fragment, useContext } from 'react'; import { Button } from '@patternfly/react-core'; -import { withI18n } from '@lingui/react'; + import { t } from '@lingui/macro'; import { WorkflowDispatchContext, @@ -8,46 +8,44 @@ import { } from '../../../../../contexts/Workflow'; import AlertModal from '../../../../../components/AlertModal'; -function LinkDeleteModal({ i18n }) { +function LinkDeleteModal() { const dispatch = useContext(WorkflowDispatchContext); const { linkToDelete } = useContext(WorkflowStateContext); return ( dispatch({ type: 'SET_LINK_TO_DELETE', value: null })} actions={[ , , ]} > -

    {i18n._(t`Are you sure you want to remove this link?`)}

    +

    {t`Are you sure you want to remove this link?`}

    {!linkToDelete.isConvergenceLink && (

    - {i18n._( - t`Removing this link will orphan the rest of the branch and cause it to be executed immediately on launch.` - )} + {t`Removing this link will orphan the rest of the branch and cause it to be executed immediately on launch.`}

    )} @@ -55,4 +53,4 @@ function LinkDeleteModal({ i18n }) { ); } -export default withI18n()(LinkDeleteModal); +export default LinkDeleteModal; diff --git a/awx/ui_next/src/screens/Template/WorkflowJobTemplateVisualizer/Modals/LinkModals/LinkEditModal.jsx b/awx/ui_next/src/screens/Template/WorkflowJobTemplateVisualizer/Modals/LinkModals/LinkEditModal.jsx index 8c4259b73a..be3ba0a697 100644 --- a/awx/ui_next/src/screens/Template/WorkflowJobTemplateVisualizer/Modals/LinkModals/LinkEditModal.jsx +++ b/awx/ui_next/src/screens/Template/WorkflowJobTemplateVisualizer/Modals/LinkModals/LinkEditModal.jsx @@ -1,17 +1,17 @@ import React, { useContext } from 'react'; import { Title } from '@patternfly/react-core'; -import { withI18n } from '@lingui/react'; + import { t } from '@lingui/macro'; import { WorkflowDispatchContext } from '../../../../../contexts/Workflow'; import LinkModal from './LinkModal'; -function LinkEditModal({ i18n }) { +function LinkEditModal() { const dispatch = useContext(WorkflowDispatchContext); return ( - {i18n._(t`Edit Link`)} + {t`Edit Link`} } onConfirm={linkType => dispatch({ type: 'UPDATE_LINK', linkType })} @@ -19,4 +19,4 @@ function LinkEditModal({ i18n }) { ); } -export default withI18n()(LinkEditModal); +export default LinkEditModal; diff --git a/awx/ui_next/src/screens/Template/WorkflowJobTemplateVisualizer/Modals/LinkModals/LinkModal.jsx b/awx/ui_next/src/screens/Template/WorkflowJobTemplateVisualizer/Modals/LinkModals/LinkModal.jsx index fcf8d0129d..41d869bb9e 100644 --- a/awx/ui_next/src/screens/Template/WorkflowJobTemplateVisualizer/Modals/LinkModals/LinkModal.jsx +++ b/awx/ui_next/src/screens/Template/WorkflowJobTemplateVisualizer/Modals/LinkModals/LinkModal.jsx @@ -1,6 +1,6 @@ import React, { useContext, useState } from 'react'; import { Button, FormGroup, Modal } from '@patternfly/react-core'; -import { withI18n } from '@lingui/react'; + import { t } from '@lingui/macro'; import { func } from 'prop-types'; import { @@ -9,7 +9,7 @@ import { } from '../../../../../contexts/Workflow'; import AnsibleSelect from '../../../../../components/AnsibleSelect'; -function LinkModal({ header, i18n, onConfirm }) { +function LinkModal({ header, onConfirm }) { const dispatch = useContext(WorkflowDispatchContext); const { linkToEdit } = useContext(WorkflowStateContext); const [linkType, setLinkType] = useState( @@ -20,8 +20,8 @@ function LinkModal({ header, i18n, onConfirm }) { width={600} header={header} isOpen - title={i18n._(t`Workflow Link`)} - aria-label={i18n._(t`Workflow link modal`)} + title={t`Workflow Link`} + aria-label={t`Workflow link modal`} onClose={() => dispatch({ type: 'CANCEL_LINK_MODAL' })} actions={[ , , ]} > - + { @@ -81,4 +81,4 @@ LinkModal.propTypes = { onConfirm: func.isRequired, }; -export default withI18n()(LinkModal); +export default LinkModal; diff --git a/awx/ui_next/src/screens/Template/WorkflowJobTemplateVisualizer/Modals/NodeModals/NodeAddModal.jsx b/awx/ui_next/src/screens/Template/WorkflowJobTemplateVisualizer/Modals/NodeModals/NodeAddModal.jsx index 736a40dddd..47dc2b3348 100644 --- a/awx/ui_next/src/screens/Template/WorkflowJobTemplateVisualizer/Modals/NodeModals/NodeAddModal.jsx +++ b/awx/ui_next/src/screens/Template/WorkflowJobTemplateVisualizer/Modals/NodeModals/NodeAddModal.jsx @@ -1,5 +1,5 @@ import React, { useContext } from 'react'; -import { withI18n } from '@lingui/react'; + import { t } from '@lingui/macro'; import { WorkflowDispatchContext, @@ -8,7 +8,7 @@ import { import NodeModal from './NodeModal'; import { getAddedAndRemoved } from '../../../../../util/lists'; -function NodeAddModal({ i18n }) { +function NodeAddModal() { const dispatch = useContext(WorkflowDispatchContext); const { addNodeSource } = useContext(WorkflowStateContext); @@ -67,9 +67,9 @@ function NodeAddModal({ i18n }) { ); } -export default withI18n()(NodeAddModal); +export default NodeAddModal; diff --git a/awx/ui_next/src/screens/Template/WorkflowJobTemplateVisualizer/Modals/NodeModals/NodeDeleteModal.jsx b/awx/ui_next/src/screens/Template/WorkflowJobTemplateVisualizer/Modals/NodeModals/NodeDeleteModal.jsx index 9c05eb063a..1367e563f6 100644 --- a/awx/ui_next/src/screens/Template/WorkflowJobTemplateVisualizer/Modals/NodeModals/NodeDeleteModal.jsx +++ b/awx/ui_next/src/screens/Template/WorkflowJobTemplateVisualizer/Modals/NodeModals/NodeDeleteModal.jsx @@ -1,7 +1,7 @@ import 'styled-components/macro'; import React, { Fragment, useContext } from 'react'; import { Button } from '@patternfly/react-core'; -import { withI18n } from '@lingui/react'; + import { t } from '@lingui/macro'; import { WorkflowDispatchContext, @@ -9,13 +9,13 @@ import { } from '../../../../../contexts/Workflow'; import AlertModal from '../../../../../components/AlertModal'; -function NodeDeleteModal({ i18n }) { +function NodeDeleteModal() { const dispatch = useContext(WorkflowDispatchContext); const { nodeToDelete } = useContext(WorkflowStateContext); return ( dispatch({ type: 'SET_NODE_TO_DELETE', value: null })} actions={[ @@ -24,36 +24,36 @@ function NodeDeleteModal({ i18n }) { id="confirm-node-removal" key="remove" variant="danger" - aria-label={i18n._(t`Confirm node removal`)} + aria-label={t`Confirm node removal`} onClick={() => dispatch({ type: 'DELETE_NODE' })} > - {i18n._(t`Remove`)} + {t`Remove`} , , ]} > {nodeToDelete && nodeToDelete.unifiedJobTemplate ? ( -

    {i18n._(t`Are you sure you want to remove the node below:`)}

    +

    {t`Are you sure you want to remove the node below:`}


    {nodeToDelete.unifiedJobTemplate.name}
    ) : ( -

    {i18n._(t`Are you sure you want to remove this node?`)}

    +

    {t`Are you sure you want to remove this node?`}

    )}
    ); } -export default withI18n()(NodeDeleteModal); +export default NodeDeleteModal; diff --git a/awx/ui_next/src/screens/Template/WorkflowJobTemplateVisualizer/Modals/NodeModals/NodeEditModal.jsx b/awx/ui_next/src/screens/Template/WorkflowJobTemplateVisualizer/Modals/NodeModals/NodeEditModal.jsx index 8298294324..a09d70f34a 100644 --- a/awx/ui_next/src/screens/Template/WorkflowJobTemplateVisualizer/Modals/NodeModals/NodeEditModal.jsx +++ b/awx/ui_next/src/screens/Template/WorkflowJobTemplateVisualizer/Modals/NodeModals/NodeEditModal.jsx @@ -1,10 +1,10 @@ import React, { useContext } from 'react'; -import { withI18n } from '@lingui/react'; + import { t } from '@lingui/macro'; import { WorkflowDispatchContext } from '../../../../../contexts/Workflow'; import NodeModal from './NodeModal'; -function NodeEditModal({ i18n }) { +function NodeEditModal() { const dispatch = useContext(WorkflowDispatchContext); const updateNode = (values, config) => { @@ -53,12 +53,8 @@ function NodeEditModal({ i18n }) { }; return ( - + ); } -export default withI18n()(NodeEditModal); +export default NodeEditModal; diff --git a/awx/ui_next/src/screens/Template/WorkflowJobTemplateVisualizer/Modals/NodeModals/NodeModal.jsx b/awx/ui_next/src/screens/Template/WorkflowJobTemplateVisualizer/Modals/NodeModals/NodeModal.jsx index 631ee9cc31..e289bd508e 100644 --- a/awx/ui_next/src/screens/Template/WorkflowJobTemplateVisualizer/Modals/NodeModals/NodeModal.jsx +++ b/awx/ui_next/src/screens/Template/WorkflowJobTemplateVisualizer/Modals/NodeModals/NodeModal.jsx @@ -1,7 +1,7 @@ import 'styled-components/macro'; import React, { useContext, useState, useEffect, useCallback } from 'react'; import { useHistory } from 'react-router-dom'; -import { withI18n } from '@lingui/react'; + import { t } from '@lingui/macro'; import { Formik, useFormikContext } from 'formik'; import yaml from 'js-yaml'; @@ -34,7 +34,7 @@ import NodeNextButton from './NodeNextButton'; function NodeModalForm({ askLinkType, - i18n, + onSave, title, credentialError, @@ -68,7 +68,7 @@ function NodeModalForm({ } = useWorkflowNodeSteps( launchConfig, surveyConfig, - i18n, + values.nodeResource, askLinkType, resourceDefaultCredentials @@ -116,8 +116,8 @@ function NodeModalForm({ const nextButtonText = activeStep => activeStep.id === promptSteps[promptSteps?.length - 1]?.id || activeStep.name === 'Preview' - ? i18n._(t`Save`) - : i18n._(t`Next`); + ? t`Save` + : t`Next`; const CustomFooter = ( @@ -138,20 +138,20 @@ function NodeModalForm({ ouiaId="node-modal-back-button" id="back-node-modal" variant="secondary" - aria-label={i18n._(t`Back`)} + aria-label={t`Back`} onClick={onBack} > - {i18n._(t`Back`)} + {t`Back`} )} )} @@ -164,7 +164,7 @@ function NodeModalForm({ { dismissError(); }} @@ -179,7 +179,7 @@ function NodeModalForm({ { dismissError(); }} @@ -222,7 +222,7 @@ function NodeModalForm({ ); } -const NodeModalInner = ({ i18n, title, ...rest }) => { +const NodeModalInner = ({ title, ...rest }) => { const { values } = useFormikContext(); const wizardTitle = values.nodeResource @@ -304,7 +304,7 @@ const NodeModalInner = ({ i18n, title, ...rest }) => { { dismissError(); }} @@ -320,7 +320,7 @@ const NodeModalInner = ({ i18n, title, ...rest }) => { isOpen steps={[ { - name: i18n._(t`Loading`), + name: t`Loading`, component: , }, ]} @@ -338,12 +338,11 @@ const NodeModalInner = ({ i18n, title, ...rest }) => { resourceDefaultCredentials={resourceDefaultCredentials} isLaunchLoading={isLoading} title={wizardTitle} - i18n={i18n} /> ); }; -const NodeModal = ({ onSave, i18n, askLinkType, title }) => { +const NodeModal = ({ onSave, askLinkType, title }) => { const { nodeToEdit } = useContext(WorkflowStateContext); const onSaveForm = (values, config) => { onSave(values, config); @@ -367,7 +366,6 @@ const NodeModal = ({ onSave, i18n, askLinkType, title }) => {
    @@ -383,4 +381,4 @@ NodeModal.propTypes = { title: node.isRequired, }; -export default withI18n()(NodeModal); +export default NodeModal; diff --git a/awx/ui_next/src/screens/Template/WorkflowJobTemplateVisualizer/Modals/NodeModals/NodeTypeStep/InventorySourcesList.jsx b/awx/ui_next/src/screens/Template/WorkflowJobTemplateVisualizer/Modals/NodeModals/NodeTypeStep/InventorySourcesList.jsx index f5d0ce4dda..fb27d2521a 100644 --- a/awx/ui_next/src/screens/Template/WorkflowJobTemplateVisualizer/Modals/NodeModals/NodeTypeStep/InventorySourcesList.jsx +++ b/awx/ui_next/src/screens/Template/WorkflowJobTemplateVisualizer/Modals/NodeModals/NodeTypeStep/InventorySourcesList.jsx @@ -1,6 +1,6 @@ import React, { useEffect, useCallback } from 'react'; import { useLocation } from 'react-router-dom'; -import { withI18n } from '@lingui/react'; + import { t } from '@lingui/macro'; import { func, shape } from 'prop-types'; import { InventorySourcesAPI } from '../../../../../../api'; @@ -16,7 +16,7 @@ const QS_CONFIG = getQSConfig('inventory-sources', { order_by: 'name', }); -function InventorySourcesList({ i18n, nodeResource, onUpdateNodeResource }) { +function InventorySourcesList({ nodeResource, onUpdateNodeResource }) { const location = useLocation(); const { @@ -78,30 +78,30 @@ function InventorySourcesList({ i18n, nodeResource, onUpdateNodeResource }) { renderToolbar={props => } toolbarSearchColumns={[ { - name: i18n._(t`Name`), + name: t`Name`, key: 'name__icontains', isDefault: true, }, { - name: i18n._(t`Source`), + name: t`Source`, key: 'or__source', options: [ - [`file`, i18n._(t`File, directory or script`)], - [`scm`, i18n._(t`Sourced from a project`)], - [`ec2`, i18n._(t`Amazon EC2`)], - [`gce`, i18n._(t`Google Compute Engine`)], - [`azure_rm`, i18n._(t`Microsoft Azure Resource Manager`)], - [`vmware`, i18n._(t`VMware vCenter`)], - [`satellite6`, i18n._(t`Red Hat Satellite 6`)], - [`openstack`, i18n._(t`OpenStack`)], - [`rhv`, i18n._(t`Red Hat Virtualization`)], - [`tower`, i18n._(t`Ansible Tower`)], + [`file`, t`File, directory or script`], + [`scm`, t`Sourced from a project`], + [`ec2`, t`Amazon EC2`], + [`gce`, t`Google Compute Engine`], + [`azure_rm`, t`Microsoft Azure Resource Manager`], + [`vmware`, t`VMware vCenter`], + [`satellite6`, t`Red Hat Satellite 6`], + [`openstack`, t`OpenStack`], + [`rhv`, t`Red Hat Virtualization`], + [`tower`, t`Ansible Tower`], ], }, ]} toolbarSortColumns={[ { - name: i18n._(t`Name`), + name: t`Name`, key: 'name', }, ]} @@ -120,4 +120,4 @@ InventorySourcesList.defaultProps = { nodeResource: null, }; -export default withI18n()(InventorySourcesList); +export default InventorySourcesList; diff --git a/awx/ui_next/src/screens/Template/WorkflowJobTemplateVisualizer/Modals/NodeModals/NodeTypeStep/JobTemplatesList.jsx b/awx/ui_next/src/screens/Template/WorkflowJobTemplateVisualizer/Modals/NodeModals/NodeTypeStep/JobTemplatesList.jsx index 3d4f226580..ede270eee1 100644 --- a/awx/ui_next/src/screens/Template/WorkflowJobTemplateVisualizer/Modals/NodeModals/NodeTypeStep/JobTemplatesList.jsx +++ b/awx/ui_next/src/screens/Template/WorkflowJobTemplateVisualizer/Modals/NodeModals/NodeTypeStep/JobTemplatesList.jsx @@ -1,6 +1,6 @@ import React, { useEffect, useCallback } from 'react'; import { useLocation } from 'react-router-dom'; -import { withI18n } from '@lingui/react'; + import { t } from '@lingui/macro'; import { func, shape } from 'prop-types'; import { JobTemplatesAPI } from '../../../../../../api'; @@ -16,7 +16,7 @@ const QS_CONFIG = getQSConfig('job-templates', { order_by: 'name', }); -function JobTemplatesList({ i18n, nodeResource, onUpdateNodeResource }) { +function JobTemplatesList({ nodeResource, onUpdateNodeResource }) { const location = useLocation(); const { @@ -80,26 +80,26 @@ function JobTemplatesList({ i18n, nodeResource, onUpdateNodeResource }) { showPageSizeOptions={false} toolbarSearchColumns={[ { - name: i18n._(t`Name`), + name: t`Name`, key: 'name__icontains', isDefault: true, }, { - name: i18n._(t`Playbook name`), + name: t`Playbook name`, key: 'playbook__icontains', }, { - name: i18n._(t`Created By (Username)`), + name: t`Created By (Username)`, key: 'created_by__username__icontains', }, { - name: i18n._(t`Modified By (Username)`), + name: t`Modified By (Username)`, key: 'modified_by__username__icontains', }, ]} toolbarSortColumns={[ { - name: i18n._(t`Name`), + name: t`Name`, key: 'name', }, ]} @@ -118,4 +118,4 @@ JobTemplatesList.defaultProps = { nodeResource: null, }; -export default withI18n()(JobTemplatesList); +export default JobTemplatesList; diff --git a/awx/ui_next/src/screens/Template/WorkflowJobTemplateVisualizer/Modals/NodeModals/NodeTypeStep/NodeTypeStep.jsx b/awx/ui_next/src/screens/Template/WorkflowJobTemplateVisualizer/Modals/NodeModals/NodeTypeStep/NodeTypeStep.jsx index 59d0872826..2fd7a84732 100644 --- a/awx/ui_next/src/screens/Template/WorkflowJobTemplateVisualizer/Modals/NodeModals/NodeTypeStep/NodeTypeStep.jsx +++ b/awx/ui_next/src/screens/Template/WorkflowJobTemplateVisualizer/Modals/NodeModals/NodeTypeStep/NodeTypeStep.jsx @@ -1,6 +1,6 @@ import 'styled-components/macro'; import React, { useState } from 'react'; -import { withI18n } from '@lingui/react'; + import { t, Trans } from '@lingui/macro'; import styled from 'styled-components'; import { useField } from 'formik'; @@ -45,7 +45,7 @@ const TimeoutLabel = styled.p` margin-left: 10px; `; -function NodeTypeStep({ i18n }) { +function NodeTypeStep() { const [nodeTypeField, , nodeTypeHelpers] = useField('nodeType'); const [nodeResourceField, nodeResourceMeta, nodeResourceHelpers] = useField( 'nodeResource' @@ -74,40 +74,40 @@ function NodeTypeStep({ i18n }) { /> )}
    - {i18n._(t`Node Type`)} + {t`Node Type`}
    { @@ -187,7 +187,7 @@ function NodeTypeStep({ i18n }) { { @@ -205,15 +205,13 @@ function NodeTypeStep({ i18n }) { )} - {i18n._( - t`Preconditions for running this node when there are multiple parents. Refer to the` - )}{' '} + {t`Preconditions for running this node when there are multiple parents. Refer to the`}{' '} - {i18n._(t`documentation`)} + {t`documentation`} {' '} - {i18n._(t`for more info.`)} + {t`for more info.`} } /> @@ -238,16 +236,16 @@ function NodeTypeStep({ i18n }) { convergenceFieldHelpers.setValue(selection); setIsConvergenceOpen(false); }} - aria-label={i18n._(t`Convergence select`)} - typeAheadAriaLabel={i18n._(t`Convergence select`)} + aria-label={t`Convergence select`} + typeAheadAriaLabel={t`Convergence select`} className="convergenceSelect" ouiaId="convergenceSelect" > - {i18n._(t`Any`)} + {t`Any`} - {i18n._(t`All`)} + {t`All`} @@ -256,4 +254,4 @@ function NodeTypeStep({ i18n }) { ); } -export default withI18n()(NodeTypeStep); +export default NodeTypeStep; diff --git a/awx/ui_next/src/screens/Template/WorkflowJobTemplateVisualizer/Modals/NodeModals/NodeTypeStep/ProjectsList.jsx b/awx/ui_next/src/screens/Template/WorkflowJobTemplateVisualizer/Modals/NodeModals/NodeTypeStep/ProjectsList.jsx index 34fc52bef2..73d79b3bb3 100644 --- a/awx/ui_next/src/screens/Template/WorkflowJobTemplateVisualizer/Modals/NodeModals/NodeTypeStep/ProjectsList.jsx +++ b/awx/ui_next/src/screens/Template/WorkflowJobTemplateVisualizer/Modals/NodeModals/NodeTypeStep/ProjectsList.jsx @@ -1,6 +1,6 @@ import React, { useEffect, useCallback } from 'react'; import { useLocation } from 'react-router-dom'; -import { withI18n } from '@lingui/react'; + import { t } from '@lingui/macro'; import { func, shape } from 'prop-types'; import { ProjectsAPI } from '../../../../../../api'; @@ -16,7 +16,7 @@ const QS_CONFIG = getQSConfig('projects', { order_by: 'name', }); -function ProjectsList({ i18n, nodeResource, onUpdateNodeResource }) { +function ProjectsList({ nodeResource, onUpdateNodeResource }) { const location = useLocation(); const { @@ -78,37 +78,37 @@ function ProjectsList({ i18n, nodeResource, onUpdateNodeResource }) { showPageSizeOptions={false} toolbarSearchColumns={[ { - name: i18n._(t`Name`), + name: t`Name`, key: 'name__icontains', isDefault: true, }, { - name: i18n._(t`Type`), + name: t`Type`, key: 'or__scm_type', options: [ - [``, i18n._(t`Manual`)], - [`git`, i18n._(t`Git`)], - [`svn`, i18n._(t`Subversion`)], - [`archive`, i18n._(t`Remote Archive`)], - [`insights`, i18n._(t`Red Hat Insights`)], + [``, t`Manual`], + [`git`, t`Git`], + [`svn`, t`Subversion`], + [`archive`, t`Remote Archive`], + [`insights`, t`Red Hat Insights`], ], }, { - name: i18n._(t`Source Control URL`), + name: t`Source Control URL`, key: 'scm_url__icontains', }, { - name: i18n._(t`Modified By (Username)`), + name: t`Modified By (Username)`, key: 'modified_by__username__icontains', }, { - name: i18n._(t`Created By (Username)`), + name: t`Created By (Username)`, key: 'created_by__username__icontains', }, ]} toolbarSortColumns={[ { - name: i18n._(t`Name`), + name: t`Name`, key: 'name', }, ]} @@ -127,4 +127,4 @@ ProjectsList.defaultProps = { nodeResource: null, }; -export default withI18n()(ProjectsList); +export default ProjectsList; diff --git a/awx/ui_next/src/screens/Template/WorkflowJobTemplateVisualizer/Modals/NodeModals/NodeTypeStep/WorkflowJobTemplatesList.jsx b/awx/ui_next/src/screens/Template/WorkflowJobTemplateVisualizer/Modals/NodeModals/NodeTypeStep/WorkflowJobTemplatesList.jsx index aac3f669d0..56a6642c28 100644 --- a/awx/ui_next/src/screens/Template/WorkflowJobTemplateVisualizer/Modals/NodeModals/NodeTypeStep/WorkflowJobTemplatesList.jsx +++ b/awx/ui_next/src/screens/Template/WorkflowJobTemplateVisualizer/Modals/NodeModals/NodeTypeStep/WorkflowJobTemplatesList.jsx @@ -1,6 +1,6 @@ import React, { useEffect, useCallback } from 'react'; import { useLocation } from 'react-router-dom'; -import { withI18n } from '@lingui/react'; + import { t } from '@lingui/macro'; import { func, shape } from 'prop-types'; import { WorkflowJobTemplatesAPI } from '../../../../../../api'; @@ -16,11 +16,7 @@ const QS_CONFIG = getQSConfig('workflow-job-templates', { order_by: 'name', }); -function WorkflowJobTemplatesList({ - i18n, - nodeResource, - onUpdateNodeResource, -}) { +function WorkflowJobTemplatesList({ nodeResource, onUpdateNodeResource }) { const location = useLocation(); const { @@ -89,30 +85,30 @@ function WorkflowJobTemplatesList({ showPageSizeOptions={false} toolbarSearchColumns={[ { - name: i18n._(t`Name`), + name: t`Name`, key: 'name__icontains', isDefault: true, }, { - name: i18n._(t`Organization (Name)`), + name: t`Organization (Name)`, key: 'organization__name__icontains', }, { - name: i18n._(t`Inventory (Name)`), + name: t`Inventory (Name)`, key: 'inventory__name__icontains', }, { - name: i18n._(t`Created By (Username)`), + name: t`Created By (Username)`, key: 'created_by__username__icontains', }, { - name: i18n._(t`Modified By (Username)`), + name: t`Modified By (Username)`, key: 'modified_by__username__icontains', }, ]} toolbarSortColumns={[ { - name: i18n._(t`Name`), + name: t`Name`, key: 'name', }, ]} @@ -131,4 +127,4 @@ WorkflowJobTemplatesList.defaultProps = { nodeResource: null, }; -export default withI18n()(WorkflowJobTemplatesList); +export default WorkflowJobTemplatesList; diff --git a/awx/ui_next/src/screens/Template/WorkflowJobTemplateVisualizer/Modals/NodeModals/NodeTypeStep/useNodeTypeStep.jsx b/awx/ui_next/src/screens/Template/WorkflowJobTemplateVisualizer/Modals/NodeModals/NodeTypeStep/useNodeTypeStep.jsx index 5931d2041b..8f83c025df 100644 --- a/awx/ui_next/src/screens/Template/WorkflowJobTemplateVisualizer/Modals/NodeModals/NodeTypeStep/useNodeTypeStep.jsx +++ b/awx/ui_next/src/screens/Template/WorkflowJobTemplateVisualizer/Modals/NodeModals/NodeTypeStep/useNodeTypeStep.jsx @@ -6,7 +6,7 @@ import StepName from '../../../../../../components/LaunchPrompt/steps/StepName'; const STEP_ID = 'nodeType'; -export default function useNodeTypeStep(launchConfig, i18n) { +export default function useNodeTypeStep() { const [, meta] = useField('nodeType'); const [approvalNameField] = useField('approvalName'); const [nodeTypeField, ,] = useField('nodeType'); @@ -20,9 +20,7 @@ export default function useNodeTypeStep(launchConfig, i18n) { ((!value?.inventory || value?.inventory === null) && !value?.ask_inventory_on_launch)) ) { - return i18n._( - t`Job Templates with a missing inventory or project cannot be selected when creating or editing nodes. Select another template or fix the missing fields to proceed.` - ); + return t`Job Templates with a missing inventory or project cannot be selected when creating or editing nodes. Select another template or fix the missing fields to proceed.`; } return undefined; }, @@ -32,7 +30,6 @@ export default function useNodeTypeStep(launchConfig, i18n) { return { step: getStep( - i18n, nodeTypeField, approvalNameField, nodeResourceField, @@ -49,7 +46,6 @@ export default function useNodeTypeStep(launchConfig, i18n) { }; } function getStep( - i18n, nodeTypeField, approvalNameField, nodeResourceField, @@ -71,10 +67,10 @@ function getStep( id: STEP_ID, name: ( - {i18n._(t`Node type`)} + {t`Node type`} ), - component: , + component: , enableNext: isEnabled(), }; } diff --git a/awx/ui_next/src/screens/Template/WorkflowJobTemplateVisualizer/Modals/NodeModals/NodeViewModal.jsx b/awx/ui_next/src/screens/Template/WorkflowJobTemplateVisualizer/Modals/NodeModals/NodeViewModal.jsx index d3288e4750..3cc3423d4c 100644 --- a/awx/ui_next/src/screens/Template/WorkflowJobTemplateVisualizer/Modals/NodeModals/NodeViewModal.jsx +++ b/awx/ui_next/src/screens/Template/WorkflowJobTemplateVisualizer/Modals/NodeModals/NodeViewModal.jsx @@ -1,5 +1,5 @@ import React, { useContext, useEffect, useCallback } from 'react'; -import { withI18n } from '@lingui/react'; + import { t } from '@lingui/macro'; import { Button, Modal } from '@patternfly/react-core'; import { @@ -15,7 +15,7 @@ import { jsonToYaml } from '../../../../../util/yaml'; import { JobTemplatesAPI, WorkflowJobTemplatesAPI } from '../../../../../api'; import getNodeType from '../../shared/WorkflowJobTemplateVisualizerUtils'; -function NodeViewModal({ i18n, readOnly }) { +function NodeViewModal({ readOnly }) { const dispatch = useContext(WorkflowDispatchContext); const { nodeToView } = useContext(WorkflowStateContext); const { @@ -123,10 +123,10 @@ function NodeViewModal({ i18n, readOnly }) { } else if (!fullUnifiedJobTemplate) { Content = (

    - {i18n._(t`The resource associated with this node has been deleted.`)} + {t`The resource associated with this node has been deleted.`}    {!readOnly - ? i18n._(t`Click the Edit button below to reconfigure the node.`) + ? t`Click the Edit button below to reconfigure the node.` : ''}

    ); @@ -191,8 +191,8 @@ function NodeViewModal({ i18n, readOnly }) { dispatch({ type: 'SET_NODE_TO_VIEW', value: null })} actions={ readOnly @@ -202,10 +202,10 @@ function NodeViewModal({ i18n, readOnly }) { ouiaId="node-view-edit-button" id="node-view-edit-button" key="edit" - aria-label={i18n._(t`Edit Node`)} + aria-label={t`Edit Node`} onClick={handleEdit} > - {i18n._(t`Edit`)} + {t`Edit`} , ] } @@ -215,4 +215,4 @@ function NodeViewModal({ i18n, readOnly }) { ); } -export default withI18n()(NodeViewModal); +export default NodeViewModal; diff --git a/awx/ui_next/src/screens/Template/WorkflowJobTemplateVisualizer/Modals/NodeModals/RunStep.jsx b/awx/ui_next/src/screens/Template/WorkflowJobTemplateVisualizer/Modals/NodeModals/RunStep.jsx index da08b9ad71..ba5c9a08f8 100644 --- a/awx/ui_next/src/screens/Template/WorkflowJobTemplateVisualizer/Modals/NodeModals/RunStep.jsx +++ b/awx/ui_next/src/screens/Template/WorkflowJobTemplateVisualizer/Modals/NodeModals/RunStep.jsx @@ -1,5 +1,5 @@ import React from 'react'; -import { withI18n } from '@lingui/react'; + import { useField } from 'formik'; import { t } from '@lingui/macro'; import styled from 'styled-components'; @@ -16,48 +16,40 @@ const Grid = styled.div` width: 100%; `; -function RunStep({ i18n }) { +function RunStep() { const [field, , helpers] = useField('linkType'); return ( <> - {i18n._(t`Run`)} + {t`Run`}

    - {i18n._( - t`Specify the conditions under which this node should be executed` - )} + {t`Specify the conditions under which this node should be executed`}

    helpers.setValue('success')} /> helpers.setValue('failure')} /> helpers.setValue('always')} /> ); } -export default withI18n()(RunStep); +export default RunStep; diff --git a/awx/ui_next/src/screens/Template/WorkflowJobTemplateVisualizer/Modals/NodeModals/useRunTypeStep.jsx b/awx/ui_next/src/screens/Template/WorkflowJobTemplateVisualizer/Modals/NodeModals/useRunTypeStep.jsx index 2ee6098fb7..a6fc249399 100644 --- a/awx/ui_next/src/screens/Template/WorkflowJobTemplateVisualizer/Modals/NodeModals/useRunTypeStep.jsx +++ b/awx/ui_next/src/screens/Template/WorkflowJobTemplateVisualizer/Modals/NodeModals/useRunTypeStep.jsx @@ -6,11 +6,11 @@ import StepName from '../../../../../components/LaunchPrompt/steps/StepName'; const STEP_ID = 'runType'; -export default function useRunTypeStep(i18n, askLinkType) { +export default function useRunTypeStep(askLinkType) { const [, meta] = useField('linkType'); return { - step: getStep(askLinkType, meta, i18n), + step: getStep(askLinkType, meta), initialValues: askLinkType ? { linkType: 'success' } : {}, isReady: true, contentError: null, @@ -21,7 +21,7 @@ export default function useRunTypeStep(i18n, askLinkType) { validate: () => {}, }; } -function getStep(askLinkType, meta, i18n) { +function getStep(askLinkType, meta) { if (!askLinkType) { return null; } @@ -29,7 +29,7 @@ function getStep(askLinkType, meta, i18n) { id: STEP_ID, name: ( - {i18n._(t`Run type`)} + {t`Run type`} ), component: , diff --git a/awx/ui_next/src/screens/Template/WorkflowJobTemplateVisualizer/Modals/NodeModals/useWorkflowNodeSteps.js b/awx/ui_next/src/screens/Template/WorkflowJobTemplateVisualizer/Modals/NodeModals/useWorkflowNodeSteps.js index 9d60376c64..771c8dad1f 100644 --- a/awx/ui_next/src/screens/Template/WorkflowJobTemplateVisualizer/Modals/NodeModals/useWorkflowNodeSteps.js +++ b/awx/ui_next/src/screens/Template/WorkflowJobTemplateVisualizer/Modals/NodeModals/useWorkflowNodeSteps.js @@ -187,7 +187,7 @@ const getNodeToEditDefaultValues = ( export default function useWorkflowNodeSteps( launchConfig, surveyConfig, - i18n, + resource, askLinkType, resourceDefaultCredentials @@ -201,17 +201,12 @@ export default function useWorkflowNodeSteps( const [visited, setVisited] = useState({}); const steps = [ - useRunTypeStep(i18n, askLinkType), - useNodeTypeStep(launchConfig, i18n), - useInventoryStep(launchConfig, resource, i18n, visited), - useCredentialsStep( - launchConfig, - resource, - resourceDefaultCredentials, - i18n - ), - useOtherPromptsStep(launchConfig, resource, i18n), - useSurveyStep(launchConfig, surveyConfig, resource, i18n, visited), + useRunTypeStep(askLinkType), + useNodeTypeStep(launchConfig), + useInventoryStep(launchConfig, resource, visited), + useCredentialsStep(launchConfig, resource, resourceDefaultCredentials), + useOtherPromptsStep(launchConfig, resource), + useSurveyStep(launchConfig, surveyConfig, resource, visited), ]; const hasErrors = steps.some(step => step.hasError); @@ -219,7 +214,7 @@ export default function useWorkflowNodeSteps( steps.push( usePreviewStep( launchConfig, - i18n, + resource, surveyConfig, hasErrors, @@ -263,9 +258,7 @@ export default function useWorkflowNodeSteps( !launchConfig?.ask_credential_on_launch && launchConfig?.passwords_needed_to_start?.length > 0 ) { - errors.nodeResource = i18n._( - t`Job Templates with credentials that prompt for passwords cannot be selected when creating or editing nodes` - ); + errors.nodeResource = t`Job Templates with credentials that prompt for passwords cannot be selected when creating or editing nodes`; } if (initialValues.convergence === 'all') { diff --git a/awx/ui_next/src/screens/Template/WorkflowJobTemplateVisualizer/Modals/UnsavedChangesModal.jsx b/awx/ui_next/src/screens/Template/WorkflowJobTemplateVisualizer/Modals/UnsavedChangesModal.jsx index ce5c82b3e0..e57f04712c 100644 --- a/awx/ui_next/src/screens/Template/WorkflowJobTemplateVisualizer/Modals/UnsavedChangesModal.jsx +++ b/awx/ui_next/src/screens/Template/WorkflowJobTemplateVisualizer/Modals/UnsavedChangesModal.jsx @@ -1,18 +1,18 @@ import React, { useContext } from 'react'; import { Button, Modal } from '@patternfly/react-core'; -import { withI18n } from '@lingui/react'; + import { t, Trans } from '@lingui/macro'; import { func } from 'prop-types'; import { WorkflowDispatchContext } from '../../../../contexts/Workflow'; -function UnsavedChangesModal({ i18n, onSaveAndExit, onExit }) { +function UnsavedChangesModal({ onSaveAndExit, onExit }) { const dispatch = useContext(WorkflowDispatchContext); return ( dispatch({ type: 'TOGGLE_UNSAVED_CHANGES_MODAL' })} actions={[ , , ]} > @@ -52,4 +52,4 @@ UnsavedChangesModal.propTypes = { onSaveAndExit: func.isRequired, }; -export default withI18n()(UnsavedChangesModal); +export default UnsavedChangesModal; diff --git a/awx/ui_next/src/screens/Template/WorkflowJobTemplateVisualizer/Visualizer.jsx b/awx/ui_next/src/screens/Template/WorkflowJobTemplateVisualizer/Visualizer.jsx index b94bd7ac44..577488c2d0 100644 --- a/awx/ui_next/src/screens/Template/WorkflowJobTemplateVisualizer/Visualizer.jsx +++ b/awx/ui_next/src/screens/Template/WorkflowJobTemplateVisualizer/Visualizer.jsx @@ -1,6 +1,6 @@ import React, { useCallback, useEffect, useReducer } from 'react'; import { useHistory } from 'react-router-dom'; -import { withI18n } from '@lingui/react'; + import styled from 'styled-components'; import { shape } from 'prop-types'; import { t } from '@lingui/macro'; @@ -109,7 +109,7 @@ const fetchWorkflowNodes = async ( return workflowNodes.concat(data.results); }; -function Visualizer({ template, i18n }) { +function Visualizer({ template }) { const history = useHistory(); const [state, dispatch] = useReducer(workflowReducer, { addLinkSourceNode: null, @@ -257,7 +257,6 @@ function Visualizer({ template, i18n }) { dispatch({ type: 'GENERATE_NODES_AND_LINKS', nodes: workflowNodes, - i18n, }); } catch (error) { dispatch({ type: 'SET_CONTENT_ERROR', value: error }); @@ -266,7 +265,7 @@ function Visualizer({ template, i18n }) { } } fetchData(); - }, [template.id, i18n]); + }, [template.id]); // Update positions of nodes/links useEffect(() => { @@ -593,11 +592,11 @@ function Visualizer({ template, i18n }) { - {i18n._(t`There was an error saving the workflow.`)} + {t`There was an error saving the workflow.`} )} @@ -610,4 +609,4 @@ Visualizer.propTypes = { template: shape().isRequired, }; -export default withI18n()(Visualizer); +export default Visualizer; diff --git a/awx/ui_next/src/screens/Template/WorkflowJobTemplateVisualizer/VisualizerGraph.jsx b/awx/ui_next/src/screens/Template/WorkflowJobTemplateVisualizer/VisualizerGraph.jsx index 877979e711..a3c026b25c 100644 --- a/awx/ui_next/src/screens/Template/WorkflowJobTemplateVisualizer/VisualizerGraph.jsx +++ b/awx/ui_next/src/screens/Template/WorkflowJobTemplateVisualizer/VisualizerGraph.jsx @@ -1,6 +1,6 @@ import 'styled-components/macro'; import React, { useContext, useEffect, useRef, useState } from 'react'; -import { withI18n } from '@lingui/react'; + import { t } from '@lingui/macro'; import styled from 'styled-components'; import { bool } from 'prop-types'; @@ -35,7 +35,7 @@ const WorkflowSVG = styled.svg` height: 100%; `; -function VisualizerGraph({ i18n, readOnly }) { +function VisualizerGraph({ readOnly }) { const [helpText, setHelpText] = useState(null); const [linkHelp, setLinkHelp] = useState(); const [nodeHelp, setNodeHelp] = useState(); @@ -257,9 +257,7 @@ function VisualizerGraph({ i18n, readOnly }) { onMouseMove: e => drawPotentialLinkToCursor(e), onMouseOver: () => setHelpText( - i18n._( - t`Click an available node to create a new link. Click outside the graph to cancel.` - ) + t`Click an available node to create a new link. Click outside the graph to cancel.` ), onMouseOut: () => setHelpText(null), onClick: () => handleBackgroundClick(), @@ -339,4 +337,4 @@ VisualizerGraph.propTypes = { readOnly: bool.isRequired, }; -export default withI18n()(VisualizerGraph); +export default VisualizerGraph; diff --git a/awx/ui_next/src/screens/Template/WorkflowJobTemplateVisualizer/VisualizerLink.jsx b/awx/ui_next/src/screens/Template/WorkflowJobTemplateVisualizer/VisualizerLink.jsx index cc00d9af9a..525b61a4c8 100644 --- a/awx/ui_next/src/screens/Template/WorkflowJobTemplateVisualizer/VisualizerLink.jsx +++ b/awx/ui_next/src/screens/Template/WorkflowJobTemplateVisualizer/VisualizerLink.jsx @@ -1,6 +1,6 @@ import React, { useContext, useEffect, useRef, useState } from 'react'; import styled from 'styled-components'; -import { withI18n } from '@lingui/react'; + import { t } from '@lingui/macro'; import { bool, func, shape } from 'prop-types'; import { PencilAltIcon, PlusIcon, TrashAltIcon } from '@patternfly/react-icons'; @@ -22,13 +22,7 @@ const LinkG = styled.g` pointer-events: ${props => (props.ignorePointerEvents ? 'none' : 'auto')}; `; -function VisualizerLink({ - i18n, - link, - updateLinkHelp, - readOnly, - updateHelpText, -}) { +function VisualizerLink({ link, updateLinkHelp, readOnly, updateHelpText }) { const ref = useRef(null); const [hovering, setHovering] = useState(false); const [pathD, setPathD] = useState(); @@ -52,7 +46,7 @@ function VisualizerLink({ }); }} onMouseEnter={() => - updateHelpText(i18n._(t`Add a new node between these two nodes`)) + updateHelpText(t`Add a new node between these two nodes`) } onMouseLeave={() => updateHelpText(null)} > @@ -73,7 +67,7 @@ function VisualizerLink({ setHovering(false); dispatch({ type: 'SET_LINK_TO_EDIT', value: link }); }} - onMouseEnter={() => updateHelpText(i18n._(t`Edit this link`))} + onMouseEnter={() => updateHelpText(t`Edit this link`)} onMouseLeave={() => updateHelpText(null)} > @@ -86,7 +80,7 @@ function VisualizerLink({ setHovering(false); dispatch({ type: 'START_DELETE_LINK', link }); }} - onMouseEnter={() => updateHelpText(i18n._(t`Delete this link`))} + onMouseEnter={() => updateHelpText(t`Delete this link`)} onMouseLeave={() => updateHelpText(null)} > @@ -163,4 +157,4 @@ VisualizerLink.propTypes = { updateLinkHelp: func.isRequired, }; -export default withI18n()(VisualizerLink); +export default VisualizerLink; diff --git a/awx/ui_next/src/screens/Template/WorkflowJobTemplateVisualizer/VisualizerNode.jsx b/awx/ui_next/src/screens/Template/WorkflowJobTemplateVisualizer/VisualizerNode.jsx index a92be897f8..73f96b116e 100644 --- a/awx/ui_next/src/screens/Template/WorkflowJobTemplateVisualizer/VisualizerNode.jsx +++ b/awx/ui_next/src/screens/Template/WorkflowJobTemplateVisualizer/VisualizerNode.jsx @@ -1,6 +1,6 @@ import React, { useContext, useRef, useState } from 'react'; import styled from 'styled-components'; -import { withI18n } from '@lingui/react'; + import { t } from '@lingui/macro'; import { bool, func, shape } from 'prop-types'; import { @@ -53,7 +53,6 @@ const ConvergenceLabel = styled.p` NodeResourceName.displayName = 'NodeResourceName'; function VisualizerNode({ - i18n, node, onMouseOver, readOnly, @@ -147,10 +146,8 @@ function VisualizerNode({ if (addingLink) { updateHelpText( node.isInvalidLinkTarget - ? i18n._( - t`Invalid link target. Unable to link to children or ancestor nodes. Graph cycles are not supported.` - ) - : i18n._(t`Click to create a new link to this node.`) + ? t`Invalid link target. Unable to link to children or ancestor nodes. Graph cycles are not supported.` + : t`Click to create a new link to this node.` ); onMouseOver(node); } @@ -174,7 +171,7 @@ function VisualizerNode({ id="node-details" key="details" onClick={handleViewClick} - onMouseEnter={() => updateHelpText(i18n._(t`View node details`))} + onMouseEnter={() => updateHelpText(t`View node details`)} onMouseLeave={() => updateHelpText(null)} > @@ -192,7 +189,7 @@ function VisualizerNode({ setHovering(false); dispatch({ type: 'START_ADD_NODE', sourceNodeId: node.id }); }} - onMouseEnter={() => updateHelpText(i18n._(t`Add a new node`))} + onMouseEnter={() => updateHelpText(t`Add a new node`)} onMouseLeave={() => updateHelpText(null)} > @@ -202,7 +199,7 @@ function VisualizerNode({ id="node-edit" key="edit" onClick={handleEditClick} - onMouseEnter={() => updateHelpText(i18n._(t`Edit this node`))} + onMouseEnter={() => updateHelpText(t`Edit this node`)} onMouseLeave={() => updateHelpText(null)} > @@ -215,9 +212,7 @@ function VisualizerNode({ setHovering(false); dispatch({ type: 'SELECT_SOURCE_FOR_LINKING', node }); }} - onMouseEnter={() => - updateHelpText(i18n._(t`Link to an available node`)) - } + onMouseEnter={() => updateHelpText(t`Link to an available node`)} onMouseLeave={() => updateHelpText(null)} > @@ -230,7 +225,7 @@ function VisualizerNode({ setHovering(false); dispatch({ type: 'SET_NODE_TO_DELETE', value: node }); }} - onMouseEnter={() => updateHelpText(i18n._(t`Delete this node`))} + onMouseEnter={() => updateHelpText(t`Delete this node`)} onMouseLeave={() => updateHelpText(null)} > @@ -278,7 +273,7 @@ function VisualizerNode({ x={wfConstants.nodeW / 2 - wfConstants.nodeW / 10 + 7} y={-wfConstants.nodeH / 4 - 1} > - {i18n._(t`ALL`)} + {t`ALL`} )} @@ -311,7 +306,7 @@ function VisualizerNode({ {node?.fullUnifiedJobTemplate?.name || node?.originalNodeObject?.summary_fields?.unified_job_template ?.name || - i18n._(t`DELETED`)} + t`DELETED`} @@ -328,10 +323,10 @@ function VisualizerNode({ - {i18n._(t`Failed to retrieve full node resource object.`)} + {t`Failed to retrieve full node resource object.`} )} @@ -339,10 +334,10 @@ function VisualizerNode({ - {i18n._(t`Failed to retrieve node credentials.`)} + {t`Failed to retrieve node credentials.`} )} @@ -362,4 +357,4 @@ VisualizerNode.defaultProps = { onMouseOver: () => {}, }; -export default withI18n()(VisualizerNode); +export default VisualizerNode; diff --git a/awx/ui_next/src/screens/Template/WorkflowJobTemplateVisualizer/VisualizerStartScreen.jsx b/awx/ui_next/src/screens/Template/WorkflowJobTemplateVisualizer/VisualizerStartScreen.jsx index 66cebb6bf1..93b49502b2 100644 --- a/awx/ui_next/src/screens/Template/WorkflowJobTemplateVisualizer/VisualizerStartScreen.jsx +++ b/awx/ui_next/src/screens/Template/WorkflowJobTemplateVisualizer/VisualizerStartScreen.jsx @@ -1,6 +1,6 @@ import 'styled-components/macro'; import React, { useContext } from 'react'; -import { withI18n } from '@lingui/react'; + import { t } from '@lingui/macro'; import { Button as PFButton } from '@patternfly/react-core'; import styled from 'styled-components'; @@ -30,29 +30,27 @@ const StartPanelWrapper = styled.div` justify-content: center; `; -function VisualizerStartScreen({ i18n, readOnly }) { +function VisualizerStartScreen({ readOnly }) { const dispatch = useContext(WorkflowDispatchContext); return (
    {readOnly ? ( -

    - {i18n._(t`This workflow does not have any nodes configured.`)} -

    +

    {t`This workflow does not have any nodes configured.`}

    ) : ( <> -

    {i18n._(t`Please click the Start button to begin.`)}

    +

    {t`Please click the Start button to begin.`}

    )} @@ -62,4 +60,4 @@ function VisualizerStartScreen({ i18n, readOnly }) { ); } -export default withI18n()(VisualizerStartScreen); +export default VisualizerStartScreen; diff --git a/awx/ui_next/src/screens/Template/WorkflowJobTemplateVisualizer/VisualizerToolbar.jsx b/awx/ui_next/src/screens/Template/WorkflowJobTemplateVisualizer/VisualizerToolbar.jsx index 0235bfd919..96f38aaed8 100644 --- a/awx/ui_next/src/screens/Template/WorkflowJobTemplateVisualizer/VisualizerToolbar.jsx +++ b/awx/ui_next/src/screens/Template/WorkflowJobTemplateVisualizer/VisualizerToolbar.jsx @@ -1,6 +1,6 @@ import 'styled-components/macro'; import React, { useContext } from 'react'; -import { withI18n } from '@lingui/react'; + import { t } from '@lingui/macro'; import { bool, func, shape } from 'prop-types'; import { @@ -50,7 +50,6 @@ const ActionButton = styled(Button)` ActionButton.displayName = 'ActionButton'; function VisualizerToolbar({ - i18n, onClose, onSave, template, @@ -74,13 +73,13 @@ function VisualizerToolbar({ {template.name}
    -
    {i18n._(t`Total Nodes`)}
    +
    {t`Total Nodes`}
    {totalNodes} - + 0 && showLegend} isDisabled={totalNodes === 0} @@ -90,9 +89,9 @@ function VisualizerToolbar({ - + 0 && showTools} isDisabled={totalNodes === 0} @@ -102,12 +101,9 @@ function VisualizerToolbar({ - + {template.summary_fields?.user_capabilities?.start && ( - - + + {({ handleLaunch, isLaunching }) => ( - + dispatch({ @@ -162,18 +155,18 @@ function VisualizerToolbar({ ouiaId="visualizer-save-button" id="visualizer-save" css="margin: 0 32px" - aria-label={i18n._(t`Save`)} + aria-label={t`Save`} variant="primary" onClick={onSave} > - {i18n._(t`Save`)} + {t`Save`} )} )} {summary_fields.user_capabilities && summary_fields.user_capabilities.delete && ( - {i18n._(t`Delete`)} + {t`Delete`} )} @@ -109,10 +104,10 @@ function UserDetail({ user, i18n }) { - {i18n._(t`Failed to delete user.`)} + {t`Failed to delete user.`} )} @@ -120,4 +115,4 @@ function UserDetail({ user, i18n }) { ); } -export default withI18n()(UserDetail); +export default UserDetail; diff --git a/awx/ui_next/src/screens/User/UserEdit/UserEdit.jsx b/awx/ui_next/src/screens/User/UserEdit/UserEdit.jsx index 96e159e02c..bb08f395ad 100644 --- a/awx/ui_next/src/screens/User/UserEdit/UserEdit.jsx +++ b/awx/ui_next/src/screens/User/UserEdit/UserEdit.jsx @@ -1,6 +1,6 @@ import React, { useState } from 'react'; import { useHistory } from 'react-router-dom'; -import { withI18n } from '@lingui/react'; + import { CardBody } from '../../../components/Card'; import UserForm from '../shared/UserForm'; import { UsersAPI } from '../../../api'; @@ -36,4 +36,4 @@ function UserEdit({ user }) { ); } -export default withI18n()(UserEdit); +export default UserEdit; diff --git a/awx/ui_next/src/screens/User/UserList/UserList.jsx b/awx/ui_next/src/screens/User/UserList/UserList.jsx index 9a48938744..4ff7395e11 100644 --- a/awx/ui_next/src/screens/User/UserList/UserList.jsx +++ b/awx/ui_next/src/screens/User/UserList/UserList.jsx @@ -1,6 +1,6 @@ import React, { useEffect, useCallback } from 'react'; import { useLocation, useRouteMatch } from 'react-router-dom'; -import { withI18n } from '@lingui/react'; + import { t } from '@lingui/macro'; import { Card, PageSection } from '@patternfly/react-core'; import { UsersAPI } from '../../../api'; @@ -26,7 +26,7 @@ const QS_CONFIG = getQSConfig('user', { order_by: 'username', }); -function UserList({ i18n }) { +function UserList() { const location = useLocation(); const match = useRouteMatch(); @@ -110,21 +110,21 @@ function UserList({ i18n }) { hasContentLoading={hasContentLoading} items={users} itemCount={itemCount} - pluralizedItemName={i18n._(t`Users`)} + pluralizedItemName={t`Users`} qsConfig={QS_CONFIG} onRowClick={handleSelect} toolbarSearchColumns={[ { - name: i18n._(t`Username`), + name: t`Username`, key: 'username__icontains', isDefault: true, }, { - name: i18n._(t`First Name`), + name: t`First Name`, key: 'first_name__icontains', }, { - name: i18n._(t`Last Name`), + name: t`Last Name`, key: 'last_name__icontains', }, ]} @@ -152,24 +152,18 @@ function UserList({ i18n }) { key="delete" onDelete={handleUserDelete} itemsToDelete={selected} - pluralizedItemName={i18n._(t`Users`)} + pluralizedItemName={t`Users`} />, ]} /> )} headerRow={ - - {i18n._(t`Username`)} - - - {i18n._(t`First Name`)} - - - {i18n._(t`Last Name`)} - - {i18n._(t`Role`)} - {i18n._(t`Actions`)} + {t`Username`} + {t`First Name`} + {t`Last Name`} + {t`Role`} + {t`Actions`} } renderRow={(user, index) => ( @@ -194,10 +188,10 @@ function UserList({ i18n }) { - {i18n._(t`Failed to delete one or more users.`)} + {t`Failed to delete one or more users.`} )} @@ -205,4 +199,4 @@ function UserList({ i18n }) { ); } -export default withI18n()(UserList); +export default UserList; diff --git a/awx/ui_next/src/screens/User/UserList/UserListItem.jsx b/awx/ui_next/src/screens/User/UserList/UserListItem.jsx index 731d0eac2b..9c0eb312ae 100644 --- a/awx/ui_next/src/screens/User/UserList/UserListItem.jsx +++ b/awx/ui_next/src/screens/User/UserList/UserListItem.jsx @@ -1,7 +1,7 @@ import 'styled-components/macro'; import React, { Fragment } from 'react'; import { string, bool, func } from 'prop-types'; -import { withI18n } from '@lingui/react'; + import { t } from '@lingui/macro'; import { Button, Label } from '@patternfly/react-core'; import { Tr, Td } from '@patternfly/react-table'; @@ -11,23 +11,16 @@ import { ActionsTd, ActionItem } from '../../../components/PaginatedTable'; import { User } from '../../../types'; -function UserListItem({ - user, - isSelected, - onSelect, - detailUrl, - rowIndex, - i18n, -}) { +function UserListItem({ user, isSelected, onSelect, detailUrl, rowIndex }) { const labelId = `check-action-${user.id}`; let user_type; if (user.is_superuser) { - user_type = i18n._(t`System Administrator`); + user_type = t`System Administrator`; } else if (user.is_system_auditor) { - user_type = i18n._(t`System Auditor`); + user_type = t`System Auditor`; } else { - user_type = i18n._(t`Normal User`); + user_type = t`Normal User`; } const ldapUser = user.ldap_dn; @@ -42,48 +35,46 @@ function UserListItem({ onSelect, }} /> - + {user.username} {ldapUser && ( - + )} {socialAuthUser && ( - + )} - + {user.first_name && ( - {i18n._(t`First Name`)} + {t`First Name`} {user.first_name} )} - + {user.last_name && ( - {i18n._(t`Last Name`)} + {t`Last Name`} {user.last_name} )} - {user_type} - + {user_type} + , , ]} >
    - {i18n._( - t`This action will disassociate the following role from ${roleToDisassociate.summary_fields.resource_name}:` - )} + {t`This action will disassociate the following role from ${roleToDisassociate.summary_fields.resource_name}:`}
    {roleToDisassociate.name}
    @@ -228,14 +224,14 @@ function UserRolesList({ i18n, user }) { - {i18n._(t`Failed to delete role.`)} + {t`Failed to delete role.`} )} ); } -export default withI18n()(UserRolesList); +export default UserRolesList; diff --git a/awx/ui_next/src/screens/User/UserRoles/UserRolesListItem.jsx b/awx/ui_next/src/screens/User/UserRoles/UserRolesListItem.jsx index 8f47315efa..1b93de5f6a 100644 --- a/awx/ui_next/src/screens/User/UserRoles/UserRolesListItem.jsx +++ b/awx/ui_next/src/screens/User/UserRoles/UserRolesListItem.jsx @@ -1,5 +1,5 @@ import React from 'react'; -import { withI18n } from '@lingui/react'; + import { t } from '@lingui/macro'; import { DataListItem, @@ -11,37 +11,37 @@ import { Link } from 'react-router-dom'; import { DetailList, Detail } from '../../../components/DetailList'; import DataListCell from '../../../components/DataListCell'; -function UserRolesListItem({ role, i18n, detailUrl, onSelect }) { +function UserRolesListItem({ role, detailUrl, onSelect }) { const labelId = `userRole-${role.id}`; return ( + {role.summary_fields.resource_name ? ( {role.summary_fields.resource_name} ) : ( - {i18n._(t`System`)} + {t`System`} )} , - + {role.summary_fields && ( )} , - + {role.name && ( ( @@ -201,7 +201,7 @@ function UserTeamList({ i18n }) { setIsModalOpen(true)} - defaultLabel={i18n._(t`Associate`)} + defaultLabel={t`Associate`} />, ] : []), @@ -209,10 +209,8 @@ function UserTeamList({ i18n }) { key="disassociate" onDisassociate={handleDisassociate} itemsToDisassociate={selected} - modalTitle={i18n._(t`Disassociate related team(s)?`)} - modalNote={i18n._( - t`This action will disassociate all roles for this user from the selected teams.` - )} + modalTitle={t`Disassociate related team(s)?`} + modalNote={t`This action will disassociate all roles for this user from the selected teams.`} />, ]} emptyStateControls={ @@ -227,12 +225,12 @@ function UserTeamList({ i18n }) { )} toolbarSearchColumns={[ { - name: i18n._(t`Name`), + name: t`Name`, key: 'name__icontains', isDefault: true, }, { - name: i18n._(t`Organization`), + name: t`Organization`, key: 'organization__name__icontains', }, ]} @@ -241,12 +239,12 @@ function UserTeamList({ i18n }) { /> {isModalOpen && ( setIsModalOpen(false)} - title={i18n._(t`Select Teams`)} + title={t`Select Teams`} optionsRequest={readTeamOptions} /> )} @@ -254,12 +252,12 @@ function UserTeamList({ i18n }) { {associateError - ? i18n._(t`Failed to associate.`) - : i18n._(t`Failed to disassociate one or more teams.`)} + ? t`Failed to associate.` + : t`Failed to disassociate one or more teams.`} )} @@ -267,4 +265,4 @@ function UserTeamList({ i18n }) { ); } -export default withI18n()(UserTeamList); +export default UserTeamList; diff --git a/awx/ui_next/src/screens/User/UserTeams/UserTeamListItem.jsx b/awx/ui_next/src/screens/User/UserTeams/UserTeamListItem.jsx index d6f09e6761..71b7657a6f 100644 --- a/awx/ui_next/src/screens/User/UserTeams/UserTeamListItem.jsx +++ b/awx/ui_next/src/screens/User/UserTeams/UserTeamListItem.jsx @@ -1,7 +1,7 @@ import React from 'react'; import { bool, func } from 'prop-types'; import { Link } from 'react-router-dom'; -import { withI18n } from '@lingui/react'; + import { t } from '@lingui/macro'; import { DataListItemCells, @@ -14,7 +14,7 @@ import { import DataListCell from '../../../components/DataListCell'; import { Team } from '../../../types'; -function UserTeamListItem({ team, isSelected, onSelect, i18n }) { +function UserTeamListItem({ team, isSelected, onSelect }) { return ( - {i18n._(t`Organization`)}{' '} + {t`Organization`}{' '} - {i18n._(t`Back to Tokens`)} + {t`Back to Tokens`} ), link: `/users/${id}/tokens`, id: 99, }, { - name: i18n._(t`Details`), + name: t`Details`, link: `/users/${id}/tokens/${tokenId}/details`, id: 0, }, @@ -70,10 +70,8 @@ function UserToken({ i18n, setBreadcrumb, user }) { {error.response.status === 404 && ( - {i18n._(t`Token not found.`)}{' '} - - {i18n._(t`View all tokens.`)} - + {t`Token not found.`}{' '} + {t`View all tokens.`} )} @@ -99,9 +97,7 @@ function UserToken({ i18n, setBreadcrumb, user }) { {!isLoading && ( - {id && ( - {i18n._(t`View Tokens`)} - )} + {id && {t`View Tokens`}} )} @@ -110,4 +106,4 @@ function UserToken({ i18n, setBreadcrumb, user }) { ); } -export default withI18n()(UserToken); +export default UserToken; diff --git a/awx/ui_next/src/screens/User/UserTokenDetail/UserTokenDetail.jsx b/awx/ui_next/src/screens/User/UserTokenDetail/UserTokenDetail.jsx index 9285d05b43..9c7c98fd30 100644 --- a/awx/ui_next/src/screens/User/UserTokenDetail/UserTokenDetail.jsx +++ b/awx/ui_next/src/screens/User/UserTokenDetail/UserTokenDetail.jsx @@ -1,6 +1,6 @@ import React, { useCallback } from 'react'; import { useHistory, useParams } from 'react-router-dom'; -import { withI18n } from '@lingui/react'; + import { t } from '@lingui/macro'; import AlertModal from '../../../components/AlertModal'; @@ -17,7 +17,7 @@ import { formatDateString } from '../../../util/dates'; import useRequest, { useDismissableError } from '../../../util/useRequest'; import { toTitleCase } from '../../../util/strings'; -function UserTokenDetail({ token, i18n }) { +function UserTokenDetail({ token }) { const { scope, description, @@ -40,33 +40,33 @@ function UserTokenDetail({ token, i18n }) { - {i18n._(t`Delete`)} + {t`Delete`} {error && ( - {i18n._(t`Failed to user token.`)} + {t`Failed to user token.`} )} @@ -97,4 +97,4 @@ function UserTokenDetail({ token, i18n }) { ); } -export default withI18n()(UserTokenDetail); +export default UserTokenDetail; diff --git a/awx/ui_next/src/screens/User/UserTokenList/UserTokenList.jsx b/awx/ui_next/src/screens/User/UserTokenList/UserTokenList.jsx index 72ba8b31c5..2c111d9be3 100644 --- a/awx/ui_next/src/screens/User/UserTokenList/UserTokenList.jsx +++ b/awx/ui_next/src/screens/User/UserTokenList/UserTokenList.jsx @@ -1,6 +1,6 @@ import React, { useCallback, useEffect } from 'react'; import { useLocation, useParams } from 'react-router-dom'; -import { withI18n } from '@lingui/react'; + import { t } from '@lingui/macro'; import { getQSConfig, parseQueryString } from '../../../util/qs'; import PaginatedDataList, { @@ -20,7 +20,7 @@ const QS_CONFIG = getQSConfig('user', { page_size: 20, order_by: 'application__name', }); -function UserTokenList({ i18n }) { +function UserTokenList() { const location = useLocation(); const { id } = useParams(); @@ -103,39 +103,39 @@ function UserTokenList({ i18n }) { hasContentLoading={isLoading || isDeleteLoading} items={tokens} itemCount={itemCount} - pluralizedItemName={i18n._(t`Tokens`)} + pluralizedItemName={t`Tokens`} qsConfig={QS_CONFIG} onRowClick={handleSelect} toolbarSearchColumns={[ { - name: i18n._(t`Application name`), + name: t`Application name`, key: 'application__name__icontains', isDefault: true, }, { - name: i18n._(t`Description`), + name: t`Description`, key: 'description__icontains', }, ]} toolbarSortColumns={[ { - name: i18n._(t`Application name`), + name: t`Application name`, key: 'application__name', }, { - name: i18n._(t`Scope`), + name: t`Scope`, key: 'scope', }, { - name: i18n._(t`Expires`), + name: t`Expires`, key: 'expires', }, { - name: i18n._(t`Created`), + name: t`Created`, key: 'created', }, { - name: i18n._(t`Modified`), + name: t`Modified`, key: 'modified', }, ]} @@ -163,7 +163,7 @@ function UserTokenList({ i18n }) { key="delete" onDelete={handleDelete} itemsToDelete={selected} - pluralizedItemName={i18n._(t`User tokens`)} + pluralizedItemName={t`User tokens`} />, ]} /> @@ -188,10 +188,10 @@ function UserTokenList({ i18n }) { - {i18n._(t`Failed to delete one or more user tokens.`)} + {t`Failed to delete one or more user tokens.`} )} @@ -199,4 +199,4 @@ function UserTokenList({ i18n }) { ); } -export default withI18n()(UserTokenList); +export default UserTokenList; diff --git a/awx/ui_next/src/screens/User/UserTokenList/UserTokenListItem.jsx b/awx/ui_next/src/screens/User/UserTokenList/UserTokenListItem.jsx index 6ae8325723..5248802e1e 100644 --- a/awx/ui_next/src/screens/User/UserTokenList/UserTokenListItem.jsx +++ b/awx/ui_next/src/screens/User/UserTokenList/UserTokenListItem.jsx @@ -1,6 +1,6 @@ import React from 'react'; import { Link, useParams } from 'react-router-dom'; -import { withI18n } from '@lingui/react'; + import { t } from '@lingui/macro'; import { DataListItemCells, @@ -22,7 +22,7 @@ const NameLabel = styled.b` margin-right: 5px; `; -function UserTokenListItem({ i18n, token, isSelected, onSelect }) { +function UserTokenListItem({ token, isSelected, onSelect }) { const { id } = useParams(); const labelId = `check-action-${token.id}`; return ( @@ -36,20 +36,20 @@ function UserTokenListItem({ i18n, token, isSelected, onSelect }) { /> + {token.summary_fields?.application - ? i18n._(t`Application access token`) - : i18n._(t`Personal access token`)} + ? t`Application access token` + : t`Personal access token`} , {token.summary_fields?.application && ( - {i18n._(t`Application`)} + {t`Application`} @@ -58,12 +58,12 @@ function UserTokenListItem({ i18n, token, isSelected, onSelect }) { )} , - - + + {toTitleCase(token.scope)} , - - + + {formatDateString(token.expires)} , ]} @@ -73,4 +73,4 @@ function UserTokenListItem({ i18n, token, isSelected, onSelect }) { ); } -export default withI18n()(UserTokenListItem); +export default UserTokenListItem; diff --git a/awx/ui_next/src/screens/User/UserTokens/UserTokens.jsx b/awx/ui_next/src/screens/User/UserTokens/UserTokens.jsx index 450bd41822..a97955b18c 100644 --- a/awx/ui_next/src/screens/User/UserTokens/UserTokens.jsx +++ b/awx/ui_next/src/screens/User/UserTokens/UserTokens.jsx @@ -1,5 +1,5 @@ import React, { useCallback, useState } from 'react'; -import { withI18n } from '@lingui/react'; + import { t } from '@lingui/macro'; import styled from 'styled-components'; import { Switch, Route, useParams } from 'react-router-dom'; @@ -19,7 +19,7 @@ const TokenAlert = styled(Alert)` margin-bottom: 20px; `; -function UserTokens({ i18n, setBreadcrumb, user }) { +function UserTokens({ setBreadcrumb, user }) { const [tokenModalSource, setTokenModalSource] = useState(null); const { id } = useParams(); @@ -46,23 +46,21 @@ function UserTokens({ i18n, setBreadcrumb, user }) { {tokenModalSource && ( setTokenModalSource(null)} > {tokenModalSource.token && ( )} @@ -97,4 +95,4 @@ function UserTokens({ i18n, setBreadcrumb, user }) { ); } -export default withI18n()(UserTokens); +export default UserTokens; diff --git a/awx/ui_next/src/screens/User/Users.jsx b/awx/ui_next/src/screens/User/Users.jsx index 323e8e37a4..99b75eeb20 100644 --- a/awx/ui_next/src/screens/User/Users.jsx +++ b/awx/ui_next/src/screens/User/Users.jsx @@ -1,6 +1,6 @@ import React, { Fragment, useState, useCallback } from 'react'; import { Route, useRouteMatch, Switch } from 'react-router-dom'; -import { withI18n } from '@lingui/react'; + import { t } from '@lingui/macro'; import ScreenHeader from '../../components/ScreenHeader/ScreenHeader'; @@ -10,40 +10,33 @@ import UsersList from './UserList/UserList'; import UserAdd from './UserAdd/UserAdd'; import User from './User'; -function Users({ i18n }) { +function Users() { const [breadcrumbConfig, setBreadcrumbConfig] = useState({ - '/users': i18n._(t`Users`), - '/users/add': i18n._(t`Create New User`), + '/users': t`Users`, + '/users/add': t`Create New User`, }); const match = useRouteMatch(); - const addUserBreadcrumb = useCallback( - (user, token) => { - if (!user) { - return; - } + const addUserBreadcrumb = useCallback((user, token) => { + if (!user) { + return; + } - setBreadcrumbConfig({ - '/users': i18n._(t`Users`), - '/users/add': i18n._(t`Create New User`), - [`/users/${user.id}`]: `${user.username}`, - [`/users/${user.id}/edit`]: i18n._(t`Edit Details`), - [`/users/${user.id}/details`]: i18n._(t`Details`), - [`/users/${user.id}/roles`]: i18n._(t`Roles`), - [`/users/${user.id}/teams`]: i18n._(t`Teams`), - [`/users/${user.id}/organizations`]: i18n._(t`Organizations`), - [`/users/${user.id}/tokens`]: i18n._(t`Tokens`), - [`/users/${user.id}/tokens/add`]: i18n._(t`Create user token`), - [`/users/${user.id}/tokens/${token && token.id}`]: i18n._( - t`Application Name` - ), - [`/users/${user.id}/tokens/${token && token.id}/details`]: i18n._( - t`Details` - ), - }); - }, - [i18n] - ); + setBreadcrumbConfig({ + '/users': t`Users`, + '/users/add': t`Create New User`, + [`/users/${user.id}`]: `${user.username}`, + [`/users/${user.id}/edit`]: t`Edit Details`, + [`/users/${user.id}/details`]: t`Details`, + [`/users/${user.id}/roles`]: t`Roles`, + [`/users/${user.id}/teams`]: t`Teams`, + [`/users/${user.id}/organizations`]: t`Organizations`, + [`/users/${user.id}/tokens`]: t`Tokens`, + [`/users/${user.id}/tokens/add`]: t`Create user token`, + [`/users/${user.id}/tokens/${token && token.id}`]: t`Application Name`, + [`/users/${user.id}/tokens/${token && token.id}/details`]: t`Details`, + }); + }, []); return ( @@ -67,4 +60,4 @@ function Users({ i18n }) { } export { Users as _Users }; -export default withI18n()(Users); +export default Users; diff --git a/awx/ui_next/src/screens/User/shared/UserForm.jsx b/awx/ui_next/src/screens/User/shared/UserForm.jsx index 0449af1808..cd189b4cff 100644 --- a/awx/ui_next/src/screens/User/shared/UserForm.jsx +++ b/awx/ui_next/src/screens/User/shared/UserForm.jsx @@ -1,6 +1,6 @@ import React, { useCallback, useState } from 'react'; import PropTypes from 'prop-types'; -import { withI18n } from '@lingui/react'; + import { t } from '@lingui/macro'; import { Formik, useField, useFormikContext } from 'formik'; import { Form, FormGroup } from '@patternfly/react-core'; @@ -14,7 +14,7 @@ import OrganizationLookup from '../../../components/Lookup/OrganizationLookup'; import { required } from '../../../util/validators'; import { FormColumnLayout } from '../../../components/FormLayout'; -function UserFormFields({ user, i18n }) { +function UserFormFields({ user }) { const [organization, setOrganization] = useState(null); const { setFieldValue } = useFormikContext(); @@ -26,19 +26,19 @@ function UserFormFields({ user, i18n }) { { value: 'normal', key: 'normal', - label: i18n._(t`Normal User`), + label: t`Normal User`, isDisabled: false, }, { value: 'auditor', key: 'auditor', - label: i18n._(t`System Auditor`), + label: t`System Auditor`, isDisabled: false, }, { value: 'administrator', key: 'administrator', - label: i18n._(t`System Administrator`), + label: t`System Administrator`, isDisabled: false, }, ]; @@ -46,7 +46,7 @@ function UserFormFields({ user, i18n }) { const [, organizationMeta, organizationHelpers] = useField({ name: 'organization', validate: !user.id - ? required(i18n._(t`Select a value for this field`), i18n) + ? required(t`Select a value for this field`) : () => undefined, }); @@ -64,40 +64,35 @@ function UserFormFields({ user, i18n }) { <> undefined + !ldapUser && !externalAccount ? required(null) : () => undefined } isRequired={!ldapUser && !externalAccount} /> - + {!ldapUser && !(socialAuthUser && externalAccount) && ( <> undefined } isRequired={!user.id} /> undefined } isRequired={!user.id} @@ -106,13 +101,13 @@ function UserFormFields({ user, i18n }) { )} @@ -134,7 +129,7 @@ function UserFormFields({ user, i18n }) { validated={ !userTypeMeta.touched || !userTypeMeta.error ? 'default' : 'error' } - label={i18n._(t`User Type`)} + label={t`User Type`} > { if (values.password !== values.confirm_password) { setErrors({ - confirm_password: i18n._( - t`This value does not match the password you entered previously. Please confirm that password.` - ), + confirm_password: t`This value does not match the password you entered previously. Please confirm that password.`, }); } else { values.is_superuser = values.user_type === 'administrator'; @@ -192,7 +185,7 @@ function UserForm({ user, handleCancel, handleSubmit, submitError, i18n }) { {formik => ( - + - {i18n._(t`Application`)} + {t`Application`} } @@ -56,7 +54,7 @@ function UserTokenFormFields({ i18n }) { id="token-description" name="description" type="text" - label={i18n._(t`Description`)} + label={t`Description`} /> + } > { scopeHelpers.setValue(value); @@ -93,7 +89,7 @@ function UserTokenForm({ handleCancel, handleSubmit, submitError, - i18n, + token = {}, }) { return ( @@ -108,7 +104,7 @@ function UserTokenForm({ {formik => ( - + {submitError && } ); } -export default withI18n()(UserTokenForm); +export default UserTokenForm; diff --git a/awx/ui_next/src/screens/WorkflowApproval/WorkflowApproval.jsx b/awx/ui_next/src/screens/WorkflowApproval/WorkflowApproval.jsx index 066a566ec5..f6ce033684 100644 --- a/awx/ui_next/src/screens/WorkflowApproval/WorkflowApproval.jsx +++ b/awx/ui_next/src/screens/WorkflowApproval/WorkflowApproval.jsx @@ -1,6 +1,6 @@ import React, { useEffect, useCallback } from 'react'; import { t } from '@lingui/macro'; -import { withI18n } from '@lingui/react'; + import { Card, PageSection } from '@patternfly/react-core'; import { CaretLeftIcon } from '@patternfly/react-icons'; import { @@ -18,7 +18,7 @@ import ContentError from '../../components/ContentError'; import { WorkflowApprovalsAPI } from '../../api'; import WorkflowApprovalDetail from './WorkflowApprovalDetail'; -function WorkflowApproval({ setBreadcrumb, i18n }) { +function WorkflowApproval({ setBreadcrumb }) { const { id: workflowApprovalId } = useParams(); const match = useRouteMatch(); const location = useLocation(); @@ -49,9 +49,9 @@ function WorkflowApproval({ setBreadcrumb, i18n }) { {error.response.status === 404 && ( - {i18n._(t`Workflow Approval not found.`)}{' '} + {t`Workflow Approval not found.`}{' '} - {i18n._(t`View all Workflow Approvals.`)} + {t`View all Workflow Approvals.`} )} @@ -66,14 +66,14 @@ function WorkflowApproval({ setBreadcrumb, i18n }) { name: ( <> - {i18n._(t`Back to Workflow Approvals`)} + {t`Back to Workflow Approvals`} ), link: `/workflow_approvals`, id: 99, }, { - name: i18n._(t`Details`), + name: t`Details`, link: `${match.url}/details`, id: 0, }, @@ -101,7 +101,7 @@ function WorkflowApproval({ setBreadcrumb, i18n }) { {match.params.id && ( - {i18n._(t`View Workflow Approval Details`)} + {t`View Workflow Approval Details`} )} @@ -113,4 +113,4 @@ function WorkflowApproval({ setBreadcrumb, i18n }) { ); } -export default withI18n()(WorkflowApproval); +export default WorkflowApproval; diff --git a/awx/ui_next/src/screens/WorkflowApproval/WorkflowApprovalDetail/WorkflowApprovalDetail.jsx b/awx/ui_next/src/screens/WorkflowApproval/WorkflowApprovalDetail/WorkflowApprovalDetail.jsx index bbc6d3c659..19790f8533 100644 --- a/awx/ui_next/src/screens/WorkflowApproval/WorkflowApprovalDetail/WorkflowApprovalDetail.jsx +++ b/awx/ui_next/src/screens/WorkflowApproval/WorkflowApprovalDetail/WorkflowApprovalDetail.jsx @@ -1,5 +1,5 @@ import React, { useCallback } from 'react'; -import { withI18n } from '@lingui/react'; + import { t } from '@lingui/macro'; import { Link, useHistory, useParams } from 'react-router-dom'; import { Button } from '@patternfly/react-core'; @@ -18,7 +18,7 @@ import { WorkflowApprovalsAPI } from '../../../api'; import useRequest, { useDismissableError } from '../../../util/useRequest'; import { WorkflowApproval } from '../../../types'; -function WorkflowApprovalDetail({ i18n, workflowApproval }) { +function WorkflowApprovalDetail({ workflowApproval }) { const { id: workflowApprovalId } = useParams(); const history = useHistory(); const { @@ -83,29 +83,29 @@ function WorkflowApprovalDetail({ i18n, workflowApproval }) { {workflowApproval.status === 'pending' && ( )} {workflowApproval.status !== 'pending' && ( } @@ -114,7 +114,7 @@ function WorkflowApprovalDetail({ i18n, workflowApproval }) { )} {workflowApproval.summary_fields.approved_or_denied_by && ( )} {`${sourceWorkflowJob?.id} - ${sourceWorkflowJob?.name}`} ) : ( - i18n._(t`Deleted`) + t`Deleted` ) } dataCy="wa-detail-source-job" /> @@ -188,21 +188,21 @@ function WorkflowApprovalDetail({ i18n, workflowApproval }) { <> )} @@ -211,11 +211,11 @@ function WorkflowApprovalDetail({ i18n, workflowApproval }) { workflowApproval.summary_fields.user_capabilities.delete && ( - {i18n._(t`Delete`)} + {t`Delete`} )} @@ -223,10 +223,10 @@ function WorkflowApprovalDetail({ i18n, workflowApproval }) { - {i18n._(t`Failed to delete workflow approval.`)} + {t`Failed to delete workflow approval.`} )} @@ -234,10 +234,10 @@ function WorkflowApprovalDetail({ i18n, workflowApproval }) { - {i18n._(t`Failed to approve workflow approval.`)} + {t`Failed to approve workflow approval.`} )} @@ -245,10 +245,10 @@ function WorkflowApprovalDetail({ i18n, workflowApproval }) { - {i18n._(t`Failed to deny workflow approval.`)} + {t`Failed to deny workflow approval.`} )} @@ -260,4 +260,4 @@ WorkflowApprovalDetail.defaultProps = { workflowApproval: WorkflowApproval.isRequired, }; -export default withI18n()(WorkflowApprovalDetail); +export default WorkflowApprovalDetail; diff --git a/awx/ui_next/src/screens/WorkflowApproval/WorkflowApprovalList/WorkflowApprovalListApproveButton.jsx b/awx/ui_next/src/screens/WorkflowApproval/WorkflowApprovalList/WorkflowApprovalListApproveButton.jsx index fdf92597aa..6c448d3048 100644 --- a/awx/ui_next/src/screens/WorkflowApproval/WorkflowApprovalList/WorkflowApprovalListApproveButton.jsx +++ b/awx/ui_next/src/screens/WorkflowApproval/WorkflowApprovalList/WorkflowApprovalListApproveButton.jsx @@ -1,5 +1,5 @@ import React, { useContext } from 'react'; -import { withI18n } from '@lingui/react'; + import { t } from '@lingui/macro'; import PropTypes from 'prop-types'; import { Button, DropdownItem, Tooltip } from '@patternfly/react-core'; @@ -10,12 +10,12 @@ function cannotApprove(item) { return !item.can_approve_or_deny; } -function WorkflowApprovalListApproveButton({ onApprove, selectedItems, i18n }) { +function WorkflowApprovalListApproveButton({ onApprove, selectedItems }) { const { isKebabified } = useContext(KebabifiedContext); const renderTooltip = () => { if (selectedItems.length === 0) { - return i18n._(t`Select a row to approve`); + return t`Select a row to approve`; } const itemsUnableToApprove = selectedItems @@ -24,12 +24,10 @@ function WorkflowApprovalListApproveButton({ onApprove, selectedItems, i18n }) { .join(', '); if (selectedItems.some(cannotApprove)) { - return i18n._( - t`You are unable to act on the following workflow approvals: ${itemsUnableToApprove}` - ); + return t`You are unable to act on the following workflow approvals: ${itemsUnableToApprove}`; } - return i18n._(t`Approve`); + return t`Approve`; }; const isDisabled = @@ -44,7 +42,7 @@ function WorkflowApprovalListApproveButton({ onApprove, selectedItems, i18n }) { component="button" onClick={onApprove} > - {i18n._(t`Approve`)} + {t`Approve`} ) : ( @@ -52,11 +50,11 @@ function WorkflowApprovalListApproveButton({ onApprove, selectedItems, i18n }) {
    @@ -74,4 +72,4 @@ WorkflowApprovalListApproveButton.defaultProps = { selectedItems: [], }; -export default withI18n()(WorkflowApprovalListApproveButton); +export default WorkflowApprovalListApproveButton; diff --git a/awx/ui_next/src/screens/WorkflowApproval/WorkflowApprovalList/WorkflowApprovalListDenyButton.jsx b/awx/ui_next/src/screens/WorkflowApproval/WorkflowApprovalList/WorkflowApprovalListDenyButton.jsx index 822b2aa9c4..00909dbff2 100644 --- a/awx/ui_next/src/screens/WorkflowApproval/WorkflowApprovalList/WorkflowApprovalListDenyButton.jsx +++ b/awx/ui_next/src/screens/WorkflowApproval/WorkflowApprovalList/WorkflowApprovalListDenyButton.jsx @@ -1,5 +1,5 @@ import React, { useContext } from 'react'; -import { withI18n } from '@lingui/react'; + import { t } from '@lingui/macro'; import PropTypes from 'prop-types'; import { Button, DropdownItem, Tooltip } from '@patternfly/react-core'; @@ -10,12 +10,12 @@ function cannotDeny(item) { return !item.can_approve_or_deny; } -function WorkflowApprovalListDenyButton({ onDeny, selectedItems, i18n }) { +function WorkflowApprovalListDenyButton({ onDeny, selectedItems }) { const { isKebabified } = useContext(KebabifiedContext); const renderTooltip = () => { if (selectedItems.length === 0) { - return i18n._(t`Select a row to deny`); + return t`Select a row to deny`; } const itemsUnableToDeny = selectedItems @@ -24,12 +24,10 @@ function WorkflowApprovalListDenyButton({ onDeny, selectedItems, i18n }) { .join(', '); if (selectedItems.some(cannotDeny)) { - return i18n._( - t`You are unable to act on the following workflow approvals: ${itemsUnableToDeny}` - ); + return t`You are unable to act on the following workflow approvals: ${itemsUnableToDeny}`; } - return i18n._(t`Deny`); + return t`Deny`; }; const isDisabled = @@ -44,7 +42,7 @@ function WorkflowApprovalListDenyButton({ onDeny, selectedItems, i18n }) { component="button" onClick={onDeny} > - {i18n._(t`Deny`)} + {t`Deny`} ) : ( @@ -52,11 +50,11 @@ function WorkflowApprovalListDenyButton({ onDeny, selectedItems, i18n }) {
    @@ -74,4 +72,4 @@ WorkflowApprovalListDenyButton.defaultProps = { selectedItems: [], }; -export default withI18n()(WorkflowApprovalListDenyButton); +export default WorkflowApprovalListDenyButton; diff --git a/awx/ui_next/src/screens/WorkflowApproval/WorkflowApprovalList/WorkflowApprovalListItem.jsx b/awx/ui_next/src/screens/WorkflowApproval/WorkflowApprovalList/WorkflowApprovalListItem.jsx index 95aab631ca..a5d11cfb6e 100644 --- a/awx/ui_next/src/screens/WorkflowApproval/WorkflowApprovalList/WorkflowApprovalListItem.jsx +++ b/awx/ui_next/src/screens/WorkflowApproval/WorkflowApprovalList/WorkflowApprovalListItem.jsx @@ -1,5 +1,5 @@ import React from 'react'; -import { withI18n } from '@lingui/react'; + import { t } from '@lingui/macro'; import { string, bool, func } from 'prop-types'; import { Label } from '@patternfly/react-core'; @@ -20,7 +20,6 @@ function WorkflowApprovalListItem({ onSelect, detailUrl, rowIndex, - i18n, }) { const labelId = `check-action-${workflowApproval.id}`; const workflowJob = workflowApproval?.summary_fields?.source_workflow_job; @@ -32,11 +31,9 @@ function WorkflowApprovalListItem({ ) { return ( ); } @@ -44,7 +41,7 @@ function WorkflowApprovalListItem({ workflowApproval.status === 'pending' && !workflowApproval.approval_expiration ) { - return ; + return ; } return ; }; @@ -57,29 +54,29 @@ function WorkflowApprovalListItem({ isSelected, onSelect, }} - dataLabel={i18n._(t`Selected`)} + dataLabel={t`Selected`} /> - + {workflowApproval.name} <> - {i18n._(t`Job`)} + {t`Job`} {workflowJob && workflowJob?.id ? ( {`${workflowJob?.id} - ${workflowJob?.name}`} ) : ( - i18n._(t`Deleted`) + t`Deleted` )} - + {formatDateString(workflowApproval.started)} - +
    {getStatus()}
    @@ -93,4 +90,4 @@ WorkflowApprovalListItem.propTypes = { onSelect: func.isRequired, }; -export default withI18n()(WorkflowApprovalListItem); +export default WorkflowApprovalListItem; diff --git a/awx/ui_next/src/screens/WorkflowApproval/WorkflowApprovals.jsx b/awx/ui_next/src/screens/WorkflowApproval/WorkflowApprovals.jsx index def42f1100..31c7d1461b 100644 --- a/awx/ui_next/src/screens/WorkflowApproval/WorkflowApprovals.jsx +++ b/awx/ui_next/src/screens/WorkflowApproval/WorkflowApprovals.jsx @@ -1,31 +1,28 @@ import React, { useState, useCallback } from 'react'; import { Route, Switch, useRouteMatch } from 'react-router-dom'; -import { withI18n } from '@lingui/react'; + import { t } from '@lingui/macro'; import WorkflowApprovalList from './WorkflowApprovalList'; import WorkflowApproval from './WorkflowApproval'; import ScreenHeader from '../../components/ScreenHeader/ScreenHeader'; -function WorkflowApprovals({ i18n }) { +function WorkflowApprovals() { const match = useRouteMatch(); const [breadcrumbConfig, setBreadcrumbConfig] = useState({ - '/workflow_approvals': i18n._(t`Workflow Approvals`), + '/workflow_approvals': t`Workflow Approvals`, }); - const updateBreadcrumbConfig = useCallback( - workflowApproval => { - if (!workflowApproval) { - return; - } - const { id } = workflowApproval; - setBreadcrumbConfig({ - '/workflow_approvals': i18n._(t`Workflow Approvals`), - [`/workflow_approvals/${id}`]: workflowApproval.name, - [`/workflow_approvals/${id}/details`]: i18n._(t`Details`), - }); - }, - [i18n] - ); + const updateBreadcrumbConfig = useCallback(workflowApproval => { + if (!workflowApproval) { + return; + } + const { id } = workflowApproval; + setBreadcrumbConfig({ + '/workflow_approvals': t`Workflow Approvals`, + [`/workflow_approvals/${id}`]: workflowApproval.name, + [`/workflow_approvals/${id}/details`]: t`Details`, + }); + }, []); return ( <> @@ -45,4 +42,4 @@ function WorkflowApprovals({ i18n }) { ); } -export default withI18n()(WorkflowApprovals); +export default WorkflowApprovals; diff --git a/awx/ui_next/src/screens/WorkflowApproval/shared/WorkflowApprovalStatus.jsx b/awx/ui_next/src/screens/WorkflowApproval/shared/WorkflowApprovalStatus.jsx index d1540ca644..dca5401e5e 100644 --- a/awx/ui_next/src/screens/WorkflowApproval/shared/WorkflowApprovalStatus.jsx +++ b/awx/ui_next/src/screens/WorkflowApproval/shared/WorkflowApprovalStatus.jsx @@ -1,42 +1,36 @@ import React from 'react'; -import { withI18n } from '@lingui/react'; + import { t } from '@lingui/macro'; import { Label, Tooltip } from '@patternfly/react-core'; import { CheckIcon, InfoCircleIcon } from '@patternfly/react-icons'; import { WorkflowApproval } from '../../../types'; import { formatDateString } from '../../../util/dates'; -function WorkflowApprovalStatus({ workflowApproval, i18n }) { +function WorkflowApprovalStatus({ workflowApproval }) { if (workflowApproval.status === 'pending') { return workflowApproval.approval_expiration - ? i18n._( - t`Expires on ${formatDateString( - workflowApproval.approval_expiration - )}` - ) - : i18n._(t`Never expires`); + ? t`Expires on ${formatDateString(workflowApproval.approval_expiration)}` + : t`Never expires`; } if (workflowApproval.timed_out) { - return ; + return ; } if (workflowApproval.canceled_on) { - return ; + return ; } if (workflowApproval.status === 'failed' && workflowApproval.failed) { return ( ); @@ -45,15 +39,13 @@ function WorkflowApprovalStatus({ workflowApproval, i18n }) { if (workflowApproval.status === 'successful') { return ( ); @@ -66,4 +58,4 @@ WorkflowApprovalStatus.defaultProps = { workflowApproval: WorkflowApproval.isRequired, }; -export default withI18n()(WorkflowApprovalStatus); +export default WorkflowApprovalStatus; diff --git a/awx/ui_next/src/util/dates.jsx b/awx/ui_next/src/util/dates.jsx index f86f423eef..392ae83933 100644 --- a/awx/ui_next/src/util/dates.jsx +++ b/awx/ui_next/src/util/dates.jsx @@ -55,7 +55,7 @@ export function dateToInputDateTime(dateObj) { return `${year}-${month}-${day}T${hour}:${minute}:${second}`; } -export function getRRuleDayConstants(dayString, i18n) { +export function getRRuleDayConstants(dayString) { switch (dayString) { case 'sunday': return RRule.SU; @@ -86,6 +86,6 @@ export function getRRuleDayConstants(dayString, i18n) { case 'weekendDay': return [RRule.SA, RRule.SU]; default: - throw new Error(i18n._(t`Unrecognized day string`)); + throw new Error(t`Unrecognized day string`); } } diff --git a/awx/ui_next/src/util/getRelatedResourceDeleteDetails.js b/awx/ui_next/src/util/getRelatedResourceDeleteDetails.js index dbcd62080e..656236c936 100644 --- a/awx/ui_next/src/util/getRelatedResourceDeleteDetails.js +++ b/awx/ui_next/src/util/getRelatedResourceDeleteDetails.js @@ -1,5 +1,4 @@ import { t } from '@lingui/macro'; -import { i18n } from '@lingui/core'; import { UnifiedJobTemplatesAPI, @@ -53,39 +52,39 @@ export const relatedResourceDeleteRequests = { JobTemplatesAPI.read({ credentials: selected.id, }), - label: i18n._(t`Job Templates`), + label: t`Job Templates`, }, { request: () => ProjectsAPI.read({ credentials: selected.id }), - label: i18n._(t`Projects`), + label: t`Projects`, }, { request: () => InventoriesAPI.read({ insights_credential: selected.id, }), - label: i18n._(t`Inventories`), + label: t`Inventories`, }, { request: () => InventorySourcesAPI.read({ credentials__id: selected.id, }), - label: i18n._(t`Inventory Sources`), + label: t`Inventory Sources`, }, { request: () => CredentialInputSourcesAPI.read({ source_credential: selected.id, }), - label: i18n._(t`Credential Input Sources`), + label: t`Credential Input Sources`, }, { request: () => ExecutionEnvironmentsAPI.read({ credential: selected.id, }), - label: i18n._(t`Execution Environments`), + label: t`Execution Environments`, }, ], @@ -95,7 +94,7 @@ export const relatedResourceDeleteRequests = { CredentialsAPI.read({ credential_type__id: selected.id, }), - label: i18n._(t`Credentials`), + label: t`Credentials`, }, ], @@ -105,11 +104,11 @@ export const relatedResourceDeleteRequests = { JobTemplatesAPI.read({ inventory: selected.id, }), - label: i18n._(t`Job Templates`), + label: t`Job Templates`, }, { request: () => WorkflowJobTemplatesAPI.read({ inventory: selected.id }), - label: i18n._(t`Workflow Job Template`), + label: t`Workflow Job Template`, }, ], @@ -119,15 +118,15 @@ export const relatedResourceDeleteRequests = { WorkflowJobTemplateNodesAPI.read({ unified_job_template: inventorySourceId, }), - label: i18n._(t`Workflow Job Template Nodes`), + label: t`Workflow Job Template Nodes`, }, { request: async () => InventorySourcesAPI.readGroups(inventorySourceId), - label: i18n._(t`Groups`), + label: t`Groups`, }, { request: async () => InventorySourcesAPI.readHosts(inventorySourceId), - label: i18n._(t`Hosts`), + label: t`Hosts`, }, ], @@ -137,21 +136,21 @@ export const relatedResourceDeleteRequests = { JobTemplatesAPI.read({ project: selected.id, }), - label: i18n._(t`Job Templates`), + label: t`Job Templates`, }, { request: () => WorkflowJobTemplateNodesAPI.read({ unified_job_template: selected.id, }), - label: i18n._(t`Workflow Job Templates`), + label: t`Workflow Job Templates`, }, { request: () => InventorySourcesAPI.read({ source_project: selected.id, }), - label: i18n._(t`Inventory Sources`), + label: t`Inventory Sources`, }, ], @@ -161,7 +160,7 @@ export const relatedResourceDeleteRequests = { WorkflowJobTemplateNodesAPI.read({ unified_job_template: selected.id, }), - label: [i18n._(t`Workflow Job Template Nodes`)], + label: [t`Workflow Job Template Nodes`], }, ], @@ -171,49 +170,49 @@ export const relatedResourceDeleteRequests = { CredentialsAPI.read({ organization: selected.id, }), - label: i18n._(t`Credential`), + label: t`Credential`, }, { request: async () => TeamsAPI.read({ organization: selected.id, }), - label: i18n._(t`Teams`), + label: t`Teams`, }, { request: async () => NotificationTemplatesAPI.read({ organization: selected.id, }), - label: i18n._(t`Notification Templates`), + label: t`Notification Templates`, }, { request: () => ExecutionEnvironmentsAPI.read({ organization: selected.id, }), - label: i18n._(t`Execution Environments`), + label: t`Execution Environments`, }, { request: async () => ProjectsAPI.read({ organization: selected.id, }), - label: [i18n._(t`Projects`)], + label: [t`Projects`], }, { request: () => InventoriesAPI.read({ organization: selected.id, }), - label: i18n._(t`Inventories`), + label: t`Inventories`, }, { request: () => ApplicationsAPI.read({ organization: selected.id, }), - label: i18n._(t`Applications`), + label: t`Applications`, }, ], executionEnvironment: selected => [ @@ -222,21 +221,21 @@ export const relatedResourceDeleteRequests = { UnifiedJobTemplatesAPI.read({ execution_environment: selected.id, }), - label: [i18n._(t`Templates`)], + label: [t`Templates`], }, { request: async () => ProjectsAPI.read({ default_environment: selected.id, }), - label: [i18n._(t`Projects`)], + label: [t`Projects`], }, { request: async () => OrganizationsAPI.read({ default_environment: selected.id, }), - label: [i18n._(t`Organizations`)], + label: [t`Organizations`], }, { request: async () => { @@ -264,22 +263,22 @@ export const relatedResourceDeleteRequests = { throw new Error(err); } }, - label: [i18n._(t`Workflow Job Template Nodes`)], + label: [t`Workflow Job Template Nodes`], }, ], instanceGroup: selected => [ { request: () => OrganizationsAPI.read({ instance_groups: selected.id }), - label: i18n._(t`Organizations`), + label: t`Organizations`, }, { request: () => InventoriesAPI.read({ instance_groups: selected.id }), - label: i18n._(t`Inventories`), + label: t`Inventories`, }, { request: () => UnifiedJobTemplatesAPI.read({ instance_groups: selected.id }), - label: i18n._(t`Templates`), + label: t`Templates`, }, ], }; diff --git a/awx/ui_next/src/util/validators.jsx b/awx/ui_next/src/util/validators.jsx index c7b3c7ab6b..d69b370e34 100644 --- a/awx/ui_next/src/util/validators.jsx +++ b/awx/ui_next/src/util/validators.jsx @@ -1,7 +1,7 @@ import { t } from '@lingui/macro'; -export function required(message, i18n) { - const errorMessage = message || i18n._(t`This field must not be blank`); +export function required(message) { + const errorMessage = message || t`This field must not be blank`; return value => { if (typeof value === 'string' && !value.trim()) { return errorMessage; @@ -16,39 +16,37 @@ export function required(message, i18n) { }; } -export function maxLength(max, i18n) { +export function maxLength(max) { return value => { if (value.trim().length > max) { - return i18n._(t`This field must not exceed ${max} characters`); + return t`This field must not exceed ${max} characters`; } return undefined; }; } -export function minLength(min, i18n) { +export function minLength(min) { return value => { if (value.trim().length < min) { - return i18n._(t`This field must be at least ${min} characters`); + return t`This field must be at least ${min} characters`; } return undefined; }; } -export function minMaxValue(min, max, i18n) { +export function minMaxValue(min, max) { return value => { if (value < min || value > max) { - return i18n._( - t`This field must be a number and have a value between ${min} and ${max}` - ); + return t`This field must be a number and have a value between ${min} and ${max}`; } return undefined; }; } -export function requiredEmail(i18n) { +export function requiredEmail() { return value => { if (!value) { - return i18n._(t`This field must not be blank`); + return t`This field must not be blank`; } // This isn't a perfect validator. It's likely to let a few @@ -66,30 +64,30 @@ export function requiredEmail(i18n) { } } - return i18n._(t`Invalid email address`); + return t`Invalid email address`; }; } -export function noWhiteSpace(i18n) { +export function noWhiteSpace() { return value => { if (/\s/.test(value)) { - return i18n._(t`This field must not contain spaces`); + return t`This field must not contain spaces`; } return undefined; }; } -export function integer(i18n) { +export function integer() { return value => { const str = String(value); if (!Number.isInteger(value) && /[^0-9]/.test(str)) { - return i18n._(t`This field must be an integer`); + return t`This field must be an integer`; } return undefined; }; } -export function number(i18n) { +export function number() { return value => { const str = String(value); if (/^-?[0-9]*(\.[0-9]*)?$/.test(str)) { @@ -99,11 +97,11 @@ export function number(i18n) { if (/^-?[0-9]*e[+-][0-9]*$/.test(str)) { return undefined; } - return i18n._(t`This field must be a number`); + return t`This field must be a number`; }; } -export function url(i18n) { +export function url() { return value => { if (!value) { return undefined; @@ -115,7 +113,7 @@ export function url(i18n) { value ) ) { - return i18n._(t`Please enter a valid URL`); + return t`Please enter a valid URL`; } return undefined; }; @@ -134,12 +132,12 @@ export function combine(validators) { }; } -export function regExp(i18n) { +export function regExp() { return value => { try { RegExp(value); } catch { - return i18n._(t`This field must be a regular expression`); + return t`This field must be a regular expression`; } return undefined; }; diff --git a/awx/ui_next/src/util/validators.test.js b/awx/ui_next/src/util/validators.test.js index 1fcc58bc2a..ab3ac55e84 100644 --- a/awx/ui_next/src/util/validators.test.js +++ b/awx/ui_next/src/util/validators.test.js @@ -11,142 +11,136 @@ import { requiredEmail, } from './validators'; -const i18n = { _: val => val }; - describe('validators', () => { test('required returns undefined if value given', () => { - expect(required(null, i18n)('some value')).toBeUndefined(); - expect(required('oops', i18n)('some value')).toBeUndefined(); + expect(required(null)('some value')).toBeUndefined(); + expect(required('oops')('some value')).toBeUndefined(); }); test('required returns default message if value missing', () => { - expect(required(null, i18n)('')).toEqual('This field must not be blank'); + expect(required(null)('')).toEqual('This field must not be blank'); }); test('required returns custom message if value missing', () => { - expect(required('oops', i18n)('')).toEqual('oops'); + expect(required('oops')('')).toEqual('oops'); }); test('required interprets white space as empty value', () => { - expect(required(null, i18n)(' ')).toEqual('This field must not be blank'); - expect(required(null, i18n)('\t')).toEqual('This field must not be blank'); + expect(required(null)(' ')).toEqual('This field must not be blank'); + expect(required(null)('\t')).toEqual('This field must not be blank'); }); test('required interprets undefined as empty value', () => { - expect(required(null, i18n)(undefined)).toEqual( - 'This field must not be blank' - ); + expect(required(null)(undefined)).toEqual('This field must not be blank'); }); test('required interprets 0 as non-empty value', () => { - expect(required(null, i18n)(0)).toBeUndefined(); + expect(required(null)(0)).toBeUndefined(); }); test('maxLength accepts value below max', () => { - expect(maxLength(10, i18n)('snazzy')).toBeUndefined(); + expect(maxLength(10)('snazzy')).toBeUndefined(); }); test('maxLength accepts value equal to max', () => { - expect(maxLength(10, i18n)('abracadbra')).toBeUndefined(); + expect(maxLength(10)('abracadbra')).toBeUndefined(); }); test('maxLength rejects value above max', () => { - expect(maxLength(8, i18n)('abracadbra')).toEqual( - 'This field must not exceed {max} characters' + expect(maxLength(8)('abracadbra')).toEqual( + 'This field must not exceed 8 characters' ); }); test('minLength accepts value above min', () => { - expect(minLength(3, i18n)('snazzy')).toBeUndefined(); + expect(minLength(3)('snazzy')).toBeUndefined(); }); test('minLength accepts value equal to min', () => { - expect(minLength(10, i18n)('abracadbra')).toBeUndefined(); + expect(minLength(10)('abracadbra')).toBeUndefined(); }); test('minLength rejects value below min', () => { - expect(minLength(12, i18n)('abracadbra')).toEqual( - 'This field must be at least {min} characters' + expect(minLength(12)('abracadbra')).toEqual( + 'This field must be at least 12 characters' ); }); test('noWhiteSpace returns error', () => { - expect(noWhiteSpace(i18n)('this has spaces')).toEqual( + expect(noWhiteSpace()('this has spaces')).toEqual( 'This field must not contain spaces' ); - expect(noWhiteSpace(i18n)('this has\twhitespace')).toEqual( + expect(noWhiteSpace()('this has\twhitespace')).toEqual( 'This field must not contain spaces' ); - expect(noWhiteSpace(i18n)('this\nhas\nnewlines')).toEqual( + expect(noWhiteSpace()('this\nhas\nnewlines')).toEqual( 'This field must not contain spaces' ); }); test('noWhiteSpace should accept valid string', () => { - expect(noWhiteSpace(i18n)('this_has_no_whitespace')).toBeUndefined(); + expect(noWhiteSpace()('this_has_no_whitespace')).toBeUndefined(); }); test('integer should accept integer (number)', () => { - expect(integer(i18n)(13)).toBeUndefined(); + expect(integer()(13)).toBeUndefined(); }); test('integer should accept integer (string)', () => { - expect(integer(i18n)('13')).toBeUndefined(); + expect(integer()('13')).toBeUndefined(); }); test('integer should reject decimal/float', () => { - expect(integer(i18n)(13.1)).toEqual('This field must be an integer'); + expect(integer()(13.1)).toEqual('This field must be an integer'); }); test('integer should reject string containing alphanum', () => { - expect(integer(i18n)('15a')).toEqual('This field must be an integer'); + expect(integer()('15a')).toEqual('This field must be an integer'); }); test('number should accept number (number)', () => { - expect(number(i18n)(13)).toBeUndefined(); + expect(number()(13)).toBeUndefined(); }); test('number should accept number (string)', () => { - expect(number(i18n)('13')).toBeUndefined(); + expect(number()('13')).toBeUndefined(); }); test('number should accept negative number', () => { - expect(number(i18n)(-14)).toBeUndefined(); + expect(number()(-14)).toBeUndefined(); }); test('number should accept decimal/float', () => { - expect(number(i18n)(13.1)).toBeUndefined(); + expect(number()(13.1)).toBeUndefined(); }); test('number should accept large number', () => { - expect(number(i18n)(999999999999999999999.9)).toBeUndefined(); - expect(number(i18n)(-999999999999999999999.9)).toBeUndefined(); + expect(number()(999999999999999999999.9)).toBeUndefined(); + expect(number()(-999999999999999999999.9)).toBeUndefined(); }); test('number should reject string containing alphanum', () => { - expect(number(i18n)('15a')).toEqual('This field must be a number'); + expect(number()('15a')).toEqual('This field must be a number'); }); test('url should reject incomplete url', () => { - expect(url(i18n)('abcd')).toEqual('Please enter a valid URL'); + expect(url()('abcd')).toEqual('Please enter a valid URL'); }); test('url should accept fully qualified url', () => { - expect(url(i18n)('http://example.com/foo')).toBeUndefined(); + expect(url()('http://example.com/foo')).toBeUndefined(); }); test('url should accept url with query params', () => { - expect(url(i18n)('https://example.com/foo?bar=baz')).toBeUndefined(); + expect(url()('https://example.com/foo?bar=baz')).toBeUndefined(); }); test('url should reject short protocol', () => { - expect(url(i18n)('h://example.com/foo')).toEqual( - 'Please enter a valid URL' - ); + expect(url()('h://example.com/foo')).toEqual('Please enter a valid URL'); }); test('combine should run all validators', () => { - const validators = [required(null, i18n), noWhiteSpace(i18n)]; + const validators = [required(null), noWhiteSpace()]; expect(combine(validators)('')).toEqual('This field must not be blank'); expect(combine(validators)('one two')).toEqual( 'This field must not contain spaces' @@ -155,25 +149,23 @@ describe('validators', () => { }); test('combine should skip null validators', () => { - const validators = [required(null, i18n), null]; + const validators = [required(null), null]; expect(combine(validators)('')).toEqual('This field must not be blank'); expect(combine(validators)('ok')).toBeUndefined(); }); test('regExp rejects invalid regular expression', () => { - expect(regExp(i18n)('[')).toEqual( - 'This field must be a regular expression' - ); - expect(regExp(i18n)('')).toBeUndefined(); - expect(regExp(i18n)('ok')).toBeUndefined(); - expect(regExp(i18n)('[^a-zA-Z]')).toBeUndefined(); + expect(regExp()('[')).toEqual('This field must be a regular expression'); + expect(regExp()('')).toBeUndefined(); + expect(regExp()('ok')).toBeUndefined(); + expect(regExp()('[^a-zA-Z]')).toBeUndefined(); }); test('email validator rejects obviously invalid email ', () => { - expect(requiredEmail(i18n)('foobar321')).toEqual('Invalid email address'); + expect(requiredEmail()('foobar321')).toEqual('Invalid email address'); }); test('bob has email', () => { - expect(requiredEmail(i18n)('bob@localhost')).toBeUndefined(); + expect(requiredEmail()('bob@localhost')).toBeUndefined(); }); });