feat: reworking the calls, and changing the name
Signed-off-by: blam <ben@blam.sh>
This commit is contained in:
+5
-5
@@ -18,7 +18,7 @@ import React from 'react';
|
||||
import { render, waitFor } from '@testing-library/react';
|
||||
import { CatalogApi } from '@backstage/catalog-client';
|
||||
import { FieldProps } from '@rjsf/core';
|
||||
import { OwnershipEntityRefPicker } from './OwnershipEntityRefPicker';
|
||||
import { MyGroupsPicker } from './MyGroupsPicker';
|
||||
import { TestApiProvider } from '@backstage/test-utils';
|
||||
import { catalogApiRef } from '@backstage/plugin-catalog-react';
|
||||
import { Entity } from '@backstage/catalog-model';
|
||||
@@ -50,7 +50,7 @@ const mockIdentityApi: IdentityApi = {
|
||||
signOut: () => Promise.resolve(),
|
||||
};
|
||||
|
||||
describe('<OwnershipEntityRefPicker />', () => {
|
||||
describe('<MyGroupsPicker />', () => {
|
||||
let entities: Entity[];
|
||||
const onChange = jest.fn();
|
||||
const schema = {};
|
||||
@@ -119,7 +119,7 @@ describe('<OwnershipEntityRefPicker />', () => {
|
||||
[errorApiRef, mockErrorApi],
|
||||
]}
|
||||
>
|
||||
<OwnershipEntityRefPicker {...props} />
|
||||
<MyGroupsPicker {...props} />
|
||||
</TestApiProvider>,
|
||||
);
|
||||
|
||||
@@ -191,7 +191,7 @@ describe('<OwnershipEntityRefPicker />', () => {
|
||||
[errorApiRef, mockErrorApi],
|
||||
]}
|
||||
>
|
||||
<OwnershipEntityRefPicker {...props} />
|
||||
<MyGroupsPicker {...props} />
|
||||
</TestApiProvider>,
|
||||
);
|
||||
|
||||
@@ -248,7 +248,7 @@ describe('<OwnershipEntityRefPicker />', () => {
|
||||
[errorApiRef, mockErrorApi],
|
||||
]}
|
||||
>
|
||||
<OwnershipEntityRefPicker {...props} />
|
||||
<MyGroupsPicker {...props} />
|
||||
</TestApiProvider>,
|
||||
);
|
||||
|
||||
+3
-8
@@ -21,21 +21,16 @@ import {
|
||||
useApi,
|
||||
} from '@backstage/core-plugin-api';
|
||||
import { TextField, FormControl } from '@material-ui/core';
|
||||
import {
|
||||
OwnershipEntityRefPickerProps,
|
||||
OwnershipEntityRefPickerSchema,
|
||||
} from './schema';
|
||||
import { MyGroupsPickerProps, MyGroupsPickerSchema } from './schema';
|
||||
import { Autocomplete } from '@material-ui/lab';
|
||||
import { catalogApiRef } from '@backstage/plugin-catalog-react';
|
||||
import { NotFoundError } from '@backstage/errors';
|
||||
import useAsync from 'react-use/lib/useAsync';
|
||||
import { Entity, stringifyEntityRef } from '@backstage/catalog-model';
|
||||
|
||||
export { OwnershipEntityRefPickerSchema };
|
||||
export { MyGroupsPickerSchema };
|
||||
|
||||
export const OwnershipEntityRefPicker = (
|
||||
props: OwnershipEntityRefPickerProps,
|
||||
) => {
|
||||
export const MyGroupsPicker = (props: MyGroupsPickerProps) => {
|
||||
const {
|
||||
schema: { title, description },
|
||||
required,
|
||||
+3
-3
@@ -15,7 +15,7 @@
|
||||
*/
|
||||
|
||||
export {
|
||||
OwnershipEntityRefPickerSchema,
|
||||
type OwnershipEntityRefPickerUiOptions,
|
||||
OwnershipEntityRefPickerFieldSchema,
|
||||
MyGroupsPickerSchema,
|
||||
type MyGroupsPickerUiOptions,
|
||||
MyGroupsPickerFieldSchema,
|
||||
} from './schema';
|
||||
+9
-11
@@ -18,11 +18,11 @@ import { z } from 'zod';
|
||||
import { makeFieldSchemaFromZod } from '../utils';
|
||||
|
||||
/**
|
||||
* Field schema for the OwnershipEntityRefPicker.
|
||||
* Field schema for the MyGroupsPicker.
|
||||
* @public
|
||||
*/
|
||||
|
||||
export const OwnershipEntityRefPickerFieldSchema = makeFieldSchemaFromZod(
|
||||
export const MyGroupsPickerFieldSchema = makeFieldSchemaFromZod(
|
||||
z.string(),
|
||||
z.object({
|
||||
title: z.string().default('Group').describe('Group'),
|
||||
@@ -34,24 +34,22 @@ export const OwnershipEntityRefPickerFieldSchema = makeFieldSchemaFromZod(
|
||||
);
|
||||
|
||||
/**
|
||||
* UI options for the OwnershipEntityRefPicker.
|
||||
* UI options for the MyGroupsPicker.
|
||||
* @public
|
||||
*/
|
||||
|
||||
export type OwnershipEntityRefPickerUiOptions =
|
||||
typeof OwnershipEntityRefPickerFieldSchema.uiOptionsType;
|
||||
export type MyGroupsPickerUiOptions =
|
||||
typeof MyGroupsPickerFieldSchema.uiOptionsType;
|
||||
/**
|
||||
* Props for the OwnershipEntityRefPicker.
|
||||
* Props for the MyGroupsPicker.
|
||||
* @public
|
||||
*/
|
||||
|
||||
export type OwnershipEntityRefPickerProps =
|
||||
typeof OwnershipEntityRefPickerFieldSchema.type;
|
||||
export type MyGroupsPickerProps = typeof MyGroupsPickerFieldSchema.type;
|
||||
|
||||
/**
|
||||
* Schema for the OwnershipEntityRefPicker.
|
||||
* Schema for the MyGroupsPicker.
|
||||
* @public
|
||||
*/
|
||||
|
||||
export const OwnershipEntityRefPickerSchema =
|
||||
OwnershipEntityRefPickerFieldSchema.schema;
|
||||
export const MyGroupsPickerSchema = MyGroupsPickerFieldSchema.schema;
|
||||
@@ -18,5 +18,5 @@ export * from './OwnerPicker';
|
||||
export * from './RepoUrlPicker';
|
||||
export * from './OwnedEntityPicker';
|
||||
export * from './EntityTagsPicker';
|
||||
export * from './OwnershipEntityRefPicker';
|
||||
export * from './MyGroupsPicker';
|
||||
export { type FieldSchema, makeFieldSchemaFromZod } from './utils';
|
||||
|
||||
@@ -40,9 +40,10 @@ import {
|
||||
OwnedEntityPickerSchema,
|
||||
} from '../components/fields/OwnedEntityPicker/OwnedEntityPicker';
|
||||
import {
|
||||
OwnershipEntityRefPicker,
|
||||
OwnershipEntityRefPickerSchema,
|
||||
} from '../components/fields/OwnershipEntityRefPicker/OwnershipEntityRefPicker';
|
||||
MyGroupsPicker,
|
||||
MyGroupsPickerSchema,
|
||||
} from '../components/fields/MyGroupsPicker/MyGroupsPicker';
|
||||
import { MyGroupsPickerFieldSchema } from '../components';
|
||||
|
||||
export const DEFAULT_SCAFFOLDER_FIELD_EXTENSIONS = [
|
||||
{
|
||||
@@ -78,8 +79,8 @@ export const DEFAULT_SCAFFOLDER_FIELD_EXTENSIONS = [
|
||||
schema: OwnedEntityPickerSchema,
|
||||
},
|
||||
{
|
||||
component: OwnershipEntityRefPicker,
|
||||
name: 'OwnershipEntityRefPicker',
|
||||
schema: OwnershipEntityRefPickerSchema,
|
||||
component: MyGroupsPicker,
|
||||
name: 'MyGroupsPicker',
|
||||
schema: MyGroupsPickerFieldSchema,
|
||||
},
|
||||
];
|
||||
|
||||
@@ -67,7 +67,7 @@ import {
|
||||
import {
|
||||
OwnershipEntityRefPicker,
|
||||
OwnershipEntityRefPickerSchema,
|
||||
} from './components/fields/OwnershipEntityRefPicker/OwnershipEntityRefPicker';
|
||||
} from './components/fields/MyGroupsPicker/MyGroupsPicker';
|
||||
|
||||
/**
|
||||
* The main plugin export for the scaffolder.
|
||||
|
||||
Reference in New Issue
Block a user