From 5b85cc1595ddf6ba4dcd9e60d21f6f5569d61fc7 Mon Sep 17 00:00:00 2001 From: pamelin Date: Thu, 16 Feb 2023 10:03:18 +0000 Subject: [PATCH] fix: update case of StackStrom to Stackstorm or stackstorm where necessary Signed-off-by: pamelin --- plugins/stackstorm/src/api/StackStormClient.test.ts | 8 ++++---- plugins/stackstorm/src/api/StackStormClient.ts | 4 ++-- plugins/stackstorm/src/api/index.ts | 6 +++--- plugins/stackstorm/src/api/types.ts | 4 ++-- .../src/components/ActionsList/ActionsList.test.tsx | 8 ++++---- .../src/components/ActionsList/ActionsList.tsx | 6 +++--- .../ExecutionsTable/ExecutionPanel.test.tsx | 6 +++--- .../components/ExecutionsTable/ExecutionPanel.tsx | 4 ++-- .../ExecutionsTable/ExecutionsTable.test.tsx | 6 +++--- .../components/ExecutionsTable/ExecutionsTable.tsx | 4 ++-- .../src/components/PacksTable/PacksTable.test.tsx | 6 +++--- .../src/components/PacksTable/PacksTable.tsx | 4 ++-- .../StackStormHome/StackStormHome.test.tsx | 12 ++++++------ .../src/components/StackStormHome/StackStormHome.tsx | 2 +- .../src/components/StackStormHome/index.ts | 2 +- plugins/stackstorm/src/plugin.ts | 9 ++++----- 16 files changed, 45 insertions(+), 46 deletions(-) diff --git a/plugins/stackstorm/src/api/StackStormClient.test.ts b/plugins/stackstorm/src/api/StackStormClient.test.ts index 24400e3174..4a3e4cb79b 100644 --- a/plugins/stackstorm/src/api/StackStormClient.test.ts +++ b/plugins/stackstorm/src/api/StackStormClient.test.ts @@ -17,7 +17,7 @@ import { UrlPatternDiscovery } from '@backstage/core-app-api'; import { setupRequestMockHandlers } from '@backstage/test-utils'; import { rest } from 'msw'; import { setupServer } from 'msw/node'; -import { StackStormClient } from './StackStormClient'; +import { StackstormClient } from './StackstormClient'; import { Action, Execution, Pack } from './types'; const server = setupServer(); @@ -148,12 +148,12 @@ const identityApiMock = () => ({ getCredentials: jest.fn().mockResolvedValue({ token: undefined }), }); -describe('StackStormClient', () => { +describe('StackstormClient', () => { setupRequestMockHandlers(server); const mockBaseUrl = 'http://backstage:9191/api/proxy'; const discoveryApi = UrlPatternDiscovery.compile(mockBaseUrl); - let client: StackStormClient; + let client: StackstormClient; const setupHandlers = () => { server.use( @@ -184,7 +184,7 @@ describe('StackStormClient', () => { beforeEach(() => { setupHandlers(); - client = new StackStormClient({ + client = new StackstormClient({ discoveryApi: discoveryApi, identityApi: identityApiMock(), }); diff --git a/plugins/stackstorm/src/api/StackStormClient.ts b/plugins/stackstorm/src/api/StackStormClient.ts index c93901ce43..5fa862dc5a 100644 --- a/plugins/stackstorm/src/api/StackStormClient.ts +++ b/plugins/stackstorm/src/api/StackStormClient.ts @@ -13,10 +13,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { Action, Execution, Pack, StackStormApi } from './types'; +import { Action, Execution, Pack, StackstormApi } from './types'; import { DiscoveryApi, IdentityApi } from '@backstage/core-plugin-api'; -export class StackStormClient implements StackStormApi { +export class StackstormClient implements StackstormApi { private readonly discoveryApi: DiscoveryApi; private readonly identityApi: IdentityApi; diff --git a/plugins/stackstorm/src/api/index.ts b/plugins/stackstorm/src/api/index.ts index 2291fb1f73..0ce652e27b 100644 --- a/plugins/stackstorm/src/api/index.ts +++ b/plugins/stackstorm/src/api/index.ts @@ -13,12 +13,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -export { stackStormApiRef } from './types'; +export { stackstormApiRef } from './types'; export type { Action, Execution, ExecutionLog, Pack, - StackStormApi, + StackstormApi, } from './types'; -export { StackStormClient } from './StackStormClient'; +export { StackstormClient } from './StackstormClient'; diff --git a/plugins/stackstorm/src/api/types.ts b/plugins/stackstorm/src/api/types.ts index 13c92fb055..401f79c9b6 100644 --- a/plugins/stackstorm/src/api/types.ts +++ b/plugins/stackstorm/src/api/types.ts @@ -15,7 +15,7 @@ */ import { createApiRef } from '@backstage/core-plugin-api'; -export const stackStormApiRef = createApiRef({ +export const stackstormApiRef = createApiRef({ id: 'plugin.stackstorm.service', }); @@ -51,7 +51,7 @@ export type Pack = { version: string; }; -export interface StackStormApi { +export interface StackstormApi { getExecutions(limit: number, offset: number): Promise; getExecution(id: string): Promise; getPacks(): Promise; diff --git a/plugins/stackstorm/src/components/ActionsList/ActionsList.test.tsx b/plugins/stackstorm/src/components/ActionsList/ActionsList.test.tsx index b59d2f4132..5876860c54 100644 --- a/plugins/stackstorm/src/components/ActionsList/ActionsList.test.tsx +++ b/plugins/stackstorm/src/components/ActionsList/ActionsList.test.tsx @@ -15,7 +15,7 @@ */ import { renderInTestApp, TestApiProvider } from '@backstage/test-utils'; import React from 'react'; -import { Action, Pack, StackStormApi, stackStormApiRef } from '../../api'; +import { Action, Pack, StackstormApi, stackstormApiRef } from '../../api'; import { ActionsList, PackListItem } from './ActionsList'; const packs: Pack[] = [ @@ -53,14 +53,14 @@ const actions: Action[] = [ ]; describe('ActionsList', () => { - const mockApi: jest.Mocked = { + const mockApi: jest.Mocked = { getPacks: jest.fn().mockResolvedValue(packs), getActions: jest.fn().mockResolvedValue(actions), } as any; it('should render all packs', async () => { const { getByText } = await renderInTestApp( - + , ); @@ -73,7 +73,7 @@ describe('ActionsList', () => { it('should render all pack actions', async () => { const { getByText } = await renderInTestApp( - + {}} /> , ); diff --git a/plugins/stackstorm/src/components/ActionsList/ActionsList.tsx b/plugins/stackstorm/src/components/ActionsList/ActionsList.tsx index 47e328716f..e792a4f6d2 100644 --- a/plugins/stackstorm/src/components/ActionsList/ActionsList.tsx +++ b/plugins/stackstorm/src/components/ActionsList/ActionsList.tsx @@ -29,7 +29,7 @@ import { makeStyles } from '@material-ui/core/styles'; import ExpandMore from '@material-ui/icons/ExpandMore'; import ExpandLess from '@material-ui/icons/ExpandLess'; import { Alert } from '@material-ui/lab'; -import { Action, Pack, stackStormApiRef } from '../../api'; +import { Action, Pack, stackstormApiRef } from '../../api'; const useStyles = makeStyles(theme => ({ root: { @@ -54,7 +54,7 @@ type ActionItemsProps = { export const ActionItems = ({ pack }: ActionItemsProps) => { const classes = useStyles(); - const st2 = useApi(stackStormApiRef); + const st2 = useApi(stackstormApiRef); const config = useApi(configApiRef); const { value, loading, error } = useAsync(async (): Promise => { @@ -120,7 +120,7 @@ export const PackListItem = ({ pack, opened, onClick }: PackListItemProps) => { }; export const ActionsList = () => { - const st2 = useApi(stackStormApiRef); + const st2 = useApi(stackstormApiRef); const classes = useStyles(); const [expanded, setExpanded] = useState([]); diff --git a/plugins/stackstorm/src/components/ExecutionsTable/ExecutionPanel.test.tsx b/plugins/stackstorm/src/components/ExecutionsTable/ExecutionPanel.test.tsx index 51adbe0371..442151ebc1 100644 --- a/plugins/stackstorm/src/components/ExecutionsTable/ExecutionPanel.test.tsx +++ b/plugins/stackstorm/src/components/ExecutionsTable/ExecutionPanel.test.tsx @@ -20,7 +20,7 @@ import { TestApiProvider, } from '@backstage/test-utils'; import React from 'react'; -import { Execution, StackStormApi, stackStormApiRef } from '../../api'; +import { Execution, StackstormApi, stackstormApiRef } from '../../api'; import { ExecutionPanel } from './ExecutionPanel'; const execution: Execution = { @@ -52,7 +52,7 @@ const execution: Execution = { }; describe('ExecutionPanel', () => { - const mockApi: jest.Mocked = { + const mockApi: jest.Mocked = { getExecution: jest.fn().mockResolvedValue(execution), } as any; @@ -60,7 +60,7 @@ describe('ExecutionPanel', () => { const { getByText } = await renderInTestApp( { }; export const ExecutionPanel = ({ id }: { id: string }) => { - const st2 = useApi(stackStormApiRef); + const st2 = useApi(stackstormApiRef); const { value, loading, error } = useAsync(async (): Promise => { const data = await st2.getExecution(id); diff --git a/plugins/stackstorm/src/components/ExecutionsTable/ExecutionsTable.test.tsx b/plugins/stackstorm/src/components/ExecutionsTable/ExecutionsTable.test.tsx index dc2bfa4db8..b53d3a2f5f 100644 --- a/plugins/stackstorm/src/components/ExecutionsTable/ExecutionsTable.test.tsx +++ b/plugins/stackstorm/src/components/ExecutionsTable/ExecutionsTable.test.tsx @@ -20,7 +20,7 @@ import { TestApiProvider, } from '@backstage/test-utils'; import React from 'react'; -import { Execution, StackStormApi, stackStormApiRef } from '../../api'; +import { Execution, StackstormApi, stackstormApiRef } from '../../api'; import { ExecutionsTable } from './ExecutionsTable'; const executions: Execution[] = [ @@ -81,7 +81,7 @@ const executions: Execution[] = [ ]; describe('ExecutionsTable', () => { - const mockApi: jest.Mocked = { + const mockApi: jest.Mocked = { getExecutions: jest.fn().mockResolvedValue(executions), } as any; @@ -89,7 +89,7 @@ describe('ExecutionsTable', () => { const { getByText } = await renderInTestApp( { - const st2 = useApi(stackStormApiRef); + const st2 = useApi(stackstormApiRef); const errorApi = useApi(errorApiRef); const [page, setPage] = useState(0); const [rowsPerPage, setRowsPerPage] = useState(10); diff --git a/plugins/stackstorm/src/components/PacksTable/PacksTable.test.tsx b/plugins/stackstorm/src/components/PacksTable/PacksTable.test.tsx index b45d460068..9de17e2f14 100644 --- a/plugins/stackstorm/src/components/PacksTable/PacksTable.test.tsx +++ b/plugins/stackstorm/src/components/PacksTable/PacksTable.test.tsx @@ -15,7 +15,7 @@ */ import { renderInTestApp, TestApiProvider } from '@backstage/test-utils'; import React from 'react'; -import { Pack, StackStormApi, stackStormApiRef } from '../../api'; +import { Pack, StackstormApi, stackstormApiRef } from '../../api'; import { PacksTable } from './PacksTable'; const packs: Pack[] = [ @@ -32,13 +32,13 @@ const packs: Pack[] = [ ]; describe('PacksTable', () => { - const mockApi: jest.Mocked = { + const mockApi: jest.Mocked = { getPacks: jest.fn().mockResolvedValue(packs), } as any; it('should render all packs', async () => { const { getByText } = await renderInTestApp( - + , ); diff --git a/plugins/stackstorm/src/components/PacksTable/PacksTable.tsx b/plugins/stackstorm/src/components/PacksTable/PacksTable.tsx index b150aeec4d..ebb5e8a14e 100644 --- a/plugins/stackstorm/src/components/PacksTable/PacksTable.tsx +++ b/plugins/stackstorm/src/components/PacksTable/PacksTable.tsx @@ -18,7 +18,7 @@ import { Progress, Table, TableColumn } from '@backstage/core-components'; import { Alert } from '@material-ui/lab'; import useAsync from 'react-use/lib/useAsync'; import { useApi } from '@backstage/core-plugin-api'; -import { Pack, stackStormApiRef } from '../../api'; +import { Pack, stackstormApiRef } from '../../api'; type DenseTableProps = { packs: Pack[]; @@ -42,7 +42,7 @@ export const DenseTable = ({ packs }: DenseTableProps) => { }; export const PacksTable = () => { - const st2 = useApi(stackStormApiRef); + const st2 = useApi(stackstormApiRef); const { value, loading, error } = useAsync(async (): Promise => { const data = await st2.getPacks(); diff --git a/plugins/stackstorm/src/components/StackStormHome/StackStormHome.test.tsx b/plugins/stackstorm/src/components/StackStormHome/StackStormHome.test.tsx index 6249fa71e8..897cec61c1 100644 --- a/plugins/stackstorm/src/components/StackStormHome/StackStormHome.test.tsx +++ b/plugins/stackstorm/src/components/StackStormHome/StackStormHome.test.tsx @@ -14,13 +14,13 @@ * limitations under the License. */ import React from 'react'; -import { StackStormHome } from './StackStormHome'; +import { StackstormHome } from './StackstormHome'; import { screen } from '@testing-library/react'; import { renderInTestApp, TestApiProvider } from '@backstage/test-utils'; -import { StackStormApi, stackStormApiRef } from '../../api'; +import { StackstormApi, stackstormApiRef } from '../../api'; -describe('StackStormHome', () => { - const mockApi: jest.Mocked = { +describe('StackstormHome', () => { + const mockApi: jest.Mocked = { getExecutions: jest.fn().mockResolvedValue([]), getExecution: jest.fn().mockResolvedValue({}), getPacks: jest.fn().mockResolvedValue([]), @@ -29,8 +29,8 @@ describe('StackStormHome', () => { it('should render', async () => { await renderInTestApp( - - + + , ); expect(screen.getByText('Welcome to StackStorm!')).toBeInTheDocument(); diff --git a/plugins/stackstorm/src/components/StackStormHome/StackStormHome.tsx b/plugins/stackstorm/src/components/StackStormHome/StackStormHome.tsx index d3065ff2e5..d96d45e82d 100644 --- a/plugins/stackstorm/src/components/StackStormHome/StackStormHome.tsx +++ b/plugins/stackstorm/src/components/StackStormHome/StackStormHome.tsx @@ -27,7 +27,7 @@ import { ExecutionsTable } from '../ExecutionsTable'; import { PacksTable } from '../PacksTable/PacksTable'; import { ActionsList } from '../ActionsList'; -export const StackStormHome = () => ( +export const StackstormHome = () => (
diff --git a/plugins/stackstorm/src/components/StackStormHome/index.ts b/plugins/stackstorm/src/components/StackStormHome/index.ts index 27c6db48ab..2063d21f34 100644 --- a/plugins/stackstorm/src/components/StackStormHome/index.ts +++ b/plugins/stackstorm/src/components/StackStormHome/index.ts @@ -13,4 +13,4 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -export { StackStormHome } from './StackStormHome'; +export { StackstormHome } from './StackstormHome'; diff --git a/plugins/stackstorm/src/plugin.ts b/plugins/stackstorm/src/plugin.ts index 74df4a0b66..6f36e4fc7f 100644 --- a/plugins/stackstorm/src/plugin.ts +++ b/plugins/stackstorm/src/plugin.ts @@ -21,8 +21,7 @@ import { discoveryApiRef, identityApiRef, } from '@backstage/core-plugin-api'; -import { stackStormApiRef, StackStormClient } from './api'; - +import { stackstormApiRef, StackstormClient } from './api'; import { rootRouteRef } from './routes'; /** @@ -34,13 +33,13 @@ export const stackstormPlugin = createPlugin({ id: 'stackstorm', apis: [ createApiFactory({ - api: stackStormApiRef, + api: stackstormApiRef, deps: { discoveryApi: discoveryApiRef, identityApi: identityApiRef, }, factory: ({ discoveryApi, identityApi }) => - new StackStormClient({ + new StackstormClient({ discoveryApi, identityApi, }), @@ -60,7 +59,7 @@ export const StackstormPage = stackstormPlugin.provide( createRoutableExtension({ name: 'StackstormPage', component: () => - import('./components/StackStormHome').then(m => m.StackStormHome), + import('./components/StackstormHome').then(m => m.StackstormHome), mountPoint: rootRouteRef, }), );