chore: remove old rjsf

Signed-off-by: blam <ben@blam.sh>
This commit is contained in:
blam
2023-10-13 08:22:41 +02:00
committed by Patrik Oldsberg
parent 72b7dc147f
commit fadd3ca42a
25 changed files with 62 additions and 105 deletions
+2 -2
View File
@@ -46,8 +46,8 @@
"@material-ui/core": "^4.12.2",
"@material-ui/icons": "^4.9.1",
"@material-ui/lab": "4.0.0-alpha.61",
"@rjsf/core-v5": "npm:@rjsf/core@5.13.0",
"@rjsf/material-ui-v5": "npm:@rjsf/material-ui@5.13.0",
"@rjsf/core": "5.13.0",
"@rjsf/material-ui": "5.13.0",
"@rjsf/utils": "5.13.0",
"@rjsf/validator-ajv8": "5.13.0",
"@types/react": "^16.13.1 || ^17.0.0",
@@ -27,10 +27,11 @@ import SettingsIcon from '@material-ui/icons/Settings';
import DeleteIcon from '@material-ui/icons/Delete';
import React from 'react';
import { Widget } from './types';
import { withTheme } from '@rjsf/core-v5';
import { withTheme } from '@rjsf/core';
import { Theme as MuiTheme } from '@rjsf/material-ui';
import validator from '@rjsf/validator-ajv8';
const Form = withTheme(require('@rjsf/material-ui-v5').Theme);
const Form = withTheme(MuiTheme);
const useStyles = makeStyles((theme: Theme) =>
createStyles({
+4 -5
View File
@@ -13,9 +13,7 @@ import { Dispatch } from 'react';
import { Extension } from '@backstage/core-plugin-api';
import { FieldExtensionComponent } from '@backstage/plugin-scaffolder-react';
import { FieldExtensionOptions } from '@backstage/plugin-scaffolder-react';
import { FieldProps } from '@rjsf/core';
import { FieldValidation } from '@rjsf/utils';
import { FieldValidation as FieldValidation_2 } from '@rjsf/core';
import { FormProps } from '@backstage/plugin-scaffolder-react';
import { IconComponent } from '@backstage/core-plugin-api';
import { JsonObject } from '@backstage/types';
@@ -26,6 +24,7 @@ import { default as React_2 } from 'react';
import { ReactElement } from 'react';
import { ReactNode } from 'react';
import { ReviewStepProps } from '@backstage/plugin-scaffolder-react';
import { ScaffolderRJSFFieldProps } from '@backstage/plugin-scaffolder-react';
import { ScaffolderRJSFFormProps } from '@backstage/plugin-scaffolder-react';
import { ScaffolderStep } from '@backstage/plugin-scaffolder-react';
import { ScaffolderTaskOutput } from '@backstage/plugin-scaffolder-react';
@@ -86,7 +85,7 @@ export type FormValidation = {
// @alpha
export type LegacyCustomFieldValidator<TFieldReturnValue> = (
data: TFieldReturnValue,
field: FieldValidation_2,
field: FieldValidation,
context: {
apiHolder: ApiHolder;
},
@@ -96,9 +95,9 @@ export type LegacyCustomFieldValidator<TFieldReturnValue> = (
export interface LegacyFieldExtensionComponentProps<
TFieldReturnValue,
TUiOptions = unknown,
> extends FieldProps<TFieldReturnValue> {
> extends ScaffolderRJSFFieldProps<TFieldReturnValue> {
// (undocumented)
uiSchema: FieldProps['uiSchema'] & {
uiSchema: ScaffolderRJSFFieldProps['uiSchema'] & {
'ui:options'?: TUiOptions;
};
}
+3 -3
View File
@@ -15,13 +15,13 @@ import { ErrorTransformer } from '@rjsf/utils';
import { Experimental_DefaultFormStateBehavior } from '@rjsf/utils';
import { Extension } from '@backstage/core-plugin-api';
import { FieldValidation } from '@rjsf/utils';
import Form from '@rjsf/core-v5';
import Form from '@rjsf/core';
import { FormContextType } from '@rjsf/utils';
import { FormEvent } from 'react';
import type { FormProps as FormProps_2 } from '@rjsf/core-v5';
import type { FormProps as FormProps_2 } from '@rjsf/core';
import { GenericObjectType } from '@rjsf/utils';
import { HTMLAttributes } from 'react';
import { IChangeEvent } from '@rjsf/core-v5';
import { IChangeEvent } from '@rjsf/core';
import { IdSchema } from '@rjsf/utils';
import { JsonObject } from '@backstage/types';
import { JSONSchema7 } from 'json-schema';
+2 -4
View File
@@ -60,10 +60,8 @@
"@material-ui/icons": "^4.9.1",
"@material-ui/lab": "4.0.0-alpha.61",
"@react-hookz/web": "^20.0.0",
"@rjsf/core": "^3.2.1",
"@rjsf/core-v5": "npm:@rjsf/core@5.13.0",
"@rjsf/material-ui": "^3.2.1",
"@rjsf/material-ui-v5": "npm:@rjsf/material-ui@5.13.0",
"@rjsf/core": "5.13.0",
"@rjsf/material-ui": "5.13.0",
"@rjsf/utils": "5.13.0",
"@rjsf/validator-ajv8": "5.13.0",
"@types/json-schema": "^7.0.9",
@@ -15,7 +15,7 @@
*/
import { TemplateEntityV1beta3 } from '@backstage/plugin-scaffolder-common';
import type { FormProps as SchemaFormProps } from '@rjsf/core-v5';
import type { FormProps as SchemaFormProps } from '@rjsf/core';
import { UiSchema } from '@rjsf/utils';
import { JsonObject } from '@backstage/types';
@@ -33,7 +33,7 @@ import {
ErrorTransformer,
} from '@rjsf/utils';
import { HTMLAttributes } from 'react';
import Form, { IChangeEvent } from '@rjsf/core-v5';
import Form, { IChangeEvent } from '@rjsf/core';
/**
* The props for the `Field` components
@@ -16,7 +16,7 @@
import { LAYOUTS_KEY, LAYOUTS_WRAPPER_KEY } from './keys';
import { attachComponentData, Extension } from '@backstage/core-plugin-api';
import type { FormProps as SchemaFormProps } from '@rjsf/core-v5';
import type { FormProps as SchemaFormProps } from '@rjsf/core';
import React from 'react';
/**
@@ -14,8 +14,11 @@
* limitations under the License.
*/
import { ApiHolder } from '@backstage/core-plugin-api';
import { FieldValidation, FieldProps } from '@rjsf/core';
import { CustomFieldExtensionSchema } from '@backstage/plugin-scaffolder-react';
import { FieldValidation } from '@rjsf/utils';
import {
CustomFieldExtensionSchema,
ScaffolderRJSFFieldProps,
} from '@backstage/plugin-scaffolder-react';
/**
* Field validation type for Custom Field Extensions.
@@ -55,8 +58,8 @@ export type LegacyFieldExtensionOptions<
export interface LegacyFieldExtensionComponentProps<
TFieldReturnValue,
TUiOptions = unknown,
> extends FieldProps<TFieldReturnValue> {
uiSchema: FieldProps['uiSchema'] & {
> extends ScaffolderRJSFFieldProps<TFieldReturnValue> {
uiSchema: ScaffolderRJSFFieldProps['uiSchema'] & {
'ui:options'?: TUiOptions;
};
}
@@ -14,18 +14,16 @@
* limitations under the License.
*/
import { withTheme } from '@rjsf/core-v5';
import { withTheme } from '@rjsf/core';
import React from 'react';
import { PropsWithChildren } from 'react';
import { FieldTemplate } from './FieldTemplate';
import { DescriptionFieldTemplate } from './DescriptionFieldTemplate';
import { FieldProps } from '@rjsf/utils';
import { ScaffolderRJSFFormProps } from '@backstage/plugin-scaffolder-react';
import { Theme as MuiTheme } from '@rjsf/material-ui';
// TODO(blam): We require here, as the types in this package depend on @rjsf/core explicitly
// which is what we're using here as the default types, it needs to depend on @rjsf/core-v5 because
// of the re-writing we're doing. Once we've migrated, we can import this the exact same as before.
const WrappedForm = withTheme(require('@rjsf/material-ui-v5').Theme);
const WrappedForm = withTheme(MuiTheme);
/**
* The Form component
@@ -23,7 +23,7 @@ import {
makeStyles,
LinearProgress,
} from '@material-ui/core';
import { type IChangeEvent } from '@rjsf/core-v5';
import { type IChangeEvent } from '@rjsf/core';
import { ErrorSchema } from '@rjsf/utils';
import React, {
useCallback,
+1 -1
View File
@@ -8,7 +8,7 @@
import { ComponentType } from 'react';
import { Entity } from '@backstage/catalog-model';
import { FieldExtensionOptions } from '@backstage/plugin-scaffolder-react';
import type { FormProps as FormProps_2 } from '@rjsf/core-v5';
import type { FormProps as FormProps_2 } from '@rjsf/core';
import { FormProps as FormProps_3 } from '@backstage/plugin-scaffolder-react';
import { JSX as JSX_2 } from 'react';
import { LayoutOptions } from '@backstage/plugin-scaffolder-react';
+2 -2
View File
@@ -68,8 +68,8 @@
"@material-ui/icons": "^4.9.1",
"@material-ui/lab": "4.0.0-alpha.61",
"@react-hookz/web": "^20.0.0",
"@rjsf/core": "^3.2.1",
"@rjsf/material-ui": "^3.2.1",
"@rjsf/core": "5.13.0",
"@rjsf/material-ui": "5.13.0",
"@rjsf/utils": "5.13.0",
"@rjsf/validator-ajv8": "5.13.0",
"@types/react": "^16.13.1 || ^17.0.0",
@@ -14,7 +14,7 @@
* limitations under the License.
*/
import { FieldValidation } from '@rjsf/core';
import { FieldValidation } from '@rjsf/utils';
import { KubernetesValidatorFunctions } from '@backstage/catalog-model';
import { entityNamePickerValidation } from './validation';
@@ -15,7 +15,7 @@
*/
import { repoPickerValidation } from './validation';
import { FieldValidation } from '@rjsf/core';
import { FieldValidation } from '@rjsf/utils';
import { ScmIntegrations } from '@backstage/integration';
import { ConfigReader } from '@backstage/core-app-api';
import { ApiHolder } from '@backstage/core-plugin-api';
@@ -16,7 +16,7 @@
import React from 'react';
import { MarkdownContent } from '@backstage/core-components';
import { FieldProps } from '@rjsf/core';
import { FieldProps } from '@rjsf/utils';
export const DescriptionField = ({ description }: FieldProps) =>
description && <MarkdownContent content={description} linkTarget="_blank" />;
@@ -36,6 +36,7 @@ import { transformSchemaToProps } from './schema';
import cloneDeep from 'lodash/cloneDeep';
import * as fieldOverrides from './FieldOverrides';
import { ReviewStep } from './ReviewStep';
import validator from '@rjsf/validator-ajv8';
import { extractSchemaFromStep } from '@backstage/plugin-scaffolder-react/alpha';
import { selectedTemplateRouteRef } from '../../routes';
import {
@@ -180,6 +181,7 @@ export const MultistepJsonForm = (props: MultistepJsonFormProps) => {
</StepLabel>
<StepContent key={title}>
<Form
validator={validator}
showErrorList={false}
fields={{ ...fieldOverrides, ...fields }}
widgets={widgets}
@@ -16,7 +16,7 @@
import { Box, Button, Paper, Typography } from '@material-ui/core';
import React from 'react';
import { Content, StructuredMetadataTable } from '@backstage/core-components';
import { UiSchema } from '@rjsf/core';
import { UiSchema } from '@rjsf/utils';
import { JsonObject } from '@backstage/types';
import { ReviewStepProps } from '@backstage/plugin-scaffolder-react';
@@ -15,8 +15,9 @@
*/
import { JsonObject } from '@backstage/types';
import { FormProps, UiSchema } from '@rjsf/core';
import { UiSchema } from '@rjsf/utils';
import type { LayoutOptions } from '@backstage/plugin-scaffolder-react';
import { FormProps } from '@rjsf/core';
function isObject(value: unknown): value is JsonObject {
return typeof value === 'object' && value !== null && !Array.isArray(value);
@@ -120,8 +121,7 @@ export function transformSchemaToProps(
)?.component;
if (Layout) {
uiSchema['ui:ObjectFieldTemplate'] =
Layout as unknown as FormProps<any>['ObjectFieldTemplate'];
uiSchema['ui:ObjectFieldTemplate'] = Layout;
}
}
@@ -192,7 +192,7 @@ export function TemplateEditorForm(props: TemplateEditorFormProps) {
<ErrorBoundary invalidator={steps} setErrorText={setErrorText}>
<MultistepJsonForm
steps={steps}
fields={fields}
fields={fields as any}
formData={data}
onChange={e => onUpdate(e.formData)}
onReset={() => onUpdate({})}
@@ -162,7 +162,7 @@ export const TemplatePage = ({
<MultistepJsonForm
ReviewStepComponent={ReviewStepComponent}
formData={formState}
fields={customFieldComponents}
fields={customFieldComponents as any}
onChange={handleChange}
onReset={handleFormReset}
onFinish={handleCreate}
@@ -17,7 +17,7 @@
import { createValidator } from './createValidator';
import { LegacyCustomFieldValidator } from '@backstage/plugin-scaffolder-react/alpha';
import { ApiHolder } from '@backstage/core-plugin-api';
import { FieldValidation, FormValidation } from '@rjsf/core';
import { FieldValidation, FormValidation } from '@rjsf/utils';
type CustomLinkType = {
url: string;
@@ -111,7 +111,7 @@ describe('createValidator', () => {
/* THEN */
expect(result).not.toBeNull();
expect(result.p1.addError).toHaveBeenCalledTimes(1);
expect(result.p1?.addError).toHaveBeenCalledTimes(1);
});
it('should call validator for array property from a custom field extension', () => {
@@ -146,7 +146,7 @@ describe('createValidator', () => {
/* THEN */
expect(result).not.toBeNull();
expect(result.tags.addError).toHaveBeenCalledTimes(1);
expect(result.tags?.addError).toHaveBeenCalledTimes(1);
});
it('should call validator for array object property from a custom field extension', () => {
@@ -195,6 +195,6 @@ describe('createValidator', () => {
/* THEN */
expect(result).not.toBeNull();
expect(result.links.addError).toHaveBeenCalledTimes(1);
expect(result.links?.addError).toHaveBeenCalledTimes(1);
});
});
@@ -15,7 +15,7 @@
*/
import { LegacyCustomFieldValidator } from '@backstage/plugin-scaffolder-react/alpha';
import { FormValidation } from '@rjsf/core';
import { FieldValidation, FormValidation } from '@rjsf/utils';
import { JsonObject, JsonValue } from '@backstage/types';
import { ApiHolder } from '@backstage/core-plugin-api';
@@ -56,7 +56,7 @@ export const createValidator = (
if (fieldName && typeof validators[fieldName] === 'function') {
validators[fieldName]!(
propData as JsonObject[],
propValidation,
propValidation as FieldValidation,
context,
);
}
+1 -1
View File
@@ -20,7 +20,7 @@
* It exists already in the `scaffolder-react` plugin, so you may have to update both files.
*/
import type { FormProps as SchemaFormProps } from '@rjsf/core-v5';
import type { FormProps as SchemaFormProps } from '@rjsf/core';
/**
* Any `@rjsf/core` form properties that are publicly exposed to the `NextScaffolderPage`
+13 -57
View File
@@ -7216,8 +7216,8 @@ __metadata:
"@material-ui/core": ^4.12.2
"@material-ui/icons": ^4.9.1
"@material-ui/lab": 4.0.0-alpha.61
"@rjsf/core-v5": "npm:@rjsf/core@5.13.0"
"@rjsf/material-ui-v5": "npm:@rjsf/material-ui@5.13.0"
"@rjsf/core": 5.13.0
"@rjsf/material-ui": 5.13.0
"@rjsf/utils": 5.13.0
"@rjsf/validator-ajv8": 5.13.0
"@testing-library/dom": ^9.0.0
@@ -8663,10 +8663,8 @@ __metadata:
"@material-ui/icons": ^4.9.1
"@material-ui/lab": 4.0.0-alpha.61
"@react-hookz/web": ^20.0.0
"@rjsf/core": ^3.2.1
"@rjsf/core-v5": "npm:@rjsf/core@5.13.0"
"@rjsf/material-ui": ^3.2.1
"@rjsf/material-ui-v5": "npm:@rjsf/material-ui@5.13.0"
"@rjsf/core": 5.13.0
"@rjsf/material-ui": 5.13.0
"@rjsf/utils": 5.13.0
"@rjsf/validator-ajv8": 5.13.0
"@testing-library/dom": ^9.0.0
@@ -8729,8 +8727,8 @@ __metadata:
"@material-ui/icons": ^4.9.1
"@material-ui/lab": 4.0.0-alpha.61
"@react-hookz/web": ^20.0.0
"@rjsf/core": ^3.2.1
"@rjsf/material-ui": ^3.2.1
"@rjsf/core": 5.13.0
"@rjsf/material-ui": 5.13.0
"@rjsf/utils": 5.13.0
"@rjsf/validator-ajv8": 5.13.0
"@testing-library/dom": ^9.0.0
@@ -14621,7 +14619,7 @@ __metadata:
languageName: node
linkType: hard
"@rjsf/core-v5@npm:@rjsf/core@5.13.0":
"@rjsf/core@npm:5.13.0":
version: 5.13.0
resolution: "@rjsf/core@npm:5.13.0"
dependencies:
@@ -14637,26 +14635,7 @@ __metadata:
languageName: node
linkType: hard
"@rjsf/core@npm:^3.2.1":
version: 3.2.1
resolution: "@rjsf/core@npm:3.2.1"
dependencies:
"@types/json-schema": ^7.0.7
ajv: ^6.7.0
core-js-pure: ^3.6.5
json-schema-merge-allof: ^0.6.0
jsonpointer: ^5.0.0
lodash: ^4.17.15
nanoid: ^3.1.23
prop-types: ^15.7.2
react-is: ^16.9.0
peerDependencies:
react: ">=16"
checksum: 2142d4a31229ea242b79aca4ed93e2fe89e75f15ce93111457c3017d3ab295cae8f53e4dd870c619afa571959d00f46b3c19085c6a336f522c891fc07ecc46f1
languageName: node
linkType: hard
"@rjsf/material-ui-v5@npm:@rjsf/material-ui@5.13.0":
"@rjsf/material-ui@npm:5.13.0":
version: 5.13.0
resolution: "@rjsf/material-ui@npm:5.13.0"
peerDependencies:
@@ -14669,18 +14648,6 @@ __metadata:
languageName: node
linkType: hard
"@rjsf/material-ui@npm:^3.2.1":
version: 3.2.1
resolution: "@rjsf/material-ui@npm:3.2.1"
peerDependencies:
"@material-ui/core": ^4.2.0
"@material-ui/icons": ^4.2.1
"@rjsf/core": ^3.0.0
react: ">=16"
checksum: bd25cd9f2e2d568c653755e7268fe3e53279e1ae675e39bccd85f65557623d2052b706763e017a949f897751e25a16d0f2c8b995508bb56907be6786b09e2b1e
languageName: node
linkType: hard
"@rjsf/utils@npm:5.13.0":
version: 5.13.0
resolution: "@rjsf/utils@npm:5.13.0"
@@ -19611,7 +19578,7 @@ __metadata:
languageName: node
linkType: hard
"ajv@npm:^6.10.1, ajv@npm:^6.12.2, ajv@npm:^6.12.4, ajv@npm:^6.12.5, ajv@npm:^6.5.5, ajv@npm:^6.7.0, ajv@npm:~6.12.6":
"ajv@npm:^6.10.1, ajv@npm:^6.12.2, ajv@npm:^6.12.4, ajv@npm:^6.12.5, ajv@npm:^6.5.5, ajv@npm:~6.12.6":
version: 6.12.6
resolution: "ajv@npm:6.12.6"
dependencies:
@@ -22270,7 +22237,7 @@ __metadata:
languageName: node
linkType: hard
"compute-lcm@npm:^1.1.0, compute-lcm@npm:^1.1.2":
"compute-lcm@npm:^1.1.2":
version: 1.1.2
resolution: "compute-lcm@npm:1.1.2"
dependencies:
@@ -22536,7 +22503,7 @@ __metadata:
languageName: node
linkType: hard
"core-js-pure@npm:^3.23.3, core-js-pure@npm:^3.30.2, core-js-pure@npm:^3.6.5":
"core-js-pure@npm:^3.23.3, core-js-pure@npm:^3.30.2":
version: 3.31.0
resolution: "core-js-pure@npm:3.31.0"
checksum: 2bc5d2f6c3c9732fd5c066529b8d41fae9c746206ddf7614712dc4120a9efd47bf894df4fc600fde8c04324171c1999869798b48b23fca128eff5f09f58cd2f6
@@ -30316,17 +30283,6 @@ __metadata:
languageName: node
linkType: hard
"json-schema-merge-allof@npm:^0.6.0":
version: 0.6.0
resolution: "json-schema-merge-allof@npm:0.6.0"
dependencies:
compute-lcm: ^1.1.0
json-schema-compare: ^0.2.2
lodash: ^4.17.4
checksum: 2008aede3f5d05d7870e7d5e554e5c6a5b451cfff1357d34d3d8b34e2ba57468a97c76aa5b967bdb411d91b98c734f19f350de578d25b2a0a27cd4e1ca92bd1d
languageName: node
linkType: hard
"json-schema-merge-allof@npm:^0.8.1":
version: 0.8.1
resolution: "json-schema-merge-allof@npm:0.8.1"
@@ -33243,7 +33199,7 @@ __metadata:
languageName: node
linkType: hard
"nanoid@npm:^3.1.23, nanoid@npm:^3.3.6":
"nanoid@npm:^3.3.6":
version: 3.3.6
resolution: "nanoid@npm:3.3.6"
bin:
@@ -36760,7 +36716,7 @@ __metadata:
languageName: node
linkType: hard
"react-is@npm:^16.10.2, react-is@npm:^16.12.0, react-is@npm:^16.13.1, react-is@npm:^16.6.3, react-is@npm:^16.7.0, react-is@npm:^16.8.0, react-is@npm:^16.8.6, react-is@npm:^16.9.0":
"react-is@npm:^16.10.2, react-is@npm:^16.12.0, react-is@npm:^16.13.1, react-is@npm:^16.6.3, react-is@npm:^16.7.0, react-is@npm:^16.8.0, react-is@npm:^16.8.6":
version: 16.13.1
resolution: "react-is@npm:16.13.1"
checksum: f7a19ac3496de32ca9ae12aa030f00f14a3d45374f1ceca0af707c831b2a6098ef0d6bdae51bd437b0a306d7f01d4677fcc8de7c0d331eb47ad0f46130e53c5f