From 811ae9f478f0aeeb6a2d237261eab1afadd664dc Mon Sep 17 00:00:00 2001 From: Bogdan Nechyporenko Date: Wed, 4 Oct 2023 16:25:21 +0200 Subject: [PATCH] Removed unrelated code Signed-off-by: Bogdan Nechyporenko --- .changeset/plenty-singers-notice.md | 6 --- package.json | 4 +- packages/core-components/api-report.md | 1 - .../components/ErrorPanel/ErrorPanel.test.tsx | 47 ------------------- .../src/components/ErrorPanel/ErrorPanel.tsx | 4 +- .../WarningPanel/WarningPanel.test.tsx | 17 ------- .../components/WarningPanel/WarningPanel.tsx | 20 +------- .../src/next/OngoingTask/OngoingTask.tsx | 1 - 8 files changed, 4 insertions(+), 96 deletions(-) delete mode 100644 .changeset/plenty-singers-notice.md delete mode 100644 packages/core-components/src/components/ErrorPanel/ErrorPanel.test.tsx diff --git a/.changeset/plenty-singers-notice.md b/.changeset/plenty-singers-notice.md deleted file mode 100644 index 436be35a26..0000000000 --- a/.changeset/plenty-singers-notice.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -'@backstage/core-components': patch -'@backstage/plugin-scaffolder': patch ---- - -Add a possibility to use a formatter for on a warning panel. Applied it for a scaffolder template diff --git a/package.json b/package.json index 7b7d962780..24faec097a 100644 --- a/package.json +++ b/package.json @@ -28,8 +28,8 @@ "new": "backstage-cli new --scope backstage --baseVersion 0.0.0 --no-private", "create-plugin": "echo \"use 'yarn new' instead\"", "release": "node scripts/prepare-release.js && changeset version && yarn prettier --write '{packages,plugins}/*/{package.json,CHANGELOG.md}' '.changeset/*.json' && yarn install --no-immutable", - "prettier:check": "prettier --check .", - "prettier:fix": "prettier --write .", + "prettier:check": "prettier --check ./.changeset", + "prettier:fix": "prettier --write ./.changeset", "storybook": "yarn ./storybook run start", "snyk:test": "npx snyk test --yarn-workspaces --strict-out-of-sync=false", "snyk:test:package": "yarn snyk:test --include", diff --git a/packages/core-components/api-report.md b/packages/core-components/api-report.md index 04fcfa63a2..44a8b33e04 100644 --- a/packages/core-components/api-report.md +++ b/packages/core-components/api-report.md @@ -384,7 +384,6 @@ export type ErrorPanelClassKey = 'text' | 'divider'; export type ErrorPanelProps = { error: Error; defaultExpanded?: boolean; - formatTitle?: string; title?: string; }; diff --git a/packages/core-components/src/components/ErrorPanel/ErrorPanel.test.tsx b/packages/core-components/src/components/ErrorPanel/ErrorPanel.test.tsx deleted file mode 100644 index a3588b99c3..0000000000 --- a/packages/core-components/src/components/ErrorPanel/ErrorPanel.test.tsx +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright 2020 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 { WarningPanel } from '../WarningPanel'; -import { screen } from '@testing-library/react'; -import React from 'react'; -import { renderInTestApp } from '@backstage/test-utils'; -import { WarningProps } from '../WarningPanel/WarningPanel'; - -describe('', () => { - const propsErrorMessage: WarningProps = { - severity: 'error', - title: 'Mock title', - message: 'Some more info', - }; - - it('renders a title formatted by markdown', async () => { - await renderInTestApp( - , - ); - expect( - screen.getByText('Error: Step has been failed.'), - ).toBeInTheDocument(); - - expect(screen.getByText('Help')).toHaveAttribute( - 'href', - 'https://commonmark.org/help', - ); - }); -}); diff --git a/packages/core-components/src/components/ErrorPanel/ErrorPanel.tsx b/packages/core-components/src/components/ErrorPanel/ErrorPanel.tsx index a25a864083..02520d2c5c 100644 --- a/packages/core-components/src/components/ErrorPanel/ErrorPanel.tsx +++ b/packages/core-components/src/components/ErrorPanel/ErrorPanel.tsx @@ -96,7 +96,6 @@ const ErrorList = ({ export type ErrorPanelProps = { error: Error; defaultExpanded?: boolean; - formatTitle?: string; title?: string; }; @@ -106,13 +105,12 @@ export type ErrorPanelProps = { * @public */ export function ErrorPanel(props: PropsWithChildren) { - const { title, error, defaultExpanded, formatTitle, children } = props; + const { title, error, defaultExpanded, children } = props; return ( ', () => { await renderInTestApp(); expect(screen.getByText('Error: Mock title')).toBeInTheDocument(); }); - it('renders a title formatted by markdown', async () => { - await renderInTestApp( - , - ); - expect( - screen.getByText('Error: Step has been failed.'), - ).toBeInTheDocument(); - - expect(screen.getByText('Help')).toHaveAttribute( - 'href', - 'https://commonmark.org/help', - ); - }); }); diff --git a/packages/core-components/src/components/WarningPanel/WarningPanel.tsx b/packages/core-components/src/components/WarningPanel/WarningPanel.tsx index 0b1e97c40e..bcf2004267 100644 --- a/packages/core-components/src/components/WarningPanel/WarningPanel.tsx +++ b/packages/core-components/src/components/WarningPanel/WarningPanel.tsx @@ -23,7 +23,6 @@ import Typography from '@material-ui/core/Typography'; import ErrorOutline from '@material-ui/icons/ErrorOutline'; import ExpandMoreIcon from '@material-ui/icons/ExpandMore'; import React from 'react'; -import { MarkdownContent } from '../MarkdownContent'; const getWarningTextColor = ( severity: NonNullable, @@ -70,9 +69,6 @@ export type WarningPanelClassKey = const useStyles = makeStyles( theme => ({ - content: { - lineBreak: 'anywhere', - }, panel: { backgroundColor: ({ severity }: WarningProps) => getWarningBackgroundColor( @@ -98,11 +94,6 @@ const useStyles = makeStyles( ), fontWeight: theme.typography.fontWeightBold, }, - markdownContent: { - '& p': { - display: 'inline', - }, - }, message: { width: '100%', display: 'block', @@ -133,7 +124,6 @@ const useStyles = makeStyles( export type WarningProps = { title?: string; severity?: 'warning' | 'error' | 'info'; - formatTitle?: string; message?: React.ReactNode; defaultExpanded?: boolean; children?: React.ReactNode; @@ -161,7 +151,6 @@ export function WarningPanel(props: WarningProps) { const { severity = 'warning', title, - formatTitle, message, children, defaultExpanded, @@ -184,14 +173,7 @@ export function WarningPanel(props: WarningProps) { > - {formatTitle === 'markdown' ? ( - - ) : ( - subTitle - )} + {subTitle} {(message || children) && ( diff --git a/plugins/scaffolder/src/next/OngoingTask/OngoingTask.tsx b/plugins/scaffolder/src/next/OngoingTask/OngoingTask.tsx index 609f9bde8b..b483cd27cb 100644 --- a/plugins/scaffolder/src/next/OngoingTask/OngoingTask.tsx +++ b/plugins/scaffolder/src/next/OngoingTask/OngoingTask.tsx @@ -162,7 +162,6 @@ export const OngoingTask = (props: {