Merge branch 'master' of github.com:payloadcms/payload

This commit is contained in:
James
2022-09-23 09:49:06 -07:00
38 changed files with 430 additions and 139 deletions

View File

@@ -32,9 +32,11 @@ const Duplicate: React.FC<Props> = ({ slug, collection, id }) => {
return;
}
const create = async (locale?: string): Promise<string | null> => {
const localeParam = locale ? `locale=${locale}` : '';
const response = await requests.get(`${serverURL}${api}/${slug}/${id}?${localeParam}`);
const create = async (locale = ''): Promise<string | null> => {
const response = await requests.get(`${serverURL}${api}/${slug}/${id}`, {
locale,
depth: 0,
});
const data = await response.json();
const result = await requests.post(`${serverURL}${api}/${slug}`, {
headers: {
@@ -59,7 +61,10 @@ const Duplicate: React.FC<Props> = ({ slug, collection, id }) => {
.filter((locale) => locale !== localization.defaultLocale)
.forEach(async (locale) => {
if (!abort) {
const res = await requests.get(`${serverURL}${api}/${slug}/${id}?locale=${locale}`);
const res = await requests.get(`${serverURL}${api}/${slug}/${id}`, {
locale,
depth: 0,
});
const localizedDoc = await res.json();
const patchResult = await requests.patch(`${serverURL}${api}/${slug}/${duplicateID}?locale=${locale}`, {
headers: {

View File

@@ -88,7 +88,7 @@ const RenderFields: React.FC<Props> = (props) => {
DefaultComponent={FieldComponent}
componentProps={{
...field,
path: field.path || (isFieldAffectingData ? field.name : undefined),
path: field.path || (isFieldAffectingData ? field.name : ''),
fieldTypes,
admin: {
...(field.admin || {}),

View File

@@ -6,7 +6,7 @@ export type Props = {
className?: string
readOnly?: boolean
forceRender?: boolean
permissions?: {
permissions?: FieldPermissions | {
[field: string]: FieldPermissions
}
filter?: (field: Field) => boolean

View File

@@ -75,7 +75,7 @@ const CollapsibleField: React.FC<Props> = (props) => {
<RenderFields
forceRender
readOnly={readOnly}
permissions={permissions?.fields}
permissions={permissions}
fieldTypes={fieldTypes}
fieldSchema={fields.map((field) => ({
...field,

View File

@@ -28,7 +28,7 @@ const Row: React.FC<Props> = (props) => {
<RenderFields
readOnly={readOnly}
className={classes}
permissions={permissions?.fields}
permissions={permissions}
fieldTypes={fieldTypes}
fieldSchema={fields.map((field) => ({
...field,

View File

@@ -71,7 +71,7 @@ const TabsField: React.FC<Props> = (props) => {
key={String(activeTab.label)}
forceRender
readOnly={readOnly}
permissions={permissions?.fields}
permissions={tabHasName(activeTab) ? permissions[activeTab.name].fields : permissions}
fieldTypes={fieldTypes}
fieldSchema={activeTab.fields.map((field) => ({
...field,

View File

@@ -28,7 +28,7 @@ const withCondition = <P extends Record<string, unknown>>(Field: React.Component
path?: string
};
const path = pathFromProps || name;
const path = typeof pathFromProps === 'string' ? pathFromProps : name;
const { getData, getSiblingData, getField, dispatchFields } = useWatchForm();

View File

@@ -82,7 +82,7 @@ const Dashboard: React.FC<Props> = (props) => {
if (type === EntityType.global) {
title = entity.label;
onClick = () => push({ pathname: `${admin}/globals/${global.slug}` });
onClick = () => push({ pathname: `${admin}/globals/${entity.slug}` });
}
return (