Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

i18n support in devconsole Gitops and Guided tour components #7137

Merged
merged 1 commit into from
Nov 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
28 changes: 27 additions & 1 deletion frontend/packages/dev-console/locales/en/devconsole.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,34 @@
"Cancel": "Cancel",
"Edit": "Edit",
"Select a way to create an application, component or service from one of the options.": "Select a way to create an application, component or service from one of the options.",
" by ": " by ",
"Commit details not available": "Commit details not available",
"Cluster URL not available": "Cluster URL not available",
"Application Stages": "Application Stages",
"Application Details": "Application Details",
"Manifest File Repo": "Manifest File Repo",
"Image not available": "Image not available",
"Service source URL not available": "Service source URL not available",
"Pod Info Not Available": "Pod Info Not Available",
"Info not available": "Info not available",
"Environment details were not found. Try reloading the page or contacting an administrator.": "Environment details were not found. Try reloading the page or contacting an administrator.",
"{{appName}} · Details": "{{appName}} · Details",
"Argo CD": "Argo CD",
"{{count, number}} item": "{{count, number}} item",
"{{count, number}} item_plural": "{{count, number}} items",
"{{count, number}} Environment": "{{count, number}} Environment",
"{{count, number}} Environment_plural": "{{count, number}} Environments",
"No GitOps Manifest URLs found": "No GitOps Manifest URLs found",
"No Application groups found": "No Application groups found",
"Get started with a tour of some of the key areas in OpenShift {{version}} Developer perspective that can help you complete workflows and be more productive.": "Get started with a tour of some of the key areas in OpenShift {{version}} Developer perspective that can help you complete workflows and be more productive.",
"Switch between the Developer and Administrator perspectives.": "Switch between the Developer and Administrator perspectives.",
"Use the Administrator perspective to manage workload storage, networking, cluster settings, and more. This may require additional user access.": "Use the Administrator perspective to manage workload storage, networking, cluster settings, and more. This may require additional user access.",
"Use the Developer perspective to build applications and associated components and services, define how they work together, and monitor their health over time.": "Use the Developer perspective to build applications and associated components and services, define how they work together, and monitor their health over time.",
"Search for resources in your project by simply starting to type or scrolling through a list of existing resources.": "Search for resources in your project by simply starting to type or scrolling through a list of existing resources.",
"Add frequently accessed resources to your side navigation for quick access. Look for the": "Add frequently accessed resources to your side navigation for quick access. Look for the",
"Add to navigation": "Add to navigation",
"link next to your search result.": "link next to your search result.",
"Stay up-to-date with everything OpenShift on our <2>blog</2> or continue to learn more in our <6>documentation</6>.": "Stay up-to-date with everything OpenShift on our <2>blog</2> or continue to learn more in our <6>documentation</6>.",
"Edit Health Checks": "Edit Health Checks",
"Add Health Checks": "Add Health Checks",
"Learn More": "Learn More",
Expand Down Expand Up @@ -403,7 +430,6 @@
"+Add": "+Add",
"Topology": "Topology",
"Search": "Search",
"Application Stages": "Application Stages",
"Helm": "Helm",
"Developer": "Developer",
"Create an application from a code sample": "Create an application from a code sample",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as React from 'react';
import Helmet from 'react-helmet';
import { useTranslation } from 'react-i18next';
import { RouteComponentProps } from 'react-router-dom';
import * as _ from 'lodash';
import { LoadingBox } from '@console/internal/components/utils';
Expand All @@ -18,6 +19,7 @@ import GitOpsDetailsController from './details/GitOpsDetailsController';
type GitOpsDetailsPageProps = RouteComponentProps<{ appName?: string }>;

const GitOpsDetailsPage: React.FC<GitOpsDetailsPageProps> = ({ match, location }) => {
const { t } = useTranslation();
const [envs, setEnvs] = React.useState<string[]>(null);
const [envsData, setEnvsData] = React.useState<GitOpsEnvironment[]>(null);
const [emptyStateMsg, setEmptyStateMsg] = React.useState(null);
Expand All @@ -42,8 +44,9 @@ const GitOpsDetailsPage: React.FC<GitOpsDetailsPageProps> = ({ match, location }
if (ignore) return;
const app = _.find(appGroups, (appObj) => appName === appObj?.name);
if (!app?.environments) {
emptyMsg =
'Environment details were not found. Try reloading the page or contacting an administrator.';
emptyMsg = t(
'devconsole~Environment details were not found. Try reloading the page or contacting an administrator.',
);
}
setEmptyStateMsg(emptyMsg);
setEnvs(app?.environments);
Expand All @@ -54,7 +57,7 @@ const GitOpsDetailsPage: React.FC<GitOpsDetailsPageProps> = ({ match, location }
return () => {
ignore = true;
};
}, [appName, manifestURL, pipelinesBaseURI]);
}, [appName, manifestURL, pipelinesBaseURI, t]);

