diff --git a/.changeset/short-ants-notice.md b/.changeset/short-ants-notice.md new file mode 100644 index 0000000000..779839387e --- /dev/null +++ b/.changeset/short-ants-notice.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-xcmetrics': patch +--- + +Internal refactoring diff --git a/plugins/xcmetrics/src/components/AccordionComponent/AccordionComponent.test.tsx b/plugins/xcmetrics/src/components/Accordion/Accordion.test.tsx similarity index 89% rename from plugins/xcmetrics/src/components/AccordionComponent/AccordionComponent.test.tsx rename to plugins/xcmetrics/src/components/Accordion/Accordion.test.tsx index baa8c0e5f2..70be560abf 100644 --- a/plugins/xcmetrics/src/components/AccordionComponent/AccordionComponent.test.tsx +++ b/plugins/xcmetrics/src/components/Accordion/Accordion.test.tsx @@ -15,13 +15,13 @@ */ import React from 'react'; import { renderInTestApp } from '@backstage/test-utils'; -import { AccordionComponent } from './AccordionComponent'; +import { Accordion } from './Accordion'; import userEvent from '@testing-library/user-event'; -describe('AccordionComponent', () => { +describe('Accordion', () => { it('should render', async () => { const rendered = await renderInTestApp( - { it('should show content when clicked', async () => { const rendered = await renderInTestApp( - Content - , + , ); expect(rendered.getByText('Content')).not.toBeVisible(); diff --git a/plugins/xcmetrics/src/components/AccordionComponent/AccordionComponent.tsx b/plugins/xcmetrics/src/components/Accordion/Accordion.tsx similarity index 88% rename from plugins/xcmetrics/src/components/AccordionComponent/AccordionComponent.tsx rename to plugins/xcmetrics/src/components/Accordion/Accordion.tsx index 9afe736a2a..2e2100a816 100644 --- a/plugins/xcmetrics/src/components/AccordionComponent/AccordionComponent.tsx +++ b/plugins/xcmetrics/src/components/Accordion/Accordion.tsx @@ -14,8 +14,8 @@ * limitations under the License. */ import { - Accordion, - AccordionSummary, + Accordion as MuiAccordion, + AccordionSummary as MuiAccordionSummary, Typography, AccordionDetails, makeStyles, @@ -45,17 +45,15 @@ interface AccordionProps { unmountOnExit?: boolean; } -export const AccordionComponent = ( - props: PropsWithChildren, -) => { +export const Accordion = (props: PropsWithChildren) => { const classes = useStyles(); return ( - - } aria-controls={`${props.id}-content`} id={`${props.id}-header`} @@ -64,8 +62,8 @@ export const AccordionComponent = ( {props.secondaryHeading} - + {props.children} - + ); }; diff --git a/plugins/xcmetrics/src/components/BuildListComponent/index.ts b/plugins/xcmetrics/src/components/Accordion/index.ts similarity index 93% rename from plugins/xcmetrics/src/components/BuildListComponent/index.ts rename to plugins/xcmetrics/src/components/Accordion/index.ts index 3fb881458d..4bb2e58df9 100644 --- a/plugins/xcmetrics/src/components/BuildListComponent/index.ts +++ b/plugins/xcmetrics/src/components/Accordion/index.ts @@ -13,4 +13,4 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -export * from './BuildListComponent'; +export { Accordion } from './Accordion'; diff --git a/plugins/xcmetrics/src/components/BuildDetailsComponent/BuildDetailsComponent.test.tsx b/plugins/xcmetrics/src/components/BuildDetails/BuildDetails.test.tsx similarity index 81% rename from plugins/xcmetrics/src/components/BuildDetailsComponent/BuildDetailsComponent.test.tsx rename to plugins/xcmetrics/src/components/BuildDetails/BuildDetails.test.tsx index 15b8720a1d..2d949d7abc 100644 --- a/plugins/xcmetrics/src/components/BuildDetailsComponent/BuildDetailsComponent.test.tsx +++ b/plugins/xcmetrics/src/components/BuildDetails/BuildDetails.test.tsx @@ -16,29 +16,29 @@ import React from 'react'; import { renderInTestApp } from '@backstage/test-utils'; import { ApiProvider, ApiRegistry } from '@backstage/core-app-api'; -import { BuildDetailsComponent, withRequest } from './BuildDetailsComponent'; +import { BuildDetails, withRequest } from './BuildDetails'; import { xcmetricsApiRef } from '../../api'; jest.mock('../../api/XcmetricsClient'); const client = require('../../api/XcmetricsClient'); -jest.mock('../AccordionComponent', () => ({ - AccordionComponent: ({ heading }: { heading: string }) => ( +jest.mock('../Accordion', () => ({ + Accordion: ({ heading }: { heading: string }) => (
accordion-{heading}
), })); -jest.mock('../BuildTimelineComponent', () => ({ - BuildTimelineComponent: () => 'BuildTimelineComponent', +jest.mock('../BuildTimeline', () => ({ + BuildTimeline: () => 'BuildTimeline', })); -describe('BuildDetailsComponent', () => { +describe('BuildDetails', () => { it('should render', async () => { const rendered = await renderInTestApp( - + , ); @@ -56,15 +56,15 @@ describe('BuildDetailsComponent', () => { }); }); -describe('BuildDetailsComponent with request', () => { - const BuildDetails = withRequest(BuildDetailsComponent); +describe('BuildDetails with request', () => { + const BuildDetailsWithRequest = withRequest(BuildDetails); it('should fetch the build and render', async () => { const rendered = await renderInTestApp( - + , ); @@ -81,7 +81,7 @@ describe('BuildDetailsComponent with request', () => { - + , ); @@ -95,7 +95,7 @@ describe('BuildDetailsComponent with request', () => { - + , ); diff --git a/plugins/xcmetrics/src/components/BuildDetailsComponent/BuildDetailsComponent.tsx b/plugins/xcmetrics/src/components/BuildDetails/BuildDetails.tsx similarity index 86% rename from plugins/xcmetrics/src/components/BuildDetailsComponent/BuildDetailsComponent.tsx rename to plugins/xcmetrics/src/components/BuildDetails/BuildDetails.tsx index 44f43a268b..1d77bf7a7a 100644 --- a/plugins/xcmetrics/src/components/BuildDetailsComponent/BuildDetailsComponent.tsx +++ b/plugins/xcmetrics/src/components/BuildDetails/BuildDetails.tsx @@ -21,11 +21,11 @@ import { Alert } from '@material-ui/lab'; import { useAsync } from 'react-use'; import { useApi } from '@backstage/core-plugin-api'; import { formatDuration, formatStatus, formatTime } from '../../utils'; -import { StatusIconComponent as StatusIcon } from '../StatusIconComponent'; +import { StatusIcon } from '../StatusIcon'; import { BackstageTheme } from '@backstage/theme'; -import { AccordionComponent } from '../AccordionComponent'; -import { BuildTimelineComponent } from '../BuildTimelineComponent'; -import { PreformattedTextComponent } from '../PreformattedTextComponent'; +import { Accordion } from '../Accordion'; +import { BuildTimeline } from '../BuildTimeline'; +import { PreformattedText } from '../PreformattedText'; const useStyles = makeStyles((theme: BackstageTheme) => createStyles({ @@ -41,7 +41,7 @@ interface BuildDetailsProps { showId?: boolean; } -export const BuildDetailsComponent = ({ +export const BuildDetails = ({ buildData: { build, targets, xcode }, showId, }: BuildDetailsProps) => { @@ -92,7 +92,7 @@ export const BuildDetailsComponent = ({ /> - )} - + - (
- ))}
-
+ - (
- ))}
-
+ - )} - + - - - + + +
); @@ -177,7 +177,7 @@ type WithRequestProps = Omit & { }; export const withRequest = - (Component: typeof BuildDetailsComponent) => + (Component: typeof BuildDetails) => ({ buildId, ...props }: WithRequestProps) => { const client = useApi(xcmetricsApiRef); const { diff --git a/plugins/xcmetrics/src/components/AccordionComponent/index.ts b/plugins/xcmetrics/src/components/BuildDetails/index.ts similarity index 90% rename from plugins/xcmetrics/src/components/AccordionComponent/index.ts rename to plugins/xcmetrics/src/components/BuildDetails/index.ts index 33632d6828..c2511b248e 100644 --- a/plugins/xcmetrics/src/components/AccordionComponent/index.ts +++ b/plugins/xcmetrics/src/components/BuildDetails/index.ts @@ -13,4 +13,4 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -export { AccordionComponent } from './AccordionComponent'; +export { BuildDetails, withRequest } from './BuildDetails'; diff --git a/plugins/xcmetrics/src/components/BuildDetailsComponent/index.ts b/plugins/xcmetrics/src/components/BuildDetailsComponent/index.ts deleted file mode 100644 index 4e50cf23a0..0000000000 --- a/plugins/xcmetrics/src/components/BuildDetailsComponent/index.ts +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Copyright 2021 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 { BuildDetailsComponent, withRequest } from './BuildDetailsComponent'; diff --git a/plugins/xcmetrics/src/components/BuildListComponent/BuildListComponent.test.tsx b/plugins/xcmetrics/src/components/BuildList/BuildList.test.tsx similarity index 80% rename from plugins/xcmetrics/src/components/BuildListComponent/BuildListComponent.test.tsx rename to plugins/xcmetrics/src/components/BuildList/BuildList.test.tsx index 761c08a711..eb141209e7 100644 --- a/plugins/xcmetrics/src/components/BuildListComponent/BuildListComponent.test.tsx +++ b/plugins/xcmetrics/src/components/BuildList/BuildList.test.tsx @@ -16,29 +16,29 @@ import React from 'react'; import { renderInTestApp } from '@backstage/test-utils'; import { ApiProvider, ApiRegistry } from '@backstage/core-app-api'; -import { BuildListComponent } from './BuildListComponent'; +import { BuildList } from './BuildList'; import { xcmetricsApiRef } from '../../api'; import userEvent from '@testing-library/user-event'; jest.mock('../../api/XcmetricsClient'); const client = require('../../api/XcmetricsClient'); -jest.mock('../BuildListFilterComponent', () => ({ - BuildListFilterComponent: () => 'BuildListFilterComponent', +jest.mock('../BuildListFilter', () => ({ + BuildListFilter: () => 'BuildListFilter', })); -jest.mock('../BuildDetailsComponent', () => ({ +jest.mock('../BuildDetails', () => ({ withRequest: (component: any) => component, - BuildDetailsComponent: () => 'BuildDetailsComponent', + BuildDetails: () => 'BuildDetails', })); -describe('BuildListComponent', () => { +describe('BuildList', () => { it('should render', async () => { const rendered = await renderInTestApp( - + , ); @@ -53,16 +53,14 @@ describe('BuildListComponent', () => { - + , ); userEvent.click( (await rendered.findAllByLabelText('Detail panel visiblity toggle'))[0], ); - expect( - await rendered.findByText('BuildDetailsComponent'), - ).toBeInTheDocument(); + expect(await rendered.findByText('BuildDetails')).toBeInTheDocument(); }); it('should show errors', async () => { @@ -75,7 +73,7 @@ describe('BuildListComponent', () => { - + , ); diff --git a/plugins/xcmetrics/src/components/BuildListComponent/BuildListComponent.tsx b/plugins/xcmetrics/src/components/BuildList/BuildList.tsx similarity index 89% rename from plugins/xcmetrics/src/components/BuildListComponent/BuildListComponent.tsx rename to plugins/xcmetrics/src/components/BuildList/BuildList.tsx index 42f6bf4414..f9e8bfdd98 100644 --- a/plugins/xcmetrics/src/components/BuildListComponent/BuildListComponent.tsx +++ b/plugins/xcmetrics/src/components/BuildList/BuildList.tsx @@ -18,10 +18,10 @@ import { Table } from '@backstage/core-components'; import { useApi } from '@backstage/core-plugin-api'; import { BuildFilters, xcmetricsApiRef } from '../../api'; import { createStyles, Grid, makeStyles } from '@material-ui/core'; -import { BuildListFilterComponent as Filters } from '../BuildListFilterComponent'; +import { BuildListFilter as Filters } from '../BuildListFilter'; import { DateTime } from 'luxon'; import { buildPageColumns } from '../BuildTableColumns'; -import { BuildDetailsComponent, withRequest } from '../BuildDetailsComponent'; +import { BuildDetails, withRequest } from '../BuildDetails'; import { BackstageTheme } from '@backstage/theme'; const useStyles = makeStyles((theme: BackstageTheme) => @@ -33,7 +33,7 @@ const useStyles = makeStyles((theme: BackstageTheme) => }), ); -export const BuildListComponent = () => { +export const BuildList = () => { const classes = useStyles(); const client = useApi(xcmetricsApiRef); const tableRef = useRef(); @@ -81,10 +81,10 @@ export const BuildListComponent = () => { }); }} detailPanel={rowData => { - const BuildDetails = withRequest(BuildDetailsComponent); + const BuildDetailsWithRequest = withRequest(BuildDetails); return (
- +
); }} diff --git a/plugins/xcmetrics/src/components/DatePickerComponent/index.ts b/plugins/xcmetrics/src/components/BuildList/index.ts similarity index 93% rename from plugins/xcmetrics/src/components/DatePickerComponent/index.ts rename to plugins/xcmetrics/src/components/BuildList/index.ts index 0d7e061612..12b44d01be 100644 --- a/plugins/xcmetrics/src/components/DatePickerComponent/index.ts +++ b/plugins/xcmetrics/src/components/BuildList/index.ts @@ -13,4 +13,4 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -export * from './DatePickerComponent'; +export { BuildList } from './BuildList'; diff --git a/plugins/xcmetrics/src/components/BuildListFilterComponent/BuildListFilterComponent.test.tsx b/plugins/xcmetrics/src/components/BuildListFilter/BuildListFilter.test.tsx similarity index 91% rename from plugins/xcmetrics/src/components/BuildListFilterComponent/BuildListFilterComponent.test.tsx rename to plugins/xcmetrics/src/components/BuildListFilter/BuildListFilter.test.tsx index eac5775d77..b997de68e0 100644 --- a/plugins/xcmetrics/src/components/BuildListFilterComponent/BuildListFilterComponent.test.tsx +++ b/plugins/xcmetrics/src/components/BuildListFilter/BuildListFilter.test.tsx @@ -17,15 +17,15 @@ import React from 'react'; import { renderInTestApp } from '@backstage/test-utils'; import { ApiProvider, ApiRegistry } from '@backstage/core-app-api'; import userEvent from '@testing-library/user-event'; -import { BuildListFilterComponent } from './BuildListFilterComponent'; +import { BuildListFilter } from './BuildListFilter'; import { BuildFilters, xcmetricsApiRef } from '../../api'; import { RenderResult } from '@testing-library/react'; jest.mock('../../api/XcmetricsClient'); const client = require('../../api/XcmetricsClient'); -jest.mock('../DatePickerComponent', () => ({ - DatePickerComponent: () => 'DatePickerComponent', +jest.mock('../DatePicker', () => ({ + DatePicker: () => 'DatePicker', })); const initialValues = { @@ -40,7 +40,7 @@ const renderWithFiltersVisible = async ( - @@ -64,13 +64,13 @@ const setProjectFilter = async (rendered: RenderResult, option: string) => { userEvent.click(options[options.length - 1]); }; -describe('BuildListFilterComponent', () => { +describe('BuildListFilter', () => { it('should render', async () => { const rendered = await renderInTestApp( - @@ -83,14 +83,12 @@ describe('BuildListFilterComponent', () => { it('should toggle between showing and hiding filters', async () => { const rendered = await renderWithFiltersVisible(); - expect( - (await rendered.findAllByText('DatePickerComponent')).length, - ).toEqual(2); + expect((await rendered.findAllByText('DatePicker')).length).toEqual(2); expect(await rendered.findByText('Status')).toBeInTheDocument(); expect(await rendered.findByText('Project')).toBeInTheDocument(); userEvent.click(rendered.getByLabelText('hide filters')); - expect(rendered.queryByText('DatePickerComponent')).toBeNull(); + expect(rendered.queryByText('DatePicker')).toBeNull(); expect(rendered.queryByText('Status')).toBeNull(); expect(rendered.queryByText('Project')).toBeNull(); }); diff --git a/plugins/xcmetrics/src/components/BuildListFilterComponent/BuildListFilterComponent.tsx b/plugins/xcmetrics/src/components/BuildListFilter/BuildListFilter.tsx similarity index 96% rename from plugins/xcmetrics/src/components/BuildListFilterComponent/BuildListFilterComponent.tsx rename to plugins/xcmetrics/src/components/BuildListFilter/BuildListFilter.tsx index ff45e15925..8c1334f928 100644 --- a/plugins/xcmetrics/src/components/BuildListFilterComponent/BuildListFilterComponent.tsx +++ b/plugins/xcmetrics/src/components/BuildListFilter/BuildListFilter.tsx @@ -22,7 +22,7 @@ import { BackstageTheme } from '@backstage/theme'; import { useApi } from '@backstage/core-plugin-api'; import { useAsync } from 'react-use'; import { BuildFilters, BuildStatus, xcmetricsApiRef } from '../../api'; -import { DatePickerComponent } from '../DatePickerComponent'; +import { DatePicker } from '../DatePicker'; const toSelectItems = (strings: string[]) => { return strings.map(str => ({ label: str, value: str })); @@ -41,7 +41,7 @@ interface FiltersProps { onFilterChange: (filters: BuildFilters) => void; } -export const BuildListFilterComponent = ({ +export const BuildListFilter = ({ onFilterChange, initialValues, }: FiltersProps) => { @@ -93,14 +93,14 @@ export const BuildListFilterComponent = ({ className={classes.filtersContent} > - setValues({ ...values, from: date })} /> - setValues({ ...values, to: date })} diff --git a/plugins/xcmetrics/src/components/BuildListFilter/index.ts b/plugins/xcmetrics/src/components/BuildListFilter/index.ts new file mode 100644 index 0000000000..9b599f20c5 --- /dev/null +++ b/plugins/xcmetrics/src/components/BuildListFilter/index.ts @@ -0,0 +1,16 @@ +/* + * Copyright 2021 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 { BuildListFilter } from './BuildListFilter'; diff --git a/plugins/xcmetrics/src/components/BuildTableColumns.tsx b/plugins/xcmetrics/src/components/BuildTableColumns.tsx index a8bfd0166e..0d1141dfae 100644 --- a/plugins/xcmetrics/src/components/BuildTableColumns.tsx +++ b/plugins/xcmetrics/src/components/BuildTableColumns.tsx @@ -19,7 +19,7 @@ import React from 'react'; import { TableColumn } from '@backstage/core-components'; import { Build } from '../api'; import { formatTime, formatDuration } from '../utils'; -import { StatusIconComponent as StatusIcon } from './StatusIconComponent'; +import { StatusIcon } from './StatusIcon'; const baseColumns: TableColumn[] = [ { diff --git a/plugins/xcmetrics/src/components/BuildTimelineComponent/BuildTimelineComponent.test.tsx b/plugins/xcmetrics/src/components/BuildTimeline/BuildTimeline.test.tsx similarity index 77% rename from plugins/xcmetrics/src/components/BuildTimelineComponent/BuildTimelineComponent.test.tsx rename to plugins/xcmetrics/src/components/BuildTimeline/BuildTimeline.test.tsx index 3adb1ede58..bb7e43a43c 100644 --- a/plugins/xcmetrics/src/components/BuildTimelineComponent/BuildTimelineComponent.test.tsx +++ b/plugins/xcmetrics/src/components/BuildTimeline/BuildTimeline.test.tsx @@ -15,19 +15,15 @@ */ import React from 'react'; import { renderInTestApp } from '@backstage/test-utils'; -import { BuildTimelineComponent } from './BuildTimelineComponent'; +import { BuildTimeline } from './BuildTimeline'; jest.mock('../../api/XcmetricsClient'); const client = require('../../api/XcmetricsClient'); -describe('BuildTimelineComponent', () => { +describe('BuildTimeline', () => { it('should render', async () => { const rendered = await renderInTestApp( - , + , ); expect( await rendered.findByText(client.mockTarget.name), @@ -35,9 +31,7 @@ describe('BuildTimelineComponent', () => { }); it('should render a message if no targets are provided', async () => { - const rendered = await renderInTestApp( - , - ); + const rendered = await renderInTestApp(); expect(rendered.getByText('No Targets')).toBeInTheDocument(); }); }); diff --git a/plugins/xcmetrics/src/components/BuildTimelineComponent/BuildTimelineComponent.tsx b/plugins/xcmetrics/src/components/BuildTimeline/BuildTimeline.tsx similarity index 98% rename from plugins/xcmetrics/src/components/BuildTimelineComponent/BuildTimelineComponent.tsx rename to plugins/xcmetrics/src/components/BuildTimeline/BuildTimeline.tsx index 0d0f249a95..f00ee03d56 100644 --- a/plugins/xcmetrics/src/components/BuildTimelineComponent/BuildTimelineComponent.tsx +++ b/plugins/xcmetrics/src/components/BuildTimeline/BuildTimeline.tsx @@ -85,7 +85,7 @@ export interface BuildTimelineProps { width?: number; } -export const BuildTimelineComponent = ({ +export const BuildTimeline = ({ targets, height, width, diff --git a/plugins/xcmetrics/src/components/BuildTimeline/index.ts b/plugins/xcmetrics/src/components/BuildTimeline/index.ts new file mode 100644 index 0000000000..cb8e40a219 --- /dev/null +++ b/plugins/xcmetrics/src/components/BuildTimeline/index.ts @@ -0,0 +1,16 @@ +/* + * Copyright 2021 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 { BuildTimeline } from './BuildTimeline'; diff --git a/plugins/xcmetrics/src/components/BuildTimelineComponent/index.ts b/plugins/xcmetrics/src/components/BuildTimelineComponent/index.ts deleted file mode 100644 index fe294f8467..0000000000 --- a/plugins/xcmetrics/src/components/BuildTimelineComponent/index.ts +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Copyright 2021 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 { BuildTimelineComponent } from './BuildTimelineComponent'; diff --git a/plugins/xcmetrics/src/components/BuildsPage/BuildsPage.test.tsx b/plugins/xcmetrics/src/components/BuildsPage/BuildsPage.test.tsx index 601f3ea6a2..75e31427ae 100644 --- a/plugins/xcmetrics/src/components/BuildsPage/BuildsPage.test.tsx +++ b/plugins/xcmetrics/src/components/BuildsPage/BuildsPage.test.tsx @@ -17,27 +17,27 @@ import React from 'react'; import { renderInTestApp } from '@backstage/test-utils'; import { BuildsPage } from './BuildsPage'; -jest.mock('../BuildDetailsComponent', () => ({ +jest.mock('../BuildDetails', () => ({ withRequest: (component: any) => component, - BuildDetailsComponent: () => 'BuildDetailsComponent', + BuildDetails: () => 'BuildDetails', })); -jest.mock('../BuildListComponent', () => ({ - BuildListComponent: () => 'BuildListComponent', +jest.mock('../BuildList', () => ({ + BuildList: () => 'BuildList', })); -describe('BuildPageComponent', () => { - it('should render BuildDetailsWithDataComponent if build id is provided in path', async () => { +describe('BuildPage', () => { + it('should render BuildDetails if build id is provided in path', async () => { const rendered = await renderInTestApp(, { routeEntries: [`/buildId`], }); - expect(rendered.getByText('BuildDetailsComponent')).toBeInTheDocument(); + expect(rendered.getByText('BuildDetails')).toBeInTheDocument(); }); - it('should render BuildListComponent if no build id is provided in path', async () => { + it('should render BuildList if no build id is provided in path', async () => { const rendered = await renderInTestApp(); - expect(rendered.getByText('BuildListComponent')).toBeInTheDocument(); + expect(rendered.getByText('BuildList')).toBeInTheDocument(); }); }); diff --git a/plugins/xcmetrics/src/components/BuildsPage/BuildsPage.tsx b/plugins/xcmetrics/src/components/BuildsPage/BuildsPage.tsx index ca3f023ff5..152337707d 100644 --- a/plugins/xcmetrics/src/components/BuildsPage/BuildsPage.tsx +++ b/plugins/xcmetrics/src/components/BuildsPage/BuildsPage.tsx @@ -16,22 +16,22 @@ import React from 'react'; import { useRouteRefParams } from '@backstage/core-plugin-api'; import { buildsRouteRef } from '../../routes'; -import { BuildListComponent } from '../BuildListComponent'; -import { BuildDetailsComponent, withRequest } from '../BuildDetailsComponent'; +import { BuildList } from '../BuildList'; +import { BuildDetails, withRequest } from '../BuildDetails'; import { InfoCard } from '@backstage/core-components'; export const BuildsPage = () => { const { '*': buildId } = useRouteRefParams(buildsRouteRef) ?? { '*': '' }; if (buildId) { - const BuildDetails = withRequest(BuildDetailsComponent); + const BuildDetailsWithRequest = withRequest(BuildDetails); return ( - + ); } - return ; + return ; }; diff --git a/plugins/xcmetrics/src/components/DataValueComponent/DataValueComponent.test.tsx b/plugins/xcmetrics/src/components/DataValue/DataValue.test.tsx similarity index 84% rename from plugins/xcmetrics/src/components/DataValueComponent/DataValueComponent.test.tsx rename to plugins/xcmetrics/src/components/DataValue/DataValue.test.tsx index df52d020ee..3422140029 100644 --- a/plugins/xcmetrics/src/components/DataValueComponent/DataValueComponent.test.tsx +++ b/plugins/xcmetrics/src/components/DataValue/DataValue.test.tsx @@ -14,15 +14,15 @@ * limitations under the License. */ import React from 'react'; -import { DataValueComponent, DataValueGridItem } from './DataValueComponent'; +import { DataValue, DataValueGridItem } from './DataValue'; import { renderInTestApp } from '@backstage/test-utils'; -describe('DataValueComponent', () => { +describe('DataValue', () => { it('should render', async () => { const field = 'Field'; const value = 'Value'; const rendered = await renderInTestApp( - , + , ); expect(rendered.getByText(field)).toBeInTheDocument(); expect(rendered.getByText(value)).toBeInTheDocument(); @@ -30,9 +30,7 @@ describe('DataValueComponent', () => { it('should render placeholder text when no value is present', async () => { const field = 'Field'; - const rendered = await renderInTestApp( - , - ); + const rendered = await renderInTestApp(); expect(rendered.getByText(field)).toBeInTheDocument(); expect(rendered.getByText('--')).toBeInTheDocument(); }); diff --git a/plugins/xcmetrics/src/components/DataValueComponent/DataValueComponent.tsx b/plugins/xcmetrics/src/components/DataValue/DataValue.tsx similarity index 91% rename from plugins/xcmetrics/src/components/DataValueComponent/DataValueComponent.tsx rename to plugins/xcmetrics/src/components/DataValue/DataValue.tsx index 35b0331001..78f1cdcaea 100644 --- a/plugins/xcmetrics/src/components/DataValueComponent/DataValueComponent.tsx +++ b/plugins/xcmetrics/src/components/DataValue/DataValue.tsx @@ -21,7 +21,7 @@ interface DataValueProps { value?: string | number | null | undefined; } -export const DataValueComponent = ({ field, value }: DataValueProps) => { +export const DataValue = ({ field, value }: DataValueProps) => { return (
{field} @@ -38,6 +38,6 @@ interface GridProps { export const DataValueGridItem = (props: DataValueProps & GridProps) => ( - + ); diff --git a/plugins/xcmetrics/src/components/DataValue/index.ts b/plugins/xcmetrics/src/components/DataValue/index.ts new file mode 100644 index 0000000000..99658f96b1 --- /dev/null +++ b/plugins/xcmetrics/src/components/DataValue/index.ts @@ -0,0 +1,16 @@ +/* + * Copyright 2021 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 { DataValue, DataValueGridItem } from './DataValue'; diff --git a/plugins/xcmetrics/src/components/DatePickerComponent/DatePickerComponent.test.tsx b/plugins/xcmetrics/src/components/DatePicker/DatePicker.test.tsx similarity index 81% rename from plugins/xcmetrics/src/components/DatePickerComponent/DatePickerComponent.test.tsx rename to plugins/xcmetrics/src/components/DatePicker/DatePicker.test.tsx index 74633fe786..924e83da7e 100644 --- a/plugins/xcmetrics/src/components/DatePickerComponent/DatePickerComponent.test.tsx +++ b/plugins/xcmetrics/src/components/DatePicker/DatePicker.test.tsx @@ -15,15 +15,13 @@ */ import React from 'react'; import { renderInTestApp } from '@backstage/test-utils'; -import { DatePickerComponent } from './DatePickerComponent'; +import { DatePicker } from './DatePicker'; import userEvent from '@testing-library/user-event'; -describe('DatePickerComponent', () => { +describe('DatePicker', () => { it('should render', async () => { const label = 'label'; - const rendered = await renderInTestApp( - , - ); + const rendered = await renderInTestApp(); expect(rendered.getByText(label)).toBeInTheDocument(); }); @@ -31,7 +29,7 @@ describe('DatePickerComponent', () => { const label = 'label'; const callback = jest.fn(); const rendered = await renderInTestApp( - , + , ); const input = rendered.getByLabelText(label); @@ -43,7 +41,7 @@ describe('DatePickerComponent', () => { const label = 'label'; const callback = jest.fn(); const rendered = await renderInTestApp( - , + , ); const input = rendered.getByLabelText(label); diff --git a/plugins/xcmetrics/src/components/DatePickerComponent/DatePickerComponent.tsx b/plugins/xcmetrics/src/components/DatePicker/DatePicker.tsx similarity index 98% rename from plugins/xcmetrics/src/components/DatePickerComponent/DatePickerComponent.tsx rename to plugins/xcmetrics/src/components/DatePicker/DatePicker.tsx index 854fbbd87f..b524243ff7 100644 --- a/plugins/xcmetrics/src/components/DatePickerComponent/DatePickerComponent.tsx +++ b/plugins/xcmetrics/src/components/DatePicker/DatePicker.tsx @@ -63,7 +63,7 @@ interface DatePickerProps { onDateChange?: (date: string) => void; } -export const DatePickerComponent = ({ +export const DatePicker = ({ label, onDateChange, ...inputProps diff --git a/plugins/xcmetrics/src/components/OverviewComponent/index.ts b/plugins/xcmetrics/src/components/DatePicker/index.ts similarity index 93% rename from plugins/xcmetrics/src/components/OverviewComponent/index.ts rename to plugins/xcmetrics/src/components/DatePicker/index.ts index 58b284e6f1..599f24510f 100644 --- a/plugins/xcmetrics/src/components/OverviewComponent/index.ts +++ b/plugins/xcmetrics/src/components/DatePicker/index.ts @@ -13,4 +13,4 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -export * from './OverviewComponent'; +export { DatePicker } from './DatePicker'; diff --git a/plugins/xcmetrics/src/components/OverviewComponent/OverviewComponent.test.tsx b/plugins/xcmetrics/src/components/Overview/Overview.test.tsx similarity index 84% rename from plugins/xcmetrics/src/components/OverviewComponent/OverviewComponent.test.tsx rename to plugins/xcmetrics/src/components/Overview/Overview.test.tsx index fb5ef42cd8..3d24d2a422 100644 --- a/plugins/xcmetrics/src/components/OverviewComponent/OverviewComponent.test.tsx +++ b/plugins/xcmetrics/src/components/Overview/Overview.test.tsx @@ -17,26 +17,26 @@ import React from 'react'; import { renderInTestApp } from '@backstage/test-utils'; import { xcmetricsApiRef } from '../../api'; import { ApiProvider, ApiRegistry } from '@backstage/core-app-api'; -import { OverviewComponent } from './OverviewComponent'; +import { Overview } from './Overview'; jest.mock('../../api/XcmetricsClient'); const client = require('../../api/XcmetricsClient'); -jest.mock('../OverviewTrendsComponent', () => ({ - OverviewTrendsComponent: () => 'OverviewTrendsComponent', +jest.mock('../OverviewTrends', () => ({ + OverviewTrends: () => 'OverviewTrends', })); -jest.mock('../StatusMatrixComponent', () => ({ - StatusMatrixComponent: () => 'StatusMatrixComponent', +jest.mock('../StatusMatrix', () => ({ + StatusMatrix: () => 'StatusMatrix', })); -describe('OverviewComponent', () => { +describe('Overview', () => { it('should render', async () => { const rendered = await renderInTestApp( - + , ); @@ -50,7 +50,7 @@ describe('OverviewComponent', () => { const rendered = await renderInTestApp( - + , ); @@ -65,7 +65,7 @@ describe('OverviewComponent', () => { const rendered = await renderInTestApp( - + , ); diff --git a/plugins/xcmetrics/src/components/OverviewComponent/OverviewComponent.tsx b/plugins/xcmetrics/src/components/Overview/Overview.tsx similarity index 89% rename from plugins/xcmetrics/src/components/OverviewComponent/OverviewComponent.tsx rename to plugins/xcmetrics/src/components/Overview/Overview.tsx index b293c2a99c..e7a9a1d705 100644 --- a/plugins/xcmetrics/src/components/OverviewComponent/OverviewComponent.tsx +++ b/plugins/xcmetrics/src/components/Overview/Overview.tsx @@ -26,12 +26,12 @@ import { useApi } from '@backstage/core-plugin-api'; import { xcmetricsApiRef } from '../../api'; import { useAsync } from 'react-use'; import { Alert } from '@material-ui/lab'; -import { StatusMatrixComponent } from '../StatusMatrixComponent'; +import { StatusMatrix } from '../StatusMatrix'; import { Grid } from '@material-ui/core'; -import { OverviewTrendsComponent } from '../OverviewTrendsComponent'; +import { OverviewTrends } from '../OverviewTrends'; import { overviewColumns } from '../BuildTableColumns'; -export const OverviewComponent = () => { +export const Overview = () => { const client = useApi(xcmetricsApiRef); const { value: builds, @@ -74,14 +74,14 @@ export const OverviewComponent = () => { title={ <> Latest Builds - + } /> - + diff --git a/plugins/xcmetrics/src/components/DataValueComponent/index.ts b/plugins/xcmetrics/src/components/Overview/index.ts similarity index 93% rename from plugins/xcmetrics/src/components/DataValueComponent/index.ts rename to plugins/xcmetrics/src/components/Overview/index.ts index cbf0ffe851..77685905e9 100644 --- a/plugins/xcmetrics/src/components/DataValueComponent/index.ts +++ b/plugins/xcmetrics/src/components/Overview/index.ts @@ -13,4 +13,4 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -export * from './DataValueComponent'; +export { Overview } from './Overview'; diff --git a/plugins/xcmetrics/src/components/OverviewTrendsComponent/OverviewTrendsComponent.test.tsx b/plugins/xcmetrics/src/components/OverviewTrends/OverviewTrends.test.tsx similarity index 91% rename from plugins/xcmetrics/src/components/OverviewTrendsComponent/OverviewTrendsComponent.test.tsx rename to plugins/xcmetrics/src/components/OverviewTrends/OverviewTrends.test.tsx index cb33be1451..76b47f4943 100644 --- a/plugins/xcmetrics/src/components/OverviewTrendsComponent/OverviewTrendsComponent.test.tsx +++ b/plugins/xcmetrics/src/components/OverviewTrends/OverviewTrends.test.tsx @@ -14,7 +14,7 @@ * limitations under the License. */ import React from 'react'; -import { OverviewTrendsComponent } from './OverviewTrendsComponent'; +import { OverviewTrends } from './OverviewTrends'; import { renderInTestApp } from '@backstage/test-utils'; import { xcmetricsApiRef } from '../../api'; import { ApiProvider, ApiRegistry } from '@backstage/core-app-api'; @@ -23,13 +23,13 @@ import userEvent from '@testing-library/user-event'; jest.mock('../../api/XcmetricsClient'); const client = require('../../api/XcmetricsClient'); -describe('OverviewTrendsComponent', () => { +describe('OverviewTrends', () => { it('should render', async () => { const rendered = await renderInTestApp( - + , ); expect(rendered.getByText('Trends for')).toBeInTheDocument(); @@ -43,7 +43,7 @@ describe('OverviewTrendsComponent', () => { const rendered = await renderInTestApp( - + , ); expect(rendered.getByText('--')).toBeInTheDocument(); @@ -54,7 +54,7 @@ describe('OverviewTrendsComponent', () => { - + , ); @@ -77,7 +77,7 @@ describe('OverviewTrendsComponent', () => { const rendered = await renderInTestApp( - + , ); expect(rendered.getByText(buildCountError)).toBeInTheDocument(); diff --git a/plugins/xcmetrics/src/components/OverviewTrendsComponent/OverviewTrendsComponent.tsx b/plugins/xcmetrics/src/components/OverviewTrends/OverviewTrends.tsx similarity index 95% rename from plugins/xcmetrics/src/components/OverviewTrendsComponent/OverviewTrendsComponent.tsx rename to plugins/xcmetrics/src/components/OverviewTrends/OverviewTrends.tsx index 52ac632cc3..8b16d689bb 100644 --- a/plugins/xcmetrics/src/components/OverviewTrendsComponent/OverviewTrendsComponent.tsx +++ b/plugins/xcmetrics/src/components/OverviewTrends/OverviewTrends.tsx @@ -16,12 +16,12 @@ import { Grid, makeStyles, useTheme } from '@material-ui/core'; import React, { useState } from 'react'; import { Progress, Select } from '@backstage/core-components'; -import { TrendComponent } from '../TrendComponent'; +import { Trend } from '../Trend'; import { Alert, AlertTitle } from '@material-ui/lab'; import { xcmetricsApiRef } from '../../api'; import { useAsync } from 'react-use'; import { useApi } from '@backstage/core-plugin-api'; -import { DataValueGridItem } from '../DataValueComponent'; +import { DataValueGridItem } from '../DataValue'; import { formatDuration, formatPercentage, @@ -49,7 +49,7 @@ const DAYS_SELECT_ITEMS = [ { label: '60 days', value: 60 }, ]; -export const OverviewTrendsComponent = () => { +export const OverviewTrends = () => { const [days, setDays] = useState(14); const theme = useTheme(); const classes = useStyles(); @@ -103,17 +103,17 @@ export const OverviewTrendsComponent = () => { )} {(!buildCountsResult.error || !buildTimesResult.error) && (
- e.durationP50, buildTimesResult.value)} /> - - e.builds, buildCountsResult.value)} diff --git a/plugins/xcmetrics/src/components/OverviewTrends/index.ts b/plugins/xcmetrics/src/components/OverviewTrends/index.ts new file mode 100644 index 0000000000..7a3e7e62b9 --- /dev/null +++ b/plugins/xcmetrics/src/components/OverviewTrends/index.ts @@ -0,0 +1,16 @@ +/* + * Copyright 2021 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 { OverviewTrends } from './OverviewTrends'; diff --git a/plugins/xcmetrics/src/components/OverviewTrendsComponent/index.ts b/plugins/xcmetrics/src/components/OverviewTrendsComponent/index.ts deleted file mode 100644 index 778a4bf503..0000000000 --- a/plugins/xcmetrics/src/components/OverviewTrendsComponent/index.ts +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Copyright 2021 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 * from './OverviewTrendsComponent'; diff --git a/plugins/xcmetrics/src/components/PreformattedTextComponent/PreformattedTextComponent.tsx b/plugins/xcmetrics/src/components/PreformattedText/PreformattedText.tsx similarity index 98% rename from plugins/xcmetrics/src/components/PreformattedTextComponent/PreformattedTextComponent.tsx rename to plugins/xcmetrics/src/components/PreformattedText/PreformattedText.tsx index b73e2cead5..c2c3f8ce25 100644 --- a/plugins/xcmetrics/src/components/PreformattedTextComponent/PreformattedTextComponent.tsx +++ b/plugins/xcmetrics/src/components/PreformattedText/PreformattedText.tsx @@ -65,7 +65,7 @@ interface NonExpandableProps extends PreformattedTextProps { title?: string; } -export const PreformattedTextComponent = ({ +export const PreformattedText = ({ text, maxChars, expandable, diff --git a/plugins/xcmetrics/src/components/PreformattedText/index.ts b/plugins/xcmetrics/src/components/PreformattedText/index.ts new file mode 100644 index 0000000000..9a03d821b2 --- /dev/null +++ b/plugins/xcmetrics/src/components/PreformattedText/index.ts @@ -0,0 +1,16 @@ +/* + * Copyright 2021 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 { PreformattedText } from './PreformattedText'; diff --git a/plugins/xcmetrics/src/components/PreformattedTextComponent/index.ts b/plugins/xcmetrics/src/components/PreformattedTextComponent/index.ts deleted file mode 100644 index dbc27dd869..0000000000 --- a/plugins/xcmetrics/src/components/PreformattedTextComponent/index.ts +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Copyright 2021 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 { PreformattedTextComponent } from './PreformattedTextComponent'; diff --git a/plugins/xcmetrics/src/components/StatusCellComponent/StatusCellComponent.test.tsx b/plugins/xcmetrics/src/components/StatusCell/StatusCell.test.tsx similarity index 93% rename from plugins/xcmetrics/src/components/StatusCellComponent/StatusCellComponent.test.tsx rename to plugins/xcmetrics/src/components/StatusCell/StatusCell.test.tsx index 6ee832ceb8..cac111d13e 100644 --- a/plugins/xcmetrics/src/components/StatusCellComponent/StatusCellComponent.test.tsx +++ b/plugins/xcmetrics/src/components/StatusCell/StatusCell.test.tsx @@ -17,20 +17,20 @@ import React from 'react'; import { renderInTestApp } from '@backstage/test-utils'; import { ApiProvider, ApiRegistry } from '@backstage/core-app-api'; import userEvent from '@testing-library/user-event'; -import { StatusCellComponent } from './StatusCellComponent'; +import { StatusCell } from './StatusCell'; import { xcmetricsApiRef } from '../../api'; import { formatDuration, formatStatus } from '../../utils'; jest.mock('../../api/XcmetricsClient'); const client = require('../../api/XcmetricsClient'); -describe('StatusCellComponent', () => { +describe('StatusCell', () => { it('should render', async () => { const rendered = await renderInTestApp( - (theme => ({ } as StatusStyle), })); -export const StatusCellComponent = (props: StatusCellProps) => { +export const StatusCell = (props: StatusCellProps) => { const classes = useStyles(props); const { buildStatus } = props; diff --git a/plugins/xcmetrics/src/components/StatusCell/index.ts b/plugins/xcmetrics/src/components/StatusCell/index.ts new file mode 100644 index 0000000000..60008aeacf --- /dev/null +++ b/plugins/xcmetrics/src/components/StatusCell/index.ts @@ -0,0 +1,16 @@ +/* + * Copyright 2021 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 { StatusCell } from './StatusCell'; diff --git a/plugins/xcmetrics/src/components/StatusCellComponent/index.ts b/plugins/xcmetrics/src/components/StatusCellComponent/index.ts deleted file mode 100644 index e1d4f81e34..0000000000 --- a/plugins/xcmetrics/src/components/StatusCellComponent/index.ts +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Copyright 2021 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 * from './StatusCellComponent'; diff --git a/plugins/xcmetrics/src/components/StatusIconComponent/StatusIconComponent.test.tsx b/plugins/xcmetrics/src/components/StatusIcon/StatusIcon.test.tsx similarity index 74% rename from plugins/xcmetrics/src/components/StatusIconComponent/StatusIconComponent.test.tsx rename to plugins/xcmetrics/src/components/StatusIcon/StatusIcon.test.tsx index 8833d828f0..a208432f59 100644 --- a/plugins/xcmetrics/src/components/StatusIconComponent/StatusIconComponent.test.tsx +++ b/plugins/xcmetrics/src/components/StatusIcon/StatusIcon.test.tsx @@ -16,23 +16,19 @@ import React from 'react'; import { renderInTestApp } from '@backstage/test-utils'; -import { StatusIconComponent } from './StatusIconComponent'; +import { StatusIcon } from './StatusIcon'; -describe('StatusIconComponent', () => { +describe('StatusIcon', () => { it('should render', async () => { let rendered = await renderInTestApp( - , + , ); expect(rendered.getByLabelText('Status ok')).toBeInTheDocument(); - rendered = await renderInTestApp( - , - ); + rendered = await renderInTestApp(); expect(rendered.getByLabelText('Status error')).toBeInTheDocument(); - rendered = await renderInTestApp( - , - ); + rendered = await renderInTestApp(); expect(rendered.getByLabelText('Status warning')).toBeInTheDocument(); }); }); diff --git a/plugins/xcmetrics/src/components/StatusIconComponent/StatusIconComponent.tsx b/plugins/xcmetrics/src/components/StatusIcon/StatusIcon.tsx similarity index 93% rename from plugins/xcmetrics/src/components/StatusIconComponent/StatusIconComponent.tsx rename to plugins/xcmetrics/src/components/StatusIcon/StatusIcon.tsx index f680003ff4..610575b817 100644 --- a/plugins/xcmetrics/src/components/StatusIconComponent/StatusIconComponent.tsx +++ b/plugins/xcmetrics/src/components/StatusIcon/StatusIcon.tsx @@ -31,5 +31,5 @@ interface StatusIconProps { buildStatus: BuildStatus; } -export const StatusIconComponent = ({ buildStatus }: StatusIconProps) => +export const StatusIcon = ({ buildStatus }: StatusIconProps) => STATUS_ICONS[buildStatus]; diff --git a/plugins/xcmetrics/src/components/StatusIcon/index.ts b/plugins/xcmetrics/src/components/StatusIcon/index.ts new file mode 100644 index 0000000000..597caaca89 --- /dev/null +++ b/plugins/xcmetrics/src/components/StatusIcon/index.ts @@ -0,0 +1,16 @@ +/* + * Copyright 2021 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 { StatusIcon } from './StatusIcon'; diff --git a/plugins/xcmetrics/src/components/StatusIconComponent/index.ts b/plugins/xcmetrics/src/components/StatusIconComponent/index.ts deleted file mode 100644 index b69415bd78..0000000000 --- a/plugins/xcmetrics/src/components/StatusIconComponent/index.ts +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Copyright 2021 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 { StatusIconComponent } from './StatusIconComponent'; diff --git a/plugins/xcmetrics/src/components/StatusMatrixComponent/StatusMatrixComponent.test.tsx b/plugins/xcmetrics/src/components/StatusMatrix/StatusMatrix.test.tsx similarity index 89% rename from plugins/xcmetrics/src/components/StatusMatrixComponent/StatusMatrixComponent.test.tsx rename to plugins/xcmetrics/src/components/StatusMatrix/StatusMatrix.test.tsx index aac029a919..7d3854bbda 100644 --- a/plugins/xcmetrics/src/components/StatusMatrixComponent/StatusMatrixComponent.test.tsx +++ b/plugins/xcmetrics/src/components/StatusMatrix/StatusMatrix.test.tsx @@ -16,19 +16,19 @@ import React from 'react'; import { renderInTestApp } from '@backstage/test-utils'; import { ApiProvider, ApiRegistry } from '@backstage/core-app-api'; -import { StatusMatrixComponent } from './StatusMatrixComponent'; +import { StatusMatrix } from './StatusMatrix'; import { xcmetricsApiRef } from '../../api'; jest.mock('../../api/XcmetricsClient'); const client = require('../../api/XcmetricsClient'); -describe('StatusMatrixComponent', () => { +describe('StatusMatrix', () => { it('should render', async () => { const rendered = await renderInTestApp( - + , ); diff --git a/plugins/xcmetrics/src/components/StatusMatrixComponent/StatusMatrixComponent.tsx b/plugins/xcmetrics/src/components/StatusMatrix/StatusMatrix.tsx similarity index 89% rename from plugins/xcmetrics/src/components/StatusMatrixComponent/StatusMatrixComponent.tsx rename to plugins/xcmetrics/src/components/StatusMatrix/StatusMatrix.tsx index 503c0b7ed4..e7f3294e6d 100644 --- a/plugins/xcmetrics/src/components/StatusMatrixComponent/StatusMatrixComponent.tsx +++ b/plugins/xcmetrics/src/components/StatusMatrix/StatusMatrix.tsx @@ -21,7 +21,7 @@ import { useAsync, useMeasure } from 'react-use'; import { cn } from '../../utils'; import { useApi } from '@backstage/core-plugin-api'; import { Alert } from '@material-ui/lab'; -import { StatusCellComponent } from '../StatusCellComponent'; +import { StatusCell } from '../StatusCell'; const CELL_SIZE = 12; const CELL_MARGIN = 4; @@ -44,7 +44,7 @@ const useStyles = makeStyles(theme => ({ }, })); -export const StatusMatrixComponent = () => { +export const StatusMatrix = () => { const classes = useStyles(); const [measureRef, { width: rootWidth }] = useMeasure(); const client = useApi(xcmetricsApiRef); @@ -68,11 +68,7 @@ export const StatusMatrixComponent = () => { {loading && [...new Array(cols * MAX_ROWS)].map((_, index) => { return ( - + ); })} @@ -80,7 +76,7 @@ export const StatusMatrixComponent = () => { builds .slice(0, cols * MAX_ROWS) .map((buildStatus, index) => ( - { +describe('Trend', () => { it('should render', async () => { const data = [1, 2, 3, 4]; const title = 'testTitle'; const rendered = await renderInTestApp( - , + , ); expect(rendered.findAllByText('testTitle')).toBeTruthy(); }); @@ -30,7 +30,7 @@ describe('TrendComponent', () => { it('should render empty state', async () => { const title = 'testTitle'; const rendered = await renderInTestApp( - , + , ); expect(rendered.findAllByText('testTitle')).toBeTruthy(); }); diff --git a/plugins/xcmetrics/src/components/TrendComponent/TrendComponent.tsx b/plugins/xcmetrics/src/components/Trend/Trend.tsx similarity index 93% rename from plugins/xcmetrics/src/components/TrendComponent/TrendComponent.tsx rename to plugins/xcmetrics/src/components/Trend/Trend.tsx index ece6acfd6c..575872e813 100644 --- a/plugins/xcmetrics/src/components/TrendComponent/TrendComponent.tsx +++ b/plugins/xcmetrics/src/components/Trend/Trend.tsx @@ -23,7 +23,7 @@ interface TrendProps { color: string; } -export const TrendComponent = ({ data, title, color }: TrendProps) => { +export const Trend = ({ data, title, color }: TrendProps) => { const emptyData = [0, 0]; const max = Math.max(...(data ?? emptyData)); diff --git a/plugins/xcmetrics/src/components/TrendComponent/index.ts b/plugins/xcmetrics/src/components/Trend/index.ts similarity index 94% rename from plugins/xcmetrics/src/components/TrendComponent/index.ts rename to plugins/xcmetrics/src/components/Trend/index.ts index 69dce3ff7f..5e32e2fe3c 100644 --- a/plugins/xcmetrics/src/components/TrendComponent/index.ts +++ b/plugins/xcmetrics/src/components/Trend/index.ts @@ -13,4 +13,4 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -export * from './TrendComponent'; +export { Trend } from './Trend'; diff --git a/plugins/xcmetrics/src/components/XcmetricsLayout/XcmetricsLayout.test.tsx b/plugins/xcmetrics/src/components/XcmetricsLayout/XcmetricsLayout.test.tsx index b0d81757a9..84bd25624c 100644 --- a/plugins/xcmetrics/src/components/XcmetricsLayout/XcmetricsLayout.test.tsx +++ b/plugins/xcmetrics/src/components/XcmetricsLayout/XcmetricsLayout.test.tsx @@ -23,12 +23,12 @@ import userEvent from '@testing-library/user-event'; jest.mock('../../api/XcmetricsClient'); const client = require('../../api/XcmetricsClient'); -jest.mock('../OverviewComponent', () => ({ - OverviewComponent: () => 'OverviewComponent', +jest.mock('../Overview', () => ({ + Overview: () => 'OverviewComponent', })); -jest.mock('../BuildListComponent', () => ({ - BuildListComponent: () => 'BuildListComponent', +jest.mock('../BuildList', () => ({ + BuildList: () => 'BuildList', })); describe('XcmetricsLayout', () => { @@ -45,7 +45,18 @@ describe('XcmetricsLayout', () => { expect(rendered.getByText('Builds')).toBeInTheDocument(); expect(rendered.getByText('OverviewComponent')).toBeInTheDocument(); + }); + + it('should show a list of builds when the Builds tab is selected', async () => { + const rendered = await renderInTestApp( + + + , + ); + userEvent.click(rendered.getByText('Builds')); - expect(await rendered.findByText('BuildListComponent')).toBeInTheDocument(); + expect(await rendered.findByText('BuildList')).toBeInTheDocument(); }); }); diff --git a/plugins/xcmetrics/src/components/XcmetricsLayout/XcmetricsLayout.tsx b/plugins/xcmetrics/src/components/XcmetricsLayout/XcmetricsLayout.tsx index 33e9d64c6b..53545890a4 100644 --- a/plugins/xcmetrics/src/components/XcmetricsLayout/XcmetricsLayout.tsx +++ b/plugins/xcmetrics/src/components/XcmetricsLayout/XcmetricsLayout.tsx @@ -21,7 +21,7 @@ import { Page, TabbedLayout, } from '@backstage/core-components'; -import { OverviewComponent } from '../OverviewComponent'; +import { Overview } from '../Overview'; import { buildsRouteRef, rootRouteRef } from '../../routes'; import { RouteRef, SubRouteRef } from '@backstage/core-plugin-api'; import { BuildsPage } from '../BuildsPage'; @@ -36,7 +36,7 @@ const TABS: TabConfig[] = [ { routeRef: rootRouteRef, title: 'Overview', - component: , + component: , }, { routeRef: buildsRouteRef, diff --git a/plugins/xcmetrics/src/components/XcmetricsLayout/index.ts b/plugins/xcmetrics/src/components/XcmetricsLayout/index.ts index eaaadcbaea..aa7cd4b8dc 100644 --- a/plugins/xcmetrics/src/components/XcmetricsLayout/index.ts +++ b/plugins/xcmetrics/src/components/XcmetricsLayout/index.ts @@ -13,4 +13,4 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -export * from './XcmetricsLayout'; +export { XcmetricsLayout } from './XcmetricsLayout';