gcp-projects: port to new composability API

This commit is contained in:
Patrik Oldsberg
2021-01-20 00:12:19 +01:00
parent 5df0714a84
commit bad33a2ec2
7 changed files with 97 additions and 93 deletions
+1 -1
View File
@@ -37,7 +37,7 @@
"@material-ui/lab": "4.0.0-alpha.45",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"react-router-dom": "^5.2.0",
"react-router-dom": "^6.0.0-beta.0",
"react-use": "^15.3.3"
},
"devDependencies": {
@@ -0,0 +1,29 @@
/*
* Copyright 2020 Spotify AB
*
* 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 { Route, Routes } from 'react-router-dom';
import { NewProjectPage } from '../NewProjectPage';
import { ProjectDetailsPage } from '../ProjectDetailsPage';
import { ProjectListPage } from '../ProjectListPage';
export const GcpProjectsPage = () => (
<Routes>
<Route path="/" element={<ProjectListPage />} />
<Route path="/new" element={<NewProjectPage />} />
<Route path="/project" element={<ProjectDetailsPage />} />
</Routes>
);
@@ -0,0 +1,17 @@
/*
* Copyright 2020 Spotify AB
*
* 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 { GcpProjectsPage } from './GcpProjectsPage';
+1 -1
View File
@@ -14,5 +14,5 @@
* limitations under the License.
*/
export { plugin } from './plugin';
export { plugin, GcpProjectsPage } from './plugin';
export * from './api';
+13 -14
View File
@@ -17,29 +17,20 @@
import {
createApiFactory,
createPlugin,
createRouteRef,
createRoutableExtension,
googleAuthApiRef,
} from '@backstage/core';
import { gcpApiRef, GcpClient } from './api';
import { NewProjectPage } from './components/NewProjectPage';
import { ProjectDetailsPage } from './components/ProjectDetailsPage';
import { ProjectListPage } from './components/ProjectListPage';
export const rootRouteRef = createRouteRef({
path: '/gcp-projects',
title: 'GCP Projects',
});
export const projectRouteRef = createRouteRef({
path: '/gcp-projects/project',
title: 'GCP Project Page',
});
export const newProjectRouteRef = createRouteRef({
path: '/gcp-projects/new',
title: 'GCP Project Page',
});
import { rootRouteRef, projectRouteRef, newProjectRouteRef } from './routes';
export const plugin = createPlugin({
id: 'gcp-projects',
routes: {
root: rootRouteRef,
},
apis: [
createApiFactory({
api: gcpApiRef,
@@ -55,3 +46,11 @@ export const plugin = createPlugin({
router.addRoute(newProjectRouteRef, NewProjectPage);
},
});
export const GcpProjectsPage = plugin.provide(
createRoutableExtension({
component: () =>
import('./components/GcpProjectsPage').then(m => m.GcpProjectsPage),
mountPoint: rootRouteRef,
}),
);
+30
View File
@@ -0,0 +1,30 @@
/*
* Copyright 2021 Spotify AB
*
* 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';
export const rootRouteRef = createRouteRef({
path: '/gcp-projects',
title: 'GCP Projects',
});
export const projectRouteRef = createRouteRef({
path: '/gcp-projects/project',
title: 'GCP Project Page',
});
export const newProjectRouteRef = createRouteRef({
path: '/gcp-projects/new',
title: 'GCP Project Page',
});