React.useEffect(() => {
const getEnvsData = async () => {
Expand All @@ -75,7 +78,7 @@ const GitOpsDetailsPage: React.FC<GitOpsDetailsPageProps> = ({ match, location }
return (
<>
<Helmet>
<title>{`${appName} · Details`}</title>
<title>{t('devconsole~{{appName}} · Details', { appName })}</title>
</Helmet>
<GitOpsDetailsPageHeading
url={match.url}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as React from 'react';
import Helmet from 'react-helmet';
import { useTranslation } from 'react-i18next';
import { PageHeading, LoadingBox, ExternalLink } from '@console/internal/components/utils';
import { ProjectModel, ConsoleLinkModel } from '@console/internal/models';
import { useK8sWatchResource } from '@console/internal/components/utils/k8s-watch-hook';
Expand All @@ -20,14 +21,15 @@ const GitOpsListPage: React.FC = () => {
const [namespaces, nsLoaded, nsError] = useK8sWatchResource<K8sResourceKind[]>(projectRes);
const [secretNS, secretName] = useDefaultSecret();
const baseURL = getPipelinesBaseURI(secretNS, secretName);
const { t } = useTranslation();

React.useEffect(() => {
let ignore = false;

const getAppGroups = async () => {
if (nsLoaded) {
const manifestURLs = (!nsError && getManifestURLs(namespaces)) || [];
const [allAppGroups, emptyMsg] = await fetchAllAppGroups(baseURL, manifestURLs);
const [allAppGroups, emptyMsg] = await fetchAllAppGroups(baseURL, manifestURLs, t);
if (ignore) return;
setAppGroups(allAppGroups);
setEmptyStateMsg(emptyMsg);
Expand All @@ -39,7 +41,7 @@ const GitOpsListPage: React.FC = () => {
return () => {
ignore = true;
};
}, [baseURL, namespaces, nsError, nsLoaded]);
}, [baseURL, namespaces, nsError, nsLoaded, t]);

const [consoleLinks] = useK8sWatchResource<K8sResourceKind[]>({
isList: true,
Expand All @@ -55,14 +57,16 @@ const GitOpsListPage: React.FC = () => {
return (
<>
<Helmet>
<title>Application Stages</title>
<title>{t('devconsole~Application Stages')}</title>
</Helmet>
<PageHeading
title="Application Stages"
title={t('devconsole~Application Stages')}
badge={
<Split className="odc-gitops-list-page-heading" hasGutter>
<SplitItem>
{argocdLink && <ExternalLink href={argocdLink.spec.href} text="Argo CD" />}
{argocdLink && (
<ExternalLink href={argocdLink.spec.href} text={t('devconsole~Argo CD')} />
)}
</SplitItem>
<SplitItem>
<DevPreviewBadge />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as React from 'react';
import * as _ from 'lodash';
import { useTranslation } from 'react-i18next';
// FIXME upgrading redux types is causing many errors at this time
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
// @ts-ignore
Expand All @@ -17,6 +18,7 @@ interface CommitDetailsProps {
const CommitDetails: React.FC<CommitDetailsProps> = ({ imageName }) => {
const [commitData, setCommitData] = React.useState<CommitData>(null);
const namespace = useSelector(getActiveNamespace);
const { t } = useTranslation();
const importImage = imageName && {
kind: 'ImageStreamImport',
apiVersion: 'image.openshift.io/v1',
Expand Down Expand Up @@ -80,11 +82,11 @@ const CommitDetails: React.FC<CommitDetailsProps> = ({ imageName }) => {
<>
<Timestamp timestamp={commitData.timestamp} />
{commitData.id}
{' by '}
{t('devconsole~ by ')}
{commitData.author}
</>
) : (
<span>Commit details not available</span>
<span>{t('devconsole~Commit details not available')}</span>
)}
</>
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as React from 'react';
import * as _ from 'lodash';
import { useTranslation } from 'react-i18next';
import { Stack, StackItem, Card, CardTitle, SplitItem, Split, Label } from '@patternfly/react-core';
import { ExternalLink, ResourceIcon } from '@console/internal/components/utils';
import GitOpsServiceDetailsSection from './GitOpsServiceDetailsSection';
Expand All @@ -11,6 +12,7 @@ interface GitOpsDetailsProps {
}

const GitOpsDetails: React.FC<GitOpsDetailsProps> = ({ envs }) => {
const { t } = useTranslation();
return (
<div className="odc-gitops-details">
{_.map(
Expand Down Expand Up @@ -51,7 +53,7 @@ const GitOpsDetails: React.FC<GitOpsDetailsProps> = ({ envs }) => {
/>
) : (
<div className="odc-gitops-details__env-section__url-empty-state">
Cluster URL not available
{t('devconsole~Cluster URL not available')}
</div>
)}
</StackItem>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ const GitOpsDetailsPageHeading: React.FC<GitOpsDetailsPageHeadingProps> = ({
const { t } = useTranslation();
const breadcrumbs = [
{
name: 'Application Stages',
name: t('devconsole~Application Stages'),
path: '/applicationstages',
},
{
name: 'Application Details',
name: t('devconsole~Application Details'),
path: `${url}`,
},
];
Expand All @@ -41,7 +41,7 @@ const GitOpsDetailsPageHeading: React.FC<GitOpsDetailsPageHeadingProps> = ({
{badge && <span className="co-m-pane__heading-badge">{badge}</span>}
</h1>
<Split className="odc-gitops-details-page-heading__repo" hasGutter>
<SplitItem>Manifest File Repo:</SplitItem>
<SplitItem>{t('devconsole~Manifest File Repo')}:</SplitItem>
<SplitItem isFilled>
<Label
style={{ fontSize: '12px' }}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as React from 'react';
import * as _ from 'lodash';
import { useTranslation } from 'react-i18next';
import {
StackItem,
Card,
Expand All @@ -18,6 +19,7 @@ interface GitOpsServiceDetailsSectionProps {
}

const GitOpsServiceDetailsSection: React.FC<GitOpsServiceDetailsSectionProps> = ({ services }) => {
const { t } = useTranslation();
return (
<>
{_.map(
Expand All @@ -35,7 +37,7 @@ const GitOpsServiceDetailsSection: React.FC<GitOpsServiceDetailsSectionProps> =
</CardTitle>
<CardBody>
<Label className="co-nowrap" style={{ fontSize: '12px' }} color="cyan">
{service.image || <div>Image not available</div>}
{service.image || <div>{t('devconsole~Image not available')}</div>}
</Label>
<Split className="odc-gitops-service__details">
<SplitItem>
Expand All @@ -58,7 +60,7 @@ const GitOpsServiceDetailsSection: React.FC<GitOpsServiceDetailsSectionProps> =
/>
) : (
<div className="odc-gitops-service__details">
Service source URL not available
{t('devconsole~Service source URL not available')}
</div>
)}
</CardBody>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as React from 'react';
import * as _ from 'lodash';
import { useTranslation } from 'react-i18next';
import { PodModel } from '@console/internal/models';
import { useK8sWatchResource } from '@console/internal/components/utils/k8s-watch-hook';
import { K8sResourceKind, modelFor } from '@console/internal/module/k8s';
Expand All @@ -12,6 +13,7 @@ interface PodRingWrapperProps {
}

const PodRingWrapper: React.FC<PodRingWrapperProps> = ({ workload }) => {
const { t } = useTranslation();
const workloadResource = React.useMemo(
() => ({
kind: workload?.kind,
Expand Down Expand Up @@ -51,7 +53,7 @@ const PodRingWrapper: React.FC<PodRingWrapperProps> = ({ workload }) => {
enableScaling={false}
/>
) : (
<div style={{ border: '1px solid' }}>Pod Info Not Available</div>
<div style={{ border: '1px solid' }}>{t('devconsole~Pod Info Not Available')}</div>
)}
</>
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as React from 'react';
import * as _ from 'lodash';
import { useTranslation } from 'react-i18next';
import { useK8sWatchResources } from '@console/internal/components/utils/k8s-watch-hook';
import { Timestamp } from '@console/internal/components/utils';
import {
Expand All @@ -16,6 +17,7 @@ interface TimestampWrapperProps {

const TimestampWrapper: React.FC<TimestampWrapperProps> = ({ resModels }) => {
const [lastUpdatedTimestamp, setLastUpdatedTimestamp] = React.useState<number>(null);
const { t } = useTranslation();
const memoResources = React.useMemo(() => {
let resources = {};
_.forEach(resModels, (res) => {
Expand Down Expand Up @@ -55,7 +57,7 @@ const TimestampWrapper: React.FC<TimestampWrapperProps> = ({ resModels }) => {
{lastUpdatedTimestamp ? (
<Timestamp timestamp={lastUpdatedTimestamp} />
) : (
<div>Info not available</div>
<div>{t('devconsole~Info not available')}</div>
)}
</>
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,36 +1,44 @@
import * as React from 'react';
import * as _ from 'lodash';
import { useTranslation } from 'react-i18next';
import GitOpsListItem from './GitOpsListItem';
import { Stack, StackItem, Split, SplitItem } from '@patternfly/react-core';
import { GitOpsAppGroupData } from '../utils/gitops-types';
import './GitOpsList.scss';
import GitOpsEmptyState from '../GitOpsEmptyState';
import './GitOpsList.scss';

interface GitOpsListProps {
appGroups: GitOpsAppGroupData[];
emptyStateMsg: string;
}

const GitOpsList: React.FC<GitOpsListProps> = ({ appGroups, emptyStateMsg }) => (
<div className="odc-gitops-list">
{!emptyStateMsg ? (
<Stack hasGutter>
<StackItem>
<Split>
<SplitItem isFilled />
<SplitItem>{`${_.size(appGroups)} items`}</SplitItem>
</Split>
</StackItem>
{_.map(appGroups, (appGroup) => (
<StackItem key={`${appGroup.name}-${appGroup.repo_url}`}>
<GitOpsListItem appGroup={appGroup} />
const GitOpsList: React.FC<GitOpsListProps> = ({ appGroups, emptyStateMsg }) => {
const { t } = useTranslation();
return (
<div className="odc-gitops-list">
{!emptyStateMsg ? (
<Stack hasGutter>
<StackItem>
<Split>
<SplitItem isFilled />
<SplitItem>
{t('devconsole~{{count, number}} item', {
count: _.size(appGroups),
})}
</SplitItem>
</Split>
</StackItem>
))}
</Stack>
) : (
<GitOpsEmptyState emptyStateMsg={emptyStateMsg} />
)}
</div>
);
{_.map(appGroups, (appGroup) => (
<StackItem key={`${appGroup.name}-${appGroup.repo_url}`}>
<GitOpsListItem appGroup={appGroup} />
</StackItem>
))}
</Stack>
) : (
<GitOpsEmptyState emptyStateMsg={emptyStateMsg} />
)}
</div>
);
};

export default GitOpsList;
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as React from 'react';
import * as _ from 'lodash';
import { useTranslation } from 'react-i18next';
import { Grid, GridItem, Card, CardBody } from '@patternfly/react-core';
import { history, ResourceLink } from '@console/internal/components/utils';
import { GitOpsAppGroupData } from '../utils/gitops-types';
Expand All @@ -10,6 +11,7 @@ interface GitOpsListItemProps {
}

const GitOpsListItem: React.FC<GitOpsListItemProps> = ({ appGroup }) => {
const { t } = useTranslation();
const handleCardClick = () => {
history.push(`/applicationstages/${appGroup.name}?url=${appGroup.repo_url}`);
};
Expand All @@ -22,7 +24,9 @@ const GitOpsListItem: React.FC<GitOpsListItemProps> = ({ appGroup }) => {
<ResourceLink kind="application" name={appGroup.name} linkTo={false} />
</GridItem>
<GridItem lg={6} md={6} sm={6}>
{`${_.size(appGroup.environments)} Environments`}
{t('devconsole~{{count, number}} Environment', {
count: _.size(appGroup.environments),
})}
</GridItem>
</Grid>
</CardBody>
Expand Down