From 579136e7abad56c5f00ed98d9be8554178f1cbd3 Mon Sep 17 00:00:00 2001 From: Thuan Vo Date: Thu, 22 Aug 2024 17:56:45 -0700 Subject: [PATCH] chore: localize stored credentials table --- locales/en/common.json | 1 + locales/en/public.json | 8 ++ .../Credentials/StoredCredentials.tsx | 94 ++++++++++--------- 3 files changed, 60 insertions(+), 43 deletions(-) diff --git a/locales/en/common.json b/locales/en/common.json index 78fccfecd7..1e9645cf02 100644 --- a/locales/en/common.json +++ b/locales/en/common.json @@ -1,4 +1,5 @@ { + "ADD": "Add", "ARCHIVAL_PERIOD": "Archival Period", "AriaLabels": { "MAXIMUM_AGE": "Maximum age value", diff --git a/locales/en/public.json b/locales/en/public.json index 78fb4fae99..75af478fd4 100644 --- a/locales/en/public.json +++ b/locales/en/public.json @@ -437,6 +437,14 @@ "TABLE": "Shortcuts table" } }, + "StoredCredentials": { + "ARIA_LABELS": { + "Add": "add-credential", + "Delete": "delete-selected-credential" + }, + "AT_LEAST_ONE_MATCH": ">= 1 Match Only", + "NO_MATCH": "No Match Only" + }, "TargetContextSelector": { "CLEAR_SELECTION": "Clear selection", "CREATE_TARGET": "Create Target", diff --git a/src/app/SecurityPanel/Credentials/StoredCredentials.tsx b/src/app/SecurityPanel/Credentials/StoredCredentials.tsx index a53fe5ff83..490e42b508 100644 --- a/src/app/SecurityPanel/Credentials/StoredCredentials.tsx +++ b/src/app/SecurityPanel/Credentials/StoredCredentials.tsx @@ -32,9 +32,6 @@ import { Text, TextContent, TextVariants, - Toolbar, - ToolbarContent, - ToolbarItem, EmptyStateHeader, Dropdown, DropdownList, @@ -42,10 +39,13 @@ import { MenuToggleElement, MenuToggle, MenuToggleCheckbox, + ActionList, + ActionListItem, } from '@patternfly/react-core'; import { OutlinedQuestionCircleIcon, SearchIcon } from '@patternfly/react-icons'; import { ExpandableRowContent, Table, Tbody, Td, Th, Thead, Tr } from '@patternfly/react-table'; import * as React from 'react'; +import { useTranslation } from 'react-i18next'; import { forkJoin } from 'rxjs'; import { SecurityCard } from '../types'; import { CreateCredentialModal } from './CreateCredentialModal'; @@ -181,6 +181,7 @@ const tableColumns: TableColumn[] = [ const tableTitle = 'Stored Credentials'; export const StoredCredentials = () => { + const { t } = useTranslation(); const context = React.useContext(ServiceContext); const [state, dispatch] = React.useReducer(reducer, { credentials: [] as StoredCredential[], @@ -278,49 +279,51 @@ export const StoredCredentials = () => { setWarningModalOpen(false); }, [setWarningModalOpen]); - const TargetCredentialsToolbar = () => { - const buttons = React.useMemo(() => { - const arr = [ - , - , - ]; - return ( - <> - {arr.map((btn, idx) => ( - {btn} - ))} - - ); - }, []); + const targetCredentialsToolbar = React.useMemo(() => { + const buttons = [ + , + , + ]; - const deleteCredentialModal = React.useMemo(() => { - return ( + return ( + <> + + {buttons.map((btn, idx) => ( + {btn} + ))} + - ); - }, []); - - return ( - - {buttons} - {deleteCredentialModal} - + ); - }; + }, [ + t, + handleAuthModalOpen, + handleDeleteButton, + warningModalOpen, + handleDeleteCredentials, + handleWarningModalClose, + state.checkedCredentials.length, + ]); const matchExpressionRows = React.useMemo(() => { return sortResources(sortBy, state.credentials, tableColumns).map((credential, idx) => { @@ -414,7 +417,7 @@ export const StoredCredentials = () => { <> No{tableTitle}} + titleText={<>No {tableTitle}} icon={} headingLevel="h4" /> @@ -455,7 +458,7 @@ export const StoredCredentials = () => { return ( <> - + {targetCredentialsToolbar} {content} = ({ onSelectAll, isSelectAll, }) => { + const { t } = useTranslation(); const [isOpen, setIsOpen] = React.useState(false); const handleToggle = React.useCallback(() => setIsOpen((isOpen) => !isOpen), [setIsOpen]); @@ -486,11 +490,13 @@ export const CheckBoxActions: React.FC = ({ const dropdownItems = React.useMemo(() => { return [ - No Match Only + {t('StoredCredentials.NO_MATCH')} + , + + {t('StoredCredentials.AT_LEAST_ONE_MATCH')} , - {`>= 1 Match Only`}, ]; - }, [onNoMatchSelect, onAtLeastOneMatchSelect]); + }, [onNoMatchSelect, onAtLeastOneMatchSelect, t]); const toggle = React.useCallback( (toggleRef: React.Ref) => ( @@ -520,6 +526,8 @@ export const CheckBoxActions: React.FC = ({ }} toggle={toggle} isOpen={isOpen} + onOpenChange={setIsOpen} + onOpenChangeKeys={['Escape']} popperProps={{ appendTo: portalRoot, }}