@backstage/plugin-techdocs-react 1.2.17 → 1.3.0-next.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/dist/helpers.esm.js +38 -1
- package/dist/helpers.esm.js.map +1 -1
- package/dist/index.d.ts +20 -3
- package/dist/index.esm.js +1 -1
- package/package.json +11 -10
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @backstage/plugin-techdocs-react
|
|
2
2
|
|
|
3
|
+
## 1.3.0-next.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- ec7b35d: Introduced `backstage.io/techdocs-entity-path` annotation which allows deep linking into another entities TechDocs in conjunction with `backstage.io/techdocs-entity`.
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies
|
|
12
|
+
- @backstage/frontend-plugin-api@0.10.3-next.0
|
|
13
|
+
- @backstage/plugin-techdocs-common@0.1.1-next.0
|
|
14
|
+
|
|
3
15
|
## 1.2.17
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/dist/helpers.esm.js
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { getCompoundEntityRef, parseEntityRef } from '@backstage/catalog-model';
|
|
2
|
+
import { TECHDOCS_EXTERNAL_PATH_ANNOTATION, TECHDOCS_EXTERNAL_ANNOTATION } from '@backstage/plugin-techdocs-common';
|
|
3
|
+
|
|
1
4
|
function toLowercaseEntityRefMaybe(entityRef, config) {
|
|
2
5
|
if (config.getOptionalBoolean("techdocs.legacyUseCaseSensitiveTripletPaths"))
|
|
3
6
|
return entityRef;
|
|
@@ -6,6 +9,40 @@ function toLowercaseEntityRefMaybe(entityRef, config) {
|
|
|
6
9
|
entityRef.namespace = entityRef.namespace.toLocaleLowerCase();
|
|
7
10
|
return entityRef;
|
|
8
11
|
}
|
|
12
|
+
function getEntityRootTechDocsPath(entity) {
|
|
13
|
+
let path = entity.metadata.annotations?.[TECHDOCS_EXTERNAL_PATH_ANNOTATION];
|
|
14
|
+
if (!path) {
|
|
15
|
+
return "";
|
|
16
|
+
}
|
|
17
|
+
if (!path.startsWith("/")) {
|
|
18
|
+
path = `/${path}`;
|
|
19
|
+
}
|
|
20
|
+
return path;
|
|
21
|
+
}
|
|
22
|
+
const buildTechDocsURL = (entity, routeFunc) => {
|
|
23
|
+
if (!routeFunc) {
|
|
24
|
+
return void 0;
|
|
25
|
+
}
|
|
26
|
+
let { namespace, kind, name } = getCompoundEntityRef(entity);
|
|
27
|
+
if (entity.metadata.annotations?.[TECHDOCS_EXTERNAL_ANNOTATION]) {
|
|
28
|
+
try {
|
|
29
|
+
const techdocsRef = parseEntityRef(
|
|
30
|
+
entity.metadata.annotations?.[TECHDOCS_EXTERNAL_ANNOTATION]
|
|
31
|
+
);
|
|
32
|
+
namespace = techdocsRef.namespace;
|
|
33
|
+
kind = techdocsRef.kind;
|
|
34
|
+
name = techdocsRef.name;
|
|
35
|
+
} catch {
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
const url = routeFunc({
|
|
39
|
+
namespace,
|
|
40
|
+
kind,
|
|
41
|
+
name
|
|
42
|
+
});
|
|
43
|
+
const path = getEntityRootTechDocsPath(entity);
|
|
44
|
+
return `${url}${path}`;
|
|
45
|
+
};
|
|
9
46
|
|
|
10
|
-
export { toLowercaseEntityRefMaybe };
|
|
47
|
+
export { buildTechDocsURL, getEntityRootTechDocsPath, toLowercaseEntityRefMaybe };
|
|
11
48
|
//# sourceMappingURL=helpers.esm.js.map
|
package/dist/helpers.esm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.esm.js","sources":["../src/helpers.ts"],"sourcesContent":["/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Config } from '@backstage/config';\nimport {
|
|
1
|
+
{"version":3,"file":"helpers.esm.js","sources":["../src/helpers.ts"],"sourcesContent":["/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Config } from '@backstage/config';\nimport {\n CompoundEntityRef,\n Entity,\n getCompoundEntityRef,\n parseEntityRef,\n} from '@backstage/catalog-model';\nimport {\n TECHDOCS_EXTERNAL_ANNOTATION,\n TECHDOCS_EXTERNAL_PATH_ANNOTATION,\n} from '@backstage/plugin-techdocs-common';\nimport { RouteFunc } from '@backstage/core-plugin-api';\n\n/**\n * Lower-case entity triplets by default, but allow override.\n *\n * @public\n */\nexport function toLowercaseEntityRefMaybe(\n entityRef: CompoundEntityRef,\n config: Config,\n): CompoundEntityRef {\n if (config.getOptionalBoolean('techdocs.legacyUseCaseSensitiveTripletPaths'))\n return entityRef;\n\n entityRef.kind = entityRef.kind.toLocaleLowerCase();\n entityRef.name = entityRef.name.toLocaleLowerCase();\n entityRef.namespace = entityRef.namespace.toLocaleLowerCase();\n\n return entityRef;\n}\n\n/**\n * Get the entity path annotation from the given entity and ensure it starts with a slash.\n *\n * @public\n */\nexport function getEntityRootTechDocsPath(entity: Entity): string {\n let path = entity.metadata.annotations?.[TECHDOCS_EXTERNAL_PATH_ANNOTATION];\n if (!path) {\n return '';\n }\n if (!path.startsWith('/')) {\n path = `/${path}`;\n }\n return path;\n}\n\n/**\n * Build the TechDocs URL for the given entity. This helper should be used anywhere there\n * is a link to an entities TechDocs.\n *\n * @public\n */\nexport const buildTechDocsURL = (\n entity: Entity,\n routeFunc:\n | RouteFunc<{\n namespace: string;\n kind: string;\n name: string;\n }>\n | undefined,\n) => {\n if (!routeFunc) {\n return undefined;\n }\n\n let { namespace, kind, name } = getCompoundEntityRef(entity);\n\n if (entity.metadata.annotations?.[TECHDOCS_EXTERNAL_ANNOTATION]) {\n try {\n const techdocsRef = parseEntityRef(\n entity.metadata.annotations?.[TECHDOCS_EXTERNAL_ANNOTATION],\n );\n namespace = techdocsRef.namespace;\n kind = techdocsRef.kind;\n name = techdocsRef.name;\n } catch {\n // not a fan of this but we don't care if the parseEntityRef fails\n }\n }\n\n const url = routeFunc({\n namespace,\n kind,\n name,\n });\n\n // Add on the external entity path to the url if one exists. This allows deep linking into another\n // entities TechDocs.\n const path = getEntityRootTechDocsPath(entity);\n\n return `${url}${path}`;\n};\n"],"names":[],"mappings":";;;AAkCgB,SAAA,yBAAA,CACd,WACA,MACmB,EAAA;AACnB,EAAI,IAAA,MAAA,CAAO,mBAAmB,6CAA6C,CAAA;AACzE,IAAO,OAAA,SAAA;AAET,EAAU,SAAA,CAAA,IAAA,GAAO,SAAU,CAAA,IAAA,CAAK,iBAAkB,EAAA;AAClD,EAAU,SAAA,CAAA,IAAA,GAAO,SAAU,CAAA,IAAA,CAAK,iBAAkB,EAAA;AAClD,EAAU,SAAA,CAAA,SAAA,GAAY,SAAU,CAAA,SAAA,CAAU,iBAAkB,EAAA;AAE5D,EAAO,OAAA,SAAA;AACT;AAOO,SAAS,0BAA0B,MAAwB,EAAA;AAChE,EAAA,IAAI,IAAO,GAAA,MAAA,CAAO,QAAS,CAAA,WAAA,GAAc,iCAAiC,CAAA;AAC1E,EAAA,IAAI,CAAC,IAAM,EAAA;AACT,IAAO,OAAA,EAAA;AAAA;AAET,EAAA,IAAI,CAAC,IAAA,CAAK,UAAW,CAAA,GAAG,CAAG,EAAA;AACzB,IAAA,IAAA,GAAO,IAAI,IAAI,CAAA,CAAA;AAAA;AAEjB,EAAO,OAAA,IAAA;AACT;AAQa,MAAA,gBAAA,GAAmB,CAC9B,MAAA,EACA,SAOG,KAAA;AACH,EAAA,IAAI,CAAC,SAAW,EAAA;AACd,IAAO,OAAA,KAAA,CAAA;AAAA;AAGT,EAAA,IAAI,EAAE,SAAW,EAAA,IAAA,EAAM,IAAK,EAAA,GAAI,qBAAqB,MAAM,CAAA;AAE3D,EAAA,IAAI,MAAO,CAAA,QAAA,CAAS,WAAc,GAAA,4BAA4B,CAAG,EAAA;AAC/D,IAAI,IAAA;AACF,MAAA,MAAM,WAAc,GAAA,cAAA;AAAA,QAClB,MAAA,CAAO,QAAS,CAAA,WAAA,GAAc,4BAA4B;AAAA,OAC5D;AACA,MAAA,SAAA,GAAY,WAAY,CAAA,SAAA;AACxB,MAAA,IAAA,GAAO,WAAY,CAAA,IAAA;AACnB,MAAA,IAAA,GAAO,WAAY,CAAA,IAAA;AAAA,KACb,CAAA,MAAA;AAAA;AAER;AAGF,EAAA,MAAM,MAAM,SAAU,CAAA;AAAA,IACpB,SAAA;AAAA,IACA,IAAA;AAAA,IACA;AAAA,GACD,CAAA;AAID,EAAM,MAAA,IAAA,GAAO,0BAA0B,MAAM,CAAA;AAE7C,EAAO,OAAA,CAAA,EAAG,GAAG,CAAA,EAAG,IAAI,CAAA,CAAA;AACtB;;;;"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import { ComponentType, PropsWithChildren, Dispatch, SetStateAction, ReactNode } from 'react';
|
|
3
3
|
import * as _backstage_core_plugin_api from '@backstage/core-plugin-api';
|
|
4
|
-
import { Extension } from '@backstage/core-plugin-api';
|
|
4
|
+
import { Extension, RouteFunc } from '@backstage/core-plugin-api';
|
|
5
5
|
import { T as TechDocsAddonOptions, a as TechDocsAddonLocations, b as TechDocsMetadata, c as TechDocsEntityMetadata } from './types/types.d-BooYUMWM.js';
|
|
6
|
-
import { CompoundEntityRef } from '@backstage/catalog-model';
|
|
6
|
+
import { CompoundEntityRef, Entity } from '@backstage/catalog-model';
|
|
7
7
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
8
8
|
import { AsyncState } from 'react-use/esm/useAsync';
|
|
9
9
|
import { Config } from '@backstage/config';
|
|
@@ -268,5 +268,22 @@ declare const useShadowRootSelection: (waitMillis?: number) => Selection | null;
|
|
|
268
268
|
* @public
|
|
269
269
|
*/
|
|
270
270
|
declare function toLowercaseEntityRefMaybe(entityRef: CompoundEntityRef, config: Config): CompoundEntityRef;
|
|
271
|
+
/**
|
|
272
|
+
* Get the entity path annotation from the given entity and ensure it starts with a slash.
|
|
273
|
+
*
|
|
274
|
+
* @public
|
|
275
|
+
*/
|
|
276
|
+
declare function getEntityRootTechDocsPath(entity: Entity): string;
|
|
277
|
+
/**
|
|
278
|
+
* Build the TechDocs URL for the given entity. This helper should be used anywhere there
|
|
279
|
+
* is a link to an entities TechDocs.
|
|
280
|
+
*
|
|
281
|
+
* @public
|
|
282
|
+
*/
|
|
283
|
+
declare const buildTechDocsURL: (entity: Entity, routeFunc: RouteFunc<{
|
|
284
|
+
namespace: string;
|
|
285
|
+
kind: string;
|
|
286
|
+
name: string;
|
|
287
|
+
}> | undefined) => string | undefined;
|
|
271
288
|
|
|
272
|
-
export { SHADOW_DOM_STYLE_LOAD_EVENT, type SyncResult, TECHDOCS_ADDONS_KEY, TECHDOCS_ADDONS_WRAPPER_KEY, TechDocsAddonLocations, TechDocsAddonOptions, TechDocsAddons, type TechDocsApi, TechDocsEntityMetadata, TechDocsMetadata, TechDocsReaderPageProvider, type TechDocsReaderPageProviderProps, type TechDocsReaderPageProviderRenderFunction, type TechDocsReaderPageValue, TechDocsShadowDom, type TechDocsShadowDomProps, type TechDocsStorageApi, createTechDocsAddonExtension, techdocsApiRef, techdocsStorageApiRef, toLowercaseEntityRefMaybe, useShadowDomStylesLoading, useShadowRoot, useShadowRootElements, useShadowRootSelection, useTechDocsAddons, useTechDocsReaderPage };
|
|
289
|
+
export { SHADOW_DOM_STYLE_LOAD_EVENT, type SyncResult, TECHDOCS_ADDONS_KEY, TECHDOCS_ADDONS_WRAPPER_KEY, TechDocsAddonLocations, TechDocsAddonOptions, TechDocsAddons, type TechDocsApi, TechDocsEntityMetadata, TechDocsMetadata, TechDocsReaderPageProvider, type TechDocsReaderPageProviderProps, type TechDocsReaderPageProviderRenderFunction, type TechDocsReaderPageValue, TechDocsShadowDom, type TechDocsShadowDomProps, type TechDocsStorageApi, buildTechDocsURL, createTechDocsAddonExtension, getEntityRootTechDocsPath, techdocsApiRef, techdocsStorageApiRef, toLowercaseEntityRefMaybe, useShadowDomStylesLoading, useShadowRoot, useShadowRootElements, useShadowRootSelection, useTechDocsAddons, useTechDocsReaderPage };
|
package/dist/index.esm.js
CHANGED
|
@@ -4,5 +4,5 @@ export { TechDocsReaderPageProvider, useTechDocsReaderPage } from './context.esm
|
|
|
4
4
|
export { TechDocsAddonLocations } from './types.esm.js';
|
|
5
5
|
export { SHADOW_DOM_STYLE_LOAD_EVENT, TechDocsShadowDom, useShadowDomStylesLoading } from './component.esm.js';
|
|
6
6
|
export { useShadowRoot, useShadowRootElements, useShadowRootSelection } from './hooks.esm.js';
|
|
7
|
-
export { toLowercaseEntityRefMaybe } from './helpers.esm.js';
|
|
7
|
+
export { buildTechDocsURL, getEntityRootTechDocsPath, toLowercaseEntityRefMaybe } from './helpers.esm.js';
|
|
8
8
|
//# sourceMappingURL=index.esm.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backstage/plugin-techdocs-react",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0-next.0",
|
|
4
4
|
"description": "Shared frontend utilities for TechDocs and Addons",
|
|
5
5
|
"backstage": {
|
|
6
6
|
"role": "web-library",
|
|
@@ -66,12 +66,13 @@
|
|
|
66
66
|
"test": "backstage-cli package test"
|
|
67
67
|
},
|
|
68
68
|
"dependencies": {
|
|
69
|
-
"@backstage/catalog-model": "
|
|
70
|
-
"@backstage/config": "
|
|
71
|
-
"@backstage/core-components": "
|
|
72
|
-
"@backstage/core-plugin-api": "
|
|
73
|
-
"@backstage/frontend-plugin-api": "
|
|
74
|
-
"@backstage/
|
|
69
|
+
"@backstage/catalog-model": "1.7.4",
|
|
70
|
+
"@backstage/config": "1.3.2",
|
|
71
|
+
"@backstage/core-components": "0.17.2",
|
|
72
|
+
"@backstage/core-plugin-api": "1.10.7",
|
|
73
|
+
"@backstage/frontend-plugin-api": "0.10.3-next.0",
|
|
74
|
+
"@backstage/plugin-techdocs-common": "0.1.1-next.0",
|
|
75
|
+
"@backstage/version-bridge": "1.0.11",
|
|
75
76
|
"@material-ui/core": "^4.12.2",
|
|
76
77
|
"@material-ui/styles": "^4.11.0",
|
|
77
78
|
"jss": "~10.10.0",
|
|
@@ -80,9 +81,9 @@
|
|
|
80
81
|
"react-use": "^17.2.4"
|
|
81
82
|
},
|
|
82
83
|
"devDependencies": {
|
|
83
|
-
"@backstage/cli": "
|
|
84
|
-
"@backstage/test-utils": "
|
|
85
|
-
"@backstage/theme": "
|
|
84
|
+
"@backstage/cli": "0.32.1",
|
|
85
|
+
"@backstage/test-utils": "1.7.8",
|
|
86
|
+
"@backstage/theme": "0.6.6",
|
|
86
87
|
"@testing-library/jest-dom": "^6.0.0",
|
|
87
88
|
"@testing-library/react": "^16.0.0",
|
|
88
89
|
"@types/react": "^18.0.0",
|