From 2ca355e4913ed7b2446b1a5d515a85d9be63f99d Mon Sep 17 00:00:00 2001 From: Paul Cowan Date: Thu, 8 Dec 2022 12:41:26 +0000 Subject: [PATCH] Add SecurityTab Signed-off-by: Paul Cowan --- .../components/SecurityTab/SecurityTab.tsx | 25 +++++++++++++++++++ .../app/src/components/SecurityTab/index.ts | 17 +++++++++++++ .../components/SecurityTab/showSecurityTab.ts | 22 ++++++++++++++++ .../app/src/components/catalog/EntityPage.tsx | 10 ++++++++ .../examples/all-components.yaml | 24 +++++++++--------- .../components/wayback-search-component.yaml | 2 ++ 6 files changed, 88 insertions(+), 12 deletions(-) create mode 100644 packages/app/src/components/SecurityTab/SecurityTab.tsx create mode 100644 packages/app/src/components/SecurityTab/index.ts create mode 100644 packages/app/src/components/SecurityTab/showSecurityTab.ts diff --git a/packages/app/src/components/SecurityTab/SecurityTab.tsx b/packages/app/src/components/SecurityTab/SecurityTab.tsx new file mode 100644 index 0000000000..2adca3b0ef --- /dev/null +++ b/packages/app/src/components/SecurityTab/SecurityTab.tsx @@ -0,0 +1,25 @@ +/* eslint-disable no-console */ +/* + * Copyright 2022 The Backstage Authors + * + * 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 { useEntity } from '@backstage/plugin-catalog-react'; + +export function SecurityTab(): JSX.Element | null { + const entity = useEntity(); + console.log(entity); + return

Security

; +} diff --git a/packages/app/src/components/SecurityTab/index.ts b/packages/app/src/components/SecurityTab/index.ts new file mode 100644 index 0000000000..2c7908e958 --- /dev/null +++ b/packages/app/src/components/SecurityTab/index.ts @@ -0,0 +1,17 @@ +/* + * Copyright 2022 The Backstage Authors + * + * 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 { SecurityTab } from './SecurityTab'; +export { showSecurityTab } from './showSecurityTab'; diff --git a/packages/app/src/components/SecurityTab/showSecurityTab.ts b/packages/app/src/components/SecurityTab/showSecurityTab.ts new file mode 100644 index 0000000000..364436e44e --- /dev/null +++ b/packages/app/src/components/SecurityTab/showSecurityTab.ts @@ -0,0 +1,22 @@ +/* + * Copyright 2022 The Backstage Authors + * + * 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 { Entity } from '@backstage/catalog-model'; + +export const SECURITY_ANNOTATION = 'myorg.org/security'; + +/** @public */ +export const showSecurityTab = (entity: Entity) => + Boolean(entity.metadata.annotations?.[SECURITY_ANNOTATION]); diff --git a/packages/app/src/components/catalog/EntityPage.tsx b/packages/app/src/components/catalog/EntityPage.tsx index 02b00f038c..6288dc86ee 100644 --- a/packages/app/src/components/catalog/EntityPage.tsx +++ b/packages/app/src/components/catalog/EntityPage.tsx @@ -154,6 +154,8 @@ import { ReportIssue, } from '@backstage/plugin-techdocs-module-addons-contrib'; import { EntityCostInsightsContent } from '@backstage/plugin-cost-insights'; +import { SecurityTab } from '../SecurityTab/SecurityTab'; +import { showSecurityTab } from '../SecurityTab'; const customEntityFilterKind = ['Component', 'API', 'System']; @@ -400,6 +402,12 @@ const overviewContent = ( ); +const securityContent = ( + + + +); + const serviceEntityPage = ( @@ -440,6 +448,8 @@ const serviceEntityPage = ( {techdocsContent} + {securityContent} +