From 963648eeb72d50a9d1ec05c7f7ea950d6a2fc6c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20Adel=C3=B6w?= Date: Sun, 28 Jun 2020 20:48:11 +0200 Subject: [PATCH] Address comments --- packages/core/src/layout/HeaderTabs/index.tsx | 6 +++--- .../components/CatalogTable/CatalogTable.test.tsx | 12 +++++------- .../src/components/CatalogTable/CatalogTable.tsx | 13 +++++++++---- 3 files changed, 17 insertions(+), 14 deletions(-) diff --git a/packages/core/src/layout/HeaderTabs/index.tsx b/packages/core/src/layout/HeaderTabs/index.tsx index 35e952a10e..838b126569 100644 --- a/packages/core/src/layout/HeaderTabs/index.tsx +++ b/packages/core/src/layout/HeaderTabs/index.tsx @@ -47,12 +47,12 @@ export const HeaderTabs: React.FC<{ tabs: Tab[]; onChange?: (index: number) => void; }> = ({ tabs, onChange }) => { - const [selectedTab, setSelectedTab] = useState(0); + const [selectedTab, setSelectedTab] = useState(0); const styles = useStyles(); - const handleChange = (_: React.ChangeEvent<{}>, index: Number) => { + const handleChange = (_: React.ChangeEvent<{}>, index: number) => { setSelectedTab(index); - if (onChange) onChange(index.valueOf()); + if (onChange) onChange(index); }; return ( diff --git a/plugins/catalog/src/components/CatalogTable/CatalogTable.test.tsx b/plugins/catalog/src/components/CatalogTable/CatalogTable.test.tsx index 64d55ad2ed..707213f3bb 100644 --- a/plugins/catalog/src/components/CatalogTable/CatalogTable.test.tsx +++ b/plugins/catalog/src/components/CatalogTable/CatalogTable.test.tsx @@ -16,7 +16,7 @@ import { Entity } from '@backstage/catalog-model'; import { wrapInTestApp } from '@backstage/test-utils'; -import { render, waitFor } from '@testing-library/react'; +import { render } from '@testing-library/react'; import * as React from 'react'; import { CatalogTable } from './CatalogTable'; @@ -66,11 +66,9 @@ describe('CatalogTable component', () => { />, ), ); - waitFor(() => { - expect(rendered.queryByText(/Owned \(3\)/)).toBeInTheDocument(); - expect(rendered.queryByText(/component1/)).toBeInTheDocument(); - expect(rendered.queryByText(/component2/)).toBeInTheDocument(); - expect(rendered.queryByText(/component3/)).toBeInTheDocument(); - }); + expect(rendered.getByText(/Owned \(3\)/)).toBeInTheDocument(); + expect(rendered.getByText(/component1/)).toBeInTheDocument(); + expect(rendered.getByText(/component2/)).toBeInTheDocument(); + expect(rendered.getByText(/component3/)).toBeInTheDocument(); }); }); diff --git a/plugins/catalog/src/components/CatalogTable/CatalogTable.tsx b/plugins/catalog/src/components/CatalogTable/CatalogTable.tsx index d47d8b54c6..b507b96f05 100644 --- a/plugins/catalog/src/components/CatalogTable/CatalogTable.tsx +++ b/plugins/catalog/src/components/CatalogTable/CatalogTable.tsx @@ -92,7 +92,7 @@ export const CatalogTable = ({ (rowData: Entity) => { const location = findLocationForEntityMeta(rowData.metadata); return { - icon: GitHub, + icon: () => , tooltip: 'View on GitHub', onClick: () => { if (!location) return; @@ -112,9 +112,8 @@ export const CatalogTable = ({ }; const location = findLocationForEntityMeta(rowData.metadata); return { - icon: Edit, + icon: () => , tooltip: 'Edit', - // iconProps: { size: 'small' }, onClick: () => { if (!location) return; window.open(createEditLink(location), '_blank'); @@ -125,7 +124,13 @@ export const CatalogTable = ({ (rowData: Entity) => { const isStarred = isStarredEntity(rowData); return { - icon: isStarred ? () => : StarOutline, + cellStyle: { paddingLeft: '1em' }, + icon: () => + isStarred ? ( + + ) : ( + + ), tooltip: isStarred ? 'Remove from favorites' : 'Add to favorites', onClick: () => toggleStarredEntity(rowData), };