Skip to content

Commit

Permalink
feat: new frontend system
Browse files Browse the repository at this point in the history
  • Loading branch information
antoniomuso committed Sep 18, 2024
1 parent 9f35ba5 commit 12f35d2
Show file tree
Hide file tree
Showing 8 changed files with 923 additions and 615 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"packages/*"
],
"devDependencies": {
"@backstage/cli": "^0.26.11",
"@backstage/cli": "^0.27.1",
"@commitlint/cli": "^17.1.2",
"@commitlint/config-conventional": "^17.1.0",
"@typescript-eslint/eslint-plugin": "^5.36.0",
Expand Down
16 changes: 8 additions & 8 deletions packages/gitlab-backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@
"postpack": "backstage-cli package postpack"
},
"dependencies": {
"@backstage/backend-common": "^0.23.3",
"@backstage/backend-plugin-api": "^0.7.0",
"@backstage/backend-common": "^0.25.0",
"@backstage/backend-plugin-api": "^1.0.0",
"@backstage/config": "^1.2.0",
"@backstage/integration": "^1.13.0",
"@backstage/integration": "^1.15.0",
"body-parser": "^1.20.2",
"express": "^4.17.3",
"express-promise-router": "^4.1.0",
Expand All @@ -53,11 +53,11 @@
"yn": "^4.0.0"
},
"devDependencies": {
"@backstage/backend-test-utils": "^0.4.4",
"@backstage/catalog-model": "^1.5.0",
"@backstage/cli": "^0.26.11",
"@backstage/plugin-catalog-common": "^1.0.25",
"@backstage/plugin-catalog-node": "^1.12.4",
"@backstage/backend-test-utils": "^1.0.0",
"@backstage/catalog-model": "^1.7.0",
"@backstage/cli": "^0.27.1",
"@backstage/plugin-catalog-common": "^1.1.0",
"@backstage/plugin-catalog-node": "^1.13.0",
"@types/express": "^4.17.21",
"@types/supertest": "^2.0.12",
"msw": "^1.0.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/gitlab-backend/src/plugin.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ describe('gitlabPlugin', () => {

const { server } = await startTestBackend({
features: [
gitlabPlugin(),
gitlabPlugin,
mockServices.rootConfig.factory({ data: fakeConfig }),
],
});
Expand Down
33 changes: 24 additions & 9 deletions packages/gitlab/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,21 @@
"main": "dist/index.esm.js",
"types": "dist/index.d.ts"
},
"exports": {
".": "./src/index.ts",
"./alpha": "./src/alpha.tsx",
"./package.json": "./package.json"
},
"typesVersions": {
"*": {
"alpha": [
"src/alpha.tsx"
],
"package.json": [
"package.json"
]
}
},
"backstage": {
"role": "frontend-plugin",
"pluginId": "gitlab",
Expand Down Expand Up @@ -41,10 +56,10 @@
"postpack": "backstage-cli package postpack"
},
"dependencies": {
"@backstage/core-components": "^0.14.9",
"@backstage/core-plugin-api": "^1.9.3",
"@backstage/plugin-catalog-react": "^1.12.2",
"@backstage/theme": "^0.5.6",
"@backstage/core-components": "^0.15.0",
"@backstage/core-plugin-api": "^1.9.4",
"@backstage/plugin-catalog-react": "^1.13.0",
"@backstage/theme": "^0.5.7",
"@material-ui/core": "^4.12.2",
"@material-ui/icons": "^4.9.1",
"@material-ui/lab": "4.0.0-alpha.61",
Expand All @@ -65,11 +80,11 @@
"react-router-dom": "6.0.0-beta.0 || ^6.20.0"
},
"devDependencies": {
"@backstage/cli": "^0.26.11",
"@backstage/core-app-api": "^1.14.0",
"@backstage/dev-utils": "^1.0.35",
"@backstage/plugin-catalog-react": "^1.12.2",
"@backstage/test-utils": "^1.5.8",
"@backstage/cli": "^0.27.1",
"@backstage/core-app-api": "^1.15.0",
"@backstage/dev-utils": "^1.1.0",
"@backstage/plugin-catalog-react": "^1.13.0",
"@backstage/test-utils": "^1.6.0",
"@commitlint/cli": "^17.0.0",
"@commitlint/config-conventional": "^17.0.0",
"@gitbeaker/rest": "^40.0.2",
Expand Down
85 changes: 85 additions & 0 deletions packages/gitlab/src/alpha.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
import {
createFrontendPlugin,
PageBlueprint,
ApiBlueprint,
createApiFactory,
} from '@backstage/frontend-plugin-api';
import React from 'react';

import { rootRouteRef } from './routes';
import {
compatWrapper,
convertLegacyRouteRef,
} from '@backstage/core-compat-api';
import { GitlabCIApiRef, GitlabCIClient } from './api';
import {
configApiRef,
discoveryApiRef,
gitlabAuthApiRef,
identityApiRef,
} from '@backstage/core-plugin-api';

const gitlabAPI = ApiBlueprint.make({
params: {
factory: createApiFactory({
api: GitlabCIApiRef,
deps: {
configApi: configApiRef,
discoveryApi: discoveryApiRef,
identityApi: identityApiRef,
gitlabAuthApi: gitlabAuthApiRef,
},
factory: ({
configApi,
discoveryApi,
identityApi,
gitlabAuthApi,
}) =>
GitlabCIClient.setupAPI({
discoveryApi,
identityApi,
codeOwnersPath: configApi.getOptionalString(
'gitlab.defaultCodeOwnersPath'
),
readmePath: configApi.getOptionalString(
'gitlab.defaultReadmePath'
),
gitlabAuthApi,
useOAuth: configApi.getOptionalBoolean('gitlab.useOAuth'),
}),
}),
},
});

export default createFrontendPlugin({
id: 'Gitlab',
// bind all the extensions to the plugin
extensions: [gitlabAPI],
});

export const EntityGitlabContent = PageBlueprint.make({
name: 'EntityGitlabContent',
params: {
// you can reuse the existing routeRef
// by wrapping into the convertLegacyRouteRef.
routeRef: convertLegacyRouteRef(rootRouteRef),
defaultPath: '/gitlab',
// these inputs usually match the props required by the component.
loader: () =>
import('./components/GitlabCI').then((m) =>
compatWrapper(<m.GitlabCI />)
),
},
});

export {
LanguagesCard as EntityGitlabLanguageCard,
PeopleCard as EntityGitlabPeopleCard,
MergeRequestsTable as EntityGitlabMergeRequestsTable,
MergeRequestStats as EntityGitlabMergeRequestStatsCard,
PipelinesTable as EntityGitlabPipelinesTable,
ReleasesCard as EntityGitlabReleasesCard,
CoverageCard as EntityGitlabCoverageCard,
IssuesTable as EntityGitlabIssuesTable,
ReadmeCard as EntityGitlabReadmeCard,
} from './components/widgets/index';
2 changes: 1 addition & 1 deletion packages/gitlab/src/api/GitlabCIApi.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createApiRef } from '@backstage/core-plugin-api';
import { createApiRef } from '@backstage/frontend-plugin-api';
import { PeopleCardEntityData, Languages } from '../components/types';
import type {
IssueSchema,
Expand Down
8 changes: 3 additions & 5 deletions packages/gitlab/src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,11 @@ import {
import {
configApiRef,
createApiFactory,
createRouteRef,
discoveryApiRef,
gitlabAuthApiRef,
} from '@backstage/core-plugin-api';
import { GitlabCIApiRef, GitlabCIClient } from './api';

export const rootRouteRef = createRouteRef({
id: 'Gitlab',
});
import { rootRouteRef } from './routes';

export const gitlabPlugin = createPlugin({
id: 'Gitlab',
Expand Down Expand Up @@ -161,3 +157,5 @@ export const EntityGitlabReadmeCard = gitlabPlugin.provide(
},
})
);

export { rootRouteRef } from './routes';
Loading

0 comments on commit 12f35d2

Please sign in to comment.