-
Notifications
You must be signed in to change notification settings - Fork 226
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(github-deployments): add support for new frontend system
Adding github-deployments support for the new frontend system. Signed-off-by: Craig Tracey <[email protected]>
- Loading branch information
1 parent
b470529
commit b0a99bf
Showing
11 changed files
with
341 additions
and
3 deletions.
There are no files selected for viewing
5 changes: 5 additions & 0 deletions
5
workspaces/github-deployments/.changeset/shiny-seals-greet.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@backstage-community/plugin-github-deployments': patch | ||
--- | ||
|
||
Adding support for the new frontend system, available at the `/alpha` export. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
workspaces/github-deployments/plugins/github-deployments/report-alpha.api.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
## API Report File for "@backstage-community/plugin-github-deployments" | ||
|
||
> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). | ||
```ts | ||
/// <reference types="react" /> | ||
|
||
import { AnyApiFactory } from '@backstage/core-plugin-api'; | ||
import { ConfigurableExtensionDataRef } from '@backstage/frontend-plugin-api'; | ||
import { Entity } from '@backstage/catalog-model'; | ||
import { ExtensionDefinition } from '@backstage/frontend-plugin-api'; | ||
import { FrontendPlugin } from '@backstage/frontend-plugin-api'; | ||
import { JSX as JSX_2 } from 'react'; | ||
import { RouteRef } from '@backstage/frontend-plugin-api'; | ||
|
||
// @alpha (undocumented) | ||
const _default: FrontendPlugin< | ||
{ | ||
entityContent: RouteRef<undefined>; | ||
}, | ||
{}, | ||
{ | ||
'entity-card:github-deployments/overview': ExtensionDefinition<{ | ||
kind: 'entity-card'; | ||
name: 'overview'; | ||
config: { | ||
filter: string | undefined; | ||
}; | ||
configInput: { | ||
filter?: string | undefined; | ||
}; | ||
output: | ||
| ConfigurableExtensionDataRef<JSX_2.Element, 'core.reactElement', {}> | ||
| ConfigurableExtensionDataRef< | ||
(entity: Entity) => boolean, | ||
'catalog.entity-filter-function', | ||
{ | ||
optional: true; | ||
} | ||
> | ||
| ConfigurableExtensionDataRef< | ||
string, | ||
'catalog.entity-filter-expression', | ||
{ | ||
optional: true; | ||
} | ||
>; | ||
inputs: {}; | ||
params: { | ||
loader: () => Promise<JSX.Element>; | ||
filter?: string | ((entity: Entity) => boolean) | undefined; | ||
}; | ||
}>; | ||
'api:github-deployments': ExtensionDefinition<{ | ||
kind: 'api'; | ||
name: undefined; | ||
config: {}; | ||
configInput: {}; | ||
output: ConfigurableExtensionDataRef< | ||
AnyApiFactory, | ||
'core.api.factory', | ||
{} | ||
>; | ||
inputs: {}; | ||
params: { | ||
factory: AnyApiFactory; | ||
}; | ||
}>; | ||
} | ||
>; | ||
export default _default; | ||
|
||
// (No @packageDocumentation comment for this package) | ||
``` |
33 changes: 33 additions & 0 deletions
33
workspaces/github-deployments/plugins/github-deployments/src/alpha.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
* Copyright 2024 The Backstage Authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import { convertLegacyRouteRefs } from '@backstage/core-compat-api'; | ||
import { createFrontendPlugin } from '@backstage/frontend-plugin-api'; | ||
import { | ||
entityGithubDeploymentsCard, | ||
githubDeploymentsApiExtension, | ||
} from './alpha/index'; | ||
import { rootRouteRef } from './routes'; | ||
|
||
/** | ||
* @alpha | ||
*/ | ||
export default createFrontendPlugin({ | ||
id: 'github-deployments', | ||
routes: convertLegacyRouteRefs({ | ||
entityContent: rootRouteRef, | ||
}), | ||
extensions: [entityGithubDeploymentsCard, githubDeploymentsApiExtension], | ||
}); |
39 changes: 39 additions & 0 deletions
39
workspaces/github-deployments/plugins/github-deployments/src/alpha/apis.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
* Copyright 2024 The Backstage Authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import { scmIntegrationsApiRef } from '@backstage/integration-react'; | ||
import { | ||
ApiBlueprint, | ||
createApiFactory, | ||
githubAuthApiRef, | ||
} from '@backstage/frontend-plugin-api'; | ||
import { githubDeploymentsApiRef, GithubDeploymentsApiClient } from '../api'; | ||
|
||
/** | ||
* @alpha | ||
*/ | ||
export const githubDeploymentsApiExtension = ApiBlueprint.make({ | ||
params: { | ||
factory: createApiFactory({ | ||
api: githubDeploymentsApiRef, | ||
deps: { | ||
scmIntegrationsApi: scmIntegrationsApiRef, | ||
githubAuthApi: githubAuthApiRef, | ||
}, | ||
factory: ({ scmIntegrationsApi, githubAuthApi }) => | ||
new GithubDeploymentsApiClient({ scmIntegrationsApi, githubAuthApi }), | ||
}), | ||
}, | ||
}); |
72 changes: 72 additions & 0 deletions
72
workspaces/github-deployments/plugins/github-deployments/src/alpha/entityCards.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/* | ||
* Copyright 2024 The Backstage Authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import { screen, waitFor } from '@testing-library/react'; | ||
import { | ||
createExtensionTester, | ||
renderInTestApp, | ||
TestApiProvider, | ||
} from '@backstage/frontend-test-utils'; | ||
import * as cards from './entityCards'; | ||
import { EntityProvider } from '@backstage/plugin-catalog-react'; | ||
import { Entity } from '@backstage/catalog-model'; | ||
import React from 'react'; | ||
import { | ||
GithubDeployment, | ||
GithubDeploymentsApi, | ||
githubDeploymentsApiRef, | ||
} from '../api'; | ||
|
||
const entityComponent = { | ||
metadata: { | ||
annotations: { | ||
'github.com/project-slug': 'backstage/backstage', | ||
'backstage.io/source-location': | ||
'url:https://github.com/backstage/backstage', | ||
}, | ||
name: 'backstage', | ||
}, | ||
apiVersion: 'backstage.io/v1alpha1', | ||
kind: 'Component', | ||
} as unknown as Entity; | ||
|
||
const mockGithubDeployementsApi = { | ||
listDeployments: async (): Promise<GithubDeployment[]> => { | ||
return [] as GithubDeployment[]; | ||
}, | ||
} as GithubDeploymentsApi; | ||
|
||
const apis = [[githubDeploymentsApiRef, mockGithubDeployementsApi]] as const; | ||
|
||
describe('Entity card extensions', () => { | ||
it('should render', async () => { | ||
renderInTestApp( | ||
<TestApiProvider apis={apis}> | ||
<EntityProvider entity={entityComponent}> | ||
{createExtensionTester( | ||
cards.entityGithubDeploymentsCard, | ||
).reactElement()} | ||
</EntityProvider> | ||
</TestApiProvider>, | ||
); | ||
|
||
await waitFor( | ||
() => { | ||
expect(screen.getByText('GitHub Deployments')).toBeInTheDocument(); | ||
}, | ||
{ timeout: 5000 }, | ||
); | ||
}); | ||
}); |
31 changes: 31 additions & 0 deletions
31
workspaces/github-deployments/plugins/github-deployments/src/alpha/entityCards.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
* Copyright 2024 The Backstage Authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import React from 'react'; | ||
import { EntityCardBlueprint } from '@backstage/plugin-catalog-react/alpha'; | ||
|
||
/** | ||
* @alpha | ||
*/ | ||
export const entityGithubDeploymentsCard = EntityCardBlueprint.make({ | ||
name: 'overview', | ||
params: { | ||
filter: 'kind:component', | ||
loader: () => | ||
import('../components/GithubDeploymentsCard').then(m => ( | ||
<m.GithubDeploymentsCard /> | ||
)), | ||
}, | ||
}); |
17 changes: 17 additions & 0 deletions
17
workspaces/github-deployments/plugins/github-deployments/src/alpha/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/* | ||
* Copyright 2024 The Backstage Authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
export * from './apis'; | ||
export * from './entityCards'; |
20 changes: 20 additions & 0 deletions
20
workspaces/github-deployments/plugins/github-deployments/src/routes.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/* | ||
* Copyright 2022 The Backstage Authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import { createRouteRef } from '@backstage/core-plugin-api'; | ||
|
||
export const rootRouteRef = createRouteRef({ | ||
id: 'github-deployments', | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters