File tree Expand file tree Collapse file tree 3 files changed +16
-3
lines changed
backstage-plugin-devcontainers-backend/src
backstage-plugin-devcontainers-react/src/hooks Expand file tree Collapse file tree 3 files changed +16
-3
lines changed Original file line number Diff line number Diff line change 11export * from './service/router' ;
2- export { DevcontainersProcessor } from './processors/DevcontainersProcessor' ;
2+ export { DevcontainersProcessor , type VsCodeUrlKey } from './processors/DevcontainersProcessor' ;
Original file line number Diff line number Diff line change @@ -14,6 +14,13 @@ import { parseGitUrl } from '../utils/git';
1414export const DEFAULT_TAG_NAME = 'devcontainers' ;
1515export const PROCESSOR_NAME_PREFIX = 'backstage-plugin-devcontainers-backend' ;
1616
17+ const vsCodeUrlKey = "vsCodeUrl"
18+
19+ // We export this type instead of the actual constant so we can validate the
20+ // constant on the frontend at compile-time instead of making the backend plugin
21+ // a run-time dependency, so it can continue to run standalone.
22+ export type VsCodeUrlKey = typeof vsCodeUrlKey
23+
1724type ProcessorOptions = Readonly < {
1825 tagName : string ;
1926 logger : Logger ;
@@ -138,7 +145,7 @@ export class DevcontainersProcessor implements CatalogProcessor {
138145 ...entity . metadata ,
139146 annotations : {
140147 ...( entity . metadata . annotations ?? { } ) ,
141- vsCodeUrl : serializeVsCodeUrl ( location . target ) ,
148+ [ vsCodeUrlKey ] : serializeVsCodeUrl ( location . target ) ,
142149 } ,
143150 tags : [ ...( entity . metadata ?. tags ?? [ ] ) , newTag ] ,
144151 } ,
Original file line number Diff line number Diff line change 11import { useDevcontainersConfig } from '../components/DevcontainersProvider' ;
22import { useEntity } from '@backstage/plugin-catalog-react' ;
3+ import type { VsCodeUrlKey } from "@coder/backstage-plugin-devcontainers-backend" ;
4+
5+ // We avoid importing the actual constant to prevent making the backend plugin a
6+ // run-time dependency, but we can use the type at compile-time to validate the
7+ // string is the same.
8+ const vsCodeUrlKey : VsCodeUrlKey = "vsCodeUrl" ;
39
410export type UseDevcontainersResult = Readonly <
511 {
@@ -37,7 +43,7 @@ export function useDevcontainers(): UseDevcontainersResult {
3743 } ;
3844 }
3945
40- const vsCodeUrl = entity . metadata . annotations ?. vsCodeUrl ;
46+ const vsCodeUrl = entity . metadata . annotations ?. [ vsCodeUrlKey ] ;
4147 if ( ! vsCodeUrl ) {
4248 return {
4349 tagName,
You can’t perform that action at this time.
0 commit comments