Skip to content

Commit ecf0572

Browse files
authored
fix(richtext-slate): link and upload extra field drawers did not render fields if collection has unrelated access control set (#10583)
Fixes #9695
1 parent 918bd72 commit ecf0572

File tree

4 files changed

+21
-13
lines changed

4 files changed

+21
-13
lines changed

packages/richtext-slate/src/field/elements/link/Button/index.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ export const LinkButton: React.FC<{
6969
const { t } = useTranslation()
7070
const editor = useSlate()
7171
const { getFormState } = useServerFunctions()
72-
const { collectionSlug, docPermissions, getDocPreferences, globalSlug } = useDocumentInfo()
72+
const { collectionSlug, getDocPreferences, globalSlug } = useDocumentInfo()
7373

7474
const { closeModal, openModal } = useModal()
7575
const drawerSlug = useDrawerSlug('rich-text-link')
@@ -98,7 +98,9 @@ export const LinkButton: React.FC<{
9898
const { state } = await getFormState({
9999
collectionSlug,
100100
data,
101-
docPermissions,
101+
docPermissions: {
102+
fields: true,
103+
},
102104
docPreferences: await getDocPreferences(),
103105
globalSlug,
104106
operation: 'update',

packages/richtext-slate/src/field/elements/link/Element/index.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,9 @@ export const LinkElement = () => {
101101
const { state } = await getFormState({
102102
collectionSlug,
103103
data,
104-
docPermissions,
104+
docPermissions: {
105+
fields: true,
106+
},
105107
docPreferences: await getDocPreferences(),
106108
globalSlug,
107109
operation: 'update',

packages/richtext-slate/src/field/elements/link/LinkDrawer/index.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export const LinkDrawer: React.FC<Props> = ({
3333
const { t } = useTranslation()
3434
const fieldMapPath = `${schemaPath}.${linkFieldsSchemaPath}`
3535

36-
const { id, collectionSlug, docPermissions, getDocPreferences, globalSlug } = useDocumentInfo()
36+
const { id, collectionSlug, getDocPreferences, globalSlug } = useDocumentInfo()
3737

3838
const { getFormState } = useServerFunctions()
3939

@@ -42,7 +42,9 @@ export const LinkDrawer: React.FC<Props> = ({
4242
const { state } = await getFormState({
4343
id,
4444
collectionSlug,
45-
docPermissions,
45+
docPermissions: {
46+
fields: true,
47+
},
4648
docPreferences: await getDocPreferences(),
4749
formState: prevFormState,
4850
globalSlug,
@@ -53,7 +55,7 @@ export const LinkDrawer: React.FC<Props> = ({
5355
return state
5456
},
5557

56-
[getFormState, id, collectionSlug, getDocPreferences, docPermissions, globalSlug, fieldMapPath],
58+
[getFormState, id, collectionSlug, getDocPreferences, globalSlug, fieldMapPath],
5759
)
5860

5961
return (
@@ -72,7 +74,7 @@ export const LinkDrawer: React.FC<Props> = ({
7274
parentIndexPath=""
7375
parentPath={''}
7476
parentSchemaPath=""
75-
permissions={docPermissions.fields}
77+
permissions={true}
7678
readOnly={false}
7779
/>
7880
<LinkSubmit />

packages/richtext-slate/src/field/elements/upload/Element/UploadDrawer/index.tsx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export const UploadDrawer: React.FC<{
4141
const { i18n, t } = useTranslation()
4242
const { code: locale } = useLocale()
4343
const { closeModal } = useModal()
44-
const { id, collectionSlug, docPermissions, getDocPreferences, globalSlug } = useDocumentInfo()
44+
const { id, collectionSlug, getDocPreferences, globalSlug } = useDocumentInfo()
4545

4646
const { getFormState } = useServerFunctions()
4747

@@ -75,7 +75,9 @@ export const UploadDrawer: React.FC<{
7575
id,
7676
collectionSlug,
7777
data,
78-
docPermissions,
78+
docPermissions: {
79+
fields: true,
80+
},
7981
docPreferences: await getDocPreferences(),
8082
globalSlug,
8183
operation: 'update',
@@ -99,15 +101,16 @@ export const UploadDrawer: React.FC<{
99101
getFormState,
100102
globalSlug,
101103
getDocPreferences,
102-
docPermissions,
103104
])
104105

105106
const onChange: FormProps['onChange'][0] = useCallback(
106107
async ({ formState: prevFormState }) => {
107108
const { state } = await getFormState({
108109
id,
109110
collectionSlug,
110-
docPermissions,
111+
docPermissions: {
112+
fields: true,
113+
},
111114
docPreferences: await getDocPreferences(),
112115
formState: prevFormState,
113116
globalSlug,
@@ -122,7 +125,6 @@ export const UploadDrawer: React.FC<{
122125
getFormState,
123126
id,
124127
collectionSlug,
125-
docPermissions,
126128
getDocPreferences,
127129
globalSlug,
128130
schemaPath,
@@ -150,7 +152,7 @@ export const UploadDrawer: React.FC<{
150152
parentIndexPath=""
151153
parentPath=""
152154
parentSchemaPath=""
153-
permissions={docPermissions.fields}
155+
permissions={true}
154156
readOnly={false}
155157
/>
156158
<FormSubmit>{t('fields:saveChanges')}</FormSubmit>

0 commit comments

Comments
 (0)