import React from 'react' ; import { Button , Grid } from '@material-ui/core' ; import { EmptyState } from '@backstage/core-components' ; import { EntityApiDefinitionCard , EntityConsumedApisCard , EntityConsumingComponentsCard , EntityHasApisCard , EntityProvidedApisCard , EntityProvidingComponentsCard , } from '@backstage/plugin-api-docs' ; import { EntityAboutCard , EntityDependsOnComponentsCard , EntityDependsOnResourcesCard , EntitySystemDiagramCard , EntityHasComponentsCard , EntityHasResourcesCard , EntityHasSubcomponentsCard , EntityHasSystemsCard , EntityLayout , EntityLinksCard , EntitySwitch , isComponentType , isKind , } from '@backstage/plugin-catalog' ; import { isGithubActionsAvailable , EntityGithubActionsContent , } from '@backstage/plugin-github-actions' ; import { EntityUserProfileCard , EntityGroupProfileCard , EntityMembersListCard , EntityOwnershipCard , } from '@backstage/plugin-org' ; import { EntityTechdocsContent } from '@backstage/plugin-techdocs' ; import { EntityGithubPullRequestsContent , EntityGithubPullRequestsOverviewCard , } from '@roadiehq/backstage-plugin-github-pull-requests' ; import { isAWSLambdaAvailable , EntityAWSLambdaOverviewCard , } from '@roadiehq/backstage-plugin-aws-lambda' ; import { EntityGithubInsightsContent , EntityGithubInsightsLanguagesCard , EntityGithubInsightsReadmeCard , EntityGithubInsightsReleasesCard , isGithubInsightsAvailable , } from '@roadiehq/backstage-plugin-github-insights' ; import { EntityJiraOverviewCard , isJiraAvailable , } from '@roadiehq/backstage-plugin-jira' ; import { EntityDatadogContent , EntityDatadogGraphCard , isDatadogGraphAvailable , } from '@roadiehq/backstage-plugin-datadog' ; import { EntityTravisCIContent , EntityTravisCIOverviewCard , isTravisciAvailable , } from '@roadiehq/backstage-plugin-travis-ci' ; import { EntityBuildkiteContent , isBuildkiteAvailable , } from '@roadiehq/backstage-plugin-buildkite' ; import { EntityBugsnagErrorsOverviewTable } from '@roadiehq/backstage-plugin-bugsnag' ; import { EntitySecurityInsightsContent , EntityGithubDependabotContent , SecurityInsightsWidget , DependabotAlertsWidget , isSecurityInsightsAvailable , } from '@roadiehq/backstage-plugin-security-insights' ; import { EntityArgoCDHistoryCard , EntityArgoCDOverviewCard , EntityArgoCDContent , isArgocdAvailable , } from '@roadiehq/backstage-plugin-argo-cd' ; import { EntityPrometheusAlertCard , EntityPrometheusContent , EntityPrometheusGraphCard , } from '@roadiehq/backstage-plugin-prometheus' ; const cicdContent = ( < Grid container spacing = { 3 } alignItems = "stretch" > < EntitySwitch > < EntitySwitch . Case if = { isGithubActionsAvailable } > < EntityGithubActionsContent /> < /EntitySwitch.Case> < EntitySwitch . Case if = { isTravisciAvailable } > < EntityTravisCIContent /> < /EntitySwitch.Case> < EntitySwitch . Case if = { isBuildkiteAvailable } > < EntityBuildkiteContent /> < /EntitySwitch.Case> < EntitySwitch . Case > < EmptyState title = "No CI/CD available for this entity" missing = "info" description = "You need to add an annotation to your component if you want to enable CI/CD for it. You can read more about annotations in Backstage by clicking the button below." action = { < Button variant = "contained" color = "primary" href = "https://backstage.io/docs/features/software-catalog/well-known-annotations" > Read more < /Button>}/ > < /EntitySwitch.Case> < /EntitySwitch> < /Grid>); const overviewContent = ( < Grid container spacing = { 3 } alignItems = "stretch" > < Grid item md = { 6 } > < EntityAboutCard variant = "gridItem" / > < /Grid> < EntitySwitch > < EntitySwitch . Case if = { isSecurityInsightsAvailable } > < Grid item md = { 6 } > < SecurityInsightsWidget /> < /Grid> < Grid item md = { 6 } > < DependabotAlertsWidget /> < /Grid> < /EntitySwitch.Case> < /EntitySwitch> < EntitySwitch > < EntitySwitch . Case if = { e => Boolean ( isGithubInsightsAvailable ( e ) ) } > < Grid item md = { 6 } > < EntityGithubInsightsLanguagesCard /> < EntityGithubInsightsReleasesCard / > < /Grid> < Grid item md = { 6 } > < EntityGithubInsightsReadmeCard maxHeight = { 350 } /> < /Grid> < /EntitySwitch.Case> < /EntitySwitch> < EntitySwitch > < EntitySwitch . Case if = { e => Boolean ( isAWSLambdaAvailable ( e ) ) } > < Grid item md = { 6 } > < EntityAWSLambdaOverviewCard /> < /Grid> < /EntitySwitch.Case> < /EntitySwitch> < EntitySwitch > < EntitySwitch . Case if = { isJiraAvailable } > < Grid item md = { 6 } > < EntityJiraOverviewCard /> < /Grid> < /EntitySwitch.Case> < /EntitySwitch> < EntitySwitch > < EntitySwitch . Case if = { isDatadogGraphAvailable } > < Grid item > < EntityDatadogGraphCard /> < /Grid> < /EntitySwitch.Case> < /EntitySwitch> < EntitySwitch > < EntitySwitch . Case if = { isTravisciAvailable } > < Grid item > < EntityTravisCIOverviewCard /> < /Grid> < /EntitySwitch.Case> < /EntitySwitch> < EntitySwitch > < EntitySwitch . Case if = { e => Boolean ( isArgocdAvailable ( e ) ) } > < Grid item sm = { 6 } > < EntityArgoCDHistoryCard /> < /Grid> < Grid item sm = { 6 } > < EntityArgoCDOverviewCard /> < /Grid> < /EntitySwitch.Case> < /EntitySwitch> < Grid item md = { 6 } > < EntityGithubPullRequestsOverviewCard /> < /Grid> < Grid item md = { 4 } xs = { 12 } > < EntityLinksCard /> < /Grid> < Grid item md = { 8 } xs = { 12 } > < EntityHasSubcomponentsCard variant = "gridItem" / > < /Grid> < Grid item md = { 8 } > < EntityPrometheusAlertCard /> < /Grid> < Grid item md = { 6 } > < EntityPrometheusGraphCard /> < /Grid> < /Grid>); const serviceEntityPage = ( < EntityLayout > < EntityLayout . Route path = "/" title = "Overview" > { overviewContent } < /EntityLayout.Route> < EntityLayout . Route path = "/ci-cd" title = "CI/CD" > { cicdContent } < /EntityLayout.Route> < EntityLayout . Route path = "/api" title = "API" > < Grid container spacing = { 3 } alignItems = "stretch" > < Grid item md = { 6 } > < EntityProvidedApisCard /> < /Grid> < Grid item md = { 6 } > < EntityConsumedApisCard /> < /Grid> < /Grid> < /EntityLayout.Route> < EntityLayout . Route path = "/pull-requests" title = "Pull Requests" > < EntityGithubPullRequestsContent /> < /EntityLayout.Route> < EntityLayout . Route path = "/code-insights" title = "Code Insights" > < EntityGithubInsightsContent /> < /EntityLayout.Route> < EntityLayout . Route path = "/bugsnag" title = "Bugsnag" > < EntityBugsnagErrorsOverviewTable /> < /EntityLayout.Route> < EntityLayout . Route path = "/datadog" title = "Datadog" > < EntityDatadogContent /> < /EntityLayout.Route> < EntityLayout . Route path = "/prometheus" title = "Prometheus" > < EntityPrometheusContent /> < /EntityLayout.Route> < EntityLayout . Route path = "/dependencies" title = "Dependencies" > < Grid container spacing = { 3 } alignItems = "stretch" > < Grid item md = { 6 } > < EntityDependsOnComponentsCard variant = "gridItem" / > < /Grid> < Grid item md = { 6 } > < EntityDependsOnResourcesCard variant = "gridItem" / > < /Grid> < /Grid> < /EntityLayout.Route> < EntityLayout . Route path = "/docs" title = "Docs" > < EntityTechdocsContent /> < /EntityLayout.Route> < EntityLayout . Route path = "/security-insights" title = "Security Insights" > < EntitySecurityInsightsContent /> < /EntityLayout.Route> < EntityLayout . Route path = "/dependabot" title = "Dependabot" > < EntityGithubDependabotContent /> < /EntityLayout.Route> < EntityLayout . Route path = "/argocd" title = "Argo CD" > < EntityArgoCDContent /> < /EntityLayout.Route> < /EntityLayout>); const websiteEntityPage = ( < EntityLayout > < EntityLayout . Route path = "/" title = "Overview" > { overviewContent } < /EntityLayout.Route> < EntityLayout . Route path = "/ci-cd" title = "CI/CD" > { cicdContent } < /EntityLayout.Route> < EntityLayout . Route path = "/dependencies" title = "Dependencies" > < Grid container spacing = { 3 } alignItems = "stretch" > < Grid item md = { 6 } > < EntityDependsOnComponentsCard variant = "gridItem" / > < /Grid> < Grid item md = { 6 } > < EntityDependsOnResourcesCard variant = "gridItem" / > < /Grid> < /Grid> < /EntityLayout.Route> < EntityLayout . Route path = "/docs" title = "Docs" > < EntityTechdocsContent /> < /EntityLayout.Route> < /EntityLayout>); const defaultEntityPage = ( < EntityLayout > < EntityLayout . Route path = "/" title = "Overview" > { overviewContent } < /EntityLayout.Route> < EntityLayout . Route path = "/docs" title = "Docs" > < EntityTechdocsContent /> < /EntityLayout.Route> < /EntityLayout>); const componentPage = ( < EntitySwitch > < EntitySwitch . Case if = { isComponentType ( 'service' ) } > { serviceEntityPage } < /EntitySwitch.Case> < EntitySwitch . Case if = { isComponentType ( 'website' ) } > { websiteEntityPage } < /EntitySwitch.Case> < EntitySwitch . Case > { defaultEntityPage } < /EntitySwitch.Case> < /EntitySwitch>); const apiPage = ( < EntityLayout > < EntityLayout . Route path = "/" title = "Overview" > < Grid container spacing = { 3 } > < Grid item md = { 6 } > < EntityAboutCard /> < /Grid> < Grid container item md = { 12 } > < Grid item md = { 6 } > < EntityProvidingComponentsCard /> < /Grid> < Grid item md = { 6 } > < EntityConsumingComponentsCard /> < /Grid> < /Grid> < /Grid> < /EntityLayout.Route> < EntityLayout . Route path = "/definition" title = "Definition" > < Grid container spacing = { 3 } > < Grid item xs = { 12 } > < EntityApiDefinitionCard /> < /Grid> < /Grid> < /EntityLayout.Route> < /EntityLayout>); const userPage = ( < EntityLayout > < EntityLayout . Route path = "/" title = "Overview" > < Grid container spacing = { 3 } > < Grid item xs = { 12 } md = { 6 } > < EntityUserProfileCard variant = "gridItem" / > < /Grid> < Grid item xs = { 12 } md = { 6 } > < EntityOwnershipCard variant = "gridItem" / > < /Grid> < /Grid> < /EntityLayout.Route> < /EntityLayout>); const groupPage = ( < EntityLayout > < EntityLayout . Route path = "/" title = "Overview" > < Grid container spacing = { 3 } > < Grid item xs = { 12 } md = { 6 } > < EntityGroupProfileCard variant = "gridItem" / > < /Grid> < Grid item xs = { 12 } md = { 6 } > < EntityOwnershipCard variant = "gridItem" / > < /Grid> < Grid item xs = { 12 } > < EntityMembersListCard /> < /Grid> < /Grid> < /EntityLayout.Route> < /EntityLayout>); const systemPage = ( < EntityLayout > < EntityLayout . Route path = "/" title = "Overview" > < Grid container spacing = { 3 } alignItems = "stretch" > < Grid item md = { 6 } > < EntityAboutCard variant = "gridItem" / > < /Grid> < Grid item md = { 6 } > < EntityHasComponentsCard variant = "gridItem" / > < /Grid> < Grid item md = { 6 } > < EntityHasApisCard variant = "gridItem" / > < /Grid> < Grid item md = { 6 } > < EntityHasResourcesCard variant = "gridItem" / > < /Grid> < /Grid> < /EntityLayout.Route> < EntityLayout . Route path = "/diagram" title = "Diagram" > < EntitySystemDiagramCard /> < /EntityLayout.Route> < /EntityLayout>); const domainPage = ( < EntityLayout > < EntityLayout . Route path = "/" title = "Overview" > < Grid container spacing = { 3 } alignItems = "stretch" > < Grid item md = { 6 } > < EntityAboutCard variant = "gridItem" / > < /Grid> < Grid item md = { 6 } > < EntityHasSystemsCard variant = "gridItem" / > < /Grid> < /Grid> < /EntityLayout.Route> < /EntityLayout>); export const entityPage = ( < EntitySwitch > < EntitySwitch . Case if = { isKind ( 'component' ) } children = { componentPage } / > < EntitySwitch . Case if = { isKind ( 'api' ) } children = { apiPage } / > < EntitySwitch . Case if = { isKind ( 'group' ) } children = { groupPage } / > < EntitySwitch . Case if = { isKind ( 'user' ) } children = { userPage } / > < EntitySwitch . Case if = { isKind ( 'system' ) } children = { systemPage } / > < EntitySwitch . Case if = { isKind ( 'domain' ) } children = { domainPage } / > < EntitySwitch . Case > { defaultEntityPage } < /EntitySwitch.Case> < /EntitySwitch>);