From 6b44dd110c5ca3b009f15b4f8e6cac6c95f061b2 Mon Sep 17 00:00:00 2001 From: Ivan Shmidt Date: Wed, 6 May 2020 11:18:49 +0200 Subject: [PATCH] feat: routing -> plugin routing --- .../circleci/src/components/Layout/Layout.tsx | 12 +++++ .../circleci/src/components/Layout/index.ts | 1 + .../src/pages/BuildsPage/BuildsPage.tsx | 39 ++++++++-------- .../src/pages/CircleCIPage/CircleCIPage.tsx | 44 ------------------- .../circleci/src/pages/CircleCIPage/index.ts | 1 - .../DetailedViewPage/DetailedViewPage.tsx | 42 +++++++++++------- .../src/pages/SettingsPage/SettingsPage.tsx | 9 ++-- plugins/circleci/src/plugin.ts | 6 ++- 8 files changed, 68 insertions(+), 86 deletions(-) create mode 100644 plugins/circleci/src/components/Layout/Layout.tsx create mode 100644 plugins/circleci/src/components/Layout/index.ts delete mode 100644 plugins/circleci/src/pages/CircleCIPage/CircleCIPage.tsx delete mode 100644 plugins/circleci/src/pages/CircleCIPage/index.ts diff --git a/plugins/circleci/src/components/Layout/Layout.tsx b/plugins/circleci/src/components/Layout/Layout.tsx new file mode 100644 index 0000000000..fe82bf90e8 --- /dev/null +++ b/plugins/circleci/src/components/Layout/Layout.tsx @@ -0,0 +1,12 @@ +import React from 'react'; +import { Header, Page, pageTheme, HeaderLabel } from '@backstage/core'; + +export const Layout: React.FC = ({ children }) => ( + +
+ + +
+ {children} +
+); diff --git a/plugins/circleci/src/components/Layout/index.ts b/plugins/circleci/src/components/Layout/index.ts new file mode 100644 index 0000000000..9877e7f4ae --- /dev/null +++ b/plugins/circleci/src/components/Layout/index.ts @@ -0,0 +1 @@ +export * from './Layout'; diff --git a/plugins/circleci/src/pages/BuildsPage/BuildsPage.tsx b/plugins/circleci/src/pages/BuildsPage/BuildsPage.tsx index cb8b3500ef..98e634d4c0 100644 --- a/plugins/circleci/src/pages/BuildsPage/BuildsPage.tsx +++ b/plugins/circleci/src/pages/BuildsPage/BuildsPage.tsx @@ -9,25 +9,28 @@ import { import { Button, Grid } from '@material-ui/core'; import { CircleCIFetch } from 'components/CircleCIFetch'; import { Settings as SettingsIcon } from '@material-ui/icons'; +import { Layout } from 'components/Layout'; export const BuildsPage: FC<{}> = () => ( - - - - A description of your plugin goes here. - - - - - - + + + + + A description of your plugin goes here. + + + + + + + - - + + ); diff --git a/plugins/circleci/src/pages/CircleCIPage/CircleCIPage.tsx b/plugins/circleci/src/pages/CircleCIPage/CircleCIPage.tsx deleted file mode 100644 index fe0ef0f1ce..0000000000 --- a/plugins/circleci/src/pages/CircleCIPage/CircleCIPage.tsx +++ /dev/null @@ -1,44 +0,0 @@ -/* - * 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, { FC } from 'react'; -import { Route } from 'react-router'; -import { - Header, - Page, - pageTheme, - HeaderLabel, -} from '@backstage/core'; -import { SettingsPage } from '../SettingsPage'; -import { BuildsPage } from '../BuildsPage'; -import { DetailedViewPage } from '../DetailedViewPage'; -export const CircleCIPage: FC<{}> = () => { - return ( - <> - -
- - -
- - - -
- - ); -}; - -export default CircleCIPage; diff --git a/plugins/circleci/src/pages/CircleCIPage/index.ts b/plugins/circleci/src/pages/CircleCIPage/index.ts deleted file mode 100644 index 188ed6d61f..0000000000 --- a/plugins/circleci/src/pages/CircleCIPage/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { CircleCIPage } from './CircleCIPage'; diff --git a/plugins/circleci/src/pages/DetailedViewPage/DetailedViewPage.tsx b/plugins/circleci/src/pages/DetailedViewPage/DetailedViewPage.tsx index 53fe2fea3e..3d5d7b575b 100644 --- a/plugins/circleci/src/pages/DetailedViewPage/DetailedViewPage.tsx +++ b/plugins/circleci/src/pages/DetailedViewPage/DetailedViewPage.tsx @@ -6,6 +6,7 @@ import { BuildWithSteps, BuildStepAction } from 'circleci-api'; import { circleCIApiRef } from 'api'; import { useParams } from 'react-router-dom'; import { ActionOutput } from '../../components/ActionOutput/ActionOutput'; +import { Layout } from 'components/Layout'; export const DetailedViewPage: FC<{}> = () => { let { buildId = '' } = useParams(); @@ -30,20 +31,22 @@ export const DetailedViewPage: FC<{}> = () => { getBuildAsync(); }, [authed, buildId]); return ( - - - {!api.authed ? ( -
Not authenticated
- ) : ( - - - - - + + + + {!api.authed ? ( +
Not authenticated
+ ) : ( + + + + + + -
- )} -
+ )} + + ); }; @@ -53,16 +56,23 @@ const BuildsList: FC<{ build: BuildWithSteps | null }> = ({ build }) => ( build.steps && build.steps.map( ({ name, actions }: { name: string; actions: BuildStepAction[] }) => ( - + ), )} ); -const ActionsList: FC<{ actions: BuildStepAction[], name: string }> = ({ actions, name }) => ( +const ActionsList: FC<{ actions: BuildStepAction[]; name: string }> = ({ + actions, + name, +}) => ( {actions.map((action: BuildStepAction) => ( - + ))} ); diff --git a/plugins/circleci/src/pages/SettingsPage/SettingsPage.tsx b/plugins/circleci/src/pages/SettingsPage/SettingsPage.tsx index 95e2c86662..af380509d1 100644 --- a/plugins/circleci/src/pages/SettingsPage/SettingsPage.tsx +++ b/plugins/circleci/src/pages/SettingsPage/SettingsPage.tsx @@ -4,14 +4,13 @@ import { circleCIApiRef } from 'api'; import { InfoCard, useApi, - Page, - pageTheme, Content, ContentHeader, SupportButton, } from '@backstage/core'; import { ProjectInput } from 'components/ProjectInput/ProjectInput'; import { Link as RouterLink } from 'react-router-dom'; +import { Layout } from 'components/Layout'; export const SettingsPage = () => { const api = useApi(circleCIApiRef); @@ -27,7 +26,7 @@ export const SettingsPage = () => { }, []); return ( - + A description of your plugin goes here. - + @@ -84,6 +83,6 @@ export const SettingsPage = () => { - + ); }; diff --git a/plugins/circleci/src/plugin.ts b/plugins/circleci/src/plugin.ts index 7e96bf5e0d..11d215f30f 100644 --- a/plugins/circleci/src/plugin.ts +++ b/plugins/circleci/src/plugin.ts @@ -14,13 +14,15 @@ * limitations under the License. */ import { createPlugin } from '@backstage/core'; -import { CircleCIPage } from './pages/CircleCIPage'; +import { BuildsPage } from './pages/BuildsPage'; import { SettingsPage } from './pages/SettingsPage'; +import { DetailedViewPage } from './pages/DetailedViewPage'; export const plugin = createPlugin({ id: 'circleci', register({ router }) { - router.registerRoute('/circleci', CircleCIPage); + router.registerRoute('/circleci', BuildsPage); + router.registerRoute('/circleci/build/:buildId', DetailedViewPage); router.registerRoute('/circleci/settings', SettingsPage); }, });