chore: some more migrations and deprecations
Signed-off-by: blam <ben@blam.sh>
This commit is contained in:
@@ -62,7 +62,9 @@ describe('api', () => {
|
||||
'dev.azure.com',
|
||||
'bitbucket.org',
|
||||
];
|
||||
const integrations = await apiClient.getIntegrationsList({ allowedHosts });
|
||||
const { integrations } = await apiClient.getIntegrationsList({
|
||||
allowedHosts,
|
||||
});
|
||||
integrations.forEach(integration =>
|
||||
expect(allowedHosts).toContain(integration.host),
|
||||
);
|
||||
|
||||
@@ -35,6 +35,7 @@ import {
|
||||
ScaffolderStreamLogsOptions,
|
||||
ScaffolderGetIntegrationsListOptions,
|
||||
ScaffolderGetIntegrationsListResponse,
|
||||
ScaffolderTask,
|
||||
} from './types';
|
||||
|
||||
/**
|
||||
@@ -142,7 +143,7 @@ export class ScaffolderClient implements ScaffolderApi {
|
||||
return { jobId: id };
|
||||
}
|
||||
|
||||
async getTask(taskId: string) {
|
||||
async getTask(taskId: string): Promise<ScaffolderTask> {
|
||||
const baseUrl = await this.discoveryApi.getBaseUrl('scaffolder');
|
||||
const url = `${baseUrl}/v2/tasks/${encodeURIComponent(taskId)}`;
|
||||
|
||||
|
||||
@@ -14,11 +14,12 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
import React from 'react';
|
||||
import { ScaffolderApi, scaffolderApiRef } from '../../api';
|
||||
import { scaffolderApiRef } from '../../api';
|
||||
import { ActionsPage } from './ActionsPage';
|
||||
import { rootRouteRef } from '../../routes';
|
||||
import { renderInTestApp, TestApiRegistry } from '@backstage/test-utils';
|
||||
import { ApiProvider } from '@backstage/core-app-api';
|
||||
import { ScaffolderApi } from '../../types';
|
||||
|
||||
const scaffolderApiMock: jest.Mocked<ScaffolderApi> = {
|
||||
scaffold: jest.fn(),
|
||||
|
||||
@@ -28,8 +28,7 @@ import {
|
||||
TableRow,
|
||||
makeStyles,
|
||||
} from '@material-ui/core';
|
||||
import { JSONSchema } from '@backstage/catalog-model';
|
||||
import { JSONSchema7Definition } from 'json-schema';
|
||||
import { JSONSchema7, JSONSchema7Definition } from 'json-schema';
|
||||
import classNames from 'classnames';
|
||||
|
||||
import { useApi } from '@backstage/core-plugin-api';
|
||||
@@ -87,7 +86,7 @@ export const ActionsPage = () => {
|
||||
);
|
||||
}
|
||||
|
||||
const formatRows = (input: JSONSchema) => {
|
||||
const formatRows = (input: JSONSchema7) => {
|
||||
const properties = input.properties;
|
||||
if (!properties) {
|
||||
return undefined;
|
||||
@@ -95,7 +94,7 @@ export const ActionsPage = () => {
|
||||
|
||||
return Object.entries(properties).map(entry => {
|
||||
const [key] = entry;
|
||||
const props = entry[1] as unknown as JSONSchema;
|
||||
const props = entry[1] as unknown as JSONSchema7;
|
||||
const codeClassname = classNames(classes.code, {
|
||||
[classes.codeRequired]: input.required?.includes(key),
|
||||
});
|
||||
@@ -115,7 +114,7 @@ export const ActionsPage = () => {
|
||||
});
|
||||
};
|
||||
|
||||
const renderTable = (input: JSONSchema) => {
|
||||
const renderTable = (input: JSONSchema7) => {
|
||||
if (!input.properties) {
|
||||
return undefined;
|
||||
}
|
||||
@@ -145,7 +144,7 @@ export const ActionsPage = () => {
|
||||
<>
|
||||
<Typography variant="h6">{name}</Typography>
|
||||
{input.map((i, index) => (
|
||||
<div key={index}>{renderTable(i as unknown as JSONSchema)}</div>
|
||||
<div key={index}>{renderTable(i as unknown as JSONSchema7)}</div>
|
||||
))}
|
||||
</>
|
||||
);
|
||||
|
||||
@@ -23,7 +23,9 @@ import {
|
||||
scmAuthApiRef,
|
||||
ScmAuthApi,
|
||||
} from '@backstage/integration-react';
|
||||
import { scaffolderApiRef, ScaffolderApi } from '../../../api';
|
||||
import { scaffolderApiRef } from '../../../api';
|
||||
import { ScaffolderApi } from '../../../types';
|
||||
|
||||
import {
|
||||
SecretsContextProvider,
|
||||
SecretsContext,
|
||||
@@ -32,10 +34,12 @@ import { act, fireEvent } from '@testing-library/react';
|
||||
|
||||
describe('RepoUrlPicker', () => {
|
||||
const mockScaffolderApi: Partial<ScaffolderApi> = {
|
||||
getIntegrationsList: async () => [
|
||||
{ host: 'github.com', type: 'github', title: 'github.com' },
|
||||
{ host: 'dev.azure.com', type: 'azure', title: 'dev.azure.com' },
|
||||
],
|
||||
getIntegrationsList: async () => ({
|
||||
integrations: [
|
||||
{ host: 'github.com', type: 'github', title: 'github.com' },
|
||||
{ host: 'dev.azure.com', type: 'azure', title: 'dev.azure.com' },
|
||||
],
|
||||
}),
|
||||
};
|
||||
|
||||
const mockIntegrationsApi: Partial<ScmIntegrationsApi> = {
|
||||
|
||||
@@ -30,11 +30,13 @@ export const RepoUrlPickerHost = (props: {
|
||||
const { host, hosts, onChange, rawErrors } = props;
|
||||
const scaffolderApi = useApi(scaffolderApiRef);
|
||||
|
||||
const { value: integrations, loading } = useAsync(async () => {
|
||||
return await scaffolderApi.getIntegrationsList({
|
||||
allowedHosts: hosts ?? [],
|
||||
});
|
||||
});
|
||||
const { value: { integrations } = { integrations: [] }, loading } = useAsync(
|
||||
async () => {
|
||||
return await scaffolderApi.getIntegrationsList({
|
||||
allowedHosts: hosts ?? [],
|
||||
});
|
||||
},
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
// If there is no host chosen currently
|
||||
|
||||
Reference in New Issue
Block a user