diff --git a/.changeset/techdocs-blue-vans-care.md b/.changeset/techdocs-blue-vans-care.md
new file mode 100644
index 0000000000..a648a7aea1
--- /dev/null
+++ b/.changeset/techdocs-blue-vans-care.md
@@ -0,0 +1,5 @@
+---
+'@backstage/plugin-techdocs': patch
+---
+
+The problem of lowercase entity triplets which causes docs to not load on entity page is fixed.
diff --git a/plugins/techdocs/src/EntityPageDocs.tsx b/plugins/techdocs/src/EntityPageDocs.tsx
index c5356289f0..b10fba6d2e 100644
--- a/plugins/techdocs/src/EntityPageDocs.tsx
+++ b/plugins/techdocs/src/EntityPageDocs.tsx
@@ -17,15 +17,18 @@
import React from 'react';
import { Entity } from '@backstage/catalog-model';
import { Reader } from './reader';
+import { toLowerMaybe } from './helpers';
+import { configApiRef, useApi } from '@backstage/core-plugin-api';
export const EntityPageDocs = ({ entity }: { entity: Entity }) => {
+ const config = useApi(configApiRef);
return (
);
diff --git a/plugins/techdocs/src/helpers.ts b/plugins/techdocs/src/helpers.ts
new file mode 100644
index 0000000000..7ff4dec6e7
--- /dev/null
+++ b/plugins/techdocs/src/helpers.ts
@@ -0,0 +1,26 @@
+/*
+ * Copyright 2021 The Backstage Authors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { Config } from '@backstage/config';
+
+// Lower-case entity triplets by default, but allow override.
+export function toLowerMaybe(str: string, config: Config) {
+ return config.getOptionalBoolean(
+ 'techdocs.legacyUseCaseSensitiveTripletPaths',
+ )
+ ? str
+ : str.toLocaleLowerCase('en-US');
+}
diff --git a/plugins/techdocs/src/home/components/DocsCardGrid.tsx b/plugins/techdocs/src/home/components/DocsCardGrid.tsx
index 77e69995ae..1aef793bd2 100644
--- a/plugins/techdocs/src/home/components/DocsCardGrid.tsx
+++ b/plugins/techdocs/src/home/components/DocsCardGrid.tsx
@@ -17,7 +17,7 @@
import React from 'react';
import { Entity } from '@backstage/catalog-model';
-import { configApiRef, useApi, useRouteRef } from '@backstage/core-plugin-api';
+import { useApi, useRouteRef, configApiRef } from '@backstage/core-plugin-api';
import { Card, CardActions, CardContent, CardMedia } from '@material-ui/core';
import { rootDocsRouteRef } from '../../routes';
@@ -26,6 +26,7 @@ import {
ItemCardGrid,
ItemCardHeader,
} from '@backstage/core-components';
+import { toLowerMaybe } from '../../helpers';
export const DocsCardGrid = ({
entities,
@@ -33,14 +34,7 @@ export const DocsCardGrid = ({
entities: Entity[] | undefined;
}) => {
const getRouteToReaderPageFor = useRouteRef(rootDocsRouteRef);
-
- // Lower-case entity triplets by default, but allow override.
- const toLowerMaybe = useApi(configApiRef).getOptionalBoolean(
- 'techdocs.legacyUseCaseSensitiveTripletPaths',
- )
- ? (str: string) => str
- : (str: string) => str.toLocaleLowerCase('en-US');
-
+ const config = useApi(configApiRef);
if (!entities) return null;
return (
@@ -59,9 +53,10 @@ export const DocsCardGrid = ({
to={getRouteToReaderPageFor({
namespace: toLowerMaybe(
entity.metadata.namespace ?? 'default',
+ config,
),
- kind: toLowerMaybe(entity.kind),
- name: toLowerMaybe(entity.metadata.name),
+ kind: toLowerMaybe(entity.kind, config),
+ name: toLowerMaybe(entity.metadata.name, config),
})}
color="primary"
data-testid="read_docs"
diff --git a/plugins/techdocs/src/home/components/DocsTable.tsx b/plugins/techdocs/src/home/components/DocsTable.tsx
index 0e64c2e2e8..83d6f05788 100644
--- a/plugins/techdocs/src/home/components/DocsTable.tsx
+++ b/plugins/techdocs/src/home/components/DocsTable.tsx
@@ -17,7 +17,7 @@
import React from 'react';
import { useCopyToClipboard } from 'react-use';
-import { configApiRef, useApi, useRouteRef } from '@backstage/core-plugin-api';
+import { useRouteRef, useApi, configApiRef } from '@backstage/core-plugin-api';
import { Entity, RELATION_OWNED_BY } from '@backstage/catalog-model';
import {
formatEntityRefTitle,
@@ -34,6 +34,7 @@ import {
import * as actionFactories from './actions';
import * as columnFactories from './columns';
import { DocsTableRow } from './types';
+import { toLowerMaybe } from '../../helpers';
export const DocsTable = ({
entities,
@@ -50,26 +51,21 @@ export const DocsTable = ({
}) => {
const [, copyToClipboard] = useCopyToClipboard();
const getRouteToReaderPageFor = useRouteRef(rootDocsRouteRef);
-
- // Lower-case entity triplets by default, but allow override.
- const toLowerMaybe = useApi(configApiRef).getOptionalBoolean(
- 'techdocs.legacyUseCaseSensitiveTripletPaths',
- )
- ? (str: string) => str
- : (str: string) => str.toLocaleLowerCase('en-US');
-
+ const config = useApi(configApiRef);
if (!entities) return null;
const documents = entities.map(entity => {
const ownedByRelations = getEntityRelations(entity, RELATION_OWNED_BY);
-
return {
entity,
resolved: {
docsUrl: getRouteToReaderPageFor({
- namespace: toLowerMaybe(entity.metadata.namespace ?? 'default'),
- kind: toLowerMaybe(entity.kind),
- name: toLowerMaybe(entity.metadata.name),
+ namespace: toLowerMaybe(
+ entity.metadata.namespace ?? 'default',
+ config,
+ ),
+ kind: toLowerMaybe(entity.kind, config),
+ name: toLowerMaybe(entity.metadata.name, config),
}),
ownedByRelations,
ownedByRelationsTitle: ownedByRelations