Skip to content

Commit

Permalink
fix(core): inherit readOnly state from ancestors in copyPaste function (
Browse files Browse the repository at this point in the history
  • Loading branch information
pedrobonamin authored Oct 22, 2024
1 parent c9b574d commit 4298fe0
Show file tree
Hide file tree
Showing 4 changed files with 323 additions and 2 deletions.
90 changes: 89 additions & 1 deletion dev/test-studio/schema/standard/objects.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,10 @@ export default defineType({
)
},
},
fieldsets: [{name: 'recursive', title: 'Recursive', options: {collapsible: true}}],
fieldsets: [
{name: 'recursive', title: 'Recursive', options: {collapsible: true}},
{name: 'readOnly', title: 'Read only', options: {collapsible: true}},
],
fields: [
{
type: 'object',
Expand Down Expand Up @@ -231,5 +234,90 @@ export default defineType({
},
],
},
{
name: 'readOnlyObject',
title: 'Read only object',
type: 'object',
fieldset: 'readOnly',
readOnly: true,
fields: [
{
name: 'selfDefinedReadOnlyField',
title: 'Read only field',
description: 'ReadOnly defined in field',
type: 'string',
readOnly: true,
},
{
name: 'inheritedReadOnlyField',
title: 'Read only field',
description: 'ReadOnly inherited from object',
type: 'string',
},
],
},
{
name: 'sections',
title: 'Sections',
type: 'array',
fieldset: 'readOnly',
of: [
{
type: 'object',
name: 'blocks',
fields: [
{
type: 'array',
name: 'blocks',
title: 'Grid',
of: [{type: 'playlistTrack'}],
},
],
},
{
type: 'object',
name: 'textBlocks',
fields: [
{
type: 'text',
name: 'text',
title: 'Text',
},
],
},
],
},
{
name: 'sectionsReadOnly',
title: 'Sections (read only)',
type: 'array',
readOnly: true,
fieldset: 'readOnly',
of: [
{
type: 'object',
name: 'blocks',
fields: [
{
type: 'array',
name: 'blocks',
title: 'Grid',
of: [{type: 'playlistTrack'}],
},
],
},
{
type: 'object',
name: 'textBlocks',
fields: [
{
type: 'text',
name: 'text',
title: 'Text',
},
],
},
],
},
],
})
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ export const CopyPasteProvider: React.FC<{

const targetSchemaTypeTitle = targetSchemaType.title || targetSchemaType.name
const transferValueOptions = {
targetDocumentSchemaType: targetDocumentSchemaType,
sourceRootSchemaType: sourceSchemaType,
sourcePath: [],
sourceRootPath: clipboardItem.valuePath,
Expand Down
Loading

0 comments on commit 4298fe0

Please sign in to comment.