From 07b9316190ac85ba3c61184fe6e60c5852375632 Mon Sep 17 00:00:00 2001 From: Ivan Shmidt Date: Fri, 4 Sep 2020 16:01:20 +0200 Subject: [PATCH] feat(create-app): add circleci and cicdswitcher to template --- .../app/src/components/catalog/EntityPage.tsx | 39 +++++++++++++++++-- 1 file changed, 35 insertions(+), 4 deletions(-) diff --git a/packages/create-app/templates/default-app/packages/app/src/components/catalog/EntityPage.tsx b/packages/create-app/templates/default-app/packages/app/src/components/catalog/EntityPage.tsx index 4087789deb..06b837c173 100644 --- a/packages/create-app/templates/default-app/packages/app/src/components/catalog/EntityPage.tsx +++ b/packages/create-app/templates/default-app/packages/app/src/components/catalog/EntityPage.tsx @@ -13,7 +13,14 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { Router as GitHubActionsRouter } from '@backstage/plugin-github-actions'; +import { + Router as GitHubActionsRouter, + isPluginApplicableToEntity as isGitHubActionsAvaiable, +} from '@backstage/plugin-github-actions'; +import { + Router as CircleCIRouter, + isPluginApplicableToEntity as isCircleCIAvailable, +} from '@backstage/plugin-circleci'; import React from 'react'; import { EntityPageLayout, @@ -21,9 +28,33 @@ import { AboutCard, } from '@backstage/plugin-catalog'; import { Entity } from '@backstage/catalog-model'; +import { Grid } from '@material-ui/core'; +import { WarningPanel } from '@backstage/core'; + +const CICDSwitcher = ({ entity }: { entity: Entity }) => { + // This component is just an example of how you can implement your company's logic in entity page. + // You can for example enforce that all components of type 'service' should use GitHubActions + switch (true) { + case isGitHubActionsAvaiable(entity): + return ; + case isCircleCIAvailable(entity): + return ; + default: + return ( + + No CI/CD is available for this entity. Check corresponding + annotations! + + ); + } +}; const OverviewContent = ({ entity }: { entity: Entity }) => ( - + + + + + ); const ServiceEntityPage = ({ entity }: { entity: Entity }) => ( @@ -36,7 +67,7 @@ const ServiceEntityPage = ({ entity }: { entity: Entity }) => ( } + element={} /> ); @@ -51,7 +82,7 @@ const WebsiteEntityPage = ({ entity }: { entity: Entity }) => ( } + element={} /> );