diff --git a/packages/core-data/src/resolvers.js b/packages/core-data/src/resolvers.js index 855439f6589c9c..4882a79df2c823 100644 --- a/packages/core-data/src/resolvers.js +++ b/packages/core-data/src/resolvers.js @@ -460,16 +460,7 @@ export const canUser = export const canUserEditEntityRecord = ( kind, name, recordId ) => async ( { dispatch } ) => { - const configs = await dispatch( getOrLoadEntitiesConfig( kind, name ) ); - const entityConfig = configs.find( - ( config ) => config.name === name && config.kind === kind - ); - if ( ! entityConfig ) { - return; - } - - const resource = entityConfig.__unstable_rest_base; - await dispatch( canUser( 'update', resource, recordId ) ); + await dispatch( canUser( 'update', { kind, name, id: recordId } ) ); }; /** diff --git a/packages/core-data/src/selectors.ts b/packages/core-data/src/selectors.ts index 7d3e76ca988a1f..60aff2dab78bcb 100644 --- a/packages/core-data/src/selectors.ts +++ b/packages/core-data/src/selectors.ts @@ -1180,13 +1180,7 @@ export function canUserEditEntityRecord( name: string, recordId: EntityRecordKey ): boolean | undefined { - const entityConfig = getEntityConfig( state, kind, name ); - if ( ! entityConfig ) { - return false; - } - const resource = entityConfig.__unstable_rest_base; - - return canUser( state, 'update', resource, recordId ); + return canUser( state, 'update', { kind, name, id: recordId } ); } /** diff --git a/packages/core-data/src/test/selectors.js b/packages/core-data/src/test/selectors.js index 841bccd2ce413d..7c917f703eeb6a 100644 --- a/packages/core-data/src/test/selectors.js +++ b/packages/core-data/src/test/selectors.js @@ -18,7 +18,6 @@ import { getEmbedPreview, isPreviewEmbedFallback, canUser, - canUserEditEntityRecord, getAutosave, getAutosaves, getCurrentUser, @@ -722,61 +721,6 @@ describe( 'canUser', () => { } ); } ); -describe( 'canUserEditEntityRecord', () => { - it( 'returns false by default', () => { - const state = deepFreeze( { - userPermissions: {}, - entities: { records: {} }, - } ); - expect( canUserEditEntityRecord( state, 'postType', 'post' ) ).toBe( - false - ); - } ); - - it( 'returns whether the user can edit', () => { - const state = deepFreeze( { - userPermissions: { - 'create/posts': false, - 'update/posts/1': true, - }, - entities: { - config: [ - { - kind: 'postType', - name: 'post', - __unstable_rest_base: 'posts', - }, - ], - records: { - root: { - postType: { - queriedData: { - items: { - default: { - post: { - slug: 'post', - __unstable: 'posts', - }, - }, - }, - itemIsComplete: { - default: { - post: true, - }, - }, - queries: {}, - }, - }, - }, - }, - }, - } ); - expect( - canUserEditEntityRecord( state, 'postType', 'post', '1' ) - ).toBe( true ); - } ); -} ); - describe( 'getAutosave', () => { const testAutosave = { author: 1,