@techdocs/cli 1.8.10 → 1.8.11-next.1
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 +16 -2
- package/dist/cjs/{PublisherConfig-B9GYw8mh.cjs.js → PublisherConfig-DheuBNuV.cjs.js} +2 -2
- package/dist/cjs/{PublisherConfig-B9GYw8mh.cjs.js.map → PublisherConfig-DheuBNuV.cjs.js.map} +1 -1
- package/dist/cjs/{migrate-CccqCfHt.cjs.js → migrate-D6YuWLen.cjs.js} +2 -2
- package/dist/cjs/{migrate-CccqCfHt.cjs.js.map → migrate-D6YuWLen.cjs.js.map} +1 -1
- package/dist/cjs/{publish-D19dZg09.cjs.js → publish-DYFq3em1.cjs.js} +2 -2
- package/dist/cjs/{publish-D19dZg09.cjs.js.map → publish-DYFq3em1.cjs.js.map} +1 -1
- package/dist/embedded-app/.config-schema.json +91 -46
- package/dist/embedded-app/index.html +1 -1
- package/dist/embedded-app/static/{4487.06c23d1b.chunk.js → 4487.8a9c8ef0.chunk.js} +1 -1
- package/dist/embedded-app/static/{4487.06c23d1b.chunk.js.map → 4487.8a9c8ef0.chunk.js.map} +1 -1
- package/dist/embedded-app/static/{73.618ea766.chunk.js → 73.cc8a3548.chunk.js} +2 -2
- package/dist/embedded-app/static/{73.618ea766.chunk.js.map → 73.cc8a3548.chunk.js.map} +1 -1
- package/dist/embedded-app/static/{main.04529c71.js → main.a5f4ad6c.js} +9 -9
- package/dist/embedded-app/static/main.a5f4ad6c.js.map +1 -0
- package/dist/embedded-app/static/module-date-fns.196adaa7.js +3 -0
- package/dist/embedded-app/static/module-date-fns.196adaa7.js.map +1 -0
- package/dist/embedded-app/static/module-material-table.892da5bc.js +3 -0
- package/dist/embedded-app/static/module-material-table.892da5bc.js.map +1 -0
- package/dist/embedded-app/static/react-syntax-highlighter_languages_highlight_gherkin.4bae5020.chunk.js +3 -0
- package/dist/embedded-app/static/{react-syntax-highlighter_languages_highlight_gherkin.f9cdeff1.chunk.js.map → react-syntax-highlighter_languages_highlight_gherkin.4bae5020.chunk.js.map} +1 -1
- package/dist/embedded-app/static/{runtime.04529c71.js → runtime.a5f4ad6c.js} +2 -2
- package/dist/embedded-app/static/{runtime.04529c71.js.map → runtime.a5f4ad6c.js.map} +1 -1
- package/dist/embedded-app/static/vendor.a5f4ad6c.js +160 -0
- package/dist/embedded-app/static/vendor.a5f4ad6c.js.map +1 -0
- package/dist/index.cjs.js +3 -3
- package/package.json +5 -5
- package/dist/embedded-app/static/main.04529c71.js.map +0 -1
- package/dist/embedded-app/static/module-material-table.145eb704.js +0 -3
- package/dist/embedded-app/static/module-material-table.145eb704.js.map +0 -1
- package/dist/embedded-app/static/react-syntax-highlighter_languages_highlight_gherkin.f9cdeff1.chunk.js +0 -3
- package/dist/embedded-app/static/vendor.04529c71.js +0 -160
- package/dist/embedded-app/static/vendor.04529c71.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,10 +1,24 @@
|
|
|
1
1
|
# @techdocs/cli
|
|
2
2
|
|
|
3
|
-
## 1.8.
|
|
3
|
+
## 1.8.11-next.1
|
|
4
4
|
|
|
5
5
|
### Patch Changes
|
|
6
6
|
|
|
7
|
-
-
|
|
7
|
+
- Updated dependencies
|
|
8
|
+
- @backstage/backend-common@0.22.0-next.1
|
|
9
|
+
- @backstage/plugin-techdocs-node@1.12.4-next.1
|
|
10
|
+
|
|
11
|
+
## 1.8.10-next.0
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- 1a0e009: Fix cookie endpoint mock for `serve`
|
|
16
|
+
- Updated dependencies
|
|
17
|
+
- @backstage/catalog-model@1.5.0-next.0
|
|
18
|
+
- @backstage/backend-common@0.21.8-next.0
|
|
19
|
+
- @backstage/plugin-techdocs-node@1.12.4-next.0
|
|
20
|
+
- @backstage/cli-common@0.1.13
|
|
21
|
+
- @backstage/config@1.2.0
|
|
8
22
|
|
|
9
23
|
## 1.8.9
|
|
10
24
|
|
|
@@ -5,7 +5,7 @@ var config = require('@backstage/config');
|
|
|
5
5
|
var __defProp = Object.defineProperty;
|
|
6
6
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
7
7
|
var __publicField = (obj, key, value) => {
|
|
8
|
-
__defNormalProp(obj,
|
|
8
|
+
__defNormalProp(obj, key + "" , value);
|
|
9
9
|
return value;
|
|
10
10
|
};
|
|
11
11
|
const _PublisherConfig = class _PublisherConfig {
|
|
@@ -137,4 +137,4 @@ __publicField(_PublisherConfig, "configFactories", {
|
|
|
137
137
|
let PublisherConfig = _PublisherConfig;
|
|
138
138
|
|
|
139
139
|
exports.PublisherConfig = PublisherConfig;
|
|
140
|
-
//# sourceMappingURL=PublisherConfig-
|
|
140
|
+
//# sourceMappingURL=PublisherConfig-DheuBNuV.cjs.js.map
|
package/dist/cjs/{PublisherConfig-B9GYw8mh.cjs.js.map → PublisherConfig-DheuBNuV.cjs.js.map}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PublisherConfig-
|
|
1
|
+
{"version":3,"file":"PublisherConfig-DheuBNuV.cjs.js","sources":["../../src/lib/PublisherConfig.ts"],"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 { ConfigReader } from '@backstage/config';\nimport { OptionValues } from 'commander';\n\ntype Publisher = keyof (typeof PublisherConfig)['configFactories'];\ntype PublisherConfiguration = {\n [p in Publisher]?: any;\n} & {\n type: Publisher;\n};\n\n/**\n * Helper when working with publisher-related configurations.\n */\nexport class PublisherConfig {\n /**\n * Maps publisher-specific config keys to config getters.\n */\n private static configFactories = {\n awsS3: PublisherConfig.getValidAwsS3Config,\n azureBlobStorage: PublisherConfig.getValidAzureConfig,\n googleGcs: PublisherConfig.getValidGoogleGcsConfig,\n openStackSwift: PublisherConfig.getValidOpenStackSwiftConfig,\n };\n\n /**\n * Returns Backstage config suitable for use when instantiating a Publisher. If\n * there are any missing or invalid options provided, an error is thrown.\n *\n * Note: This assumes that proper credentials are set in Environment\n * variables for the respective GCS/AWS clients to work.\n */\n static getValidConfig(opts: OptionValues): ConfigReader {\n const publisherType = opts.publisherType;\n\n if (!PublisherConfig.isKnownPublisher(publisherType)) {\n throw new Error(`Unknown publisher type ${opts.publisherType}`);\n }\n\n return new ConfigReader({\n // This backend config is not used at all. Just something needed a create a mock discovery instance.\n backend: {\n baseUrl: 'http://localhost:7007',\n listen: {\n port: 7007,\n },\n },\n techdocs: {\n publisher: PublisherConfig.configFactories[publisherType](opts),\n legacyUseCaseSensitiveTripletPaths:\n opts.legacyUseCaseSensitiveTripletPaths,\n },\n });\n }\n\n /**\n * Typeguard to ensure the publisher has a known config getter.\n */\n private static isKnownPublisher(\n type: string,\n ): type is keyof (typeof PublisherConfig)['configFactories'] {\n return PublisherConfig.configFactories.hasOwnProperty(type);\n }\n\n /**\n * Retrieve valid AWS S3 configuration based on the command.\n */\n private static getValidAwsS3Config(\n opts: OptionValues,\n ): PublisherConfiguration {\n return {\n type: 'awsS3',\n awsS3: {\n bucketName: opts.storageName,\n ...(opts.awsBucketRootPath && {\n bucketRootPath: opts.awsBucketRootPath,\n }),\n ...(opts.awsRoleArn && { credentials: { roleArn: opts.awsRoleArn } }),\n ...(opts.awsEndpoint && { endpoint: opts.awsEndpoint }),\n ...(opts.awsS3ForcePathStyle && { s3ForcePathStyle: true }),\n ...(opts.awsS3sse && { sse: opts.awsS3sse }),\n ...(opts.awsProxy && { httpsProxy: opts.awsProxy }),\n },\n };\n }\n\n /**\n * Retrieve valid Azure Blob Storage configuration based on the command.\n */\n private static getValidAzureConfig(\n opts: OptionValues,\n ): PublisherConfiguration {\n if (!opts.azureAccountName) {\n throw new Error(\n `azureBlobStorage requires --azureAccountName to be specified`,\n );\n }\n\n return {\n type: 'azureBlobStorage',\n azureBlobStorage: {\n containerName: opts.storageName,\n credentials: {\n accountName: opts.azureAccountName,\n accountKey: opts.azureAccountKey,\n },\n },\n };\n }\n\n /**\n * Retrieve valid GCS configuration based on the command.\n */\n private static getValidGoogleGcsConfig(\n opts: OptionValues,\n ): PublisherConfiguration {\n return {\n type: 'googleGcs',\n googleGcs: {\n bucketName: opts.storageName,\n ...(opts.gcsBucketRootPath && {\n bucketRootPath: opts.gcsBucketRootPath,\n }),\n },\n };\n }\n\n /**\n * Retrieves valid OpenStack Swift configuration based on the command.\n */\n private static getValidOpenStackSwiftConfig(\n opts: OptionValues,\n ): PublisherConfiguration {\n const missingParams = [\n 'osCredentialId',\n 'osSecret',\n 'osAuthUrl',\n 'osSwiftUrl',\n ].filter((param: string) => !opts[param]);\n\n if (missingParams.length) {\n throw new Error(\n `openStackSwift requires the following params to be specified: ${missingParams.join(\n ', ',\n )}`,\n );\n }\n\n return {\n type: 'openStackSwift',\n openStackSwift: {\n containerName: opts.storageName,\n credentials: {\n id: opts.osCredentialId,\n secret: opts.osSecret,\n },\n authUrl: opts.osAuthUrl,\n swiftUrl: opts.osSwiftUrl,\n },\n };\n }\n}\n"],"names":["ConfigReader"],"mappings":";;;;;;;;;;AA6BO,MAAM,gBAAA,GAAN,MAAM,gBAAgB,CAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAkB3B,OAAO,eAAe,IAAkC,EAAA;AACtD,IAAA,MAAM,gBAAgB,IAAK,CAAA,aAAA,CAAA;AAE3B,IAAA,IAAI,CAAC,gBAAA,CAAgB,gBAAiB,CAAA,aAAa,CAAG,EAAA;AACpD,MAAA,MAAM,IAAI,KAAA,CAAM,CAA0B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gB,EAAA;AAAA,QACd,eAAe,IAAK,CAAA,WAAA;AAAA,QACpB,WAAa,EAAA;AAAA,UACX,IAAI,IAAK,CAAA,cAAA;AAAA,UACT,QAAQ,IAAK,CAAA,QAAA;AAAA,SACf;AAAA,QACA,SAAS,IAAK,CAAA,SAAA;AAAA,QACd,UAAU,IAAK,CAAA,UAAA;AAAA,OACjB;AAAA,KACF,CAAA;AAAA,GACF;AACF,CAAA,CAAA;AAAA;AAAA;AAAA;AA/IE,aAAA,CAJW,kBAII,iBAAkB,EAAA;AAAA,EAC/B,OAAO,gBAAgB,CAAA,mBAAA;AAAA,EACvB,kBAAkB,gBAAgB,CAAA,mBAAA;AAAA,EAClC,WAAW,gBAAgB,CAAA,uBAAA;AAAA,EAC3B,gBAAgB,gBAAgB,CAAA,4BAAA;AAClC,CAAA,CAAA,CAAA;AATK,IAAM,eAAN,GAAA;;;;"}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
var backendCommon = require('@backstage/backend-common');
|
|
4
4
|
var pluginTechdocsNode = require('@backstage/plugin-techdocs-node');
|
|
5
5
|
var utility = require('./utility-CsspJYjU.cjs.js');
|
|
6
|
-
var PublisherConfig = require('./PublisherConfig-
|
|
6
|
+
var PublisherConfig = require('./PublisherConfig-DheuBNuV.cjs.js');
|
|
7
7
|
require('winston');
|
|
8
8
|
require('stream');
|
|
9
9
|
require('process');
|
|
@@ -35,4 +35,4 @@ async function migrate(opts) {
|
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
exports.default = migrate;
|
|
38
|
-
//# sourceMappingURL=migrate-
|
|
38
|
+
//# sourceMappingURL=migrate-D6YuWLen.cjs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migrate-
|
|
1
|
+
{"version":3,"file":"migrate-D6YuWLen.cjs.js","sources":["../../src/commands/migrate/migrate.ts"],"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 { HostDiscovery } from '@backstage/backend-common';\nimport { Publisher } from '@backstage/plugin-techdocs-node';\nimport { OptionValues } from 'commander';\nimport { createLogger } from '../../lib/utility';\nimport { PublisherConfig } from '../../lib/PublisherConfig';\n\nexport default async function migrate(opts: OptionValues) {\n const logger = createLogger({ verbose: opts.verbose });\n\n const config = PublisherConfig.getValidConfig(opts);\n const discovery = HostDiscovery.fromConfig(config);\n const publisher = await Publisher.fromConfig(config, { logger, discovery });\n\n if (!publisher.migrateDocsCase) {\n throw new Error(`Migration not implemented for ${opts.publisherType}`);\n }\n\n // Check that the publisher's underlying storage is ready and available.\n const { isAvailable } = await publisher.getReadiness();\n if (!isAvailable) {\n // Error messages printed in getReadiness() call. This ensures exit code 1.\n throw new Error('');\n }\n\n // Validate and parse migration arguments.\n const removeOriginal = opts.removeOriginal;\n const numericConcurrency = parseInt(opts.concurrency, 10);\n\n if (!Number.isInteger(numericConcurrency) || numericConcurrency <= 0) {\n throw new Error(\n `Concurrency must be a number greater than 1. ${opts.concurrency} provided.`,\n );\n }\n\n await publisher.migrateDocsCase({\n concurrency: numericConcurrency,\n removeOriginal,\n });\n}\n"],"names":["createLogger","PublisherConfig","HostDiscovery","Publisher"],"mappings":";;;;;;;;;;;AAsBA,eAA8B,QAAQ,IAAoB,EAAA;AACxD,EAAA,MAAM,SAASA,oBAAa,CAAA,EAAE,OAAS,EAAA,IAAA,CAAK,SAAS,CAAA,CAAA;AAErD,EAAM,MAAA,MAAA,GAASC,+BAAgB,CAAA,cAAA,CAAe,IAAI,CAAA,CAAA;AAClD,EAAM,MAAA,SAAA,GAAYC,2BAAc,CAAA,UAAA,CAAW,MAAM,CAAA,CAAA;AACjD,EAAM,MAAA,SAAA,GAAY,MAAMC,4BAAU,CAAA,UAAA,CAAW,QAAQ,EAAE,MAAA,EAAQ,WAAW,CAAA,CAAA;AAE1E,EAAI,IAAA,CAAC,UAAU,eAAiB,EAAA;AAC9B,IAAA,MAAM,IAAI,KAAA,CAAM,CAAiC,8BAAA,EAAA,IAAA,CAAK,aAAa,CAAE,CAAA,CAAA,CAAA;AAAA,GACvE;AAGA,EAAA,MAAM,EAAE,WAAA,EAAgB,GAAA,MAAM,UAAU,YAAa,EAAA,CAAA;AACrD,EAAA,IAAI,CAAC,WAAa,EAAA;AAEhB,IAAM,MAAA,IAAI,MAAM,EAAE,CAAA,CAAA;AAAA,GACpB;AAGA,EAAA,MAAM,iBAAiB,IAAK,CAAA,cAAA,CAAA;AAC5B,EAAA,MAAM,kBAAqB,GAAA,QAAA,CAAS,IAAK,CAAA,WAAA,EAAa,EAAE,CAAA,CAAA;AAExD,EAAA,IAAI,CAAC,MAAO,CAAA,SAAA,CAAU,kBAAkB,CAAA,IAAK,sBAAsB,CAAG,EAAA;AACpE,IAAA,MAAM,IAAI,KAAA;AAAA,MACR,CAAA,6CAAA,EAAgD,KAAK,WAAW,CAAA,UAAA,CAAA;AAAA,KAClE,CAAA;AAAA,GACF;AAEA,EAAA,MAAM,UAAU,eAAgB,CAAA;AAAA,IAC9B,WAAa,EAAA,kBAAA;AAAA,IACb,cAAA;AAAA,GACD,CAAA,CAAA;AACH;;;;"}
|
|
@@ -4,7 +4,7 @@ var path = require('path');
|
|
|
4
4
|
var utility = require('./utility-CsspJYjU.cjs.js');
|
|
5
5
|
var backendCommon = require('@backstage/backend-common');
|
|
6
6
|
var pluginTechdocsNode = require('@backstage/plugin-techdocs-node');
|
|
7
|
-
var PublisherConfig = require('./PublisherConfig-
|
|
7
|
+
var PublisherConfig = require('./PublisherConfig-DheuBNuV.cjs.js');
|
|
8
8
|
require('winston');
|
|
9
9
|
require('stream');
|
|
10
10
|
require('process');
|
|
@@ -33,4 +33,4 @@ async function publish(opts) {
|
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
exports.default = publish;
|
|
36
|
-
//# sourceMappingURL=publish-
|
|
36
|
+
//# sourceMappingURL=publish-DYFq3em1.cjs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"publish-
|
|
1
|
+
{"version":3,"file":"publish-DYFq3em1.cjs.js","sources":["../../src/commands/publish/publish.ts"],"sourcesContent":["/*\n * Copyright 2020 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 { resolve } from 'path';\nimport { OptionValues } from 'commander';\nimport { createLogger } from '../../lib/utility';\nimport { HostDiscovery } from '@backstage/backend-common';\nimport { Publisher } from '@backstage/plugin-techdocs-node';\nimport { Entity } from '@backstage/catalog-model';\nimport { PublisherConfig } from '../../lib/PublisherConfig';\n\nexport default async function publish(opts: OptionValues): Promise<any> {\n const logger = createLogger({ verbose: opts.verbose });\n\n const config = PublisherConfig.getValidConfig(opts);\n const discovery = HostDiscovery.fromConfig(config);\n const publisher = await Publisher.fromConfig(config, { logger, discovery });\n\n // Check that the publisher's underlying storage is ready and available.\n const { isAvailable } = await publisher.getReadiness();\n if (!isAvailable) {\n // Error messages printed in getReadiness() call. This ensures exit code 1.\n return Promise.reject(new Error(''));\n }\n\n const [namespace, kind, name] = opts.entity.split('/');\n const entity = {\n kind,\n metadata: {\n namespace,\n name,\n },\n } as Entity;\n\n const directory = resolve(opts.directory);\n await publisher.publish({ entity, directory });\n\n return true;\n}\n"],"names":["createLogger","PublisherConfig","HostDiscovery","Publisher","resolve"],"mappings":";;;;;;;;;;;;AAwBA,eAA8B,QAAQ,IAAkC,EAAA;AACtE,EAAA,MAAM,SAASA,oBAAa,CAAA,EAAE,OAAS,EAAA,IAAA,CAAK,SAAS,CAAA,CAAA;AAErD,EAAM,MAAA,MAAA,GAASC,+BAAgB,CAAA,cAAA,CAAe,IAAI,CAAA,CAAA;AAClD,EAAM,MAAA,SAAA,GAAYC,2BAAc,CAAA,UAAA,CAAW,MAAM,CAAA,CAAA;AACjD,EAAM,MAAA,SAAA,GAAY,MAAMC,4BAAU,CAAA,UAAA,CAAW,QAAQ,EAAE,MAAA,EAAQ,WAAW,CAAA,CAAA;AAG1E,EAAA,MAAM,EAAE,WAAA,EAAgB,GAAA,MAAM,UAAU,YAAa,EAAA,CAAA;AACrD,EAAA,IAAI,CAAC,WAAa,EAAA;AAEhB,IAAA,OAAO,OAAQ,CAAA,MAAA,CAAO,IAAI,KAAA,CAAM,EAAE,CAAC,CAAA,CAAA;AAAA,GACrC;AAEA,EAAM,MAAA,CAAC,WAAW,IAAM,EAAA,IAAI,IAAI,IAAK,CAAA,MAAA,CAAO,MAAM,GAAG,CAAA,CAAA;AACrD,EAAA,MAAM,MAAS,GAAA;AAAA,IACb,IAAA;AAAA,IACA,QAAU,EAAA;AAAA,MACR,SAAA;AAAA,MACA,IAAA;AAAA,KACF;AAAA,GACF,CAAA;AAEA,EAAM,MAAA,SAAA,GAAYC,YAAQ,CAAA,IAAA,CAAK,SAAS,CAAA,CAAA;AACxC,EAAA,MAAM,SAAU,CAAA,OAAA,CAAQ,EAAE,MAAA,EAAQ,WAAW,CAAA,CAAA;AAE7C,EAAO,OAAA,IAAA,CAAA;AACT;;;;"}
|
|
@@ -323,6 +323,51 @@
|
|
|
323
323
|
"$schema": "http://json-schema.org/draft-07/schema#"
|
|
324
324
|
}
|
|
325
325
|
},
|
|
326
|
+
{
|
|
327
|
+
"path": "../core-components/config.d.ts",
|
|
328
|
+
"value": {
|
|
329
|
+
"type": "object",
|
|
330
|
+
"properties": {
|
|
331
|
+
"auth": {
|
|
332
|
+
"type": "object",
|
|
333
|
+
"properties": {
|
|
334
|
+
"autologout": {
|
|
335
|
+
"description": "Autologout feature configuration",
|
|
336
|
+
"type": "object",
|
|
337
|
+
"properties": {
|
|
338
|
+
"enabled": {
|
|
339
|
+
"description": "Enable or disable the autologout feature",
|
|
340
|
+
"visibility": "frontend",
|
|
341
|
+
"type": "boolean"
|
|
342
|
+
},
|
|
343
|
+
"idleTimeoutMinutes": {
|
|
344
|
+
"description": "Number of minutes after which the inactive user is logged out automatically.\nDefault is 60 minutes (1 hour)",
|
|
345
|
+
"visibility": "frontend",
|
|
346
|
+
"type": "number"
|
|
347
|
+
},
|
|
348
|
+
"promptBeforeIdleSeconds": {
|
|
349
|
+
"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.",
|
|
350
|
+
"visibility": "frontend",
|
|
351
|
+
"type": "number"
|
|
352
|
+
},
|
|
353
|
+
"useWorkerTimers": {
|
|
354
|
+
"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.",
|
|
355
|
+
"visibility": "frontend",
|
|
356
|
+
"type": "boolean"
|
|
357
|
+
},
|
|
358
|
+
"logoutIfDisconnected": {
|
|
359
|
+
"description": "Enable/disable the automatic logout also on users that are logged in but with no Backstage tabs open.\nDefault is true.",
|
|
360
|
+
"visibility": "frontend",
|
|
361
|
+
"type": "boolean"
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
},
|
|
368
|
+
"$schema": "http://json-schema.org/draft-07/schema#"
|
|
369
|
+
}
|
|
370
|
+
},
|
|
326
371
|
{
|
|
327
372
|
"path": "../../plugins/techdocs/config.d.ts",
|
|
328
373
|
"value": {
|
|
@@ -371,51 +416,6 @@
|
|
|
371
416
|
"$schema": "http://json-schema.org/draft-07/schema#"
|
|
372
417
|
}
|
|
373
418
|
},
|
|
374
|
-
{
|
|
375
|
-
"path": "../core-components/config.d.ts",
|
|
376
|
-
"value": {
|
|
377
|
-
"type": "object",
|
|
378
|
-
"properties": {
|
|
379
|
-
"auth": {
|
|
380
|
-
"type": "object",
|
|
381
|
-
"properties": {
|
|
382
|
-
"autologout": {
|
|
383
|
-
"description": "Autologout feature configuration",
|
|
384
|
-
"type": "object",
|
|
385
|
-
"properties": {
|
|
386
|
-
"enabled": {
|
|
387
|
-
"description": "Enable or disable the autologout feature",
|
|
388
|
-
"visibility": "frontend",
|
|
389
|
-
"type": "boolean"
|
|
390
|
-
},
|
|
391
|
-
"idleTimeoutMinutes": {
|
|
392
|
-
"description": "Number of minutes after which the inactive user is logged out automatically.\nDefault is 60 minutes (1 hour)",
|
|
393
|
-
"visibility": "frontend",
|
|
394
|
-
"type": "number"
|
|
395
|
-
},
|
|
396
|
-
"promptBeforeIdleSeconds": {
|
|
397
|
-
"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.",
|
|
398
|
-
"visibility": "frontend",
|
|
399
|
-
"type": "number"
|
|
400
|
-
},
|
|
401
|
-
"useWorkerTimers": {
|
|
402
|
-
"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.",
|
|
403
|
-
"visibility": "frontend",
|
|
404
|
-
"type": "boolean"
|
|
405
|
-
},
|
|
406
|
-
"logoutIfDisconnected": {
|
|
407
|
-
"description": "Enable/disable the automatic logout also on users that are logged in but with no Backstage tabs open.\nDefault is true.",
|
|
408
|
-
"visibility": "frontend",
|
|
409
|
-
"type": "boolean"
|
|
410
|
-
}
|
|
411
|
-
}
|
|
412
|
-
}
|
|
413
|
-
}
|
|
414
|
-
}
|
|
415
|
-
},
|
|
416
|
-
"$schema": "http://json-schema.org/draft-07/schema#"
|
|
417
|
-
}
|
|
418
|
-
},
|
|
419
419
|
{
|
|
420
420
|
"path": "../integration/config.d.ts",
|
|
421
421
|
"value": {
|
|
@@ -962,7 +962,7 @@
|
|
|
962
962
|
}
|
|
963
963
|
},
|
|
964
964
|
{
|
|
965
|
-
"path": "../../
|
|
965
|
+
"path": "../../node_modules/@backstage-community/plugin-stackstorm/config.d.ts",
|
|
966
966
|
"value": {
|
|
967
967
|
"type": "object",
|
|
968
968
|
"properties": {
|
|
@@ -1425,6 +1425,51 @@
|
|
|
1425
1425
|
"$schema": "http://json-schema.org/draft-07/schema#"
|
|
1426
1426
|
}
|
|
1427
1427
|
},
|
|
1428
|
+
{
|
|
1429
|
+
"path": "../../node_modules/@backstage-community/plugin-puppetdb/node_modules/@backstage/core-components/config.d.ts",
|
|
1430
|
+
"value": {
|
|
1431
|
+
"type": "object",
|
|
1432
|
+
"properties": {
|
|
1433
|
+
"auth": {
|
|
1434
|
+
"type": "object",
|
|
1435
|
+
"properties": {
|
|
1436
|
+
"autologout": {
|
|
1437
|
+
"description": "Autologout feature configuration",
|
|
1438
|
+
"type": "object",
|
|
1439
|
+
"properties": {
|
|
1440
|
+
"enabled": {
|
|
1441
|
+
"description": "Enable or disable the autologout feature",
|
|
1442
|
+
"visibility": "frontend",
|
|
1443
|
+
"type": "boolean"
|
|
1444
|
+
},
|
|
1445
|
+
"idleTimeoutMinutes": {
|
|
1446
|
+
"description": "Number of minutes after which the inactive user is logged out automatically.\nDefault is 60 minutes (1 hour)",
|
|
1447
|
+
"visibility": "frontend",
|
|
1448
|
+
"type": "number"
|
|
1449
|
+
},
|
|
1450
|
+
"promptBeforeIdleSeconds": {
|
|
1451
|
+
"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.",
|
|
1452
|
+
"visibility": "frontend",
|
|
1453
|
+
"type": "number"
|
|
1454
|
+
},
|
|
1455
|
+
"useWorkerTimers": {
|
|
1456
|
+
"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.",
|
|
1457
|
+
"visibility": "frontend",
|
|
1458
|
+
"type": "boolean"
|
|
1459
|
+
},
|
|
1460
|
+
"logoutIfDisconnected": {
|
|
1461
|
+
"description": "Enable/disable the automatic logout also on users that are logged in but with no Backstage tabs open.\nDefault is true.",
|
|
1462
|
+
"visibility": "frontend",
|
|
1463
|
+
"type": "boolean"
|
|
1464
|
+
}
|
|
1465
|
+
}
|
|
1466
|
+
}
|
|
1467
|
+
}
|
|
1468
|
+
}
|
|
1469
|
+
},
|
|
1470
|
+
"$schema": "http://json-schema.org/draft-07/schema#"
|
|
1471
|
+
}
|
|
1472
|
+
},
|
|
1428
1473
|
{
|
|
1429
1474
|
"path": "../../node_modules/@oriflame/backstage-plugin-score-card/node_modules/@backstage/core-components/config.d.ts",
|
|
1430
1475
|
"value": {
|
|
@@ -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.a5f4ad6c.js"></script><script defer="defer" src="/static/module-material-ui.1eefc717.js"></script><script defer="defer" src="/static/module-lodash.1a2b8e11.js"></script><script defer="defer" src="/static/module-date-fns.196adaa7.js"></script><script defer="defer" src="/static/module-mui.3056800b.js"></script><script defer="defer" src="/static/module-material-table.892da5bc.js"></script><script defer="defer" src="/static/module-react-dom.3e65b8bc.js"></script><script defer="defer" src="/static/module-react-router.07ec2a81.js"></script><script defer="defer" src="/static/module-react-router-dom.ba9d01bf.js"></script><script defer="defer" src="/static/module-react-beautiful-dnd.8a51ed97.js"></script><script defer="defer" src="/static/module-zod.955be94f.js"></script><script defer="defer" src="/static/module-i18next.40b7c233.js"></script><script defer="defer" src="/static/vendor.a5f4ad6c.js"></script><script defer="defer" src="/static/main.a5f4ad6c.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
1
|
"use strict";(()=>{(self.webpackChunktechdocs_cli_embedded_app=self.webpackChunktechdocs_cli_embedded_app||[]).push([[4487],{94487:function(dt,j,e){e.r(j),e.d(j,{TechDocsCustomHome:function(){return rt}});var a=e(31085),m=e(14041),A=e(73466),v=e(58837),I=e(51372),P=e(6820),h=e(72427),B=e(16009),R=e(67871);function H(){const t=(0,h.gf)(B.K),{loading:o,value:n}=(0,A.A)(async()=>{const{ownershipEntityRefs:r}=await t.getBackstageIdentity();return r},[]),s=(0,m.useMemo)(()=>{const r=new Set(n!=null?n:[]);return u=>{const l=(0,R.t)(u,I.vv).map(P.U2);for(const i of l)if(r.has(i))return!0;return!1}},[n]);return{loading:o,isOwnedEntity:s}}var b=e(7341),D=e(86519),E=e(27125),O=e(82779),p=e(95768),W=e(9222),N=e(65461),f=e(10394),S=e(12398);const U=t=>(0,S.A)({root:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(22em, 1fr))",gridAutoRows:"1fr",gridGap:t.spacing(2)}}),G=(0,v.A)(U,{name:"BackstageItemCardGrid"});function L(t){const{children:o,...n}=t,s=G(n);return(0,a.jsx)(f.A,{className:s.root,...n,children:o})}var T=e(72501);const V=t=>(0,S.A)({root:{color:t.palette.common.white,padding:t.spacing(2,2,3),backgroundImage:t.getPageTheme({themeId:"card"}).backgroundImage,backgroundPosition:0,backgroundSize:"inherit"}}),z=(0,v.A)(V,{name:"BackstageItemCardHeader"});function F(t){const{title:o,subtitle:n,children:s}=t,r=z(t);return(0,a.jsxs)(f.A,{className:r.root,children:[n&&(0,a.jsx)(T.A,{variant:"subtitle2",component:"h3",children:n}),o&&(0,a.jsx)(T.A,{variant:"h6",component:"h4",children:o}),s]})}var M=e(73896),K=e(40703),Y=e(59469),$=e(48653),J=e(57369);const Q=t=>{const{entities:o}=t,n=(0,W.S)(O.Oc),s=(0,h.gf)(N.U);return o?(0,a.jsx)(L,{"data-testid":"docs-explore",children:o!=null&&o.length?o.map((r,u)=>{var l,i;return(0,a.jsxs)(K.A,{children:[(0,a.jsx)(J.A,{children:(0,a.jsx)(F,{title:(l=r.metadata.title)!==null&&l!==void 0?l:r.metadata.name})}),(0,a.jsx)($.A,{children:r.metadata.description}),(0,a.jsx)(Y.A,{children:(0,a.jsx)(M.z,{to:n({namespace:(0,p.V)((i=r.metadata.namespace)!==null&&i!==void 0?i:"default",s),kind:(0,p.V)(r.kind,s),name:(0,p.V)(r.metadata.name,s)}),color:"primary","data-testid":"read_docs",children:"Read Docs"})})]},u)}):null}):null};var x=e(81859),X=e(59428),Z=e(27586),y=e(26280),k=e(68146),w=e(88640),q=e(77310),_=e(38605),tt=e(31653),et=e(72072);const at=(0,v.A)(t=>({tabsWrapper:{gridArea:"pageSubheader",backgroundColor:t.palette.background.paper,paddingLeft:t.spacing(3),minWidth:0},defaultTab:{...t.typography.caption,padding:t.spacing(3,3),textTransform:"uppercase",fontWeight:t.typography.fontWeightBold,color:t.palette.text.secondary},selected:{color:t.palette.text.primary},tabRoot:{"&:hover":{backgroundColor:t.palette.background.default,color:t.palette.text.primary}}}),{name:"BackstageHeaderTabs"});function nt(t){const{tabs:o,onChange:n,selectedIndex:s}=t,[r,u]=(0,m.useState)(s!=null?s:0),l=at(),i=(0,m.useCallback)((d,c)=>{s===void 0&&u(c),n&&n(c)},[s,n]);(0,m.useEffect)(()=>{s!==void 0&&u(s)},[s]);function g(d){return d.replace(/^\//,"")}return(0,a.jsx)(f.A,{className:l.tabsWrapper,children:(0,a.jsx)(tt.A,{indicatorColor:"primary",textColor:"inherit",variant:"scrollable",scrollButtons:"auto","aria-label":"tabs",onChange:i,value:r,children:o.map((d,c)=>(0,a.jsx)(_.A,{"data-testid":`header-tab-${c}`,label:d.label,component:et.N_,to:g(d.id),value:c,className:l.defaultTab,classes:{selected:l.selected,root:l.tabRoot},...d.tabProps},d.id))})})}const st={DocsTable:E.o,DocsCardGrid:Q},ot=({config:t,entities:o,index:n})=>{const r=(0,v.A)({panelContainer:{marginBottom:"2rem",...t.panelCSS?t.panelCSS:{}}})(),{loading:u,isOwnedEntity:l}=H(),i=st[t.panelType],g=o.filter(d=>t.filterPredicate==="ownedByUser"?u?!1:l(d):typeof t.filterPredicate=="function"&&t.filterPredicate(d));return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(X.d,{title:t.title,description:t.description,children:n===0?(0,a.jsx)(Z.Y,{children:"Discover documentation in your ecosystem."}):null}),(0,a.jsx)("div",{className:r.panelContainer,children:(0,a.jsx)(i,{"data-testid":"techdocs-custom-panel",entities:g})})]})},rt=t=>{const{tabsConfig:o}=t,[n,s]=(0,m.useState)(0),r=(0,h.gf)(b.v),{value:u,loading:l,error:i}=(0,A.A)(async()=>(await r.getEntities({filter:{"metadata.annotations.backstage.io/techdocs-ref":D.c},fields:["apiVersion","kind","metadata","relations","spec.owner","spec.type"]})).items.filter(c=>{var C;return!!(!((C=c.metadata.annotations)===null||C===void 0)&&C["backstage.io/techdocs-ref"])})),g=o[n];return l?(0,a.jsx)(x.S,{children:(0,a.jsx)(y.U,{children:(0,a.jsx)(k.k,{})})}):i?(0,a.jsx)(x.S,{children:(0,a.jsx)(y.U,{children:(0,a.jsx)(w.B,{severity:"error",title:"Could not load available documentation.",children:(0,a.jsx)(q.z,{language:"text",text:i.toString()})})})}):(0,a.jsxs)(x.S,{children:[(0,a.jsx)(nt,{selectedIndex:n,onChange:d=>s(d),tabs:o.map(({label:d},c)=>({id:c.toString(),label:d}))}),(0,a.jsx)(y.U,{"data-testid":"techdocs-content",children:g.panels.map((d,c)=>(0,a.jsx)(ot,{config:d,entities:u||[],index:c},c))})]})}}}]);})();
|
|
2
2
|
|
|
3
|
-
//# sourceMappingURL=4487.
|
|
3
|
+
//# sourceMappingURL=4487.8a9c8ef0.chunk.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"static/4487.06c23d1b.chunk.js","mappings":"mTAoCO,SAASA,GAAAA,CAId,MAAMC,KAAcC,EAAAA,IAAOC,EAAAA,CAAcA,EAGnC,CAAEC,QAAAA,EAASC,MAAOC,CAAK,KAAIC,EAAAA,GAC/B,UACE,KAAM,CAAEC,oBAAAA,CAAoB,EAAI,MAAMP,EAAYQ,qBAAqB,EACvE,OAAOD,CACT,EAEA,CAAC,CAAC,EAGEE,KAAgBC,EAAAA,SAAQ,KAC5B,MAAMC,EAAc,IAAIC,IAAIP,GAAAA,KAAAA,EAAQ,CAAC,CAAC,EAEtC,OAAQQ,GAAAA,CACN,MAAMC,KAAkBC,EAAAA,GAAmBF,EAAQG,EAAAA,EAAiBA,EAAEC,IACpEC,EAAAA,EAAkBA,EAEpB,UAAWC,KAAOL,EAChB,GAAI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A,EAAT,MAAO,CAAC,EAACA,GAAAA,EAAAA,EAAOuD,SAAS8E,eAAW,MAA3BrI,IAAAA,SAAAA,EAA8B,2BAA2B,EACpE,CAAC,CACF,EAEKsI,EAAmBT,EAAWtC,CAAW,EAE/C,OAAIjG,KAEA,OAACiJ,EAAAA,EAAmBA,C,YAClB,OAACC,EAAAA,EAAOA,C,YACN,OAACC,EAAAA,EAAQA,CAAAA,CAAAA,C,KAMbT,KAEA,OAACO,EAAAA,EAAmBA,C,YAClB,OAACC,EAAAA,EAAOA,C,YACN,OAACE,EAAAA,EAAYA,CACXC,SAAS,QACTrG,MAAM,0C,YAEN,OAACsG,EAAAA,EAAWA,CAACC,SAAS,OAAOhE,KAAMmD,EAAMc,SAAS,C,YAQ1D,QAACP,EAAAA,EAAmBA,C,aAClB,OAACpD,GAAUA,CACTG,cAAeC,EACfF,SAAUjC,GAASoC,EAAepC,CAAK,EACvCgC,KAAMyC,EAAWzH,IAAI,CAAC,CAAEqG,MAAAA,CAAM,EAAGrD,KAAW,CAC1CuD,GAAIvD,EAAM0F,SAAS,EACnBrC,MAAAA,CACF,EAAE,C,MAEJ,OAAC+B,EAAAA,EAAOA,CAACtF,cAAY,mB,SAClBoF,EAAiBzB,OAAOzG,IAAI,CAAC4C,EAAQI,OACpC,OAAC2D,GAAAA,CAEC/D,OAAQA,EACRJ,SAAYA,GAAsB,CAAC,EACnCQ,MAAOA,C,EAHFA,CAAK,CAALA,C,KASjB,C","sources":["webpack://techdocs-cli-embedded-app/../../plugins/catalog-react/src/hooks/useEntityOwnership.ts","webpack://techdocs-cli-embedded-app/../core-components/src/layout/ItemCard/ItemCardGrid.tsx","webpack://techdocs-cli-embedded-app/../core-components/src/layout/ItemCard/ItemCardHeader.tsx","webpack://techdocs-cli-embedded-app/../../plugins/techdocs/src/home/components/Grids/DocsCardGrid.tsx","webpack://techdocs-cli-embedded-app/../core-components/src/layout/HeaderTabs/HeaderTabs.tsx","webpack://techdocs-cli-embedded-app/../../plugins/techdocs/src/home/components/TechDocsCustomHome.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 {\n Entity,\n RELATION_OWNED_BY,\n stringifyEntityRef,\n} from '@backstage/catalog-model';\nimport { identityApiRef, useApi } from '@backstage/core-plugin-api';\nimport { useMemo } from 'react';\nimport useAsync from 'react-use/esm/useAsync';\nimport { getEntityRelations } from '../utils/getEntityRelations';\n\n/**\n * Returns a function that checks whether the currently signed-in user is an\n * owner of a given entity. When the hook is initially mounted, the loading\n * flag will be true and the results returned from the function will always be\n * false.\n *\n * @public\n *\n * @returns a function that checks if the signed in user owns an entity\n */\nexport function useEntityOwnership(): {\n loading: boolean;\n isOwnedEntity: (entity: Entity) => boolean;\n} {\n const identityApi = useApi(identityApiRef);\n\n // Trigger load only on mount\n const { loading, value: refs } = useAsync(\n async () => {\n const { ownershipEntityRefs } = await identityApi.getBackstageIdentity();\n return ownershipEntityRefs;\n },\n // load only on mount\n [],\n );\n\n const isOwnedEntity = useMemo(() => {\n const myOwnerRefs = new Set(refs ?? []);\n\n return (entity: Entity) => {\n const entityOwnerRefs = getEntityRelations(entity, RELATION_OWNED_BY).map(\n stringifyEntityRef,\n );\n for (const ref of entityOwnerRefs) {\n if (myOwnerRefs.has(ref)) {\n return true;\n }\n }\n return false;\n };\n }, [refs]);\n\n return { loading, isOwnedEntity };\n}\n","/*\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 */\nimport Box from '@material-ui/core/Box';\nimport {\n createStyles,\n makeStyles,\n Theme,\n WithStyles,\n} from '@material-ui/core/styles';\nimport React from 'react';\n\n/** @public */\nexport type ItemCardGridClassKey = 'root';\n\nconst styles = (theme: Theme) =>\n createStyles({\n root: {\n display: 'grid',\n gridTemplateColumns: 'repeat(auto-fill, minmax(22em, 1fr))',\n gridAutoRows: '1fr',\n gridGap: theme.spacing(2),\n },\n });\n\nconst useStyles = makeStyles(styles, { name: 'BackstageItemCardGrid' });\n\n/** @public */\nexport type ItemCardGridProps = Partial<WithStyles<typeof styles>> & {\n /**\n * The Card items of the grid.\n */\n children?: React.ReactNode;\n};\n\n/**\n * A default grid to use when arranging \"item cards\" - cards that let users\n * select among several options.\n *\n * @remarks\n * The immediate children are expected to be Material UI Card components.\n *\n * Styles for the grid can be overridden using the `classes` prop, e.g.:\n *\n * `<ItemCardGrid title=\"Hello\" classes={{ root: myClassName }} />`\n *\n * This can be useful for e.g. overriding gridTemplateColumns to adapt the\n * minimum size of the cells to fit the content better.\n *\n * @public\n */\nexport function ItemCardGrid(props: ItemCardGridProps) {\n const { children, ...otherProps } = props;\n const classes = useStyles(otherProps);\n return (\n <Box className={classes.root} {...otherProps}>\n {children}\n </Box>\n );\n}\n","/*\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 Box from '@material-ui/core/Box';\nimport {\n createStyles,\n makeStyles,\n Theme,\n WithStyles,\n} from '@material-ui/core/styles';\nimport Typography from '@material-ui/core/Typography';\nimport React from 'react';\n\n/** @public */\nexport type ItemCardHeaderClassKey = 'root';\n\nconst styles = (theme: Theme) =>\n createStyles({\n root: {\n color: theme.palette.common.white,\n padding: theme.spacing(2, 2, 3),\n backgroundImage: theme.getPageTheme({ themeId: 'card' }).backgroundImage,\n backgroundPosition: 0,\n backgroundSize: 'inherit',\n },\n });\n\nconst useStyles = makeStyles(styles, { name: 'BackstageItemCardHeader' });\n\n/** @public */\nexport type ItemCardHeaderProps = Partial<WithStyles<typeof styles>> & {\n /**\n * A large title to show in the header, providing the main heading.\n *\n * Use this if you want to have the default styling and placement of a title.\n */\n title?: React.ReactNode;\n /**\n * A slightly smaller title to show in the header, providing additional\n * details.\n *\n * Use this if you want to have the default styling and placement of a\n * subtitle.\n */\n subtitle?: React.ReactNode;\n /**\n * Custom children to draw in the header.\n *\n * If the title and/or subtitle were specified, the children are drawn below\n * those.\n */\n children?: React.ReactNode;\n};\n\n/**\n * A simple card header, rendering a default look for \"item cards\" - cards that\n * are arranged in a grid for users to select among several options.\n *\n * @remarks\n * This component expects to be placed within a Material UI `<CardMedia>`.\n *\n * Styles for the header can be overridden using the `classes` prop, e.g.:\n *\n * `<ItemCardHeader title=\"Hello\" classes={{ root: myClassName }} />`\n *\n * @public\n */\nexport function ItemCardHeader(props: ItemCardHeaderProps) {\n const { title, subtitle, children } = props;\n const classes = useStyles(props);\n return (\n <Box className={classes.root}>\n {subtitle && (\n <Typography variant=\"subtitle2\" component=\"h3\">\n {subtitle}\n </Typography>\n )}\n {title && (\n <Typography variant=\"h6\" component=\"h4\">\n {title}\n </Typography>\n )}\n {children}\n </Box>\n );\n}\n","/*\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 { rootDocsRouteRef } from '../../../routes';\nimport { toLowerMaybe } from '../../../helpers';\nimport { Entity } from '@backstage/catalog-model';\nimport { useApi, useRouteRef, configApiRef } from '@backstage/core-plugin-api';\nimport {\n LinkButton,\n ItemCardGrid,\n ItemCardHeader,\n} from '@backstage/core-components';\nimport Card from '@material-ui/core/Card';\nimport CardActions from '@material-ui/core/CardActions';\nimport CardContent from '@material-ui/core/CardContent';\nimport CardMedia from '@material-ui/core/CardMedia';\nimport React from 'react';\n\n/**\n * Props for {@link DocsCardGrid}\n *\n * @public\n */\nexport type DocsCardGridProps = {\n entities: Entity[] | undefined;\n};\n\n/**\n * Component which accepts a list of entities and renders a item card for each entity\n *\n * @public\n */\nexport const DocsCardGrid = (props: DocsCardGridProps) => {\n const { entities } = props;\n const getRouteToReaderPageFor = useRouteRef(rootDocsRouteRef);\n const config = useApi(configApiRef);\n if (!entities) return null;\n return (\n <ItemCardGrid data-testid=\"docs-explore\">\n {!entities?.length\n ? null\n : entities.map((entity, index: number) => (\n <Card key={index}>\n <CardMedia>\n <ItemCardHeader\n title={entity.metadata.title ?? entity.metadata.name}\n />\n </CardMedia>\n <CardContent>{entity.metadata.description}</CardContent>\n <CardActions>\n <LinkButton\n to={getRouteToReaderPageFor({\n namespace: toLowerMaybe(\n entity.metadata.namespace ?? 'default',\n config,\n ),\n kind: toLowerMaybe(entity.kind, config),\n name: toLowerMaybe(entity.metadata.name, config),\n })}\n color=\"primary\"\n data-testid=\"read_docs\"\n >\n Read Docs\n </LinkButton>\n </CardActions>\n </Card>\n ))}\n </ItemCardGrid>\n );\n};\n","/*\n * Copyright 2020 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 */\nimport Box from '@material-ui/core/Box';\nimport { makeStyles } from '@material-ui/core/styles';\nimport TabUI, { TabProps } from '@material-ui/core/Tab';\nimport Tabs from '@material-ui/core/Tabs';\nimport React, { useCallback, useEffect, useState } from 'react';\nimport { Link } from '@backstage/core-components';\n\n// TODO(blam): Remove this implementation when the Tabs are ready\n// This is just a temporary solution to implementing tabs for now\n\n/** @public */\nexport type HeaderTabsClassKey =\n | 'tabsWrapper'\n | 'defaultTab'\n | 'selected'\n | 'tabRoot';\n\nconst useStyles = makeStyles(\n theme => ({\n tabsWrapper: {\n gridArea: 'pageSubheader',\n backgroundColor: theme.palette.background.paper,\n paddingLeft: theme.spacing(3),\n minWidth: 0,\n },\n defaultTab: {\n ...theme.typography.caption,\n padding: theme.spacing(3, 3),\n textTransform: 'uppercase',\n fontWeight: theme.typography.fontWeightBold,\n color: theme.palette.text.secondary,\n },\n selected: {\n color: theme.palette.text.primary,\n },\n tabRoot: {\n '&:hover': {\n backgroundColor: theme.palette.background.default,\n color: theme.palette.text.primary,\n },\n },\n }),\n { name: 'BackstageHeaderTabs' },\n);\n\nexport type Tab = {\n id: string;\n label: string;\n tabProps?: TabProps<React.ElementType, { component?: React.ElementType }>;\n};\n\ntype HeaderTabsProps = {\n tabs: Tab[];\n onChange?: (index: number) => void;\n selectedIndex?: number;\n};\n\n/**\n * Horizontal Tabs component\n *\n * @public\n *\n */\nexport function HeaderTabs(props: HeaderTabsProps) {\n const { tabs, onChange, selectedIndex } = props;\n const [selectedTab, setSelectedTab] = useState<number>(selectedIndex ?? 0);\n const styles = useStyles();\n\n const handleChange = useCallback(\n (_: React.ChangeEvent<{}>, index: number) => {\n if (selectedIndex === undefined) {\n setSelectedTab(index);\n }\n if (onChange) onChange(index);\n },\n [selectedIndex, onChange],\n );\n\n useEffect(() => {\n if (selectedIndex !== undefined) {\n setSelectedTab(selectedIndex);\n }\n }, [selectedIndex]);\n function removeLeadingSlash(path: string) {\n return path.replace(/^\\//, '');\n }\n return (\n <Box className={styles.tabsWrapper}>\n <Tabs\n indicatorColor=\"primary\"\n textColor=\"inherit\"\n variant=\"scrollable\"\n scrollButtons=\"auto\"\n aria-label=\"tabs\"\n onChange={handleChange}\n value={selectedTab}\n >\n {tabs.map((tab, index) => (\n <TabUI\n data-testid={`header-tab-${index}`}\n label={tab.label}\n key={tab.id}\n component={Link}\n to={removeLeadingSlash(tab.id)}\n value={index}\n className={styles.defaultTab}\n classes={{ selected: styles.selected, root: styles.tabRoot }}\n {...tab.tabProps}\n />\n ))}\n </Tabs>\n </Box>\n );\n}\n","/*\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 React, { useState } from 'react';\nimport useAsync from 'react-use/esm/useAsync';\nimport { makeStyles } from '@material-ui/core/styles';\nimport { CSSProperties } from '@material-ui/styles/withStyles';\nimport {\n CATALOG_FILTER_EXISTS,\n catalogApiRef,\n CatalogApi,\n useEntityOwnership,\n} from '@backstage/plugin-catalog-react';\nimport { Entity } from '@backstage/catalog-model';\nimport { DocsTable } from './Tables';\nimport { DocsCardGrid } from './Grids';\nimport { TechDocsPageWrapper } from './TechDocsPageWrapper';\n\nimport {\n CodeSnippet,\n Content,\n HeaderTabs,\n Progress,\n WarningPanel,\n SupportButton,\n ContentHeader,\n} from '@backstage/core-components';\nimport { useApi } from '@backstage/core-plugin-api';\n\nconst panels = {\n DocsTable: DocsTable,\n DocsCardGrid: DocsCardGrid,\n};\n\n/**\n * Available panel types\n *\n * @public\n */\nexport type PanelType = 'DocsCardGrid' | 'DocsTable';\n\n/**\n * Type representing a TechDocsCustomHome panel.\n *\n * @public\n */\nexport interface PanelConfig {\n title: string;\n description: string;\n panelType: PanelType;\n panelCSS?: CSSProperties;\n filterPredicate: ((entity: Entity) => boolean) | string;\n}\n\n/**\n * Type representing a TechDocsCustomHome tab.\n *\n * @public\n */\nexport interface TabConfig {\n label: string;\n panels: PanelConfig[];\n}\n\n/**\n * Type representing a list of TechDocsCustomHome tabs.\n *\n * @public\n */\nexport type TabsConfig = TabConfig[];\n\nconst CustomPanel = ({\n config,\n entities,\n index,\n}: {\n config: PanelConfig;\n entities: Entity[];\n index: number;\n}) => {\n const useStyles = makeStyles({\n panelContainer: {\n marginBottom: '2rem',\n ...(config.panelCSS ? config.panelCSS : {}),\n },\n });\n const classes = useStyles();\n const { loading: loadingOwnership, isOwnedEntity } = useEntityOwnership();\n\n const Panel = panels[config.panelType];\n\n const shownEntities = entities.filter(entity => {\n if (config.filterPredicate === 'ownedByUser') {\n if (loadingOwnership) {\n return false;\n }\n return isOwnedEntity(entity);\n }\n\n return (\n typeof config.filterPredicate === 'function' &&\n config.filterPredicate(entity)\n );\n });\n\n return (\n <>\n <ContentHeader title={config.title} description={config.description}>\n {index === 0 ? (\n <SupportButton>\n Discover documentation in your ecosystem.\n </SupportButton>\n ) : null}\n </ContentHeader>\n <div className={classes.panelContainer}>\n <Panel data-testid=\"techdocs-custom-panel\" entities={shownEntities} />\n </div>\n </>\n );\n};\n\n/**\n * Props for {@link TechDocsCustomHome}\n *\n * @public\n */\nexport type TechDocsCustomHomeProps = {\n tabsConfig: TabsConfig;\n};\n\nexport const TechDocsCustomHome = (props: TechDocsCustomHomeProps) => {\n const { tabsConfig } = props;\n const [selectedTab, setSelectedTab] = useState<number>(0);\n const catalogApi: CatalogApi = useApi(catalogApiRef);\n\n const {\n value: entities,\n loading,\n error,\n } = useAsync(async () => {\n const response = await catalogApi.getEntities({\n filter: {\n 'metadata.annotations.backstage.io/techdocs-ref': CATALOG_FILTER_EXISTS,\n },\n fields: [\n 'apiVersion',\n 'kind',\n 'metadata',\n 'relations',\n 'spec.owner',\n 'spec.type',\n ],\n });\n return response.items.filter((entity: Entity) => {\n return !!entity.metadata.annotations?.['backstage.io/techdocs-ref'];\n });\n });\n\n const currentTabConfig = tabsConfig[selectedTab];\n\n if (loading) {\n return (\n <TechDocsPageWrapper>\n <Content>\n <Progress />\n </Content>\n </TechDocsPageWrapper>\n );\n }\n\n if (error) {\n return (\n <TechDocsPageWrapper>\n <Content>\n <WarningPanel\n severity=\"error\"\n title=\"Could not load available documentation.\"\n >\n <CodeSnippet language=\"text\" text={error.toString()} />\n </WarningPanel>\n </Content>\n </TechDocsPageWrapper>\n );\n }\n\n return (\n <TechDocsPageWrapper>\n <HeaderTabs\n selectedIndex={selectedTab}\n onChange={index => setSelectedTab(index)}\n tabs={tabsConfig.map(({ label }, index) => ({\n id: index.toString(),\n label,\n }))}\n />\n <Content data-testid=\"techdocs-content\">\n {currentTabConfig.panels.map((config, index) => (\n <CustomPanel\n key={index}\n config={config}\n entities={!!entities ? entities : []}\n index={index}\n />\n ))}\n </Content>\n </TechDocsPageWrapper>\n );\n};\n"],"names":["useEntityOwnership","identityApi","useApi","identityApiRef","loading","value","refs","useAsync","ownershipEntityRefs","getBackstageIdentity","isOwnedEntity","useMemo","myOwnerRefs","Set","entity","entityOwnerRefs","getEntityRelations","RELATION_OWNED_BY","map","stringifyEntityRef","ref","has","styles","theme","createStyles","root","display","gridTemplateColumns","gridAutoRows","gridGap","spacing","useStyles","makeStyles","name","ItemCardGrid","props","children","otherProps","classes","Box","className","color","palette","common","white","padding","backgroundImage","getPageTheme","themeId","backgroundPosition","backgroundSize","ItemCardHeader","title","subtitle","Typography","variant","component","DocsCardGrid","entities","getRouteToReaderPageFor","useRouteRef","rootDocsRouteRef","config","configApiRef","data-testid","length","index","Card","CardMedia","metadata","CardContent","description","CardActions","LinkButton","to","namespace","toLowerMaybe","kind","tabsWrapper","gridArea","backgroundColor","background","paper","paddingLeft","minWidth","defaultTab","typography","caption","textTransform","fontWeight","fontWeightBold","text","secondary","selected","primary","tabRoot","default","HeaderTabs","tabs","onChange","selectedIndex","selectedTab","setSelectedTab","useState","handleChange","useCallback","_","undefined","useEffect","removeLeadingSlash","path","replace","Tabs","indicatorColor","textColor","scrollButtons","aria-label","tab","TabUI","label","Link","id","tabProps","panels","DocsTable","CustomPanel","panelContainer","marginBottom","panelCSS","loadingOwnership","Panel","panelType","shownEntities","filter","filterPredicate","ContentHeader","SupportButton","div","TechDocsCustomHome","tabsConfig","catalogApi","catalogApiRef","error","getEntities","CATALOG_FILTER_EXISTS","fields","items","annotations","currentTabConfig","TechDocsPageWrapper","Content","Progress","WarningPanel","severity","CodeSnippet","language","toString"],"sourceRoot":""}
|
|
1
|
+
{"version":3,"file":"static/4487.8a9c8ef0.chunk.js","mappings":"mTAoCO,SAASA,GAAAA,CAId,MAAMC,KAAcC,EAAAA,IAAOC,EAAAA,CAAcA,EAGnC,CAAEC,QAAAA,EAASC,MAAOC,CAAK,KAAIC,EAAAA,GAC/B,UACE,KAAM,CAAEC,oBAAAA,CAAoB,EAAI,MAAMP,EAAYQ,qBAAqB,EACvE,OAAOD,CACT,EAEA,CAAC,CAAC,EAGEE,KAAgBC,EAAAA,SAAQ,KAC5B,MAAMC,EAAc,IAAIC,IAAIP,GAAAA,KAAAA,EAAQ,CAAC,CAAC,EAEtC,OAAQQ,GAAAA,CACN,MAAMC,KAAkBC,EAAAA,GAAmBF,EAAQG,EAAAA,EAAiBA,EAAEC,IACpEC,EAAAA,EAAkBA,EAEpB,UAAWC,KAAOL,EAChB,GAAIH,EAAYS,IAAID,CAAG,EACrB,MAAO,GAGX,MAAO,EACT,CACF,EAAG,CAACd,C,CAAK,EAET,MAAO,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,EAA8B,2BAA2B,EACpE,CAAC,CACF,EAEKsI,EAAmBT,EAAWtC,CAAW,EAE/C,OAAIjG,KAEA,OAACiJ,EAAAA,EAAmBA,C,YAClB,OAACC,EAAAA,EAAOA,C,YACN,OAACC,EAAAA,EAAQA,CAAAA,CAAAA,C,KAMbT,KAEA,OAACO,EAAAA,EAAmBA,C,YAClB,OAACC,EAAAA,EAAOA,C,YACN,OAACE,EAAAA,EAAYA,CACXC,SAAS,QACTrG,MAAM,0C,YAEN,OAACsG,EAAAA,EAAWA,CAACC,SAAS,OAAOhE,KAAMmD,EAAMc,SAAS,C,YAQ1D,QAACP,EAAAA,EAAmBA,C,aAClB,OAACpD,GAAUA,CACTG,cAAeC,EACfF,SAAUjC,GAASoC,EAAepC,CAAK,EACvCgC,KAAMyC,EAAWzH,IAAI,CAAC,CAAEqG,MAAAA,CAAM,EAAGrD,KAAW,CAC1CuD,GAAIvD,EAAM0F,SAAS,EACnBrC,MAAAA,CACF,EAAE,C,MAEJ,OAAC+B,EAAAA,EAAOA,CAACtF,cAAY,mB,SAClBoF,EAAiBzB,OAAOzG,IAAI,CAAC4C,EAAQI,OACpC,OAAC2D,GAAAA,CAEC/D,OAAQA,EACRJ,SAAYA,GAAsB,CAAC,EACnCQ,MAAOA,C,EAHFA,CAAK,CAALA,C,KASjB,C","sources":["webpack://techdocs-cli-embedded-app/../../plugins/catalog-react/src/hooks/useEntityOwnership.ts","webpack://techdocs-cli-embedded-app/../core-components/src/layout/ItemCard/ItemCardGrid.tsx","webpack://techdocs-cli-embedded-app/../core-components/src/layout/ItemCard/ItemCardHeader.tsx","webpack://techdocs-cli-embedded-app/../../plugins/techdocs/src/home/components/Grids/DocsCardGrid.tsx","webpack://techdocs-cli-embedded-app/../core-components/src/layout/HeaderTabs/HeaderTabs.tsx","webpack://techdocs-cli-embedded-app/../../plugins/techdocs/src/home/components/TechDocsCustomHome.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 {\n Entity,\n RELATION_OWNED_BY,\n stringifyEntityRef,\n} from '@backstage/catalog-model';\nimport { identityApiRef, useApi } from '@backstage/core-plugin-api';\nimport { useMemo } from 'react';\nimport useAsync from 'react-use/esm/useAsync';\nimport { getEntityRelations } from '../utils/getEntityRelations';\n\n/**\n * Returns a function that checks whether the currently signed-in user is an\n * owner of a given entity. When the hook is initially mounted, the loading\n * flag will be true and the results returned from the function will always be\n * false.\n *\n * @public\n *\n * @returns a function that checks if the signed in user owns an entity\n */\nexport function useEntityOwnership(): {\n loading: boolean;\n isOwnedEntity: (entity: Entity) => boolean;\n} {\n const identityApi = useApi(identityApiRef);\n\n // Trigger load only on mount\n const { loading, value: refs } = useAsync(\n async () => {\n const { ownershipEntityRefs } = await identityApi.getBackstageIdentity();\n return ownershipEntityRefs;\n },\n // load only on mount\n [],\n );\n\n const isOwnedEntity = useMemo(() => {\n const myOwnerRefs = new Set(refs ?? []);\n\n return (entity: Entity) => {\n const entityOwnerRefs = getEntityRelations(entity, RELATION_OWNED_BY).map(\n stringifyEntityRef,\n );\n for (const ref of entityOwnerRefs) {\n if (myOwnerRefs.has(ref)) {\n return true;\n }\n }\n return false;\n };\n }, [refs]);\n\n return { loading, isOwnedEntity };\n}\n","/*\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 */\nimport Box from '@material-ui/core/Box';\nimport {\n createStyles,\n makeStyles,\n Theme,\n WithStyles,\n} from '@material-ui/core/styles';\nimport React from 'react';\n\n/** @public */\nexport type ItemCardGridClassKey = 'root';\n\nconst styles = (theme: Theme) =>\n createStyles({\n root: {\n display: 'grid',\n gridTemplateColumns: 'repeat(auto-fill, minmax(22em, 1fr))',\n gridAutoRows: '1fr',\n gridGap: theme.spacing(2),\n },\n });\n\nconst useStyles = makeStyles(styles, { name: 'BackstageItemCardGrid' });\n\n/** @public */\nexport type ItemCardGridProps = Partial<WithStyles<typeof styles>> & {\n /**\n * The Card items of the grid.\n */\n children?: React.ReactNode;\n};\n\n/**\n * A default grid to use when arranging \"item cards\" - cards that let users\n * select among several options.\n *\n * @remarks\n * The immediate children are expected to be Material UI Card components.\n *\n * Styles for the grid can be overridden using the `classes` prop, e.g.:\n *\n * `<ItemCardGrid title=\"Hello\" classes={{ root: myClassName }} />`\n *\n * This can be useful for e.g. overriding gridTemplateColumns to adapt the\n * minimum size of the cells to fit the content better.\n *\n * @public\n */\nexport function ItemCardGrid(props: ItemCardGridProps) {\n const { children, ...otherProps } = props;\n const classes = useStyles(otherProps);\n return (\n <Box className={classes.root} {...otherProps}>\n {children}\n </Box>\n );\n}\n","/*\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 Box from '@material-ui/core/Box';\nimport {\n createStyles,\n makeStyles,\n Theme,\n WithStyles,\n} from '@material-ui/core/styles';\nimport Typography from '@material-ui/core/Typography';\nimport React from 'react';\n\n/** @public */\nexport type ItemCardHeaderClassKey = 'root';\n\nconst styles = (theme: Theme) =>\n createStyles({\n root: {\n color: theme.palette.common.white,\n padding: theme.spacing(2, 2, 3),\n backgroundImage: theme.getPageTheme({ themeId: 'card' }).backgroundImage,\n backgroundPosition: 0,\n backgroundSize: 'inherit',\n },\n });\n\nconst useStyles = makeStyles(styles, { name: 'BackstageItemCardHeader' });\n\n/** @public */\nexport type ItemCardHeaderProps = Partial<WithStyles<typeof styles>> & {\n /**\n * A large title to show in the header, providing the main heading.\n *\n * Use this if you want to have the default styling and placement of a title.\n */\n title?: React.ReactNode;\n /**\n * A slightly smaller title to show in the header, providing additional\n * details.\n *\n * Use this if you want to have the default styling and placement of a\n * subtitle.\n */\n subtitle?: React.ReactNode;\n /**\n * Custom children to draw in the header.\n *\n * If the title and/or subtitle were specified, the children are drawn below\n * those.\n */\n children?: React.ReactNode;\n};\n\n/**\n * A simple card header, rendering a default look for \"item cards\" - cards that\n * are arranged in a grid for users to select among several options.\n *\n * @remarks\n * This component expects to be placed within a Material UI `<CardMedia>`.\n *\n * Styles for the header can be overridden using the `classes` prop, e.g.:\n *\n * `<ItemCardHeader title=\"Hello\" classes={{ root: myClassName }} />`\n *\n * @public\n */\nexport function ItemCardHeader(props: ItemCardHeaderProps) {\n const { title, subtitle, children } = props;\n const classes = useStyles(props);\n return (\n <Box className={classes.root}>\n {subtitle && (\n <Typography variant=\"subtitle2\" component=\"h3\">\n {subtitle}\n </Typography>\n )}\n {title && (\n <Typography variant=\"h6\" component=\"h4\">\n {title}\n </Typography>\n )}\n {children}\n </Box>\n );\n}\n","/*\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 { rootDocsRouteRef } from '../../../routes';\nimport { toLowerMaybe } from '../../../helpers';\nimport { Entity } from '@backstage/catalog-model';\nimport { useApi, useRouteRef, configApiRef } from '@backstage/core-plugin-api';\nimport {\n LinkButton,\n ItemCardGrid,\n ItemCardHeader,\n} from '@backstage/core-components';\nimport Card from '@material-ui/core/Card';\nimport CardActions from '@material-ui/core/CardActions';\nimport CardContent from '@material-ui/core/CardContent';\nimport CardMedia from '@material-ui/core/CardMedia';\nimport React from 'react';\n\n/**\n * Props for {@link DocsCardGrid}\n *\n * @public\n */\nexport type DocsCardGridProps = {\n entities: Entity[] | undefined;\n};\n\n/**\n * Component which accepts a list of entities and renders a item card for each entity\n *\n * @public\n */\nexport const DocsCardGrid = (props: DocsCardGridProps) => {\n const { entities } = props;\n const getRouteToReaderPageFor = useRouteRef(rootDocsRouteRef);\n const config = useApi(configApiRef);\n if (!entities) return null;\n return (\n <ItemCardGrid data-testid=\"docs-explore\">\n {!entities?.length\n ? null\n : entities.map((entity, index: number) => (\n <Card key={index}>\n <CardMedia>\n <ItemCardHeader\n title={entity.metadata.title ?? entity.metadata.name}\n />\n </CardMedia>\n <CardContent>{entity.metadata.description}</CardContent>\n <CardActions>\n <LinkButton\n to={getRouteToReaderPageFor({\n namespace: toLowerMaybe(\n entity.metadata.namespace ?? 'default',\n config,\n ),\n kind: toLowerMaybe(entity.kind, config),\n name: toLowerMaybe(entity.metadata.name, config),\n })}\n color=\"primary\"\n data-testid=\"read_docs\"\n >\n Read Docs\n </LinkButton>\n </CardActions>\n </Card>\n ))}\n </ItemCardGrid>\n );\n};\n","/*\n * Copyright 2020 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 */\nimport Box from '@material-ui/core/Box';\nimport { makeStyles } from '@material-ui/core/styles';\nimport TabUI, { TabProps } from '@material-ui/core/Tab';\nimport Tabs from '@material-ui/core/Tabs';\nimport React, { useCallback, useEffect, useState } from 'react';\nimport { Link } from '../../components/Link';\n\n// TODO(blam): Remove this implementation when the Tabs are ready\n// This is just a temporary solution to implementing tabs for now\n\n/** @public */\nexport type HeaderTabsClassKey =\n | 'tabsWrapper'\n | 'defaultTab'\n | 'selected'\n | 'tabRoot';\n\nconst useStyles = makeStyles(\n theme => ({\n tabsWrapper: {\n gridArea: 'pageSubheader',\n backgroundColor: theme.palette.background.paper,\n paddingLeft: theme.spacing(3),\n minWidth: 0,\n },\n defaultTab: {\n ...theme.typography.caption,\n padding: theme.spacing(3, 3),\n textTransform: 'uppercase',\n fontWeight: theme.typography.fontWeightBold,\n color: theme.palette.text.secondary,\n },\n selected: {\n color: theme.palette.text.primary,\n },\n tabRoot: {\n '&:hover': {\n backgroundColor: theme.palette.background.default,\n color: theme.palette.text.primary,\n },\n },\n }),\n { name: 'BackstageHeaderTabs' },\n);\n\nexport type Tab = {\n id: string;\n label: string;\n tabProps?: TabProps<React.ElementType, { component?: React.ElementType }>;\n};\n\ntype HeaderTabsProps = {\n tabs: Tab[];\n onChange?: (index: number) => void;\n selectedIndex?: number;\n};\n\n/**\n * Horizontal Tabs component\n *\n * @public\n *\n */\nexport function HeaderTabs(props: HeaderTabsProps) {\n const { tabs, onChange, selectedIndex } = props;\n const [selectedTab, setSelectedTab] = useState<number>(selectedIndex ?? 0);\n const styles = useStyles();\n\n const handleChange = useCallback(\n (_: React.ChangeEvent<{}>, index: number) => {\n if (selectedIndex === undefined) {\n setSelectedTab(index);\n }\n if (onChange) onChange(index);\n },\n [selectedIndex, onChange],\n );\n\n useEffect(() => {\n if (selectedIndex !== undefined) {\n setSelectedTab(selectedIndex);\n }\n }, [selectedIndex]);\n function removeLeadingSlash(path: string) {\n return path.replace(/^\\//, '');\n }\n return (\n <Box className={styles.tabsWrapper}>\n <Tabs\n indicatorColor=\"primary\"\n textColor=\"inherit\"\n variant=\"scrollable\"\n scrollButtons=\"auto\"\n aria-label=\"tabs\"\n onChange={handleChange}\n value={selectedTab}\n >\n {tabs.map((tab, index) => (\n <TabUI\n data-testid={`header-tab-${index}`}\n label={tab.label}\n key={tab.id}\n component={Link}\n to={removeLeadingSlash(tab.id)}\n value={index}\n className={styles.defaultTab}\n classes={{ selected: styles.selected, root: styles.tabRoot }}\n {...tab.tabProps}\n />\n ))}\n </Tabs>\n </Box>\n );\n}\n","/*\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 React, { useState } from 'react';\nimport useAsync from 'react-use/esm/useAsync';\nimport { makeStyles } from '@material-ui/core/styles';\nimport { CSSProperties } from '@material-ui/styles/withStyles';\nimport {\n CATALOG_FILTER_EXISTS,\n catalogApiRef,\n CatalogApi,\n useEntityOwnership,\n} from '@backstage/plugin-catalog-react';\nimport { Entity } from '@backstage/catalog-model';\nimport { DocsTable } from './Tables';\nimport { DocsCardGrid } from './Grids';\nimport { TechDocsPageWrapper } from './TechDocsPageWrapper';\n\nimport {\n CodeSnippet,\n Content,\n HeaderTabs,\n Progress,\n WarningPanel,\n SupportButton,\n ContentHeader,\n} from '@backstage/core-components';\nimport { useApi } from '@backstage/core-plugin-api';\n\nconst panels = {\n DocsTable: DocsTable,\n DocsCardGrid: DocsCardGrid,\n};\n\n/**\n * Available panel types\n *\n * @public\n */\nexport type PanelType = 'DocsCardGrid' | 'DocsTable';\n\n/**\n * Type representing a TechDocsCustomHome panel.\n *\n * @public\n */\nexport interface PanelConfig {\n title: string;\n description: string;\n panelType: PanelType;\n panelCSS?: CSSProperties;\n filterPredicate: ((entity: Entity) => boolean) | string;\n}\n\n/**\n * Type representing a TechDocsCustomHome tab.\n *\n * @public\n */\nexport interface TabConfig {\n label: string;\n panels: PanelConfig[];\n}\n\n/**\n * Type representing a list of TechDocsCustomHome tabs.\n *\n * @public\n */\nexport type TabsConfig = TabConfig[];\n\nconst CustomPanel = ({\n config,\n entities,\n index,\n}: {\n config: PanelConfig;\n entities: Entity[];\n index: number;\n}) => {\n const useStyles = makeStyles({\n panelContainer: {\n marginBottom: '2rem',\n ...(config.panelCSS ? config.panelCSS : {}),\n },\n });\n const classes = useStyles();\n const { loading: loadingOwnership, isOwnedEntity } = useEntityOwnership();\n\n const Panel = panels[config.panelType];\n\n const shownEntities = entities.filter(entity => {\n if (config.filterPredicate === 'ownedByUser') {\n if (loadingOwnership) {\n return false;\n }\n return isOwnedEntity(entity);\n }\n\n return (\n typeof config.filterPredicate === 'function' &&\n config.filterPredicate(entity)\n );\n });\n\n return (\n <>\n <ContentHeader title={config.title} description={config.description}>\n {index === 0 ? (\n <SupportButton>\n Discover documentation in your ecosystem.\n </SupportButton>\n ) : null}\n </ContentHeader>\n <div className={classes.panelContainer}>\n <Panel data-testid=\"techdocs-custom-panel\" entities={shownEntities} />\n </div>\n </>\n );\n};\n\n/**\n * Props for {@link TechDocsCustomHome}\n *\n * @public\n */\nexport type TechDocsCustomHomeProps = {\n tabsConfig: TabsConfig;\n};\n\nexport const TechDocsCustomHome = (props: TechDocsCustomHomeProps) => {\n const { tabsConfig } = props;\n const [selectedTab, setSelectedTab] = useState<number>(0);\n const catalogApi: CatalogApi = useApi(catalogApiRef);\n\n const {\n value: entities,\n loading,\n error,\n } = useAsync(async () => {\n const response = await catalogApi.getEntities({\n filter: {\n 'metadata.annotations.backstage.io/techdocs-ref': CATALOG_FILTER_EXISTS,\n },\n fields: [\n 'apiVersion',\n 'kind',\n 'metadata',\n 'relations',\n 'spec.owner',\n 'spec.type',\n ],\n });\n return response.items.filter((entity: Entity) => {\n return !!entity.metadata.annotations?.['backstage.io/techdocs-ref'];\n });\n });\n\n const currentTabConfig = tabsConfig[selectedTab];\n\n if (loading) {\n return (\n <TechDocsPageWrapper>\n <Content>\n <Progress />\n </Content>\n </TechDocsPageWrapper>\n );\n }\n\n if (error) {\n return (\n <TechDocsPageWrapper>\n <Content>\n <WarningPanel\n severity=\"error\"\n title=\"Could not load available documentation.\"\n >\n <CodeSnippet language=\"text\" text={error.toString()} />\n </WarningPanel>\n </Content>\n </TechDocsPageWrapper>\n );\n }\n\n return (\n <TechDocsPageWrapper>\n <HeaderTabs\n selectedIndex={selectedTab}\n onChange={index => setSelectedTab(index)}\n tabs={tabsConfig.map(({ label }, index) => ({\n id: index.toString(),\n label,\n }))}\n />\n <Content data-testid=\"techdocs-content\">\n {currentTabConfig.panels.map((config, index) => (\n <CustomPanel\n key={index}\n config={config}\n entities={!!entities ? entities : []}\n index={index}\n />\n ))}\n </Content>\n </TechDocsPageWrapper>\n );\n};\n"],"names":["useEntityOwnership","identityApi","useApi","identityApiRef","loading","value","refs","useAsync","ownershipEntityRefs","getBackstageIdentity","isOwnedEntity","useMemo","myOwnerRefs","Set","entity","entityOwnerRefs","getEntityRelations","RELATION_OWNED_BY","map","stringifyEntityRef","ref","has","styles","theme","createStyles","root","display","gridTemplateColumns","gridAutoRows","gridGap","spacing","useStyles","makeStyles","name","ItemCardGrid","props","children","otherProps","classes","Box","className","color","palette","common","white","padding","backgroundImage","getPageTheme","themeId","backgroundPosition","backgroundSize","ItemCardHeader","title","subtitle","Typography","variant","component","DocsCardGrid","entities","getRouteToReaderPageFor","useRouteRef","rootDocsRouteRef","config","configApiRef","data-testid","length","index","Card","CardMedia","metadata","CardContent","description","CardActions","LinkButton","to","namespace","toLowerMaybe","kind","tabsWrapper","gridArea","backgroundColor","background","paper","paddingLeft","minWidth","defaultTab","typography","caption","textTransform","fontWeight","fontWeightBold","text","secondary","selected","primary","tabRoot","default","HeaderTabs","tabs","onChange","selectedIndex","selectedTab","setSelectedTab","useState","handleChange","useCallback","_","undefined","useEffect","removeLeadingSlash","path","replace","Tabs","indicatorColor","textColor","scrollButtons","aria-label","tab","TabUI","label","Link","id","tabProps","panels","DocsTable","CustomPanel","panelContainer","marginBottom","panelCSS","loadingOwnership","Panel","panelType","shownEntities","filter","filterPredicate","ContentHeader","SupportButton","div","TechDocsCustomHome","tabsConfig","catalogApi","catalogApiRef","error","getEntities","CATALOG_FILTER_EXISTS","fields","items","annotations","currentTabConfig","TechDocsPageWrapper","Content","Progress","WarningPanel","severity","CodeSnippet","language","toString"],"sourceRoot":""}
|