@@ -136,6 +136,7 @@ export const NonEmptyReferenceField = <
136
136
id,
137
137
reference,
138
138
queryOptions,
139
+ link,
139
140
...props
140
141
} : Omit < ReferenceFieldProps < RecordType , ReferenceRecordType > , 'source' > & {
141
142
id : Identifier ;
@@ -151,6 +152,7 @@ export const NonEmptyReferenceField = <
151
152
id,
152
153
options : queryOptions ,
153
154
} ) }
155
+ resourceLinkPath = { link }
154
156
>
155
157
{ children }
156
158
</ PureReferenceFieldView >
@@ -174,7 +176,7 @@ export const ReferenceFieldView = <
174
176
isLoading,
175
177
reference,
176
178
referenceRecord,
177
- link ,
179
+ resourceLinkPath ,
178
180
sx,
179
181
} = props ;
180
182
const getRecordRepresentation = useGetRecordRepresentation ( reference ) ;
@@ -203,18 +205,18 @@ export const ReferenceFieldView = <
203
205
) : null ;
204
206
}
205
207
206
- const resourceLinkPath =
207
- link === false ||
208
- ( link === 'edit' && ! resourceDefinition . hasEdit ) ||
209
- ( link === 'show' && ! resourceDefinition . hasShow )
208
+ const link =
209
+ resourceLinkPath === false ||
210
+ ( resourceLinkPath === 'edit' && ! resourceDefinition . hasEdit ) ||
211
+ ( resourceLinkPath === 'show' && ! resourceDefinition . hasShow )
210
212
? false
211
213
: createPath ( {
212
214
resource : reference ,
213
215
id : referenceRecord . id ,
214
216
type :
215
- typeof link === 'function'
216
- ? link ( referenceRecord , reference )
217
- : link ,
217
+ typeof resourceLinkPath === 'function'
218
+ ? resourceLinkPath ( referenceRecord , reference )
219
+ : resourceLinkPath ,
218
220
} ) ;
219
221
220
222
let child = children || (
@@ -223,11 +225,11 @@ export const ReferenceFieldView = <
223
225
</ Typography >
224
226
) ;
225
227
226
- return resourceLinkPath ? (
228
+ return link ? (
227
229
< Root className = { className } sx = { sx } >
228
230
< RecordContextProvider value = { referenceRecord } >
229
231
< Link
230
- to = { resourceLinkPath . toString ( ) }
232
+ to = { link . toString ( ) }
231
233
className = { ReferenceFieldClasses . link }
232
234
onClick = { stopPropagation }
233
235
>
@@ -251,7 +253,7 @@ ReferenceFieldView.propTypes = {
251
253
referenceRecord : PropTypes . any ,
252
254
resource : PropTypes . string ,
253
255
// @ts -ignore
254
- link : PropTypes . oneOfType ( [
256
+ resourceLinkPath : PropTypes . oneOfType ( [
255
257
PropTypes . string ,
256
258
PropTypes . bool ,
257
259
PropTypes . func ,
@@ -269,7 +271,7 @@ export interface ReferenceFieldViewProps<
269
271
reference : string ;
270
272
resource ?: string ;
271
273
translateChoice ?: Function | boolean ;
272
- link ?: LinkToType < ReferenceRecordType > ;
274
+ resourceLinkPath ?: LinkToType < ReferenceRecordType > ;
273
275
sx ?: SxProps ;
274
276
}
275
277
0 commit comments