locale added all case conversion

Signed-off-by: erdoganoksuz <erdoganoksuz95@gmail.com>
This commit is contained in:
erdoganoksuz
2021-03-12 15:06:01 +03:00
parent 37189b54ab
commit 9ca0e40094
31 changed files with 93 additions and 51 deletions
+22
View File
@@ -0,0 +1,22 @@
---
'example-app': patch
'@backstage/core': patch
'@backstage/create-app': patch
'@backstage/plugin-api-docs': patch
'@backstage/plugin-bitrise': patch
'@backstage/plugin-catalog': patch
'@backstage/plugin-catalog-import': patch
'@backstage/plugin-catalog-react': patch
'@backstage/plugin-circleci': patch
'@backstage/plugin-cloudbuild': patch
'@backstage/plugin-explore': patch
'@backstage/plugin-github-actions': patch
'@backstage/plugin-jenkins': patch
'@backstage/plugin-kubernetes': patch
'@backstage/plugin-lighthouse': patch
'@backstage/plugin-org': patch
'@backstage/plugin-scaffolder': patch
'@backstage/plugin-search': patch
---
use local version of lowerCase and upperCase methods
@@ -484,7 +484,7 @@ const DomainEntityPage = ({ entity }: { entity: Entity }) => (
export const EntityPage = () => {
const { entity } = useEntity();
switch (entity?.kind?.toLowerCase()) {
switch (entity?.kind?.toLocaleLowerCase('en-US')) {
case 'component':
return <ComponentEntityPage entity={entity} />;
case 'api':
+4 -1
View File
@@ -58,7 +58,10 @@ export const defaultConfigLoader: AppConfigLoader = async (
const configs = (appConfig.slice() as unknown) as AppConfig[];
// Avoiding this string also being replaced at runtime
if (runtimeConfigJson !== '__app_injected_runtime_config__'.toUpperCase()) {
if (
runtimeConfigJson !==
'__app_injected_runtime_config__'.toLocaleUpperCase('en-US')
) {
try {
const data = JSON.parse(runtimeConfigJson) as JsonObject;
if (Array.isArray(data)) {
@@ -213,8 +213,8 @@ export const SubvalueTable = () => {
row: any, // Only needed if you want subvalue searchable
) =>
`${row.col1} ${row.subvalue}`
.toUpperCase()
.includes(query.toUpperCase()),
.toLocaleUpperCase('en-US')
.includes(query.toLocaleUpperCase('en-US')),
field: 'col1',
highlight: true,
render: (row: any): React.ReactNode => (
@@ -81,7 +81,7 @@ type Props = {
};
const capitalize = (s: string) => {
return s.charAt(0).toUpperCase() + s.slice(1);
return s.charAt(0).toLocaleUpperCase('en-US') + s.slice(1);
};
/**
@@ -184,7 +184,7 @@ const ApiEntityPage = ({ entity }: { entity: Entity }) => (
export const EntityPage = () => {
const { entity } = useEntity();
switch (entity?.kind?.toLowerCase()) {
switch (entity?.kind?.toLocaleLowerCase('en-US')) {
case 'component':
return <ComponentEntityPage entity={entity} />;
case 'api':
@@ -74,7 +74,8 @@ export const ConsumedApisCard = ({ variant = 'gridItem' }: Props) => {
emptyContent={
<div style={{ textAlign: 'center' }}>
<Typography variant="body1">
This {entity.kind.toLowerCase()} does not consume any APIs.
This {entity.kind.toLocaleLowerCase('en-US')} does not consume any
APIs.
</Typography>
<Typography variant="body2">
<Link to="https://backstage.io/docs/features/software-catalog/descriptor-format#specconsumesapis-optional">
@@ -78,7 +78,8 @@ export const HasApisCard = ({ variant = 'gridItem' }: Props) => {
emptyContent={
<div style={{ textAlign: 'center' }}>
<Typography variant="body1">
This {entity.kind.toLowerCase()} does not contain any APIs.
This {entity.kind.toLocaleLowerCase('en-US')} does not contain any
APIs.
</Typography>
<Typography variant="body2">
<Link to="https://backstage.io/docs/features/software-catalog/descriptor-format#kind-api">
@@ -74,7 +74,8 @@ export const ProvidedApisCard = ({ variant = 'gridItem' }: Props) => {
emptyContent={
<div style={{ textAlign: 'center' }}>
<Typography variant="body1">
This {entity.kind.toLowerCase()} does not provide any APIs.
This {entity.kind.toLocaleLowerCase('en-US')} does not provide any
APIs.
</Typography>
<Typography variant="body2">
<Link to="https://backstage.io/docs/features/software-catalog/descriptor-format#specprovidesapis-optional">
@@ -162,8 +162,8 @@ export const BitriseBuildsTable = ({
title: 'Branch',
customFilterAndSearch: (query, row: any) =>
`${row.message} ${row.workflow}`
.toUpperCase()
.includes(query.toUpperCase()),
.toLocaleUpperCase('en-US')
.includes(query.toLocaleUpperCase('en-US')),
field: 'message',
width: 'auto',
highlight: true,
@@ -54,7 +54,7 @@ function sortEntities(entities: Array<EntityName | Entity>) {
}
function getEntityIcon(entity: { kind: string }): React.ReactElement {
switch (entity.kind.toLowerCase()) {
switch (entity.kind.toLocaleLowerCase('en-US')) {
case 'api':
return <ExtensionIcon />;
@@ -48,11 +48,12 @@ export const EntityRefLink = forwardRef<any, EntityRefLinkProps>(
name = entityRef.name;
}
kind = kind.toLowerCase();
kind = kind.toLocaleLowerCase('en-US');
const routeParams = {
kind,
namespace: namespace?.toLowerCase() ?? ENTITY_DEFAULT_NAMESPACE,
namespace:
namespace?.toLocaleLowerCase('en-US') ?? ENTITY_DEFAULT_NAMESPACE,
name,
};
@@ -39,10 +39,10 @@ type Props = {
export const AboutContent = ({ entity }: Props) => {
const classes = useStyles();
const isSystem = entity.kind.toLowerCase() === 'system';
const isDomain = entity.kind.toLowerCase() === 'domain';
const isResource = entity.kind.toLowerCase() === 'resource';
const isComponent = entity.kind.toLowerCase() === 'component';
const isSystem = entity.kind.toLocaleLowerCase('en-US') === 'system';
const isDomain = entity.kind.toLocaleLowerCase('en-US') === 'domain';
const isResource = entity.kind.toLocaleLowerCase('en-US') === 'resource';
const isComponent = entity.kind.toLocaleLowerCase('en-US') === 'component';
const partOfSystemRelations = getEntityRelations(entity, RELATION_PART_OF, {
kind: 'system',
});
@@ -69,10 +69,10 @@ const headerProps = (
: ''
}`,
headerType: (() => {
let t = kind.toLowerCase();
let t = kind.toLocaleLowerCase('en-US');
if (entity && entity.spec && 'type' in entity.spec) {
t += ' — ';
t += (entity.spec as { type: string }).type.toLowerCase();
t += (entity.spec as { type: string }).type.toLocaleLowerCase('en-US');
}
return t;
})(),
@@ -88,10 +88,10 @@ const headerProps = (
: ''
}`,
headerType: (() => {
let t = kind.toLowerCase();
let t = kind.toLocaleLowerCase('en-US');
if (entity && entity.spec && 'type' in entity.spec) {
t += ' — ';
t += (entity.spec as { type: string }).type.toLowerCase();
t += (entity.spec as { type: string }).type.toLocaleLowerCase('en-US');
}
return t;
})(),
+2 -1
View File
@@ -63,7 +63,8 @@ const EntityPageSwitch = ({ EntityPage }: { EntityPage: ComponentType }) => {
const OldEntityRouteRedirect = () => {
const { optionalNamespaceAndName, '*': rest } = useParams() as any;
const [name, namespace] = optionalNamespaceAndName.split(':').reverse();
const namespaceLower = namespace?.toLowerCase() ?? ENTITY_DEFAULT_NAMESPACE;
const namespaceLower =
namespace?.toLocaleLowerCase('en-US') ?? ENTITY_DEFAULT_NAMESPACE;
const restWithSlash = rest ? `/${rest}` : '';
return (
<Navigate
@@ -79,7 +79,7 @@ export type CITableBuildInfo = {
// retried, canceled, infrastructure_fail, timedout, not_run, running, failed, queued, scheduled, not_running, no_tests, fixed, success
const getStatusComponent = (status: string | undefined = '') => {
switch (status.toLowerCase()) {
switch (status.toLocaleLowerCase('en-US')) {
case 'queued':
case 'scheduled':
return <StatusPending />;
@@ -29,7 +29,7 @@ export const WorkflowRunStatus = ({
status: string | undefined;
}) => {
if (status === undefined) return null;
switch (status.toLowerCase()) {
switch (status.toLocaleLowerCase('en-US')) {
case 'queued':
return (
<>
@@ -76,13 +76,13 @@ export const ToolCard = ({ card, objectFit }: Props) => {
<CardContent>
<Typography paragraph variant="h5">
{title}{' '}
{lifecycle && lifecycle.toLowerCase() !== 'ga' && (
{lifecycle && lifecycle.toLocaleLowerCase('en-US') !== 'ga' && (
<Chip
size="small"
label={lifecycle}
className={classNames(
classes.lifecycle,
classes[lifecycle.toLowerCase()],
classes[lifecycle.toLocaleLowerCase('en-US')],
)}
/>
)}
@@ -88,8 +88,8 @@ const StepView = ({ step }: { step: Step }) => {
</TableCell>
<TableCell>
<WorkflowRunStatus
status={step.status.toUpperCase()}
conclusion={step.conclusion?.toUpperCase()}
status={step.status.toLocaleUpperCase('en-US')}
conclusion={step.conclusion?.toLocaleUpperCase('en-US')}
/>
</TableCell>
</TableRow>
@@ -32,7 +32,7 @@ export const WorkflowRunStatus = ({
conclusion: string | undefined;
}) => {
if (status === undefined) return null;
switch (status.toLowerCase()) {
switch (status.toLocaleLowerCase('en-US')) {
case 'queued':
return (
<>
@@ -46,7 +46,7 @@ export const WorkflowRunStatus = ({
</>
);
case 'completed':
switch (conclusion?.toLowerCase()) {
switch (conclusion?.toLocaleLowerCase('en-US')) {
case 'skipped' || 'canceled':
return (
<>
@@ -30,7 +30,7 @@ export const JenkinsRunStatus = ({
status: string | undefined;
}) => {
if (status === undefined) return null;
switch (status.toLowerCase()) {
switch (status.toLocaleLowerCase('en-US')) {
case 'queued':
case 'scheduled':
return (
@@ -18,7 +18,8 @@ import React from 'react';
import { KubernetesDrawer } from '../KubernetesDrawer/KubernetesDrawer';
import { Typography, Grid } from '@material-ui/core';
const capitalize = (str: string) => str.charAt(0).toUpperCase() + str.slice(1);
const capitalize = (str: string) =>
str.charAt(0).toLocaleUpperCase('en-US') + str.slice(1);
export const DefaultCustomResourceDrawer = ({
customResource,
@@ -106,7 +106,7 @@ export const AuditListTable = ({ items }: { items: Website[] }) => {
lastReport: (
<>
<AuditStatusIcon audit={website.lastAudit} />{' '}
<span>{website.lastAudit.status.toUpperCase()}</span>
<span>{website.lastAudit.status.toLocaleUpperCase('en-US')}</span>
</>
),
lastAuditTriggered: formatTime(website.lastAudit.timeCreated),
@@ -59,7 +59,7 @@ const LighthouseCategoryScoreStatus = ({ score }: { score: number }) => {
const LighthouseAuditStatus = ({ audit }: { audit: Audit }) => (
<>
<AuditStatusIcon audit={audit} />
{audit.status.toUpperCase()}
{audit.status.toLocaleUpperCase('en-US')}
</>
);
@@ -125,13 +125,15 @@ export const MembersListCard = (_props: {
kind: 'User',
},
});
const groupMembersList = ((membersList.items as unknown) as Array<UserEntity>).filter(
member =>
member?.relations?.some(
r =>
r.type === RELATION_MEMBER_OF &&
r.target.name.toLowerCase() === groupName.toLowerCase(),
),
const groupMembersList = ((membersList.items as unknown) as Array<
UserEntity
>).filter(member =>
member?.relations?.some(
r =>
r.type === RELATION_MEMBER_OF &&
r.target.name.toLocaleLowerCase('en-US') ===
groupName.toLocaleLowerCase('en-US'),
),
);
return groupMembersList;
}, [catalogApi]);
@@ -100,7 +100,9 @@ describe('Results Filter', () => {
);
for (const category of categories) {
expect(
await findByText(category.charAt(0).toUpperCase() + category.slice(1)),
await findByText(
category.charAt(0).toLocaleUpperCase('en-US') + category.slice(1),
),
).toBeInTheDocument();
}
});
@@ -107,7 +107,10 @@ export const ResultsFilter = ({ availableCategories }: Props) => {
/>
<ListItemText
id={labelId}
primary={category.charAt(0).toUpperCase() + category.slice(1)}
primary={
category.charAt(0).toLocaleUpperCase('en-US') +
category.slice(1)
}
/>
</ListItem>
);
@@ -105,8 +105,8 @@ export const ScaffolderPageContents = () => {
);
const matchesQuery = (metadata: EntityMeta, query: string) =>
`${metadata.title}`.toUpperCase().includes(query) ||
metadata.tags?.join('').toUpperCase().indexOf(query) !== -1;
`${metadata.title}`.toLocaleUpperCase('en-US').includes(query) ||
metadata.tags?.join('').toLocaleUpperCase('en-US').indexOf(query) !== -1;
useEffect(() => {
if (search.length === 0) {
@@ -114,7 +114,7 @@ export const ScaffolderPageContents = () => {
}
return setMatchingEntities(
filteredEntities.filter(template =>
matchesQuery(template.metadata, search.toUpperCase()),
matchesQuery(template.metadata, search.toLocaleUpperCase('en-US')),
),
);
}, [search, filteredEntities]);
@@ -56,7 +56,9 @@ export const SearchPage = () => {
/>
</Grid>
<Grid item xs={12}>
<SearchResult searchQuery={(queryString ?? '').toLowerCase()} />
<SearchResult
searchQuery={(queryString ?? '').toLocaleLowerCase('en-US')}
/>
</Grid>
</Grid>
</Content>
@@ -158,11 +158,13 @@ export const SearchResult = ({ searchQuery }: SearchResultProps) => {
if (searchQuery) {
withFilters = withFilters.filter(
(result: Result) =>
result.name?.toLowerCase().includes(searchQuery) ||
result.name?.toLocaleLowerCase('en-US').includes(searchQuery) ||
result.name
?.toLowerCase()
?.toLocaleLowerCase('en-US')
.includes(searchQuery.split(' ').join('-')) ||
result.description?.toLowerCase().includes(searchQuery),
result.description
?.toLocaleLowerCase('en-US')
.includes(searchQuery),
);
}