From 48ac287ee012b627a85a207fd6b0495dd6786699 Mon Sep 17 00:00:00 2001 From: lmejbar <42239917+lmejbar@users.noreply.github.com> Date: Fri, 20 Aug 2021 17:39:51 +0200 Subject: [PATCH] Minor corrections Signed-off-by: lmejbar <42239917+lmejbar@users.noreply.github.com> --- .../InputTextFilter/InputTextFilter.test.tsx | 64 ------------------- .../InputTextFilter/InputTextFilter.tsx | 4 +- .../src/components/RadarComponent.tsx | 9 +-- .../tech-radar/src/components/RadarPage.tsx | 6 +- 4 files changed, 8 insertions(+), 75 deletions(-) delete mode 100644 packages/core-components/src/components/InputTextFilter/InputTextFilter.test.tsx diff --git a/packages/core-components/src/components/InputTextFilter/InputTextFilter.test.tsx b/packages/core-components/src/components/InputTextFilter/InputTextFilter.test.tsx deleted file mode 100644 index 35be191cde..0000000000 --- a/packages/core-components/src/components/InputTextFilter/InputTextFilter.test.tsx +++ /dev/null @@ -1,64 +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 React from 'react'; -import { - render, - act, - RenderResult, - waitFor, - fireEvent, - screen, -} from '@testing-library/react'; -import { wrapInTestApp, renderInTestApp } from '@backstage/test-utils'; -import { InputTextFilter } from './InputTextFilter'; - -const SUPPORT_BUTTON_ID = 'support-button'; -const POPOVER_ID = 'support-button-popover'; - -describe('', () => { - // it('renders without exploding', async () => { - // let renderResult: RenderResult; - // await act(async () => { - // renderResult = render(wrapInTestApp()); - // }); - // await waitFor(() => - // expect(renderResult.getByTestId(SUPPORT_BUTTON_ID)).toBeInTheDocument(), - // ); - // }); - // it('supports passing a title', async () => { - // await renderInTestApp(); - // fireEvent.click(screen.getByTestId(SUPPORT_BUTTON_ID)); - // expect(screen.getByText('Custom title')).toBeInTheDocument(); - // }); - // it('shows popover on click', async () => { - // let renderResult: RenderResult; - // await act(async () => { - // renderResult = render(wrapInTestApp()); - // }); - // let button: HTMLElement; - // await waitFor(() => { - // expect(renderResult.getByTestId(SUPPORT_BUTTON_ID)).toBeInTheDocument(); - // button = renderResult.getByTestId(SUPPORT_BUTTON_ID); - // }); - // await act(async () => { - // fireEvent.click(button); - // }); - // await waitFor(() => { - // expect(renderResult.getByTestId(POPOVER_ID)).toBeInTheDocument(); - // }); - // }); -}); diff --git a/packages/core-components/src/components/InputTextFilter/InputTextFilter.tsx b/packages/core-components/src/components/InputTextFilter/InputTextFilter.tsx index 814efeccc6..e42670ad43 100644 --- a/packages/core-components/src/components/InputTextFilter/InputTextFilter.tsx +++ b/packages/core-components/src/components/InputTextFilter/InputTextFilter.tsx @@ -18,7 +18,7 @@ import React from 'react'; import { makeStyles } from '@material-ui/core/styles'; import TextField from '@material-ui/core/TextField'; -const useStyles = makeStyles(theme => ({ +const useStyles = makeStyles(() => ({ root: { '& > *': { width: '50ch', @@ -37,7 +37,7 @@ export const InputTextFilter = ({ const [, setSearchCategory] = React.useState(''); - const setSearchCategoryValue = event => { + const setSearchCategoryValue = (event: any) => { setSearchCategory(event.target.value); }; diff --git a/plugins/tech-radar/src/components/RadarComponent.tsx b/plugins/tech-radar/src/components/RadarComponent.tsx index 88c865f999..941ff87758 100644 --- a/plugins/tech-radar/src/components/RadarComponent.tsx +++ b/plugins/tech-radar/src/components/RadarComponent.tsx @@ -45,10 +45,7 @@ const useTechRadarLoader = (id: string | undefined) => { return { loading, value, error }; }; -const RadarComponent = ( - props: TechRadarComponentProps, - searchText: string, -): JSX.Element => { +const RadarComponent = (props: TechRadarComponentProps): JSX.Element => { const { loading, error, value: data } = useTechRadarLoader(props.id); const mapToEntries = ( @@ -61,10 +58,10 @@ const RadarComponent = ( element => element.title .toLowerCase() - .includes(props.searchText.toLowerCase()) || + .includes(props.searchText!.toLowerCase()) || element.timeline[0].description ?.toLowerCase() - .includes(props.searchText.toLowerCase()), + .includes(props.searchText!.toLowerCase()), ); } return filteredArray.map(entry => { diff --git a/plugins/tech-radar/src/components/RadarPage.tsx b/plugins/tech-radar/src/components/RadarPage.tsx index a332fd63c3..ae2df08e8f 100644 --- a/plugins/tech-radar/src/components/RadarPage.tsx +++ b/plugins/tech-radar/src/components/RadarPage.tsx @@ -22,7 +22,7 @@ import { Content, ContentHeader, Page, - Header, + // Header, SupportButton, InputTextFilter, } from '@backstage/core-components'; @@ -48,7 +48,7 @@ export const RadarPage = ({ const classes = useStyles(); const [searchText, setSearchText] = React.useState(''); - const searchInput = event => { + const searchInput = (event: any) => { setSearchText(event.target.value); }; @@ -66,7 +66,7 @@ export const RadarPage = ({ - +