Skip to content

Commit

Permalink
Merge pull request #9605 from debsmita1/i18n-trigger-modal
Browse files Browse the repository at this point in the history
Bug 1982727: i18n misses in add trigger modal
  • Loading branch information
openshift-merge-robot committed Jul 23, 2021
2 parents 27f0912 + a91a9ee commit bc01495
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@
"Services": "Services",
"Subscription details": "Subscription details",
"Trigger details": "Trigger details",
"Attribute": "Attribute",
"No Subscriber available": "No Subscriber available",
"To create a Subscriber, first create a Knative Service from the Add page.": "To create a Subscriber, first create a Knative Service from the Add page.",
"Select Subscriber": "Select Subscriber",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const PubSub: React.FC<PubSubProps> = ({
} = target;
const getResourceModel = () =>
sourceKind === EventingBrokerModel.kind ? EventingTriggerModel : EventingSubscriptionModel;
const { kind, apiVersion, apiGroup } = getResourceModel();
const { kind, apiVersion, apiGroup, labelKey } = getResourceModel();
const getSpecForKind = (connectorSourceKind: string) => {
let spec = {};
if (connectorSourceKind === EventingTriggerModel.kind) {
Expand Down Expand Up @@ -79,7 +79,9 @@ const PubSub: React.FC<PubSubProps> = ({
});
};

const labelTitle = t('knative-plugin~Add {{kind}}', { kind });
const labelTitle = t('knative-plugin~Add {{kind}}', {
kind: t(labelKey) || kind,
});
return (
<Formik
initialValues={initialValues}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@ import * as React from 'react';
import { FormGroup } from '@patternfly/react-core';
import { useFormikContext, FormikValues } from 'formik';
import * as _ from 'lodash';
import { useTranslation } from 'react-i18next';
import { NameValueEditor } from '@console/internal/components/utils/name-value-editor';
import { getFieldId } from '@console/shared';

const PubSubFilter: React.FC = () => {
const initialValueResources = [['', '']];
const { setFieldValue, status } = useFormikContext<FormikValues>();
const [nameValue, setNameValue] = React.useState(initialValueResources);
const { t } = useTranslation();
const handleNameValuePairs = React.useCallback(
({ nameValuePairs }) => {
let updatedNameValuePairs = {};
Expand All @@ -25,15 +27,15 @@ const PubSubFilter: React.FC = () => {
[setFieldValue],
);
return (
<FormGroup fieldId={getFieldId('pubsub', 'filter')} label="Filter" required>
<FormGroup fieldId={getFieldId('pubsub', 'filter')} label={t('knative-plugin~Filter')} required>
<NameValueEditor
nameValuePairs={status.subscriberAvailable ? nameValue : []}
valueString="Value"
nameString="Attribute"
valueString={t('knative-plugin~Value')}
nameString={t('knative-plugin~Attribute')}
readOnly={!status.subscriberAvailable}
allowSorting={false}
updateParentData={handleNameValuePairs}
addString="Add More"
addString={t('knative-plugin~Add more')}
/>
</FormGroup>
);
Expand Down

0 comments on commit bc01495

Please sign in to comment.