@techdocs/cli 0.0.0-nightly-20240806021838 → 0.0.0-nightly-20240807021931
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 +14 -3
- package/dist/embedded-app/.config-schema.json +132 -82
- package/dist/embedded-app/index.html +1 -1
- package/dist/embedded-app/static/{4036.a029793d.chunk.js → 4036.24f6021a.chunk.js} +2 -2
- package/dist/embedded-app/static/{4036.a029793d.chunk.js.map → 4036.24f6021a.chunk.js.map} +1 -1
- package/dist/embedded-app/static/{9605.18e9db70.chunk.js → 9605.391b82d4.chunk.js} +3 -3
- package/dist/embedded-app/static/{9605.18e9db70.chunk.js.map → 9605.391b82d4.chunk.js.map} +1 -1
- package/dist/embedded-app/static/main.3227a1b9.js +509 -0
- package/dist/embedded-app/static/main.3227a1b9.js.map +1 -0
- package/dist/embedded-app/static/{module-material-table.695896b2.js → module-material-table.e3f26578.js} +2 -2
- package/dist/embedded-app/static/{module-material-table.695896b2.js.map → module-material-table.e3f26578.js.map} +1 -1
- package/dist/embedded-app/static/module-material-ui.f1846a3c.js +24 -0
- package/dist/embedded-app/static/module-material-ui.f1846a3c.js.map +1 -0
- package/dist/embedded-app/static/{runtime.6518d659.js → runtime.3227a1b9.js} +2 -2
- package/dist/embedded-app/static/{runtime.6518d659.js.map → runtime.3227a1b9.js.map} +1 -1
- package/dist/embedded-app/static/{vendor.6518d659.js → vendor.3227a1b9.js} +1 -1
- package/dist/embedded-app/static/{vendor.6518d659.js.map → vendor.3227a1b9.js.map} +1 -1
- package/dist/index.cjs.js +1 -1
- package/package.json +4 -4
- package/dist/embedded-app/static/main.6518d659.js +0 -509
- package/dist/embedded-app/static/main.6518d659.js.map +0 -1
- package/dist/embedded-app/static/module-material-ui.3807a580.js +0 -24
- package/dist/embedded-app/static/module-material-ui.3807a580.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,12 +1,23 @@
|
|
|
1
1
|
# @techdocs/cli
|
|
2
2
|
|
|
3
|
-
## 0.0.0-nightly-
|
|
3
|
+
## 0.0.0-nightly-20240807021931
|
|
4
4
|
|
|
5
5
|
### Patch Changes
|
|
6
6
|
|
|
7
7
|
- Updated dependencies
|
|
8
|
-
- @backstage/
|
|
9
|
-
- @backstage/
|
|
8
|
+
- @backstage/backend-defaults@0.0.0-nightly-20240807021931
|
|
9
|
+
- @backstage/plugin-techdocs-node@0.0.0-nightly-20240807021931
|
|
10
|
+
- @backstage/catalog-model@1.5.0
|
|
11
|
+
- @backstage/cli-common@0.1.14
|
|
12
|
+
- @backstage/config@1.2.0
|
|
13
|
+
|
|
14
|
+
## 1.8.17-next.2
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- Updated dependencies
|
|
19
|
+
- @backstage/backend-defaults@0.4.2-next.2
|
|
20
|
+
- @backstage/plugin-techdocs-node@1.12.9-next.2
|
|
10
21
|
- @backstage/catalog-model@1.5.0
|
|
11
22
|
- @backstage/cli-common@0.1.14
|
|
12
23
|
- @backstage/config@1.2.0
|
|
@@ -125,6 +125,51 @@
|
|
|
125
125
|
"$schema": "http://json-schema.org/draft-07/schema#"
|
|
126
126
|
}
|
|
127
127
|
},
|
|
128
|
+
{
|
|
129
|
+
"path": "../core-components/config.d.ts",
|
|
130
|
+
"value": {
|
|
131
|
+
"type": "object",
|
|
132
|
+
"properties": {
|
|
133
|
+
"auth": {
|
|
134
|
+
"type": "object",
|
|
135
|
+
"properties": {
|
|
136
|
+
"autologout": {
|
|
137
|
+
"description": "Autologout feature configuration",
|
|
138
|
+
"type": "object",
|
|
139
|
+
"properties": {
|
|
140
|
+
"enabled": {
|
|
141
|
+
"description": "Enable or disable the autologout feature",
|
|
142
|
+
"visibility": "frontend",
|
|
143
|
+
"type": "boolean"
|
|
144
|
+
},
|
|
145
|
+
"idleTimeoutMinutes": {
|
|
146
|
+
"description": "Number of minutes after which the inactive user is logged out automatically.\nDefault is 60 minutes (1 hour)",
|
|
147
|
+
"visibility": "frontend",
|
|
148
|
+
"type": "number"
|
|
149
|
+
},
|
|
150
|
+
"promptBeforeIdleSeconds": {
|
|
151
|
+
"description": "Number of seconds before the idle timeout where the user will be asked if it's still active.\nA dialog will be shown.\nDefault is 10 seconds.\nSet to 0 seconds to disable the prompt.",
|
|
152
|
+
"visibility": "frontend",
|
|
153
|
+
"type": "number"
|
|
154
|
+
},
|
|
155
|
+
"useWorkerTimers": {
|
|
156
|
+
"description": "Enable/disable the usage of worker thread timers instead of main thread timers.\nDefault is true.\nIf you experience some browser incompatibility, you may try to set this to false.",
|
|
157
|
+
"visibility": "frontend",
|
|
158
|
+
"type": "boolean"
|
|
159
|
+
},
|
|
160
|
+
"logoutIfDisconnected": {
|
|
161
|
+
"description": "Enable/disable the automatic logout also on users that are logged in but with no Backstage tabs open.\nDefault is true.",
|
|
162
|
+
"visibility": "frontend",
|
|
163
|
+
"type": "boolean"
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
},
|
|
170
|
+
"$schema": "http://json-schema.org/draft-07/schema#"
|
|
171
|
+
}
|
|
172
|
+
},
|
|
128
173
|
{
|
|
129
174
|
"path": "../core-app-api/config.d.ts",
|
|
130
175
|
"value": {
|
|
@@ -354,51 +399,6 @@
|
|
|
354
399
|
"$schema": "http://json-schema.org/draft-07/schema#"
|
|
355
400
|
}
|
|
356
401
|
},
|
|
357
|
-
{
|
|
358
|
-
"path": "../core-components/config.d.ts",
|
|
359
|
-
"value": {
|
|
360
|
-
"type": "object",
|
|
361
|
-
"properties": {
|
|
362
|
-
"auth": {
|
|
363
|
-
"type": "object",
|
|
364
|
-
"properties": {
|
|
365
|
-
"autologout": {
|
|
366
|
-
"description": "Autologout feature configuration",
|
|
367
|
-
"type": "object",
|
|
368
|
-
"properties": {
|
|
369
|
-
"enabled": {
|
|
370
|
-
"description": "Enable or disable the autologout feature",
|
|
371
|
-
"visibility": "frontend",
|
|
372
|
-
"type": "boolean"
|
|
373
|
-
},
|
|
374
|
-
"idleTimeoutMinutes": {
|
|
375
|
-
"description": "Number of minutes after which the inactive user is logged out automatically.\nDefault is 60 minutes (1 hour)",
|
|
376
|
-
"visibility": "frontend",
|
|
377
|
-
"type": "number"
|
|
378
|
-
},
|
|
379
|
-
"promptBeforeIdleSeconds": {
|
|
380
|
-
"description": "Number of seconds before the idle timeout where the user will be asked if it's still active.\nA dialog will be shown.\nDefault is 10 seconds.\nSet to 0 seconds to disable the prompt.",
|
|
381
|
-
"visibility": "frontend",
|
|
382
|
-
"type": "number"
|
|
383
|
-
},
|
|
384
|
-
"useWorkerTimers": {
|
|
385
|
-
"description": "Enable/disable the usage of worker thread timers instead of main thread timers.\nDefault is true.\nIf you experience some browser incompatibility, you may try to set this to false.",
|
|
386
|
-
"visibility": "frontend",
|
|
387
|
-
"type": "boolean"
|
|
388
|
-
},
|
|
389
|
-
"logoutIfDisconnected": {
|
|
390
|
-
"description": "Enable/disable the automatic logout also on users that are logged in but with no Backstage tabs open.\nDefault is true.",
|
|
391
|
-
"visibility": "frontend",
|
|
392
|
-
"type": "boolean"
|
|
393
|
-
}
|
|
394
|
-
}
|
|
395
|
-
}
|
|
396
|
-
}
|
|
397
|
-
}
|
|
398
|
-
},
|
|
399
|
-
"$schema": "http://json-schema.org/draft-07/schema#"
|
|
400
|
-
}
|
|
401
|
-
},
|
|
402
402
|
{
|
|
403
403
|
"path": "../../plugins/techdocs/config.d.ts",
|
|
404
404
|
"value": {
|
|
@@ -1508,7 +1508,7 @@
|
|
|
1508
1508
|
}
|
|
1509
1509
|
},
|
|
1510
1510
|
{
|
|
1511
|
-
"path": "../../node_modules/@backstage-community/plugin-
|
|
1511
|
+
"path": "../../node_modules/@backstage-community/plugin-puppetdb/node_modules/@backstage/core-components/config.d.ts",
|
|
1512
1512
|
"value": {
|
|
1513
1513
|
"type": "object",
|
|
1514
1514
|
"properties": {
|
|
@@ -1707,7 +1707,7 @@
|
|
|
1707
1707
|
}
|
|
1708
1708
|
},
|
|
1709
1709
|
{
|
|
1710
|
-
"path": "../backend-
|
|
1710
|
+
"path": "../backend-defaults/config.d.ts",
|
|
1711
1711
|
"value": {
|
|
1712
1712
|
"type": "object",
|
|
1713
1713
|
"properties": {
|
|
@@ -1715,6 +1715,7 @@
|
|
|
1715
1715
|
"type": "object",
|
|
1716
1716
|
"properties": {
|
|
1717
1717
|
"auth": {
|
|
1718
|
+
"description": "Options used by the default auth, httpAuth and userInfo services.",
|
|
1718
1719
|
"type": "object",
|
|
1719
1720
|
"properties": {
|
|
1720
1721
|
"dangerouslyDisableDefaultAuthPolicy": {
|
|
@@ -2022,6 +2023,56 @@
|
|
|
2022
2023
|
"required": [
|
|
2023
2024
|
"url"
|
|
2024
2025
|
]
|
|
2026
|
+
},
|
|
2027
|
+
"accessRestrictions": {
|
|
2028
|
+
"description": "Restricts what types of access that are permitted for this access\nmethod. If no access restrictions are given, it'll have unlimited\naccess. This access restriction applies for the framework level;\nindividual plugins may have their own access control mechanisms\non top of this.",
|
|
2029
|
+
"type": "array",
|
|
2030
|
+
"items": {
|
|
2031
|
+
"type": "object",
|
|
2032
|
+
"properties": {
|
|
2033
|
+
"plugin": {
|
|
2034
|
+
"description": "Permit access to make requests to this plugin.\n\nCan be further refined by setting additional fields below.",
|
|
2035
|
+
"type": "string"
|
|
2036
|
+
},
|
|
2037
|
+
"permission": {
|
|
2038
|
+
"description": "If given, this method is limited to only performing actions\nwith these named permissions in this plugin.\n\nNote that this only applies where permissions checks are\nenabled in the first place. Endpoints that are not protected by\nthe permissions system at all, are not affected by this\nsetting.",
|
|
2039
|
+
"anyOf": [
|
|
2040
|
+
{
|
|
2041
|
+
"type": "array",
|
|
2042
|
+
"items": {
|
|
2043
|
+
"type": "string"
|
|
2044
|
+
}
|
|
2045
|
+
},
|
|
2046
|
+
{
|
|
2047
|
+
"type": "string"
|
|
2048
|
+
}
|
|
2049
|
+
]
|
|
2050
|
+
},
|
|
2051
|
+
"permissionAttribute": {
|
|
2052
|
+
"description": "If given, this method is limited to only performing actions\nwhose permissions have these attributes.\n\nNote that this only applies where permissions checks are\nenabled in the first place. Endpoints that are not protected by\nthe permissions system at all, are not affected by this\nsetting.",
|
|
2053
|
+
"type": "object",
|
|
2054
|
+
"properties": {
|
|
2055
|
+
"action": {
|
|
2056
|
+
"description": "One of more of 'create', 'read', 'update', or 'delete'.",
|
|
2057
|
+
"anyOf": [
|
|
2058
|
+
{
|
|
2059
|
+
"type": "array",
|
|
2060
|
+
"items": {
|
|
2061
|
+
"type": "string"
|
|
2062
|
+
}
|
|
2063
|
+
},
|
|
2064
|
+
{
|
|
2065
|
+
"type": "string"
|
|
2066
|
+
}
|
|
2067
|
+
]
|
|
2068
|
+
}
|
|
2069
|
+
}
|
|
2070
|
+
}
|
|
2071
|
+
},
|
|
2072
|
+
"required": [
|
|
2073
|
+
"plugin"
|
|
2074
|
+
]
|
|
2075
|
+
}
|
|
2025
2076
|
}
|
|
2026
2077
|
},
|
|
2027
2078
|
"required": [
|
|
@@ -2036,46 +2087,21 @@
|
|
|
2036
2087
|
"required": [
|
|
2037
2088
|
"externalAccess"
|
|
2038
2089
|
]
|
|
2039
|
-
},
|
|
2040
|
-
"packages": {
|
|
2041
|
-
"anyOf": [
|
|
2042
|
-
{
|
|
2043
|
-
"type": "object",
|
|
2044
|
-
"properties": {
|
|
2045
|
-
"include": {
|
|
2046
|
-
"type": "array",
|
|
2047
|
-
"items": {
|
|
2048
|
-
"type": "string"
|
|
2049
|
-
}
|
|
2050
|
-
},
|
|
2051
|
-
"exclude": {
|
|
2052
|
-
"type": "array",
|
|
2053
|
-
"items": {
|
|
2054
|
-
"type": "string"
|
|
2055
|
-
}
|
|
2056
|
-
}
|
|
2057
|
-
}
|
|
2058
|
-
},
|
|
2059
|
-
{
|
|
2060
|
-
"const": "all",
|
|
2061
|
-
"type": "string"
|
|
2062
|
-
}
|
|
2063
|
-
]
|
|
2064
2090
|
}
|
|
2065
2091
|
}
|
|
2066
2092
|
},
|
|
2067
2093
|
"discovery": {
|
|
2068
|
-
"description": "
|
|
2094
|
+
"description": "Options used by the default discovery service.",
|
|
2069
2095
|
"type": "object",
|
|
2070
2096
|
"properties": {
|
|
2071
2097
|
"endpoints": {
|
|
2072
|
-
"description": "
|
|
2098
|
+
"description": "A list of target baseUrls and the associated plugins.",
|
|
2073
2099
|
"type": "array",
|
|
2074
2100
|
"items": {
|
|
2075
2101
|
"type": "object",
|
|
2076
2102
|
"properties": {
|
|
2077
2103
|
"target": {
|
|
2078
|
-
"description": "The target
|
|
2104
|
+
"description": "The target base URL to use for the plugin.\n\nCan be either a string or an object with internal and external keys.\nTargets with `{{pluginId}}` or `{{ pluginId }} in the URL will be replaced with the plugin ID.",
|
|
2079
2105
|
"anyOf": [
|
|
2080
2106
|
{
|
|
2081
2107
|
"type": "object",
|
|
@@ -2098,7 +2124,7 @@
|
|
|
2098
2124
|
]
|
|
2099
2125
|
},
|
|
2100
2126
|
"plugins": {
|
|
2101
|
-
"description": "Array of plugins which use the target
|
|
2127
|
+
"description": "Array of plugins which use the target base URL.",
|
|
2102
2128
|
"type": "array",
|
|
2103
2129
|
"items": {
|
|
2104
2130
|
"type": "string"
|
|
@@ -2121,7 +2147,7 @@
|
|
|
2121
2147
|
}
|
|
2122
2148
|
},
|
|
2123
2149
|
{
|
|
2124
|
-
"path": "../backend-
|
|
2150
|
+
"path": "../backend-app-api/config.d.ts",
|
|
2125
2151
|
"value": {
|
|
2126
2152
|
"type": "object",
|
|
2127
2153
|
"properties": {
|
|
@@ -2129,7 +2155,6 @@
|
|
|
2129
2155
|
"type": "object",
|
|
2130
2156
|
"properties": {
|
|
2131
2157
|
"auth": {
|
|
2132
|
-
"description": "Options used by the default auth, httpAuth and userInfo services.",
|
|
2133
2158
|
"type": "object",
|
|
2134
2159
|
"properties": {
|
|
2135
2160
|
"dangerouslyDisableDefaultAuthPolicy": {
|
|
@@ -2451,21 +2476,46 @@
|
|
|
2451
2476
|
"required": [
|
|
2452
2477
|
"externalAccess"
|
|
2453
2478
|
]
|
|
2479
|
+
},
|
|
2480
|
+
"packages": {
|
|
2481
|
+
"anyOf": [
|
|
2482
|
+
{
|
|
2483
|
+
"type": "object",
|
|
2484
|
+
"properties": {
|
|
2485
|
+
"include": {
|
|
2486
|
+
"type": "array",
|
|
2487
|
+
"items": {
|
|
2488
|
+
"type": "string"
|
|
2489
|
+
}
|
|
2490
|
+
},
|
|
2491
|
+
"exclude": {
|
|
2492
|
+
"type": "array",
|
|
2493
|
+
"items": {
|
|
2494
|
+
"type": "string"
|
|
2495
|
+
}
|
|
2496
|
+
}
|
|
2497
|
+
}
|
|
2498
|
+
},
|
|
2499
|
+
{
|
|
2500
|
+
"const": "all",
|
|
2501
|
+
"type": "string"
|
|
2502
|
+
}
|
|
2503
|
+
]
|
|
2454
2504
|
}
|
|
2455
2505
|
}
|
|
2456
2506
|
},
|
|
2457
2507
|
"discovery": {
|
|
2458
|
-
"description": "
|
|
2508
|
+
"description": "Discovery options.",
|
|
2459
2509
|
"type": "object",
|
|
2460
2510
|
"properties": {
|
|
2461
2511
|
"endpoints": {
|
|
2462
|
-
"description": "
|
|
2512
|
+
"description": "Endpoints\n\nA list of target baseUrls and the associated plugins.",
|
|
2463
2513
|
"type": "array",
|
|
2464
2514
|
"items": {
|
|
2465
2515
|
"type": "object",
|
|
2466
2516
|
"properties": {
|
|
2467
2517
|
"target": {
|
|
2468
|
-
"description": "The target
|
|
2518
|
+
"description": "The target baseUrl to use for the plugin\n\nCan be either a string or an object with internal and external keys.\nTargets with `{{pluginId}}` or `{{ pluginId }} in the url will be replaced with the pluginId.",
|
|
2469
2519
|
"anyOf": [
|
|
2470
2520
|
{
|
|
2471
2521
|
"type": "object",
|
|
@@ -2488,7 +2538,7 @@
|
|
|
2488
2538
|
]
|
|
2489
2539
|
},
|
|
2490
2540
|
"plugins": {
|
|
2491
|
-
"description": "Array of plugins which use the target
|
|
2541
|
+
"description": "Array of plugins which use the target baseUrl.",
|
|
2492
2542
|
"type": "array",
|
|
2493
2543
|
"items": {
|
|
2494
2544
|
"type": "string"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
<!doctype html><html lang="en"><head><meta charset="utf-8"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="Backstage is an open source framework for building developer portals"/><link rel="manifest" href="/manifest.json" crossorigin="use-credentials"/><link rel="icon" href="/favicon.ico"/><link rel="shortcut icon" href="/favicon.ico"/><link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png"/><link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png"/><link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png"/><link rel="mask-icon" href="/safari-pinned-tab.svg" color="#5bbad5"/><title>Techdocs Preview App</title><meta name="backstage-app-mode" content="public"><script defer="defer" src="/static/runtime.
|
|
1
|
+
<!doctype html><html lang="en"><head><meta charset="utf-8"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="Backstage is an open source framework for building developer portals"/><link rel="manifest" href="/manifest.json" crossorigin="use-credentials"/><link rel="icon" href="/favicon.ico"/><link rel="shortcut icon" href="/favicon.ico"/><link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png"/><link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png"/><link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png"/><link rel="mask-icon" href="/safari-pinned-tab.svg" color="#5bbad5"/><title>Techdocs Preview App</title><meta name="backstage-app-mode" content="public"><script defer="defer" src="/static/runtime.3227a1b9.js"></script><script defer="defer" src="/static/module-material-ui.f1846a3c.js"></script><script defer="defer" src="/static/module-lodash.9d3aac3b.js"></script><script defer="defer" src="/static/module-date-fns.9ba6144d.js"></script><script defer="defer" src="/static/module-mui.e17dd999.js"></script><script defer="defer" src="/static/module-material-table.e3f26578.js"></script><script defer="defer" src="/static/module-react-dom.1f38e13a.js"></script><script defer="defer" src="/static/module-react-router.933956ac.js"></script><script defer="defer" src="/static/module-react-router-dom.473a1e8a.js"></script><script defer="defer" src="/static/module-react-beautiful-dnd.ea59573c.js"></script><script defer="defer" src="/static/module-zod.9a0df421.js"></script><script defer="defer" src="/static/module-i18next.6b4e6495.js"></script><script defer="defer" src="/static/vendor.3227a1b9.js"></script><script defer="defer" src="/static/main.3227a1b9.js"></script></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use strict";(()=>{(self.webpackChunktechdocs_cli_embedded_app=self.webpackChunktechdocs_cli_embedded_app||[]).push([[4036],{70048:(I,g,e)=>{e.d(g,{K:()=>a});var t=e(18690);function a(C){return(0,t.g)()}},93160:(I,g,e)=>{e.d(g,{b:()=>V,W:()=>Z});var t=e(31085),a=e(14041),C=e(18690),D=e(24504),P=e(72020),x=e(86892),B=e(
|
|
1
|
+
"use strict";(()=>{(self.webpackChunktechdocs_cli_embedded_app=self.webpackChunktechdocs_cli_embedded_app||[]).push([[4036],{70048:(I,g,e)=>{e.d(g,{K:()=>a});var t=e(18690);function a(C){return(0,t.g)()}},93160:(I,g,e)=>{e.d(g,{b:()=>V,W:()=>Z});var t=e(31085),a=e(14041),C=e(18690),D=e(24504),P=e(72020),x=e(86892),B=e(91424),L=e(45061),S=e(39299),K=e(82779),U=e(70048),v=e(19402),W=e(22020),F=e(82266),R=e(64947),M=e(72427),O=e(70795),p=e(57405),H=e(16261);function Y(l,c){const[h,u]=(0,a.useState)({status:"not-executed",error:void 0,result:c}),s=(0,a.useRef)(),n=(0,a.useRef)(),E=(0,H.J)({execute(...i){n.current=i;const d=l(...i);return s.current=d,u(r=>({...r,status:"loading"})),d.then(r=>{d===s.current&&u(o=>({...o,status:"success",error:void 0,result:r}))},r=>{d===s.current&&u(o=>({...o,status:"error",error:r}))}),d},reset(){u({status:"not-executed",error:void 0,result:c}),s.current=void 0,n.current=void 0}});return[h,(0,a.useMemo)(()=>({reset(){E.current.reset()},execute:(...i)=>E.current.execute(...i)}),[]),{promise:s.current,lastArgs:n.current}]}var $=e(76842),N=e(70835);const T="/.backstage/auth/v1/cookie",y=365*24*36e5;function A(l){const{pluginId:c}=l??{},h=(0,M.gf)(O.a),u=(0,M.gf)(p.I),s=(0,a.useMemo)(()=>"BroadcastChannel"in window?new BroadcastChannel(`${c}-auth-cookie-expires-at`):null,[c]),[n,E]=Y(async()=>{const o=`${await u.getBaseUrl(c)}${T}`,f=await h.fetch(`${o}`,{credentials:"include"});if(!f.ok){if(f.status===404)return{expiresAt:new Date(Date.now()+y)};throw await N.o.fromResponse(f)}const m=await f.json();if(!m.expiresAt)throw new Error("No expiration date found in response");return m});(0,$.u)(E.execute);const i=(0,a.useCallback)(()=>{E.execute()},[E]),d=(0,a.useCallback)(r=>{const o=(1+3*Math.random())*6e4,f=Date.parse(r.expiresAt)-Date.now()-o,m=setTimeout(i,f);return()=>clearTimeout(m)},[i]);return(0,a.useEffect)(()=>{if(n.status!=="success"||!n.result)return()=>{};s?.postMessage({action:"COOKIE_REFRESH_SUCCESS",payload:n.result});let r=d(n.result);const o=f=>{const{action:m,payload:z}=f.data;m==="COOKIE_REFRESH_SUCCESS"&&(r(),r=d(z))};return s?.addEventListener("message",o),()=>{r(),s?.removeEventListener("message",o)}},[n,d,s]),n.status==="not-executed"?{status:"loading"}:n.status==="loading"&&!n.result?{status:"loading"}:n.status==="loading"&&n.error?{status:"loading"}:n.status==="error"&&n.error?{status:"error",error:n.error,retry:i}:{status:"success",data:n.result}}function j(l){const{children:c,...h}=l,u=(0,F.n)(),{Progress:s}=u.getComponents(),n=A(h);return n.status==="loading"?(0,t.jsx)(s,{}):n.status==="error"?(0,t.jsx)(W.b,{error:n.error,children:(0,t.jsx)(R.A,{variant:"outlined",onClick:n.retry,children:"Retry"})}):(0,t.jsx)(t.Fragment,{children:c})}const V=l=>{const{withSearch:c,withHeader:h=!0}=l;return(0,t.jsxs)(D.Y,{themeId:"documentation",children:[h&&(0,t.jsx)(L.T,{}),(0,t.jsx)(S.Z,{}),(0,t.jsx)(B.p,{withSearch:c})]})},Z=l=>{const{kind:c,name:h,namespace:u}=(0,U.K)(K.Oc),{children:s,entityRef:n={kind:c,name:h,namespace:u}}=l,E=(0,C.P1)();if(!s){const r=(E?a.Children.toArray(E.props.children):[]).flatMap(o=>o?.props?.children??[]).find(o=>!(0,v.E)(o,P.AF)&&!(0,v.E)(o,P.Wm));return(0,t.jsx)(j,{pluginId:"techdocs",children:(0,t.jsx)(x.R,{entityRef:n,children:r||(0,t.jsx)(V,{})})})}return(0,t.jsx)(j,{pluginId:"techdocs",children:(0,t.jsx)(x.R,{entityRef:n,children:({metadata:i,entityMetadata:d,onReady:r})=>(0,t.jsx)("div",{className:"techdocs-reader-page",children:(0,t.jsx)(D.Y,{themeId:"documentation",children:s instanceof Function?s({entityRef:n,techdocsMetadataValue:i.value,entityMetadataValue:d.value,onReady:r}):s})})})})}},84036:(I,g,e)=>{e.r(g),e.d(g,{TechDocsReaderLayout:()=>t.b,TechDocsReaderPage:()=>t.W});var t=e(93160)},39299:(I,g,e)=>{e.d(g,{Z:()=>F});var t=e(31085),a=e(14041),C=e(58837),D=e(29365),P=e(75173),x=e(71677),B=e(37757),L=e(10394),S=e(9684),K=e(86892),U=e(72020),v=e(99730);const W=(0,C.A)(R=>({root:{gridArea:"pageSubheader",flexDirection:"column",minHeight:"auto",padding:R.spacing(3,3,0),"@media print":{display:"none"}}})),F=R=>{const M=W(),[O,p]=(0,a.useState)(null),H=(0,a.useCallback)(j=>{p(j.currentTarget)},[]),Y=(0,a.useCallback)(()=>{p(null)},[]),{entityMetadata:{value:$,loading:N}}=(0,K.V)(),T=(0,U.YR)(),y=T.renderComponentsByLocation(v.e.Subheader),A=T.renderComponentsByLocation(v.e.Settings);return!y&&!A||N===!1&&!$?null:(0,t.jsx)(P.A,{classes:M,...R.toolbarProps,children:(0,t.jsxs)(L.A,{display:"flex",justifyContent:"flex-end",width:"100%",flexWrap:"wrap",children:[y,A?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(x.Ay,{title:"Settings",children:(0,t.jsx)(D.A,{"aria-controls":"tech-docs-reader-page-settings","aria-haspopup":"true",onClick:H,children:(0,t.jsx)(S.A,{})})}),(0,t.jsx)(B.A,{id:"tech-docs-reader-page-settings",getContentAnchorEl:null,anchorEl:O,anchorOrigin:{vertical:"bottom",horizontal:"right"},open:!!O,onClose:Y,keepMounted:!0,children:(0,t.jsx)("div",{children:A})})]}):null]})})}}}]);})();
|
|
2
2
|
|
|
3
|
-
//# sourceMappingURL=4036.
|
|
3
|
+
//# sourceMappingURL=4036.24f6021a.chunk.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"static/4036.a029793d.chunk.js","mappings":"6KAwBO,SAASA,EACdC,EAAiD,CAEjD,SAAOC,EAAAA,GAAU,CACnB,C,gQC1BO,SAASC,EAASC,EAASC,EAAc,CAC5C,KAAM,CAACC,EAAOC,CAAQ,KAAI,YAAS,CAC/B,OAAQ,eACR,MAAO,OACP,OAAQF,CACZ,CAAC,EACKG,KAAa,UAAO,EACpBC,KAAU,UAAO,EACjBC,KAAUC,EAAA,GAAa,CACzB,WAAWC,EAAQ,CACfH,EAAQ,QAAUG,EAClB,MAAMC,EAAUT,EAAQ,GAAGQ,CAAM,EACjC,OAAAJ,EAAW,QAAUK,EACrBN,EAAUO,IAAO,CAAE,GAAGA,EAAG,OAAQ,SAAU,EAAE,EAC7CD,EAAQ,KAAME,GAAW,CACjBF,IAAYL,EAAW,SACvBD,EAAUO,IAAO,CAAE,GAAGA,EAAG,OAAQ,UAAW,MAAO,OAAW,OAAAC,CAAO,EAAE,CAE/E,EAAIC,GAAU,CACNH,IAAYL,EAAW,SACvBD,EAAUO,IAAO,CAAE,GAAGA,EAAG,OAAQ,QAAS,MAAAE,CAAM,EAAE,CAE1D,CAAC,EACMH,CACX,EACA,OAAQ,CACJN,EAAS,CACL,OAAQ,eACR,MAAO,OAC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AOA,CAAClB,QAASA,EAAU,GAAGxD,EAAM2E,a,YACnC,QAACC,EAAAA,EAAGA,CACFrB,QAAQ,OACRsB,eAAe,WACfC,MAAM,OACNC,SAAS,O,UAERX,EACAI,KACC,oB,aACE,OAACQ,EAAAA,GAAOA,CAACC,MAAM,W,YACb,OAACC,EAAAA,EAAUA,CACTC,gBAAc,iCACdC,gBAAc,OACd3E,QAASmD,E,YAET,OAACyB,EAAAA,EAAYA,CAAAA,CAAAA,C,QAGjB,OAACC,EAAAA,EAAIA,CACHC,GAAG,iCACHC,mBAAoB,KACpB/B,SAAUA,EACVgC,aAAc,CAAEC,SAAU,SAAUC,WAAY,OAAQ,EACxDC,KAAMC,EAAQpC,EACdqC,QAAShC,EACTiC,YAAW,G,YAEX,OAACvD,MAAAA,C,SAAKgC,C,QAGR,I,KAIZ,C","sources":["webpack://techdocs-cli-embedded-app/../core-plugin-api/src/routing/useRouteRefParams.ts","webpack://techdocs-cli-embedded-app/../../node_modules/@react-hookz/web/src/useAsync/index.js","webpack://techdocs-cli-embedded-app/../../plugins/auth-react/src/hooks/useCookieAuthRefresh/useCookieAuthRefresh.tsx","webpack://techdocs-cli-embedded-app/../../plugins/auth-react/src/components/CookieAuthRefreshProvider/CookieAuthRefreshProvider.tsx","webpack://techdocs-cli-embedded-app/../../plugins/techdocs/src/reader/components/TechDocsReaderPage/TechDocsReaderPage.tsx","webpack://techdocs-cli-embedded-app/../../plugins/techdocs/src/reader/components/TechDocsReaderPageSubheader/TechDocsReaderPageSubheader.tsx"],"sourcesContent":["/*\n * Copyright 2021 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 { useParams } from 'react-router-dom';\nimport { RouteRef, AnyParams, SubRouteRef } from './types';\n\n/**\n * React hook for retrieving dynamic params from the current URL.\n * @param _routeRef - Ref of the current route.\n * @public\n */\nexport function useRouteRefParams<Params extends AnyParams>(\n _routeRef: RouteRef<Params> | SubRouteRef<Params>,\n): Params {\n return useParams() as Params;\n}\n","import { useMemo, useRef, useState } from 'react';\nimport { useSyncedRef } from '../useSyncedRef/index.js';\nexport function useAsync(asyncFn, initialValue) {\n const [state, setState] = useState({\n status: 'not-executed',\n error: undefined,\n result: initialValue,\n });\n const promiseRef = useRef();\n const argsRef = useRef();\n const methods = useSyncedRef({\n execute(...params) {\n argsRef.current = params;\n const promise = asyncFn(...params);\n promiseRef.current = promise;\n setState((s) => ({ ...s, status: 'loading' }));\n promise.then((result) => {\n if (promise === promiseRef.current) {\n setState((s) => ({ ...s, status: 'success', error: undefined, result }));\n }\n }, (error) => {\n if (promise === promiseRef.current) {\n setState((s) => ({ ...s, status: 'error', error }));\n }\n });\n return promise;\n },\n reset() {\n setState({\n status: 'not-executed',\n error: undefined,\n result: initialValue,\n });\n promiseRef.current = undefined;\n argsRef.current = undefined;\n },\n });\n return [\n state,\n useMemo(() => ({\n reset() {\n methods.current.reset();\n },\n execute: (...params) => methods.current.execute(...params),\n }), []),\n { promise: promiseRef.current, lastArgs: argsRef.current },\n ];\n}\n","/*\n * Copyright 2024 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 { useEffect, useCallback, useMemo } from 'react';\nimport {\n discoveryApiRef,\n fetchApiRef,\n useApi,\n} from '@backstage/core-plugin-api';\nimport { useAsync, useMountEffect } from '@react-hookz/web';\nimport { ResponseError } from '@backstage/errors';\n\nconst COOKIE_PATH = '/.backstage/auth/v1/cookie';\nconst ONE_YEAR_MS = 365 * 24 * 3600_000;\n\n/**\n * @public\n * A hook that will refresh the cookie when it is about to expire.\n * @param options - Options for configuring the refresh cookie endpoint\n */\nexport function useCookieAuthRefresh(options: {\n // The plugin id used for discovering the API origin\n pluginId: string;\n}):\n | { status: 'loading' }\n | { status: 'error'; error: Error; retry: () => void }\n | { status: 'success'; data: { expiresAt: string } } {\n const { pluginId } = options ?? {};\n const fetchApi = useApi(fetchApiRef);\n const discoveryApi = useApi(discoveryApiRef);\n\n const channel = useMemo(() => {\n return 'BroadcastChannel' in window\n ? new BroadcastChannel(`${pluginId}-auth-cookie-expires-at`)\n : null;\n }, [pluginId]);\n\n const [state, actions] = useAsync<{ expiresAt: string }>(async () => {\n const apiOrigin = await discoveryApi.getBaseUrl(pluginId);\n const requestUrl = `${apiOrigin}${COOKIE_PATH}`;\n const response = await fetchApi.fetch(`${requestUrl}`, {\n credentials: 'include',\n });\n if (!response.ok) {\n // If we get a 404 from the cookie endpoint we assume that it does not\n // exist and cookie auth is not needed. For all active tabs we don't\n // schedule another refresh for the forseeable future, but new tabs will\n // still check if cookie auth has been added to the deployment.\n // TODO(Rugvip): Once the legacy backend system is no longer supported we should remove this check\n if (response.status === 404) {\n return { expiresAt: new Date(Date.now() + ONE_YEAR_MS) };\n }\n throw await ResponseError.fromResponse(response);\n }\n const data = await response.json();\n if (!data.expiresAt) {\n throw new Error('No expiration date found in response');\n }\n return data;\n });\n\n useMountEffect(actions.execute);\n\n const retry = useCallback(() => {\n actions.execute();\n }, [actions]);\n\n const refresh = useCallback(\n (params: { expiresAt: string }) => {\n // Randomize the refreshing margin with a margin of 1-4 minutes to avoid all tabs refreshing at the same time\n // It cannot be less than 5 minutes otherwise the backend will return the same expiration date\n const margin = (1 + 3 * Math.random()) * 60000;\n const delay = Date.parse(params.expiresAt) - Date.now() - margin;\n const timeout = setTimeout(retry, delay);\n return () => clearTimeout(timeout);\n },\n [retry],\n );\n\n useEffect(() => {\n // Only schedule a refresh if we have a successful response\n if (state.status !== 'success' || !state.result) {\n return () => {};\n }\n channel?.postMessage({\n action: 'COOKIE_REFRESH_SUCCESS',\n payload: state.result,\n });\n let cancel = refresh(state.result);\n const listener = (\n event: MessageEvent<{ action: string; payload: { expiresAt: string } }>,\n ) => {\n const { action, payload } = event.data;\n if (action === 'COOKIE_REFRESH_SUCCESS') {\n cancel();\n cancel = refresh(payload);\n }\n };\n channel?.addEventListener('message', listener);\n return () => {\n cancel();\n channel?.removeEventListener('message', listener);\n };\n }, [state, refresh, channel]);\n\n // Initialising\n if (state.status === 'not-executed') {\n return { status: 'loading' };\n }\n\n // First refresh or retrying without any success before\n // Possible state transitions:\n // e.g. not-executed -> loading (first-refresh)\n // e.g. not-executed -> loading (first-refresh) -> error -> loading (manual-retry)\n if (state.status === 'loading' && !state.result) {\n return { status: 'loading' };\n }\n\n // Retrying after having succeeding at least once\n // Current state is: { status: 'loading', result: {...}, error: undefined | Error }\n // e.g. not-executed -> loading (first-refresh) -> success -> loading (scheduled-refresh) -> error -> loading (manual-retry)\n if (state.status === 'loading' && state.error) {\n return { status: 'loading' };\n }\n\n // Something went wrong during any situation of a refresh\n if (state.status === 'error' && state.error) {\n return { status: 'error', error: state.error, retry };\n }\n\n // At this point it should be safe to assume that we have a successful refresh\n return { status: 'success', data: state.result! };\n}\n","/*\n * Copyright 2024 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 React, { ReactNode } from 'react';\nimport { ErrorPanel } from '@backstage/core-components';\nimport { useApp } from '@backstage/core-plugin-api';\nimport Button from '@material-ui/core/Button';\nimport { useCookieAuthRefresh } from '../../hooks';\n\n/**\n * @public\n * Props for the {@link CookieAuthRefreshProvider} component.\n */\nexport type CookieAuthRefreshProviderProps = {\n // The plugin ID used for discovering the API origin\n pluginId: string;\n // The children to render when the refresh is successful\n children: ReactNode;\n};\n\n/**\n * @public\n * A provider that will refresh the cookie when it is about to expire.\n */\nexport function CookieAuthRefreshProvider(\n props: CookieAuthRefreshProviderProps,\n): JSX.Element {\n const { children, ...options } = props;\n const app = useApp();\n const { Progress } = app.getComponents();\n\n const result = useCookieAuthRefresh(options);\n\n if (result.status === 'loading') {\n return <Progress />;\n }\n\n if (result.status === 'error') {\n return (\n <ErrorPanel error={result.error}>\n <Button variant=\"outlined\" onClick={result.retry}>\n Retry\n </Button>\n </ErrorPanel>\n );\n }\n\n return <>{children}</>;\n}\n","/*\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 React, { ReactNode, Children, ReactElement } from 'react';\nimport { useOutlet } from 'react-router-dom';\n\nimport { Page } from '@backstage/core-components';\nimport { CompoundEntityRef } from '@backstage/catalog-model';\nimport {\n TECHDOCS_ADDONS_WRAPPER_KEY,\n TECHDOCS_ADDONS_KEY,\n TechDocsReaderPageProvider,\n} from '@backstage/plugin-techdocs-react';\n\nimport { TechDocsReaderPageRenderFunction } from '../../../types';\n\nimport { TechDocsReaderPageContent } from '../TechDocsReaderPageContent';\nimport { TechDocsReaderPageHeader } from '../TechDocsReaderPageHeader';\nimport { TechDocsReaderPageSubheader } from '../TechDocsReaderPageSubheader';\nimport { rootDocsRouteRef } from '../../../routes';\nimport {\n getComponentData,\n useRouteRefParams,\n} from '@backstage/core-plugin-api';\n\nimport { CookieAuthRefreshProvider } from '@backstage/plugin-auth-react';\n\n/* An explanation for the multiple ways of customizing the TechDocs reader page\n\nPlease refer to this page on the microsite for the latest recommended approach:\nhttps://backstage.io/docs/features/techdocs/how-to-guides#how-to-customize-the-techdocs-reader-page\n\nThe <TechDocsReaderPage> component is responsible for rendering the <TechDocsReaderPageProvider> and\nits contained version of a <Page>, which in turn renders the <TechDocsReaderPageContent>.\n\nHistorically, there have been different approaches on how this <Page> can be customized, and how the\n<TechDocsReaderPageContent> inside could be exchanged for a custom implementation (which was not\npossible before). Also, the current implementation supports every scenario to avoid breaking default\nconfigurations of TechDocs.\n\nIn particular, there are 4 different TechDocs page configurations:\n\nCONFIGURATION 1: <TechDocsReaderPage> only, no children\n\n<Route path=\"/docs/:namespace/:kind/:name/*\" element={<TechDocsReaderPage />} >\n\nThis is the simplest way to use TechDocs. Only a full page is passed, assuming that it comes with\nits content inside. Since we allowed customizing it, we started providing <TechDocsReaderLayout> as\na default implementation (which contains <TechDocsReaderPageContent>).\n\nCONFIGURATION 2 (not advised): <TechDocsReaderPage> with element children\n\n<Route\n path=\"/docs/:namespace/:kind/:name/*\"\n element={\n <TechDocsReaderPage>\n {techdocsPage}\n </TechDocsReaderPage>\n }\n/>\n\nPreviously, there were two ways of passing children to <TechDocsReaderPage>: either as elements (as\nshown above), or as a render function (described below in CONFIGURATION 3). The \"techdocsPage\" is\nlocated in packages/app/src/components/techdocs and is the default implementation of the content\ninside.\n\nCONFIGURATION 3 (not advised): <TechDocsReaderPage> with render function as child\n\n<Route\n path=\"/docs/:namespace/:kind/:name/*\"\n element={\n <TechDocsReaderPage>\n {({ metadata, entityMetadata, onReady }) => (\n techdocsPage\n )}\n </TechDocsReaderPage>\n }\n/>\n\nSimilar to CONFIGURATION 2, the direct children will be passed to the <TechDocsReaderPage> but in\nthis case interpreted as render prop.\n\nCONFIGURATION 4: <TechDocsReaderPage> and provided content in <Route>\n\n<Route\n path=\"/docs/:namespace/:kind/:name/*\"\n element={<TechDocsReaderPage />}\n>\n {techDocsPage}\n <TechDocsAddons>\n <ExpandableNavigation />\n <ReportIssue />\n <TextSize />\n <LightBox />\n </TechDocsAddons>\n</Route>\n\nThis is the current state in packages/app/src/App.tsx and moved the location of children from inside\nthe element prop in the <Route> to the children of the <Route>. Then, in <TechDocsReaderPage> they\nare retrieved using the useOutlet hook from React Router.\n\nNOTE: Render functions are no longer supported in this approach.\n*/\n\n/**\n * Props for {@link TechDocsReaderLayout}\n * @public\n */\nexport type TechDocsReaderLayoutProps = {\n /**\n * Show or hide the header, defaults to true.\n */\n withHeader?: boolean;\n /**\n * Show or hide the content search bar, defaults to true.\n */\n withSearch?: boolean;\n};\n\n/**\n * Default TechDocs reader page structure composed with a header and content\n * @public\n */\nexport const TechDocsReaderLayout = (props: TechDocsReaderLayoutProps) => {\n const { withSearch, withHeader = true } = props;\n return (\n <Page themeId=\"documentation\">\n {withHeader && <TechDocsReaderPageHeader />}\n <TechDocsReaderPageSubheader />\n <TechDocsReaderPageContent withSearch={withSearch} />\n </Page>\n );\n};\n\n/**\n * @public\n */\nexport type TechDocsReaderPageProps = {\n entityRef?: CompoundEntityRef;\n children?: TechDocsReaderPageRenderFunction | ReactNode;\n};\n\n/**\n * An addon-aware implementation of the TechDocsReaderPage.\n *\n * @public\n */\nexport const TechDocsReaderPage = (props: TechDocsReaderPageProps) => {\n const { kind, name, namespace } = useRouteRefParams(rootDocsRouteRef);\n const { children, entityRef = { kind, name, namespace } } = props;\n\n const outlet = useOutlet();\n\n if (!children) {\n const childrenList = outlet ? Children.toArray(outlet.props.children) : [];\n\n const grandChildren = childrenList.flatMap<ReactElement>(\n child => (child as ReactElement)?.props?.children ?? [],\n );\n\n const page: React.ReactNode = grandChildren.find(\n grandChild =>\n !getComponentData(grandChild, TECHDOCS_ADDONS_WRAPPER_KEY) &&\n !getComponentData(grandChild, TECHDOCS_ADDONS_KEY),\n );\n\n // As explained above, \"page\" is configuration 4 and <TechDocsReaderLayout> is 1\n return (\n <CookieAuthRefreshProvider pluginId=\"techdocs\">\n <TechDocsReaderPageProvider entityRef={entityRef}>\n {(page as JSX.Element) || <TechDocsReaderLayout />}\n </TechDocsReaderPageProvider>\n </CookieAuthRefreshProvider>\n );\n }\n\n // As explained above, a render function is configuration 3 and React element is 2\n return (\n <CookieAuthRefreshProvider pluginId=\"techdocs\">\n <TechDocsReaderPageProvider entityRef={entityRef}>\n {({ metadata, entityMetadata, onReady }) => (\n <div className=\"techdocs-reader-page\">\n <Page themeId=\"documentation\">\n {children instanceof Function\n ? children({\n entityRef,\n techdocsMetadataValue: metadata.value,\n entityMetadataValue: entityMetadata.value,\n onReady,\n })\n : children}\n </Page>\n </div>\n )}\n </TechDocsReaderPageProvider>\n </CookieAuthRefreshProvider>\n );\n};\n","/*\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 React, { MouseEvent, useState, useCallback } from 'react';\n\nimport { makeStyles } from '@material-ui/core/styles';\nimport IconButton from '@material-ui/core/IconButton';\nimport Toolbar from '@material-ui/core/Toolbar';\nimport { ToolbarProps } from '@material-ui/core/Toolbar';\nimport Tooltip from '@material-ui/core/Tooltip';\nimport Menu from '@material-ui/core/Menu';\nimport Box from '@material-ui/core/Box';\nimport SettingsIcon from '@material-ui/icons/Settings';\n\nimport {\n TechDocsAddonLocations as locations,\n useTechDocsAddons,\n useTechDocsReaderPage,\n} from '@backstage/plugin-techdocs-react';\n\nconst useStyles = makeStyles(theme => ({\n root: {\n gridArea: 'pageSubheader',\n flexDirection: 'column',\n minHeight: 'auto',\n padding: theme.spacing(3, 3, 0),\n '@media print': {\n display: 'none',\n },\n },\n}));\n\n/**\n * Renders the reader page subheader.\n * Please use the Tech Docs add-ons to customize it\n * @public\n */\nexport const TechDocsReaderPageSubheader = (props: {\n toolbarProps?: ToolbarProps;\n}) => {\n const classes = useStyles();\n const [anchorEl, setAnchorEl] = useState<null | HTMLElement>(null);\n\n const handleClick = useCallback((event: MouseEvent<HTMLButtonElement>) => {\n setAnchorEl(event.currentTarget);\n }, []);\n\n const handleClose = useCallback(() => {\n setAnchorEl(null);\n }, []);\n\n const {\n entityMetadata: { value: entityMetadata, loading: entityMetadataLoading },\n } = useTechDocsReaderPage();\n\n const addons = useTechDocsAddons();\n\n const subheaderAddons = addons.renderComponentsByLocation(\n locations.Subheader,\n );\n\n const settingsAddons = addons.renderComponentsByLocation(locations.Settings);\n\n if (!subheaderAddons && !settingsAddons) return null;\n\n // No entity metadata = 404. Don't render subheader on 404.\n if (entityMetadataLoading === false && !entityMetadata) return null;\n\n return (\n <Toolbar classes={classes} {...props.toolbarProps}>\n <Box\n display=\"flex\"\n justifyContent=\"flex-end\"\n width=\"100%\"\n flexWrap=\"wrap\"\n >\n {subheaderAddons}\n {settingsAddons ? (\n <>\n <Tooltip title=\"Settings\">\n <IconButton\n aria-controls=\"tech-docs-reader-page-settings\"\n aria-haspopup=\"true\"\n onClick={handleClick}\n >\n <SettingsIcon />\n </IconButton>\n </Tooltip>\n <Menu\n id=\"tech-docs-reader-page-settings\"\n getContentAnchorEl={null}\n anchorEl={anchorEl}\n anchorOrigin={{ vertical: 'bottom', horizontal: 'right' }}\n open={Boolean(anchorEl)}\n onClose={handleClose}\n keepMounted\n >\n <div>{settingsAddons}</div>\n </Menu>\n </>\n ) : null}\n </Box>\n </Toolbar>\n );\n};\n"],"names":["useRouteRefParams","_routeRef","useParams","useAsync","asyncFn","initialValue","state","setState","promiseRef","argsRef","methods","useSyncedRef","params","promise","s","result","error","COOKIE_PATH","ONE_YEAR_MS","useCookieAuthRefresh","options","pluginId","fetchApi","useApi","fetchApiRef","discoveryApi","discoveryApiRef","channel","useMemo","window","BroadcastChannel","actions","requestUrl","getBaseUrl","response","fetch","credentials","ok","status","expiresAt","Date","now","ResponseError","fromResponse","data","json","Error","useMountEffect","execute","retry","useCallback","refresh","margin","Math","random","delay","parse","timeout","setTimeout","clearTimeout","useEffect","postMessage","action","payload","cancel","listener","event","addEventListener","removeEventListener","CookieAuthRefreshProvider","props","children","app","useApp","Progress","getComponents","ErrorPanel","Button","variant","onClick","TechDocsReaderLayout","withSearch","withHeader","Page","themeId","TechDocsReaderPageHeader","TechDocsReaderPageSubheader","TechDocsReaderPageContent","TechDocsReaderPage","kind","name","namespace","rootDocsRouteRef","entityRef","outlet","useOutlet","page","Children","toArray","flatMap","child","find","grandChild","getComponentData","TECHDOCS_ADDONS_WRAPPER_KEY","TECHDOCS_ADDONS_KEY","TechDocsReaderPageProvider","metadata","entityMetadata","onReady","div","className","Function","techdocsMetadataValue","value","entityMetadataValue","useStyles","makeStyles","theme","root","gridArea","flexDirection","minHeight","padding","spacing","display","classes","anchorEl","setAnchorEl","useState","handleClick","currentTarget","handleClose","loading","entityMetadataLoading","useTechDocsReaderPage","addons","useTechDocsAddons","subheaderAddons","renderComponentsByLocation","locations","Subheader","settingsAddons","Settings","Toolbar","toolbarProps","Box","justifyContent","width","flexWrap","Tooltip","title","IconButton","aria-controls","aria-haspopup","SettingsIcon","Menu","id","getContentAnchorEl","anchorOrigin","vertical","horizontal","open","Boolean","onClose","keepMounted"],"sourceRoot":""}
|
|
1
|
+
{"version":3,"file":"static/4036.24f6021a.chunk.js","mappings":"6KAwBO,SAASA,EACdC,EAAiD,CAEjD,SAAOC,EAAAA,GAAU,CACnB,C,gQC1BO,SAASC,EAASC,EAASC,EAAc,CAC5C,KAAM,CAACC,EAAOC,CAAQ,KAAI,YAAS,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F,CACF,EAAE,EAOWvC,EAA+BhB,GAAAA,CAG1C,MAAMwD,EAAUV,EAAU,EACpB,CAACW,EAAUC,CAAW,KAAIC,EAAAA,UAA6B,IAAI,EAE3DC,KAAchF,EAAAA,aAAagB,GAAAA,CAC/B8D,EAAY9D,EAAMiE,aAAa,CACjC,EAAG,CAAC,CAAC,EAECC,KAAclF,EAAAA,aAAY,KAC9B8E,EAAY,IAAI,CAClB,EAAG,CAAC,CAAC,EAEC,CACJpB,eAAgB,CAAEM,MAAON,EAAgByB,QAASC,CAAsB,CAAC,KACvEC,EAAAA,GAAsB,EAEpBC,KAASC,EAAAA,IAAkB,EAE3BC,EAAkBF,EAAOG,2BAC7BC,EAAAA,EAAUC,SAAS,EAGfC,EAAiBN,EAAOG,2BAA2BC,EAAAA,EAAUG,QAAQ,EAK3E,MAHI,CAACL,GAAmB,CAACI,GAGrBR,IAA0B,IAAS,CAAC1B,EAAuB,QAG7D,OAACoC,EAAAA,EAAOA,CAAClB,QAASA,EAAU,GAAGxD,EAAM2E,a,YACnC,QAACC,EAAAA,EAAGA,CACFrB,QAAQ,OACRsB,eAAe,WACfC,MAAM,OACNC,SAAS,O,UAERX,EACAI,KACC,oB,aACE,OAACQ,EAAAA,GAAOA,CAACC,MAAM,W,YACb,OAACC,EAAAA,EAAUA,CACTC,gBAAc,iCACdC,gBAAc,OACd3E,QAASmD,E,YAET,OAACyB,EAAAA,EAAYA,CAAAA,CAAAA,C,QAGjB,OAACC,EAAAA,EAAIA,CACHC,GAAG,iCACHC,mBAAoB,KACpB/B,SAAUA,EACVgC,aAAc,CAAEC,SAAU,SAAUC,WAAY,OAAQ,EACxDC,KAAMC,EAAQpC,EACdqC,QAAShC,EACTiC,YAAW,G,YAEX,OAACvD,MAAAA,C,SAAKgC,C,QAGR,I,KAIZ,C","sources":["webpack://techdocs-cli-embedded-app/../core-plugin-api/src/routing/useRouteRefParams.ts","webpack://techdocs-cli-embedded-app/../../node_modules/@react-hookz/web/src/useAsync/index.js","webpack://techdocs-cli-embedded-app/../../plugins/auth-react/src/hooks/useCookieAuthRefresh/useCookieAuthRefresh.tsx","webpack://techdocs-cli-embedded-app/../../plugins/auth-react/src/components/CookieAuthRefreshProvider/CookieAuthRefreshProvider.tsx","webpack://techdocs-cli-embedded-app/../../plugins/techdocs/src/reader/components/TechDocsReaderPage/TechDocsReaderPage.tsx","webpack://techdocs-cli-embedded-app/../../plugins/techdocs/src/reader/components/TechDocsReaderPageSubheader/TechDocsReaderPageSubheader.tsx"],"sourcesContent":["/*\n * Copyright 2021 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 { useParams } from 'react-router-dom';\nimport { RouteRef, AnyParams, SubRouteRef } from './types';\n\n/**\n * React hook for retrieving dynamic params from the current URL.\n * @param _routeRef - Ref of the current route.\n * @public\n */\nexport function useRouteRefParams<Params extends AnyParams>(\n _routeRef: RouteRef<Params> | SubRouteRef<Params>,\n): Params {\n return useParams() as Params;\n}\n","import { useMemo, useRef, useState } from 'react';\nimport { useSyncedRef } from '../useSyncedRef/index.js';\nexport function useAsync(asyncFn, initialValue) {\n const [state, setState] = useState({\n status: 'not-executed',\n error: undefined,\n result: initialValue,\n });\n const promiseRef = useRef();\n const argsRef = useRef();\n const methods = useSyncedRef({\n execute(...params) {\n argsRef.current = params;\n const promise = asyncFn(...params);\n promiseRef.current = promise;\n setState((s) => ({ ...s, status: 'loading' }));\n promise.then((result) => {\n if (promise === promiseRef.current) {\n setState((s) => ({ ...s, status: 'success', error: undefined, result }));\n }\n }, (error) => {\n if (promise === promiseRef.current) {\n setState((s) => ({ ...s, status: 'error', error }));\n }\n });\n return promise;\n },\n reset() {\n setState({\n status: 'not-executed',\n error: undefined,\n result: initialValue,\n });\n promiseRef.current = undefined;\n argsRef.current = undefined;\n },\n });\n return [\n state,\n useMemo(() => ({\n reset() {\n methods.current.reset();\n },\n execute: (...params) => methods.current.execute(...params),\n }), []),\n { promise: promiseRef.current, lastArgs: argsRef.current },\n ];\n}\n","/*\n * Copyright 2024 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 { useEffect, useCallback, useMemo } from 'react';\nimport {\n discoveryApiRef,\n fetchApiRef,\n useApi,\n} from '@backstage/core-plugin-api';\nimport { useAsync, useMountEffect } from '@react-hookz/web';\nimport { ResponseError } from '@backstage/errors';\n\nconst COOKIE_PATH = '/.backstage/auth/v1/cookie';\nconst ONE_YEAR_MS = 365 * 24 * 3600_000;\n\n/**\n * @public\n * A hook that will refresh the cookie when it is about to expire.\n * @param options - Options for configuring the refresh cookie endpoint\n */\nexport function useCookieAuthRefresh(options: {\n // The plugin id used for discovering the API origin\n pluginId: string;\n}):\n | { status: 'loading' }\n | { status: 'error'; error: Error; retry: () => void }\n | { status: 'success'; data: { expiresAt: string } } {\n const { pluginId } = options ?? {};\n const fetchApi = useApi(fetchApiRef);\n const discoveryApi = useApi(discoveryApiRef);\n\n const channel = useMemo(() => {\n return 'BroadcastChannel' in window\n ? new BroadcastChannel(`${pluginId}-auth-cookie-expires-at`)\n : null;\n }, [pluginId]);\n\n const [state, actions] = useAsync<{ expiresAt: string }>(async () => {\n const apiOrigin = await discoveryApi.getBaseUrl(pluginId);\n const requestUrl = `${apiOrigin}${COOKIE_PATH}`;\n const response = await fetchApi.fetch(`${requestUrl}`, {\n credentials: 'include',\n });\n if (!response.ok) {\n // If we get a 404 from the cookie endpoint we assume that it does not\n // exist and cookie auth is not needed. For all active tabs we don't\n // schedule another refresh for the forseeable future, but new tabs will\n // still check if cookie auth has been added to the deployment.\n // TODO(Rugvip): Once the legacy backend system is no longer supported we should remove this check\n if (response.status === 404) {\n return { expiresAt: new Date(Date.now() + ONE_YEAR_MS) };\n }\n throw await ResponseError.fromResponse(response);\n }\n const data = await response.json();\n if (!data.expiresAt) {\n throw new Error('No expiration date found in response');\n }\n return data;\n });\n\n useMountEffect(actions.execute);\n\n const retry = useCallback(() => {\n actions.execute();\n }, [actions]);\n\n const refresh = useCallback(\n (params: { expiresAt: string }) => {\n // Randomize the refreshing margin with a margin of 1-4 minutes to avoid all tabs refreshing at the same time\n // It cannot be less than 5 minutes otherwise the backend will return the same expiration date\n const margin = (1 + 3 * Math.random()) * 60000;\n const delay = Date.parse(params.expiresAt) - Date.now() - margin;\n const timeout = setTimeout(retry, delay);\n return () => clearTimeout(timeout);\n },\n [retry],\n );\n\n useEffect(() => {\n // Only schedule a refresh if we have a successful response\n if (state.status !== 'success' || !state.result) {\n return () => {};\n }\n channel?.postMessage({\n action: 'COOKIE_REFRESH_SUCCESS',\n payload: state.result,\n });\n let cancel = refresh(state.result);\n const listener = (\n event: MessageEvent<{ action: string; payload: { expiresAt: string } }>,\n ) => {\n const { action, payload } = event.data;\n if (action === 'COOKIE_REFRESH_SUCCESS') {\n cancel();\n cancel = refresh(payload);\n }\n };\n channel?.addEventListener('message', listener);\n return () => {\n cancel();\n channel?.removeEventListener('message', listener);\n };\n }, [state, refresh, channel]);\n\n // Initialising\n if (state.status === 'not-executed') {\n return { status: 'loading' };\n }\n\n // First refresh or retrying without any success before\n // Possible state transitions:\n // e.g. not-executed -> loading (first-refresh)\n // e.g. not-executed -> loading (first-refresh) -> error -> loading (manual-retry)\n if (state.status === 'loading' && !state.result) {\n return { status: 'loading' };\n }\n\n // Retrying after having succeeding at least once\n // Current state is: { status: 'loading', result: {...}, error: undefined | Error }\n // e.g. not-executed -> loading (first-refresh) -> success -> loading (scheduled-refresh) -> error -> loading (manual-retry)\n if (state.status === 'loading' && state.error) {\n return { status: 'loading' };\n }\n\n // Something went wrong during any situation of a refresh\n if (state.status === 'error' && state.error) {\n return { status: 'error', error: state.error, retry };\n }\n\n // At this point it should be safe to assume that we have a successful refresh\n return { status: 'success', data: state.result! };\n}\n","/*\n * Copyright 2024 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 React, { ReactNode } from 'react';\nimport { ErrorPanel } from '@backstage/core-components';\nimport { useApp } from '@backstage/core-plugin-api';\nimport Button from '@material-ui/core/Button';\nimport { useCookieAuthRefresh } from '../../hooks';\n\n/**\n * @public\n * Props for the {@link CookieAuthRefreshProvider} component.\n */\nexport type CookieAuthRefreshProviderProps = {\n // The plugin ID used for discovering the API origin\n pluginId: string;\n // The children to render when the refresh is successful\n children: ReactNode;\n};\n\n/**\n * @public\n * A provider that will refresh the cookie when it is about to expire.\n */\nexport function CookieAuthRefreshProvider(\n props: CookieAuthRefreshProviderProps,\n): JSX.Element {\n const { children, ...options } = props;\n const app = useApp();\n const { Progress } = app.getComponents();\n\n const result = useCookieAuthRefresh(options);\n\n if (result.status === 'loading') {\n return <Progress />;\n }\n\n if (result.status === 'error') {\n return (\n <ErrorPanel error={result.error}>\n <Button variant=\"outlined\" onClick={result.retry}>\n Retry\n </Button>\n </ErrorPanel>\n );\n }\n\n return <>{children}</>;\n}\n","/*\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 React, { ReactNode, Children, ReactElement } from 'react';\nimport { useOutlet } from 'react-router-dom';\n\nimport { Page } from '@backstage/core-components';\nimport { CompoundEntityRef } from '@backstage/catalog-model';\nimport {\n TECHDOCS_ADDONS_WRAPPER_KEY,\n TECHDOCS_ADDONS_KEY,\n TechDocsReaderPageProvider,\n} from '@backstage/plugin-techdocs-react';\n\nimport { TechDocsReaderPageRenderFunction } from '../../../types';\n\nimport { TechDocsReaderPageContent } from '../TechDocsReaderPageContent';\nimport { TechDocsReaderPageHeader } from '../TechDocsReaderPageHeader';\nimport { TechDocsReaderPageSubheader } from '../TechDocsReaderPageSubheader';\nimport { rootDocsRouteRef } from '../../../routes';\nimport {\n getComponentData,\n useRouteRefParams,\n} from '@backstage/core-plugin-api';\n\nimport { CookieAuthRefreshProvider } from '@backstage/plugin-auth-react';\n\n/* An explanation for the multiple ways of customizing the TechDocs reader page\n\nPlease refer to this page on the microsite for the latest recommended approach:\nhttps://backstage.io/docs/features/techdocs/how-to-guides#how-to-customize-the-techdocs-reader-page\n\nThe <TechDocsReaderPage> component is responsible for rendering the <TechDocsReaderPageProvider> and\nits contained version of a <Page>, which in turn renders the <TechDocsReaderPageContent>.\n\nHistorically, there have been different approaches on how this <Page> can be customized, and how the\n<TechDocsReaderPageContent> inside could be exchanged for a custom implementation (which was not\npossible before). Also, the current implementation supports every scenario to avoid breaking default\nconfigurations of TechDocs.\n\nIn particular, there are 4 different TechDocs page configurations:\n\nCONFIGURATION 1: <TechDocsReaderPage> only, no children\n\n<Route path=\"/docs/:namespace/:kind/:name/*\" element={<TechDocsReaderPage />} >\n\nThis is the simplest way to use TechDocs. Only a full page is passed, assuming that it comes with\nits content inside. Since we allowed customizing it, we started providing <TechDocsReaderLayout> as\na default implementation (which contains <TechDocsReaderPageContent>).\n\nCONFIGURATION 2 (not advised): <TechDocsReaderPage> with element children\n\n<Route\n path=\"/docs/:namespace/:kind/:name/*\"\n element={\n <TechDocsReaderPage>\n {techdocsPage}\n </TechDocsReaderPage>\n }\n/>\n\nPreviously, there were two ways of passing children to <TechDocsReaderPage>: either as elements (as\nshown above), or as a render function (described below in CONFIGURATION 3). The \"techdocsPage\" is\nlocated in packages/app/src/components/techdocs and is the default implementation of the content\ninside.\n\nCONFIGURATION 3 (not advised): <TechDocsReaderPage> with render function as child\n\n<Route\n path=\"/docs/:namespace/:kind/:name/*\"\n element={\n <TechDocsReaderPage>\n {({ metadata, entityMetadata, onReady }) => (\n techdocsPage\n )}\n </TechDocsReaderPage>\n }\n/>\n\nSimilar to CONFIGURATION 2, the direct children will be passed to the <TechDocsReaderPage> but in\nthis case interpreted as render prop.\n\nCONFIGURATION 4: <TechDocsReaderPage> and provided content in <Route>\n\n<Route\n path=\"/docs/:namespace/:kind/:name/*\"\n element={<TechDocsReaderPage />}\n>\n {techDocsPage}\n <TechDocsAddons>\n <ExpandableNavigation />\n <ReportIssue />\n <TextSize />\n <LightBox />\n </TechDocsAddons>\n</Route>\n\nThis is the current state in packages/app/src/App.tsx and moved the location of children from inside\nthe element prop in the <Route> to the children of the <Route>. Then, in <TechDocsReaderPage> they\nare retrieved using the useOutlet hook from React Router.\n\nNOTE: Render functions are no longer supported in this approach.\n*/\n\n/**\n * Props for {@link TechDocsReaderLayout}\n * @public\n */\nexport type TechDocsReaderLayoutProps = {\n /**\n * Show or hide the header, defaults to true.\n */\n withHeader?: boolean;\n /**\n * Show or hide the content search bar, defaults to true.\n */\n withSearch?: boolean;\n};\n\n/**\n * Default TechDocs reader page structure composed with a header and content\n * @public\n */\nexport const TechDocsReaderLayout = (props: TechDocsReaderLayoutProps) => {\n const { withSearch, withHeader = true } = props;\n return (\n <Page themeId=\"documentation\">\n {withHeader && <TechDocsReaderPageHeader />}\n <TechDocsReaderPageSubheader />\n <TechDocsReaderPageContent withSearch={withSearch} />\n </Page>\n );\n};\n\n/**\n * @public\n */\nexport type TechDocsReaderPageProps = {\n entityRef?: CompoundEntityRef;\n children?: TechDocsReaderPageRenderFunction | ReactNode;\n};\n\n/**\n * An addon-aware implementation of the TechDocsReaderPage.\n *\n * @public\n */\nexport const TechDocsReaderPage = (props: TechDocsReaderPageProps) => {\n const { kind, name, namespace } = useRouteRefParams(rootDocsRouteRef);\n const { children, entityRef = { kind, name, namespace } } = props;\n\n const outlet = useOutlet();\n\n if (!children) {\n const childrenList = outlet ? Children.toArray(outlet.props.children) : [];\n\n const grandChildren = childrenList.flatMap<ReactElement>(\n child => (child as ReactElement)?.props?.children ?? [],\n );\n\n const page: React.ReactNode = grandChildren.find(\n grandChild =>\n !getComponentData(grandChild, TECHDOCS_ADDONS_WRAPPER_KEY) &&\n !getComponentData(grandChild, TECHDOCS_ADDONS_KEY),\n );\n\n // As explained above, \"page\" is configuration 4 and <TechDocsReaderLayout> is 1\n return (\n <CookieAuthRefreshProvider pluginId=\"techdocs\">\n <TechDocsReaderPageProvider entityRef={entityRef}>\n {(page as JSX.Element) || <TechDocsReaderLayout />}\n </TechDocsReaderPageProvider>\n </CookieAuthRefreshProvider>\n );\n }\n\n // As explained above, a render function is configuration 3 and React element is 2\n return (\n <CookieAuthRefreshProvider pluginId=\"techdocs\">\n <TechDocsReaderPageProvider entityRef={entityRef}>\n {({ metadata, entityMetadata, onReady }) => (\n <div className=\"techdocs-reader-page\">\n <Page themeId=\"documentation\">\n {children instanceof Function\n ? children({\n entityRef,\n techdocsMetadataValue: metadata.value,\n entityMetadataValue: entityMetadata.value,\n onReady,\n })\n : children}\n </Page>\n </div>\n )}\n </TechDocsReaderPageProvider>\n </CookieAuthRefreshProvider>\n );\n};\n","/*\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 React, { MouseEvent, useState, useCallback } from 'react';\n\nimport { makeStyles } from '@material-ui/core/styles';\nimport IconButton from '@material-ui/core/IconButton';\nimport Toolbar from '@material-ui/core/Toolbar';\nimport { ToolbarProps } from '@material-ui/core/Toolbar';\nimport Tooltip from '@material-ui/core/Tooltip';\nimport Menu from '@material-ui/core/Menu';\nimport Box from '@material-ui/core/Box';\nimport SettingsIcon from '@material-ui/icons/Settings';\n\nimport {\n TechDocsAddonLocations as locations,\n useTechDocsAddons,\n useTechDocsReaderPage,\n} from '@backstage/plugin-techdocs-react';\n\nconst useStyles = makeStyles(theme => ({\n root: {\n gridArea: 'pageSubheader',\n flexDirection: 'column',\n minHeight: 'auto',\n padding: theme.spacing(3, 3, 0),\n '@media print': {\n display: 'none',\n },\n },\n}));\n\n/**\n * Renders the reader page subheader.\n * Please use the Tech Docs add-ons to customize it\n * @public\n */\nexport const TechDocsReaderPageSubheader = (props: {\n toolbarProps?: ToolbarProps;\n}) => {\n const classes = useStyles();\n const [anchorEl, setAnchorEl] = useState<null | HTMLElement>(null);\n\n const handleClick = useCallback((event: MouseEvent<HTMLButtonElement>) => {\n setAnchorEl(event.currentTarget);\n }, []);\n\n const handleClose = useCallback(() => {\n setAnchorEl(null);\n }, []);\n\n const {\n entityMetadata: { value: entityMetadata, loading: entityMetadataLoading },\n } = useTechDocsReaderPage();\n\n const addons = useTechDocsAddons();\n\n const subheaderAddons = addons.renderComponentsByLocation(\n locations.Subheader,\n );\n\n const settingsAddons = addons.renderComponentsByLocation(locations.Settings);\n\n if (!subheaderAddons && !settingsAddons) return null;\n\n // No entity metadata = 404. Don't render subheader on 404.\n if (entityMetadataLoading === false && !entityMetadata) return null;\n\n return (\n <Toolbar classes={classes} {...props.toolbarProps}>\n <Box\n display=\"flex\"\n justifyContent=\"flex-end\"\n width=\"100%\"\n flexWrap=\"wrap\"\n >\n {subheaderAddons}\n {settingsAddons ? (\n <>\n <Tooltip title=\"Settings\">\n <IconButton\n aria-controls=\"tech-docs-reader-page-settings\"\n aria-haspopup=\"true\"\n onClick={handleClick}\n >\n <SettingsIcon />\n </IconButton>\n </Tooltip>\n <Menu\n id=\"tech-docs-reader-page-settings\"\n getContentAnchorEl={null}\n anchorEl={anchorEl}\n anchorOrigin={{ vertical: 'bottom', horizontal: 'right' }}\n open={Boolean(anchorEl)}\n onClose={handleClose}\n keepMounted\n >\n <div>{settingsAddons}</div>\n </Menu>\n </>\n ) : null}\n </Box>\n </Toolbar>\n );\n};\n"],"names":["useRouteRefParams","_routeRef","useParams","useAsync","asyncFn","initialValue","state","setState","promiseRef","argsRef","methods","useSyncedRef","params","promise","s","result","error","COOKIE_PATH","ONE_YEAR_MS","useCookieAuthRefresh","options","pluginId","fetchApi","useApi","fetchApiRef","discoveryApi","discoveryApiRef","channel","useMemo","window","BroadcastChannel","actions","requestUrl","getBaseUrl","response","fetch","credentials","ok","status","expiresAt","Date","now","ResponseError","fromResponse","data","json","Error","useMountEffect","execute","retry","useCallback","refresh","margin","Math","random","delay","parse","timeout","setTimeout","clearTimeout","useEffect","postMessage","action","payload","cancel","listener","event","addEventListener","removeEventListener","CookieAuthRefreshProvider","props","children","app","useApp","Progress","getComponents","ErrorPanel","Button","variant","onClick","TechDocsReaderLayout","withSearch","withHeader","Page","themeId","TechDocsReaderPageHeader","TechDocsReaderPageSubheader","TechDocsReaderPageContent","TechDocsReaderPage","kind","name","namespace","rootDocsRouteRef","entityRef","outlet","useOutlet","page","Children","toArray","flatMap","child","find","grandChild","getComponentData","TECHDOCS_ADDONS_WRAPPER_KEY","TECHDOCS_ADDONS_KEY","TechDocsReaderPageProvider","metadata","entityMetadata","onReady","div","className","Function","techdocsMetadataValue","value","entityMetadataValue","useStyles","makeStyles","theme","root","gridArea","flexDirection","minHeight","padding","spacing","display","classes","anchorEl","setAnchorEl","useState","handleClick","currentTarget","handleClose","loading","entityMetadataLoading","useTechDocsReaderPage","addons","useTechDocsAddons","subheaderAddons","renderComponentsByLocation","locations","Subheader","settingsAddons","Settings","Toolbar","toolbarProps","Box","justifyContent","width","flexWrap","Tooltip","title","IconButton","aria-controls","aria-haspopup","SettingsIcon","Menu","id","getContentAnchorEl","anchorOrigin","vertical","horizontal","open","Boolean","onClose","keepMounted"],"sourceRoot":""}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";(()=>{(self.webpackChunktechdocs_cli_embedded_app=self.webpackChunktechdocs_cli_embedded_app||[]).push([[9605,5788],{70048:($,y,t)=>{t.d(y,{K:()=>c});var e=t(18690);function c(D){return(0,e.g)()}},99538:($,y,t)=>{t.d(y,{T7:()=>T,TY:()=>L,tN:()=>B});var e=t(31085),c=t(6820),D=t(25862),A=t(43836),u=t(10602),O=t(14041);const j=(0,A.tK)("entity-context"),T=i=>{const{children:m,entity:P,loading:R,error:M,refresh:C}=i,p={entity:P,loading:R,error:M,refresh:C};return(0,e.jsx)(j.Provider,{value:(0,u.B)({1:p}),children:(0,e.jsx)(D.Ig,{attributes:{...P?{entityRef:(0,c.U2)(P)}:void 0},children:m})})},K=i=>_jsx(T,{entity:i.entity,loading:!i.entity,error:void 0,refresh:void 0,children:i.children});function B(){const i=(0,A.qO)("entity-context");if(!i)throw new Error("Entity context is not available");const m=i.atVersion(1);if(!m)throw new Error("EntityContext v1 not available");if(!m.entity)throw new Error("useEntity hook is being called outside of an EntityLayout where the entity has not been loaded. If this is intentional, please use useAsyncEntity instead.");return{entity:m.entity}}function L(){const i=(0,A.qO)("entity-context");if(!i)throw new Error("Entity context is not available");const m=i.atVersion(1);if(!m)throw new Error("EntityContext v1 not available");const{entity:P,loading:R,error:M,refresh:C}=m;return{entity:P,loading:R,error:M,refresh:C}}},29605:($,y,t)=>{t.r(y),t.d(y,{EmbeddedDocsRouter:()=>N,Router:()=>S,isTechDocsAvailable:()=>W});var e=t(31085),c=t(14041),D=t(18690),A=t(6820),u=t(86202),O=t(39278),j=t(
|
|
1
|
+
"use strict";(()=>{(self.webpackChunktechdocs_cli_embedded_app=self.webpackChunktechdocs_cli_embedded_app||[]).push([[9605,5788],{70048:($,y,t)=>{t.d(y,{K:()=>c});var e=t(18690);function c(D){return(0,e.g)()}},99538:($,y,t)=>{t.d(y,{T7:()=>T,TY:()=>L,tN:()=>B});var e=t(31085),c=t(6820),D=t(25862),A=t(43836),u=t(10602),O=t(14041);const j=(0,A.tK)("entity-context"),T=i=>{const{children:m,entity:P,loading:R,error:M,refresh:C}=i,p={entity:P,loading:R,error:M,refresh:C};return(0,e.jsx)(j.Provider,{value:(0,u.B)({1:p}),children:(0,e.jsx)(D.Ig,{attributes:{...P?{entityRef:(0,c.U2)(P)}:void 0},children:m})})},K=i=>_jsx(T,{entity:i.entity,loading:!i.entity,error:void 0,refresh:void 0,children:i.children});function B(){const i=(0,A.qO)("entity-context");if(!i)throw new Error("Entity context is not available");const m=i.atVersion(1);if(!m)throw new Error("EntityContext v1 not available");if(!m.entity)throw new Error("useEntity hook is being called outside of an EntityLayout where the entity has not been loaded. If this is intentional, please use useAsyncEntity instead.");return{entity:m.entity}}function L(){const i=(0,A.qO)("entity-context");if(!i)throw new Error("Entity context is not available");const m=i.atVersion(1);if(!m)throw new Error("EntityContext v1 not available");const{entity:P,loading:R,error:M,refresh:C}=m;return{entity:P,loading:R,error:M,refresh:C}}},29605:($,y,t)=>{t.r(y),t.d(y,{EmbeddedDocsRouter:()=>N,Router:()=>S,isTechDocsAvailable:()=>W});var e=t(31085),c=t(14041),D=t(18690),A=t(6820),u=t(86202),O=t(39278),j=t(91424),T=t(39299);const K=({entity:s})=>{let d=(0,A.sM)(s);if(s.metadata.annotations?.[u.G])try{d=(0,A.KU)(s.metadata.annotations?.[u.G])}catch{}return(0,e.jsxs)(O.Wj,{entityRef:d,children:[(0,e.jsx)(T.Z,{}),(0,e.jsx)(j.p,{withSearch:!1})]})};var B=t(85788),L=t(93160),i=t(99538),m=t(10394),P=t(64947),R=t(58837),M=t(72501),C=t(44186),p=t(77310),H=t(72072);const Y=(0,R.A)(s=>({code:{borderRadius:6,margin:s.spacing(2,0),background:s.palette.type==="dark"?"#444":s.palette.common.white}}),{name:"BackstageMissingAnnotationEmptyState"});function V(s,d){const o=d?.kind||"Component",a=d?.metadata.name||"example",l=d?.spec?.type||"website",v=d?.spec?.owner||"user:default/guest",r=`apiVersion: backstage.io/v1alpha1
|
|
2
2
|
kind: ${o}
|
|
3
3
|
metadata:
|
|
4
4
|
name: ${a}
|
|
@@ -6,6 +6,6 @@ metadata:
|
|
|
6
6
|
${E}: value`).join("")}
|
|
7
7
|
spec:
|
|
8
8
|
type: ${l}
|
|
9
|
-
owner: ${v}`;let n=6;const f=[];return s.forEach(()=>{f.push(n),n++}),{yamlText:r,lineNumbers:f}}function G(s,d="Component"){const o=s.length<=1;return(0,e.jsxs)(e.Fragment,{children:["The ",o?"annotation":"annotations"," ",s.map(a=>(0,e.jsx)("code",{children:a})).reduce((a,l)=>(0,e.jsxs)(e.Fragment,{children:[a,", ",l]}))," ",o?"is":"are"," missing. You need to add the"," ",o?"annotation":"annotations"," to your ",d," if you want to enable this tool."]})}function U(s){let d;try{d=(0,i.tN)().entity}catch{}const{annotation:o,readMoreUrl:a}=s,l=Array.isArray(o)?o:[o],v=a||"https://backstage.io/docs/features/software-catalog/well-known-annotations",r=Y(),n=d?.kind||"Component",{yamlText:f,lineNumbers:E}=V(l,d);return(0,e.jsx)(C.p,{missing:"field",title:"Missing Annotation",description:G(l,n),action:(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)(M.A,{variant:"body1",children:["Add the annotation to your ",n," YAML as shown in the highlighted example below:"]}),(0,e.jsx)(m.A,{className:r.code,children:(0,e.jsx)(p.z,{text:f,language:"yaml",showLineNumbers:!0,highlightedNumbers:E,customStyle:{background:"inherit",fontSize:"115%"}})}),(0,e.jsx)(P.A,{color:"primary",component:H.N_,to:v,children:"Read more"})]})})}const W=s=>!!s?.metadata?.annotations?.[u.A]||!!s?.metadata?.annotations?.[u.G],S=()=>(0,e.jsxs)(D.BV,{children:[(0,e.jsx)(D.qh,{path:"/",element:(0,e.jsx)(B.TechDocsIndexPage,{})}),(0,e.jsx)(D.qh,{path:"/:namespace/:kind/:name/*",element:(0,e.jsx)(L.W,{})})]}),N=s=>{const{children:d}=s,{entity:o}=(0,i.tN)(),a=(0,D.Ye)([{path:"/*",element:(0,e.jsx)(K,{entity:o}),children:[{path:"*",element:d}]}]);return o.metadata.annotations?.[u.A]||o.metadata.annotations?.[u.G]?a:(0,e.jsx)(U,{annotation:[u.A]})}},85788:($,y,t)=>{t.r(y),t.d(y,{TechDocsIndexPage:()=>u});var e=t(31085),c=t(14041),D=t(18690),A=t(85920);const u=O=>(0,D.P1)()||(0,e.jsx)(A.K,{...O})},93160:($,y,t)=>{t.d(y,{b:()=>s,W:()=>d});var e=t(31085),c=t(14041),D=t(18690),A=t(24504),u=t(72020),O=t(86892),j=t(
|
|
9
|
+
owner: ${v}`;let n=6;const f=[];return s.forEach(()=>{f.push(n),n++}),{yamlText:r,lineNumbers:f}}function G(s,d="Component"){const o=s.length<=1;return(0,e.jsxs)(e.Fragment,{children:["The ",o?"annotation":"annotations"," ",s.map(a=>(0,e.jsx)("code",{children:a})).reduce((a,l)=>(0,e.jsxs)(e.Fragment,{children:[a,", ",l]}))," ",o?"is":"are"," missing. You need to add the"," ",o?"annotation":"annotations"," to your ",d," if you want to enable this tool."]})}function U(s){let d;try{d=(0,i.tN)().entity}catch{}const{annotation:o,readMoreUrl:a}=s,l=Array.isArray(o)?o:[o],v=a||"https://backstage.io/docs/features/software-catalog/well-known-annotations",r=Y(),n=d?.kind||"Component",{yamlText:f,lineNumbers:E}=V(l,d);return(0,e.jsx)(C.p,{missing:"field",title:"Missing Annotation",description:G(l,n),action:(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)(M.A,{variant:"body1",children:["Add the annotation to your ",n," YAML as shown in the highlighted example below:"]}),(0,e.jsx)(m.A,{className:r.code,children:(0,e.jsx)(p.z,{text:f,language:"yaml",showLineNumbers:!0,highlightedNumbers:E,customStyle:{background:"inherit",fontSize:"115%"}})}),(0,e.jsx)(P.A,{color:"primary",component:H.N_,to:v,children:"Read more"})]})})}const W=s=>!!s?.metadata?.annotations?.[u.A]||!!s?.metadata?.annotations?.[u.G],S=()=>(0,e.jsxs)(D.BV,{children:[(0,e.jsx)(D.qh,{path:"/",element:(0,e.jsx)(B.TechDocsIndexPage,{})}),(0,e.jsx)(D.qh,{path:"/:namespace/:kind/:name/*",element:(0,e.jsx)(L.W,{})})]}),N=s=>{const{children:d}=s,{entity:o}=(0,i.tN)(),a=(0,D.Ye)([{path:"/*",element:(0,e.jsx)(K,{entity:o}),children:[{path:"*",element:d}]}]);return o.metadata.annotations?.[u.A]||o.metadata.annotations?.[u.G]?a:(0,e.jsx)(U,{annotation:[u.A]})}},85788:($,y,t)=>{t.r(y),t.d(y,{TechDocsIndexPage:()=>u});var e=t(31085),c=t(14041),D=t(18690),A=t(85920);const u=O=>(0,D.P1)()||(0,e.jsx)(A.K,{...O})},93160:($,y,t)=>{t.d(y,{b:()=>s,W:()=>d});var e=t(31085),c=t(14041),D=t(18690),A=t(24504),u=t(72020),O=t(86892),j=t(91424),T=t(45061),K=t(39299),B=t(82779),L=t(70048),i=t(19402),m=t(22020),P=t(82266),R=t(64947),M=t(72427),C=t(70795),p=t(57405),H=t(16261);function Y(o,a){const[l,v]=(0,c.useState)({status:"not-executed",error:void 0,result:a}),r=(0,c.useRef)(),n=(0,c.useRef)(),f=(0,H.J)({execute(...E){n.current=E;const x=o(...E);return r.current=x,v(h=>({...h,status:"loading"})),x.then(h=>{x===r.current&&v(g=>({...g,status:"success",error:void 0,result:h}))},h=>{x===r.current&&v(g=>({...g,status:"error",error:h}))}),x},reset(){v({status:"not-executed",error:void 0,result:a}),r.current=void 0,n.current=void 0}});return[l,(0,c.useMemo)(()=>({reset(){f.current.reset()},execute:(...E)=>f.current.execute(...E)}),[]),{promise:r.current,lastArgs:n.current}]}var V=t(76842),G=t(70835);const U="/.backstage/auth/v1/cookie",W=365*24*36e5;function S(o){const{pluginId:a}=o??{},l=(0,M.gf)(C.a),v=(0,M.gf)(p.I),r=(0,c.useMemo)(()=>"BroadcastChannel"in window?new BroadcastChannel(`${a}-auth-cookie-expires-at`):null,[a]),[n,f]=Y(async()=>{const g=`${await v.getBaseUrl(a)}${U}`,I=await l.fetch(`${g}`,{credentials:"include"});if(!I.ok){if(I.status===404)return{expiresAt:new Date(Date.now()+W)};throw await G.o.fromResponse(I)}const F=await I.json();if(!F.expiresAt)throw new Error("No expiration date found in response");return F});(0,V.u)(f.execute);const E=(0,c.useCallback)(()=>{f.execute()},[f]),x=(0,c.useCallback)(h=>{const g=(1+3*Math.random())*6e4,I=Date.parse(h.expiresAt)-Date.now()-g,F=setTimeout(E,I);return()=>clearTimeout(F)},[E]);return(0,c.useEffect)(()=>{if(n.status!=="success"||!n.result)return()=>{};r?.postMessage({action:"COOKIE_REFRESH_SUCCESS",payload:n.result});let h=x(n.result);const g=I=>{const{action:F,payload:z}=I.data;F==="COOKIE_REFRESH_SUCCESS"&&(h(),h=x(z))};return r?.addEventListener("message",g),()=>{h(),r?.removeEventListener("message",g)}},[n,x,r]),n.status==="not-executed"?{status:"loading"}:n.status==="loading"&&!n.result?{status:"loading"}:n.status==="loading"&&n.error?{status:"loading"}:n.status==="error"&&n.error?{status:"error",error:n.error,retry:E}:{status:"success",data:n.result}}function N(o){const{children:a,...l}=o,v=(0,P.n)(),{Progress:r}=v.getComponents(),n=S(l);return n.status==="loading"?(0,e.jsx)(r,{}):n.status==="error"?(0,e.jsx)(m.b,{error:n.error,children:(0,e.jsx)(R.A,{variant:"outlined",onClick:n.retry,children:"Retry"})}):(0,e.jsx)(e.Fragment,{children:a})}const s=o=>{const{withSearch:a,withHeader:l=!0}=o;return(0,e.jsxs)(A.Y,{themeId:"documentation",children:[l&&(0,e.jsx)(T.T,{}),(0,e.jsx)(K.Z,{}),(0,e.jsx)(j.p,{withSearch:a})]})},d=o=>{const{kind:a,name:l,namespace:v}=(0,L.K)(B.Oc),{children:r,entityRef:n={kind:a,name:l,namespace:v}}=o,f=(0,D.P1)();if(!r){const h=(f?c.Children.toArray(f.props.children):[]).flatMap(g=>g?.props?.children??[]).find(g=>!(0,i.E)(g,u.AF)&&!(0,i.E)(g,u.Wm));return(0,e.jsx)(N,{pluginId:"techdocs",children:(0,e.jsx)(O.R,{entityRef:n,children:h||(0,e.jsx)(s,{})})})}return(0,e.jsx)(N,{pluginId:"techdocs",children:(0,e.jsx)(O.R,{entityRef:n,children:({metadata:E,entityMetadata:x,onReady:h})=>(0,e.jsx)("div",{className:"techdocs-reader-page",children:(0,e.jsx)(A.Y,{themeId:"documentation",children:r instanceof Function?r({entityRef:n,techdocsMetadataValue:E.value,entityMetadataValue:x.value,onReady:h}):r})})})})}},39299:($,y,t)=>{t.d(y,{Z:()=>P});var e=t(31085),c=t(14041),D=t(58837),A=t(29365),u=t(75173),O=t(71677),j=t(37757),T=t(10394),K=t(9684),B=t(86892),L=t(72020),i=t(99730);const m=(0,D.A)(R=>({root:{gridArea:"pageSubheader",flexDirection:"column",minHeight:"auto",padding:R.spacing(3,3,0),"@media print":{display:"none"}}})),P=R=>{const M=m(),[C,p]=(0,c.useState)(null),H=(0,c.useCallback)(N=>{p(N.currentTarget)},[]),Y=(0,c.useCallback)(()=>{p(null)},[]),{entityMetadata:{value:V,loading:G}}=(0,B.V)(),U=(0,L.YR)(),W=U.renderComponentsByLocation(i.e.Subheader),S=U.renderComponentsByLocation(i.e.Settings);return!W&&!S||G===!1&&!V?null:(0,e.jsx)(u.A,{classes:M,...R.toolbarProps,children:(0,e.jsxs)(T.A,{display:"flex",justifyContent:"flex-end",width:"100%",flexWrap:"wrap",children:[W,S?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(O.Ay,{title:"Settings",children:(0,e.jsx)(A.A,{"aria-controls":"tech-docs-reader-page-settings","aria-haspopup":"true",onClick:H,children:(0,e.jsx)(K.A,{})})}),(0,e.jsx)(j.A,{id:"tech-docs-reader-page-settings",getContentAnchorEl:null,anchorEl:C,anchorOrigin:{vertical:"bottom",horizontal:"right"},open:!!C,onClose:Y,keepMounted:!0,children:(0,e.jsx)("div",{children:S})})]}):null]})})}}}]);})();
|
|
10
10
|
|
|
11
|
-
//# sourceMappingURL=9605.
|
|
11
|
+
//# sourceMappingURL=9605.391b82d4.chunk.js.map
|