@backstage-community/plugin-badges 0.3.2 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @backstage-community/plugin-badges
|
|
2
2
|
|
|
3
|
+
## 0.5.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 0b09ae7: Backstage version bump to v1.35.1
|
|
8
|
+
|
|
9
|
+
## 0.4.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- 6ce8d6b: Backstage version bump to v1.34.1
|
|
14
|
+
|
|
3
15
|
## 0.3.2
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BadgesClient.esm.js","sources":["../../src/api/BadgesClient.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 { generatePath } from 'react-router-dom';\nimport { ResponseError } from '@backstage/errors';\nimport { Entity, DEFAULT_NAMESPACE } from '@backstage/catalog-model';\nimport { BadgesApi, BadgeSpec, BadgeStyleOptions } from './types';\nimport { ConfigApi, DiscoveryApi, FetchApi } from '@backstage/core-plugin-api';\n\nexport class BadgesClient implements BadgesApi {\n private readonly discoveryApi: DiscoveryApi;\n private readonly fetchApi: FetchApi;\n private readonly configApi: ConfigApi;\n\n constructor(options: {\n discoveryApi: DiscoveryApi;\n fetchApi: FetchApi;\n configApi: ConfigApi;\n }) {\n this.discoveryApi = options.discoveryApi;\n this.fetchApi = options.fetchApi;\n this.configApi = options.configApi;\n }\n\n static fromConfig(options: {\n fetchApi: FetchApi;\n discoveryApi: DiscoveryApi;\n configApi: ConfigApi;\n }) {\n return new BadgesClient(options);\n }\n\n public async getEntityBadgeSpecs(\n entity: Entity,\n badgeOptions: BadgeStyleOptions,\n ): Promise<BadgeSpec[]> {\n // Check if obfuscation is enabled in the configuration\n const obfuscate = this.configApi.getOptionalBoolean('app.badges.obfuscate');\n\n if (obfuscate) {\n const entityUuidUrl = await this.getEntityUuidUrl(entity);\n const entityUuid = await this.getEntityUuid(entityUuidUrl).then(data => {\n return data.uuid;\n });\n const entityUuidBadgeSpecsUrl = await this.getEntityUuidBadgeSpecsUrl(\n entityUuid,\n );\n\n const response = await this.fetchApi.fetch(entityUuidBadgeSpecsUrl);\n if (!response.ok) {\n throw await ResponseError.fromResponse(response);\n }\n\n return await response.json();\n }\n\n // If obfuscation is disabled, get the badge specs directly as the previous implementation\n const entityBadgeSpecsUrl = await this.getEntityBadgeSpecsUrl(\n entity,\n badgeOptions,\n );\n const response = await this.fetchApi.fetch(entityBadgeSpecsUrl);\n if (!response.ok) {\n throw await ResponseError.fromResponse(response);\n }\n\n return await response.json();\n }\n\n private async getEntityUuidUrl(entity: Entity): Promise<string> {\n const routeParams = this.getEntityRouteParams(entity);\n const path = generatePath(`:namespace/:kind/:name`, routeParams);\n const baseUrl = await this.discoveryApi.getBaseUrl('badges');\n const obfuscatedEntityUrl = `${baseUrl}/entity/${path}/obfuscated`;\n\n return obfuscatedEntityUrl;\n }\n\n private async getEntityUuid(entityUuidUrl: string): Promise<any> {\n const responseEntityUuid = await this.fetchApi.fetch(entityUuidUrl);\n\n if (!responseEntityUuid.ok) {\n throw await ResponseError.fromResponse(responseEntityUuid);\n }\n return await responseEntityUuid.json();\n }\n\n private async getEntityUuidBadgeSpecsUrl(entityUuid: {\n uuid: string;\n }): Promise<string> {\n const baseUrl = await this.discoveryApi.getBaseUrl('badges');\n return `${baseUrl}/entity/${entityUuid}/badge-specs`;\n }\n\n private async getEntityBadgeSpecsUrl(\n entity: Entity,\n badgeOptions: BadgeStyleOptions,\n ): Promise<string> {\n const routeParams = this.getEntityRouteParams(entity);\n const path = generatePath(`:namespace/:kind/:name`, routeParams);\n const baseUrl = await this.discoveryApi.getBaseUrl('badges');\n const queries: string[] = [];\n if (badgeOptions.style) {\n queries.push(`style=${badgeOptions.style}`);\n }\n if (badgeOptions.color) {\n queries.push(`color=${badgeOptions.color}`);\n }\n return `${baseUrl}/entity/${path}/badge-specs?${queries.join('&')}`;\n }\n\n // This function is used to generate the route parameters using the entity kind, namespace and name\n private getEntityRouteParams(entity: Entity) {\n return {\n kind: entity.kind.toLocaleLowerCase('en-US'),\n namespace:\n entity.metadata.namespace?.toLocaleLowerCase('en-US') ??\n DEFAULT_NAMESPACE,\n name: entity.metadata.name,\n };\n }\n}\n"],"names":["response"],"mappings":";;;;AAsBO,MAAM,YAAkC,CAAA;AAAA,EAC5B,YAAA
|
|
1
|
+
{"version":3,"file":"BadgesClient.esm.js","sources":["../../src/api/BadgesClient.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 { generatePath } from 'react-router-dom';\nimport { ResponseError } from '@backstage/errors';\nimport { Entity, DEFAULT_NAMESPACE } from '@backstage/catalog-model';\nimport { BadgesApi, BadgeSpec, BadgeStyleOptions } from './types';\nimport { ConfigApi, DiscoveryApi, FetchApi } from '@backstage/core-plugin-api';\n\nexport class BadgesClient implements BadgesApi {\n private readonly discoveryApi: DiscoveryApi;\n private readonly fetchApi: FetchApi;\n private readonly configApi: ConfigApi;\n\n constructor(options: {\n discoveryApi: DiscoveryApi;\n fetchApi: FetchApi;\n configApi: ConfigApi;\n }) {\n this.discoveryApi = options.discoveryApi;\n this.fetchApi = options.fetchApi;\n this.configApi = options.configApi;\n }\n\n static fromConfig(options: {\n fetchApi: FetchApi;\n discoveryApi: DiscoveryApi;\n configApi: ConfigApi;\n }) {\n return new BadgesClient(options);\n }\n\n public async getEntityBadgeSpecs(\n entity: Entity,\n badgeOptions: BadgeStyleOptions,\n ): Promise<BadgeSpec[]> {\n // Check if obfuscation is enabled in the configuration\n const obfuscate = this.configApi.getOptionalBoolean('app.badges.obfuscate');\n\n if (obfuscate) {\n const entityUuidUrl = await this.getEntityUuidUrl(entity);\n const entityUuid = await this.getEntityUuid(entityUuidUrl).then(data => {\n return data.uuid;\n });\n const entityUuidBadgeSpecsUrl = await this.getEntityUuidBadgeSpecsUrl(\n entityUuid,\n );\n\n const response = await this.fetchApi.fetch(entityUuidBadgeSpecsUrl);\n if (!response.ok) {\n throw await ResponseError.fromResponse(response);\n }\n\n return await response.json();\n }\n\n // If obfuscation is disabled, get the badge specs directly as the previous implementation\n const entityBadgeSpecsUrl = await this.getEntityBadgeSpecsUrl(\n entity,\n badgeOptions,\n );\n const response = await this.fetchApi.fetch(entityBadgeSpecsUrl);\n if (!response.ok) {\n throw await ResponseError.fromResponse(response);\n }\n\n return await response.json();\n }\n\n private async getEntityUuidUrl(entity: Entity): Promise<string> {\n const routeParams = this.getEntityRouteParams(entity);\n const path = generatePath(`:namespace/:kind/:name`, routeParams);\n const baseUrl = await this.discoveryApi.getBaseUrl('badges');\n const obfuscatedEntityUrl = `${baseUrl}/entity/${path}/obfuscated`;\n\n return obfuscatedEntityUrl;\n }\n\n private async getEntityUuid(entityUuidUrl: string): Promise<any> {\n const responseEntityUuid = await this.fetchApi.fetch(entityUuidUrl);\n\n if (!responseEntityUuid.ok) {\n throw await ResponseError.fromResponse(responseEntityUuid);\n }\n return await responseEntityUuid.json();\n }\n\n private async getEntityUuidBadgeSpecsUrl(entityUuid: {\n uuid: string;\n }): Promise<string> {\n const baseUrl = await this.discoveryApi.getBaseUrl('badges');\n return `${baseUrl}/entity/${entityUuid}/badge-specs`;\n }\n\n private async getEntityBadgeSpecsUrl(\n entity: Entity,\n badgeOptions: BadgeStyleOptions,\n ): Promise<string> {\n const routeParams = this.getEntityRouteParams(entity);\n const path = generatePath(`:namespace/:kind/:name`, routeParams);\n const baseUrl = await this.discoveryApi.getBaseUrl('badges');\n const queries: string[] = [];\n if (badgeOptions.style) {\n queries.push(`style=${badgeOptions.style}`);\n }\n if (badgeOptions.color) {\n queries.push(`color=${badgeOptions.color}`);\n }\n return `${baseUrl}/entity/${path}/badge-specs?${queries.join('&')}`;\n }\n\n // This function is used to generate the route parameters using the entity kind, namespace and name\n private getEntityRouteParams(entity: Entity) {\n return {\n kind: entity.kind.toLocaleLowerCase('en-US'),\n namespace:\n entity.metadata.namespace?.toLocaleLowerCase('en-US') ??\n DEFAULT_NAMESPACE,\n name: entity.metadata.name,\n };\n }\n}\n"],"names":["response"],"mappings":";;;;AAsBO,MAAM,YAAkC,CAAA;AAAA,EAC5B,YAAA;AAAA,EACA,QAAA;AAAA,EACA,SAAA;AAAA,EAEjB,YAAY,OAIT,EAAA;AACD,IAAA,IAAA,CAAK,eAAe,OAAQ,CAAA,YAAA;AAC5B,IAAA,IAAA,CAAK,WAAW,OAAQ,CAAA,QAAA;AACxB,IAAA,IAAA,CAAK,YAAY,OAAQ,CAAA,SAAA;AAAA;AAC3B,EAEA,OAAO,WAAW,OAIf,EAAA;AACD,IAAO,OAAA,IAAI,aAAa,OAAO,CAAA;AAAA;AACjC,EAEA,MAAa,mBACX,CAAA,MAAA,EACA,YACsB,EAAA;AAEtB,IAAA,MAAM,SAAY,GAAA,IAAA,CAAK,SAAU,CAAA,kBAAA,CAAmB,sBAAsB,CAAA;AAE1E,IAAA,IAAI,SAAW,EAAA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CAAA;AAAA;AACnE;AAAA,EAGQ,qBAAqB,MAAgB,EAAA;AAC3C,IAAO,OAAA;AAAA,MACL,IAAM,EAAA,MAAA,CAAO,IAAK,CAAA,iBAAA,CAAkB,OAAO,CAAA;AAAA,MAC3C,WACE,MAAO,CAAA,QAAA,CAAS,SAAW,EAAA,iBAAA,CAAkB,OAAO,CACpD,IAAA,iBAAA;AAAA,MACF,IAAA,EAAM,OAAO,QAAS,CAAA;AAAA,KACxB;AAAA;AAEJ;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.esm.js","sources":["../../src/api/types.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 { Entity } from '@backstage/catalog-model';\nimport { createApiRef } from '@backstage/core-plugin-api';\n\nexport const badgesApiRef = createApiRef<BadgesApi>({\n id: 'plugin.badges.client',\n});\n\nexport const BADGE_STYLES = [\n 'plastic',\n 'flat',\n 'flat-square',\n 'for-the-badge',\n 'social',\n] as const;\n\nexport type BadgeStyle = (typeof BADGE_STYLES)[number];\n\ninterface Badge {\n color?: string;\n description?: string;\n kind?: 'entity';\n label: string;\n labelColor?: string;\n link?: string;\n message: string;\n style?: BadgeStyle;\n}\n\nexport interface BadgeSpec {\n /** Badge id */\n id: string;\n\n /** Badge data */\n badge: Badge;\n\n /** The URL to the badge image */\n url: string;\n\n /** The markdown code to use the badge */\n markdown: string;\n}\n\nexport interface BadgeStyleOptions {\n style?: BadgeStyle;\n color?: string;\n}\n\nexport interface BadgesApi {\n getEntityBadgeSpecs(\n entity: Entity,\n bsOptions?: BadgeStyleOptions,\n ): Promise<BadgeSpec[]>;\n}\n"],"names":[],"mappings":";;AAmBO,MAAM,eAAe,YAAwB,CAAA;AAAA,EAClD,EAAI,EAAA
|
|
1
|
+
{"version":3,"file":"types.esm.js","sources":["../../src/api/types.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 { Entity } from '@backstage/catalog-model';\nimport { createApiRef } from '@backstage/core-plugin-api';\n\nexport const badgesApiRef = createApiRef<BadgesApi>({\n id: 'plugin.badges.client',\n});\n\nexport const BADGE_STYLES = [\n 'plastic',\n 'flat',\n 'flat-square',\n 'for-the-badge',\n 'social',\n] as const;\n\nexport type BadgeStyle = (typeof BADGE_STYLES)[number];\n\ninterface Badge {\n color?: string;\n description?: string;\n kind?: 'entity';\n label: string;\n labelColor?: string;\n link?: string;\n message: string;\n style?: BadgeStyle;\n}\n\nexport interface BadgeSpec {\n /** Badge id */\n id: string;\n\n /** Badge data */\n badge: Badge;\n\n /** The URL to the badge image */\n url: string;\n\n /** The markdown code to use the badge */\n markdown: string;\n}\n\nexport interface BadgeStyleOptions {\n style?: BadgeStyle;\n color?: string;\n}\n\nexport interface BadgesApi {\n getEntityBadgeSpecs(\n entity: Entity,\n bsOptions?: BadgeStyleOptions,\n ): Promise<BadgeSpec[]>;\n}\n"],"names":[],"mappings":";;AAmBO,MAAM,eAAe,YAAwB,CAAA;AAAA,EAClD,EAAI,EAAA;AACN,CAAC;AAEM,MAAM,YAAe,GAAA;AAAA,EAC1B,SAAA;AAAA,EACA,MAAA;AAAA,EACA,aAAA;AAAA,EACA,eAAA;AAAA,EACA;AACF;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EntityBadgesDialog.esm.js","sources":["../../src/components/EntityBadgesDialog.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 { useAsyncEntity } from '@backstage/plugin-catalog-react';\nimport Box from '@material-ui/core/Box';\nimport Button from '@material-ui/core/Button';\nimport Dialog from '@material-ui/core/Dialog';\nimport DialogActions from '@material-ui/core/DialogActions';\nimport DialogContent from '@material-ui/core/DialogContent';\nimport DialogContentText from '@material-ui/core/DialogContentText';\nimport DialogTitle from '@material-ui/core/DialogTitle';\nimport useMediaQuery from '@material-ui/core/useMediaQuery';\nimport InputLabel from '@material-ui/core/InputLabel';\nimport MenuItem from '@material-ui/core/MenuItem';\nimport FormControl from '@material-ui/core/FormControl';\nimport Select from '@material-ui/core/Select';\nimport Typography from '@material-ui/core/Typography';\nimport { useTheme } from '@material-ui/core/styles';\nimport React, { useState } from 'react';\nimport useAsync from 'react-use/esm/useAsync';\nimport { BadgeStyle, BADGE_STYLES, badgesApiRef } from '../api';\n\nimport {\n CodeSnippet,\n Progress,\n ResponseErrorPanel,\n} from '@backstage/core-components';\nimport { useApi } from '@backstage/core-plugin-api';\n\nexport const EntityBadgesDialog = (props: {\n open: boolean;\n onClose?: () => any;\n}) => {\n const { open, onClose } = props;\n const theme = useTheme();\n const { entity } = useAsyncEntity();\n const fullScreen = useMediaQuery(theme.breakpoints.down('sm'));\n const badgesApi = useApi(badgesApiRef);\n\n const [style, setStyle] = useState<BadgeStyle>();\n\n const {\n value: badges,\n loading,\n error,\n } = useAsync(async () => {\n if (open && entity) {\n return await badgesApi.getEntityBadgeSpecs(entity, { style });\n }\n return [];\n }, [badgesApi, entity, open, style]);\n\n return (\n <Dialog fullScreen={fullScreen} open={open} onClose={onClose}>\n <DialogTitle>Entity Badges</DialogTitle>\n <DialogContent>\n <DialogContentText>\n Embed badges in other web sites that link back to this entity. Copy\n the relevant snippet of Markdown code to use the badge.\n </DialogContentText>\n\n <Typography variant=\"subtitle1\">Select Badge Style</Typography>\n <FormControl\n variant=\"standard\"\n style={{ width: '100%', marginBottom: '16px' }}\n >\n <InputLabel id=\"badge-style-label\">Style</InputLabel>\n <Select\n labelId=\"badge-style-label\"\n id=\"badge-style\"\n value={style}\n label=\"Style\"\n onChange={e => setStyle(e.target.value as BadgeStyle)}\n >\n <MenuItem value={undefined}>\n <em>Default</em>\n </MenuItem>\n {BADGE_STYLES.map(s => (\n <MenuItem key={s} value={s}>\n {s}\n </MenuItem>\n ))}\n </Select>\n </FormControl>\n\n {loading && <Progress />}\n {error && <ResponseErrorPanel error={error} />}\n\n {badges && (\n <>\n <Typography variant=\"subtitle1\">Badge Previews</Typography>\n {badges.map(({ badge: { description }, id, url, markdown }) => (\n <Box marginTop={2} marginBottom={2} key={id}>\n <DialogContentText component=\"div\">\n <img alt={description || id} src={url} />\n <CodeSnippet\n language=\"markdown\"\n text={markdown}\n showCopyCodeButton\n />\n </DialogContentText>\n </Box>\n ))}\n </>\n )}\n </DialogContent>\n\n <DialogActions>\n <Button onClick={onClose} color=\"primary\">\n Close\n </Button>\n </DialogActions>\n </Dialog>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AA0Ca,MAAA,kBAAA,GAAqB,CAAC,KAG7B,KAAA;AACJ,EAAM,MAAA,EAAE,IAAM,EAAA,OAAA,EAAY,GAAA,KAAA
|
|
1
|
+
{"version":3,"file":"EntityBadgesDialog.esm.js","sources":["../../src/components/EntityBadgesDialog.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 { useAsyncEntity } from '@backstage/plugin-catalog-react';\nimport Box from '@material-ui/core/Box';\nimport Button from '@material-ui/core/Button';\nimport Dialog from '@material-ui/core/Dialog';\nimport DialogActions from '@material-ui/core/DialogActions';\nimport DialogContent from '@material-ui/core/DialogContent';\nimport DialogContentText from '@material-ui/core/DialogContentText';\nimport DialogTitle from '@material-ui/core/DialogTitle';\nimport useMediaQuery from '@material-ui/core/useMediaQuery';\nimport InputLabel from '@material-ui/core/InputLabel';\nimport MenuItem from '@material-ui/core/MenuItem';\nimport FormControl from '@material-ui/core/FormControl';\nimport Select from '@material-ui/core/Select';\nimport Typography from '@material-ui/core/Typography';\nimport { useTheme } from '@material-ui/core/styles';\nimport React, { useState } from 'react';\nimport useAsync from 'react-use/esm/useAsync';\nimport { BadgeStyle, BADGE_STYLES, badgesApiRef } from '../api';\n\nimport {\n CodeSnippet,\n Progress,\n ResponseErrorPanel,\n} from '@backstage/core-components';\nimport { useApi } from '@backstage/core-plugin-api';\n\nexport const EntityBadgesDialog = (props: {\n open: boolean;\n onClose?: () => any;\n}) => {\n const { open, onClose } = props;\n const theme = useTheme();\n const { entity } = useAsyncEntity();\n const fullScreen = useMediaQuery(theme.breakpoints.down('sm'));\n const badgesApi = useApi(badgesApiRef);\n\n const [style, setStyle] = useState<BadgeStyle>();\n\n const {\n value: badges,\n loading,\n error,\n } = useAsync(async () => {\n if (open && entity) {\n return await badgesApi.getEntityBadgeSpecs(entity, { style });\n }\n return [];\n }, [badgesApi, entity, open, style]);\n\n return (\n <Dialog fullScreen={fullScreen} open={open} onClose={onClose}>\n <DialogTitle>Entity Badges</DialogTitle>\n <DialogContent>\n <DialogContentText>\n Embed badges in other web sites that link back to this entity. Copy\n the relevant snippet of Markdown code to use the badge.\n </DialogContentText>\n\n <Typography variant=\"subtitle1\">Select Badge Style</Typography>\n <FormControl\n variant=\"standard\"\n style={{ width: '100%', marginBottom: '16px' }}\n >\n <InputLabel id=\"badge-style-label\">Style</InputLabel>\n <Select\n labelId=\"badge-style-label\"\n id=\"badge-style\"\n value={style}\n label=\"Style\"\n onChange={e => setStyle(e.target.value as BadgeStyle)}\n >\n <MenuItem value={undefined}>\n <em>Default</em>\n </MenuItem>\n {BADGE_STYLES.map(s => (\n <MenuItem key={s} value={s}>\n {s}\n </MenuItem>\n ))}\n </Select>\n </FormControl>\n\n {loading && <Progress />}\n {error && <ResponseErrorPanel error={error} />}\n\n {badges && (\n <>\n <Typography variant=\"subtitle1\">Badge Previews</Typography>\n {badges.map(({ badge: { description }, id, url, markdown }) => (\n <Box marginTop={2} marginBottom={2} key={id}>\n <DialogContentText component=\"div\">\n <img alt={description || id} src={url} />\n <CodeSnippet\n language=\"markdown\"\n text={markdown}\n showCopyCodeButton\n />\n </DialogContentText>\n </Box>\n ))}\n </>\n )}\n </DialogContent>\n\n <DialogActions>\n <Button onClick={onClose} color=\"primary\">\n Close\n </Button>\n </DialogActions>\n </Dialog>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AA0Ca,MAAA,kBAAA,GAAqB,CAAC,KAG7B,KAAA;AACJ,EAAM,MAAA,EAAE,IAAM,EAAA,OAAA,EAAY,GAAA,KAAA;AAC1B,EAAA,MAAM,QAAQ,QAAS,EAAA;AACvB,EAAM,MAAA,EAAE,MAAO,EAAA,GAAI,cAAe,EAAA;AAClC,EAAA,MAAM,aAAa,aAAc,CAAA,KAAA,CAAM,WAAY,CAAA,IAAA,CAAK,IAAI,CAAC,CAAA;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A,EAAA,EAAO,SAAS,OAAS,EAAA,KAAA,EAAM,SAAU,EAAA,EAAA,OAE1C,CACF,CACF,CAAA;AAEJ;;;;"}
|
package/dist/plugin.esm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.esm.js","sources":["../src/plugin.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 */\nimport { badgesApiRef, BadgesClient } from './api';\nimport {\n configApiRef,\n createApiFactory,\n createComponentExtension,\n createPlugin,\n fetchApiRef,\n discoveryApiRef,\n} from '@backstage/core-plugin-api';\n\n/** @public */\nexport const badgesPlugin = createPlugin({\n id: 'badges',\n apis: [\n createApiFactory({\n api: badgesApiRef,\n deps: {\n fetchApi: fetchApiRef,\n discoveryApi: discoveryApiRef,\n configApi: configApiRef,\n },\n factory: ({ fetchApi, discoveryApi, configApi }) =>\n new BadgesClient({\n fetchApi,\n discoveryApi,\n configApi,\n }),\n }),\n ],\n});\n\n/** @public */\nexport const EntityBadgesDialog = badgesPlugin.provide(\n createComponentExtension({\n name: 'EntityBadgesDialog',\n component: {\n lazy: () =>\n import('./components/EntityBadgesDialog').then(\n m => m.EntityBadgesDialog,\n ),\n },\n }),\n);\n"],"names":[],"mappings":";;;;AA0BO,MAAM,eAAe,YAAa,CAAA;AAAA,EACvC,EAAI,EAAA,QAAA;AAAA,EACJ,IAAM,EAAA;AAAA,IACJ,gBAAiB,CAAA;AAAA,MACf,GAAK,EAAA,YAAA;AAAA,MACL,IAAM,EAAA;AAAA,QACJ,QAAU,EAAA,WAAA;AAAA,QACV,YAAc,EAAA,eAAA;AAAA,QACd,SAAW,EAAA
|
|
1
|
+
{"version":3,"file":"plugin.esm.js","sources":["../src/plugin.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 */\nimport { badgesApiRef, BadgesClient } from './api';\nimport {\n configApiRef,\n createApiFactory,\n createComponentExtension,\n createPlugin,\n fetchApiRef,\n discoveryApiRef,\n} from '@backstage/core-plugin-api';\n\n/** @public */\nexport const badgesPlugin = createPlugin({\n id: 'badges',\n apis: [\n createApiFactory({\n api: badgesApiRef,\n deps: {\n fetchApi: fetchApiRef,\n discoveryApi: discoveryApiRef,\n configApi: configApiRef,\n },\n factory: ({ fetchApi, discoveryApi, configApi }) =>\n new BadgesClient({\n fetchApi,\n discoveryApi,\n configApi,\n }),\n }),\n ],\n});\n\n/** @public */\nexport const EntityBadgesDialog = badgesPlugin.provide(\n createComponentExtension({\n name: 'EntityBadgesDialog',\n component: {\n lazy: () =>\n import('./components/EntityBadgesDialog').then(\n m => m.EntityBadgesDialog,\n ),\n },\n }),\n);\n"],"names":[],"mappings":";;;;AA0BO,MAAM,eAAe,YAAa,CAAA;AAAA,EACvC,EAAI,EAAA,QAAA;AAAA,EACJ,IAAM,EAAA;AAAA,IACJ,gBAAiB,CAAA;AAAA,MACf,GAAK,EAAA,YAAA;AAAA,MACL,IAAM,EAAA;AAAA,QACJ,QAAU,EAAA,WAAA;AAAA,QACV,YAAc,EAAA,eAAA;AAAA,QACd,SAAW,EAAA;AAAA,OACb;AAAA,MACA,OAAA,EAAS,CAAC,EAAE,QAAA,EAAU,cAAc,SAAU,EAAA,KAC5C,IAAI,YAAa,CAAA;AAAA,QACf,QAAA;AAAA,QACA,YAAA;AAAA,QACA;AAAA,OACD;AAAA,KACJ;AAAA;AAEL,CAAC;AAGM,MAAM,qBAAqB,YAAa,CAAA,OAAA;AAAA,EAC7C,wBAAyB,CAAA;AAAA,IACvB,IAAM,EAAA,oBAAA;AAAA,IACN,SAAW,EAAA;AAAA,MACT,IAAM,EAAA,MACJ,OAAO,wCAAiC,CAAE,CAAA,IAAA;AAAA,QACxC,OAAK,CAAE,CAAA;AAAA;AACT;AACJ,GACD;AACH;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backstage-community/plugin-badges",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "A Backstage plugin that generates README badges for your entities",
|
|
5
5
|
"backstage": {
|
|
6
6
|
"role": "frontend-plugin",
|
|
@@ -38,19 +38,19 @@
|
|
|
38
38
|
"test": "backstage-cli package test"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@backstage/catalog-model": "^1.7.
|
|
42
|
-
"@backstage/core-components": "^0.
|
|
43
|
-
"@backstage/core-plugin-api": "^1.10.
|
|
44
|
-
"@backstage/errors": "^1.2.
|
|
45
|
-
"@backstage/plugin-catalog-react": "^1.
|
|
41
|
+
"@backstage/catalog-model": "^1.7.3",
|
|
42
|
+
"@backstage/core-components": "^0.16.3",
|
|
43
|
+
"@backstage/core-plugin-api": "^1.10.3",
|
|
44
|
+
"@backstage/errors": "^1.2.7",
|
|
45
|
+
"@backstage/plugin-catalog-react": "^1.15.1",
|
|
46
46
|
"@material-ui/core": "^4.12.2",
|
|
47
47
|
"@types/react": "^16.13.1 || ^17.0.0 || ^18.0.0",
|
|
48
48
|
"react-use": "^17.2.4"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
|
-
"@backstage/cli": "^0.
|
|
52
|
-
"@backstage/dev-utils": "^1.1.
|
|
53
|
-
"@backstage/test-utils": "^1.7.
|
|
51
|
+
"@backstage/cli": "^0.29.6",
|
|
52
|
+
"@backstage/dev-utils": "^1.1.6",
|
|
53
|
+
"@backstage/test-utils": "^1.7.4",
|
|
54
54
|
"@testing-library/dom": "^10.0.0",
|
|
55
55
|
"@testing-library/jest-dom": "^6.0.0",
|
|
56
56
|
"@testing-library/react": "^15.0.0",
|
|
@@ -65,5 +65,12 @@
|
|
|
65
65
|
"react-dom": "^16.13.1 || ^17.0.0 || ^18.0.0",
|
|
66
66
|
"react-router-dom": "6.0.0-beta.0 || ^6.3.0"
|
|
67
67
|
},
|
|
68
|
+
"typesVersions": {
|
|
69
|
+
"*": {
|
|
70
|
+
"index": [
|
|
71
|
+
"dist/index.d.ts"
|
|
72
|
+
]
|
|
73
|
+
}
|
|
74
|
+
},
|
|
68
75
|
"module": "./dist/index.esm.js"
|
|
69
76
|
}
|