{label}
@@ -331,57 +286,4 @@ const RenderBlocks = React.memo((props) => {
);
});
-RenderBlocks.defaultProps = {
- label: undefined,
- showError: false,
- errorMessage: undefined,
- rows: [],
- labels: {
- singular: 'Block',
- plural: 'Blocks',
- },
- path: '',
- value: undefined,
- readOnly: false,
- style: {},
- width: undefined,
- maxRows: undefined,
- minRows: undefined,
- required: false,
-};
-
-RenderBlocks.propTypes = {
- label: PropTypes.string,
- showError: PropTypes.bool,
- errorMessage: PropTypes.string,
- rows: PropTypes.arrayOf(
- PropTypes.shape({}),
- ),
- labels: PropTypes.shape({
- singular: PropTypes.string,
- plural: PropTypes.string,
- }),
- path: PropTypes.string,
- name: PropTypes.string.isRequired,
- value: PropTypes.number,
- onDragEnd: PropTypes.func.isRequired,
- addRow: PropTypes.func.isRequired,
- removeRow: PropTypes.func.isRequired,
- moveRow: PropTypes.func.isRequired,
- fieldTypes: PropTypes.shape({}).isRequired,
- permissions: PropTypes.shape({
- fields: PropTypes.shape({}),
- }).isRequired,
- blocks: PropTypes.arrayOf(
- PropTypes.shape({}),
- ).isRequired,
- toggleCollapse: PropTypes.func.isRequired,
- readOnly: PropTypes.bool,
- style: PropTypes.shape({}),
- width: PropTypes.string,
- maxRows: PropTypes.number,
- minRows: PropTypes.number,
- required: PropTypes.bool,
-};
-
export default withCondition(Blocks);
diff --git a/src/admin/components/forms/field-types/Blocks/index.tsx b/src/admin/components/forms/field-types/Blocks/index.tsx
index dcf63c375f..3a85ee08d3 100644
--- a/src/admin/components/forms/field-types/Blocks/index.tsx
+++ b/src/admin/components/forms/field-types/Blocks/index.tsx
@@ -3,7 +3,7 @@ import Loading from '../../../elements/Loading';
const Blocks = lazy(() => import('./Blocks'));
-export default (props) => (
+export default (props: unknown): React.ReactNode => (
}>
diff --git a/src/admin/components/forms/field-types/Blocks/types.ts b/src/admin/components/forms/field-types/Blocks/types.ts
new file mode 100644
index 0000000000..103d854c1b
--- /dev/null
+++ b/src/admin/components/forms/field-types/Blocks/types.ts
@@ -0,0 +1,33 @@
+import { Data } from '../../Form/types';
+import { BlockField, Labels, Block } from '../../../../../fields/config/types';
+import { FieldTypes } from '..';
+import { FieldPermissions } from '../../../../../auth/types';
+
+export type Props = BlockField & {
+ path?: string
+ fieldTypes: FieldTypes
+ permissions: FieldPermissions
+}
+
+export type RenderBlockProps = {
+ path: string
+ name: string
+ fieldTypes: FieldTypes
+ permissions: FieldPermissions
+ onDragEnd: (result: any) => void
+ label: string
+ value: number
+ readOnly: boolean
+ minRows: number
+ maxRows: number
+ required: boolean
+ labels: Labels
+ addRow: (index: number, blockType: string) => Promise
+ removeRow: (index: number) => void
+ moveRow: (fromIndex: number, toIndex: number) => void
+ showError: boolean
+ errorMessage: string
+ rows: Data[]
+ blocks: Block[],
+ toggleCollapse: (row: number) => void
+}
diff --git a/src/admin/components/views/collections/Edit/Default.tsx b/src/admin/components/views/collections/Edit/Default.tsx
index 7f4ba92db1..a6f2e13255 100644
--- a/src/admin/components/views/collections/Edit/Default.tsx
+++ b/src/admin/components/views/collections/Edit/Default.tsx
@@ -169,7 +169,6 @@ const DefaultEditView = (props) => {
readOnly={!hasSavePermission}
permissions={permissions.fields}
filter={(field) => field?.admin?.position === 'sidebar'}
- position="sidebar"
fieldTypes={fieldTypes}
fieldSchema={fields}
/>
diff --git a/src/admin/components/views/collections/Edit/index.tsx b/src/admin/components/views/collections/Edit/index.tsx
index c6fb5409dd..0ef13ef8c1 100644
--- a/src/admin/components/views/collections/Edit/index.tsx
+++ b/src/admin/components/views/collections/Edit/index.tsx
@@ -27,7 +27,7 @@ const EditView = (props) => {
Edit: CustomEdit,
} = {},
} = {},
- },
+ } = {},
fields,
} = collection;
diff --git a/src/auth/types.ts b/src/auth/types.ts
index f6f3ad903d..2260613b6a 100644
--- a/src/auth/types.ts
+++ b/src/auth/types.ts
@@ -6,21 +6,17 @@ export type Permission = {
where?: Record
}
-export type CollectionFieldPermissions = {
- [field: string]: {
- create: {
- permission: boolean
- }
- read: {
- permission: boolean
- }
- update: {
- permission: boolean
- }
- delete: {
- permission: boolean
- }
+export type FieldPermissions = {
+ create: {
+ permission: boolean
}
+ read: {
+ permission: boolean
+ }
+ update: {
+ permission: boolean
+ }
+ fields?: FieldPermissions
}
export type CollectionPermission = {
@@ -28,24 +24,17 @@ export type CollectionPermission = {
read: Permission
update: Permission
delete: Permission
- fields: CollectionFieldPermissions
-}
-
-export type GlobalFieldPermissions = {
- [field: string]: {
- read: {
- permission: boolean
- }
- update: {
- permission: boolean
- }
+ fields: {
+ [field: string]: FieldPermissions
}
}
export type GlobalPermission = {
read: Permission
update: Permission
- fields: GlobalFieldPermissions
+ fields: {
+ [field: string]: FieldPermissions
+ }
}
export type Permissions = {
diff --git a/src/fields/config/types.ts b/src/fields/config/types.ts
index 2cdecfbbee..3c5c464e29 100644
--- a/src/fields/config/types.ts
+++ b/src/fields/config/types.ts
@@ -25,11 +25,13 @@ type Admin = {
hidden?: boolean
}
-type Labels = {
+export type Labels = {
singular: string;
plural: string;
};
+export type Validate = (value: unknown, options: unknown) => string | boolean;
+
interface FieldBase {
name?: string;
label?: string;
@@ -41,7 +43,7 @@ interface FieldBase {
hidden?: boolean;
saveToJWT?: boolean
localized?: boolean;
- validate?: (value: any, field: Field) => any;
+ validate?: Validate;
hooks?: {
beforeValidate?: FieldHook[];
beforeChange?: FieldHook[];