Skip to content

Commit

Permalink
s/receiveUserPermissions/receiveUserPermission
Browse files Browse the repository at this point in the history
  • Loading branch information
noisysocks committed Jan 2, 2019
1 parent ccf4936 commit 02d9502
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 17 deletions.
4 changes: 2 additions & 2 deletions docs/designers-developers/developers/data/data-core.md
Original file line number Diff line number Diff line change
Expand Up @@ -237,12 +237,12 @@ Returns an action object used in signalling that Upload permissions have been re

* hasUploadPermissions: Does the user have permission to upload files?

### receiveUserPermissions
### receiveUserPermission

Returns an action object used in signalling that the current user has
permission to perform an action on a REST resource.

*Parameters*

* key: A key that represents the action and REST resource.
* isAllowed: Whether or not the user can perform the action.
* isAllowed: Whether or not the user can perform the action.
6 changes: 3 additions & 3 deletions packages/core-data/src/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ export function* saveEntityRecord( kind, name, record ) {
*/
export function receiveUploadPermissions( hasUploadPermissions ) {
return {
type: 'RECEIVE_USER_PERMISSIONS',
type: 'RECEIVE_USER_PERMISSION',
key: 'create/media',
isAllowed: hasUploadPermissions,
};
Expand All @@ -152,9 +152,9 @@ export function receiveUploadPermissions( hasUploadPermissions ) {
*
* @return {Object} Action object.
*/
export function receiveUserPermissions( key, isAllowed ) {
export function receiveUserPermission( key, isAllowed ) {
return {
type: 'RECEIVE_USER_PERMISSIONS',
type: 'RECEIVE_USER_PERMISSION',
key,
isAllowed,
};
Expand Down
2 changes: 1 addition & 1 deletion packages/core-data/src/reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ export function embedPreviews( state = {}, action ) {
*/
export function userPermissions( state = {}, action ) {
switch ( action.type ) {
case 'RECEIVE_USER_PERMISSIONS':
case 'RECEIVE_USER_PERMISSION':
return {
...state,
[ action.key ]: action.isAllowed,
Expand Down
4 changes: 2 additions & 2 deletions packages/core-data/src/resolvers.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
receiveEntityRecords,
receiveThemeSupports,
receiveEmbedPreview,
receiveUserPermissions,
receiveUserPermission,
} from './actions';
import { getKindEntities } from './entities';
import { apiFetch } from './controls';
Expand Down Expand Up @@ -158,5 +158,5 @@ export function* canUser( action, resource, id ) {

const key = compact( [ action, resource, id ] ).join( '/' );
const isAllowed = includes( allowHeader, method );
yield receiveUserPermissions( key, isAllowed );
yield receiveUserPermission( key, isAllowed );
}
8 changes: 4 additions & 4 deletions packages/core-data/src/test/actions.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* Internal dependencies
*/
import { saveEntityRecord, receiveEntityRecords, receiveUserPermissions } from '../actions';
import { saveEntityRecord, receiveEntityRecords, receiveUserPermission } from '../actions';

describe( 'saveEntityRecord', () => {
it( 'triggers a POST request for a new record', async () => {
Expand Down Expand Up @@ -59,10 +59,10 @@ describe( 'saveEntityRecord', () => {
} );
} );

describe( 'receiveUserPermissions', () => {
describe( 'receiveUserPermission', () => {
it( 'builds an action object', () => {
expect( receiveUserPermissions( 'create/media', true ) ).toEqual( {
type: 'RECEIVE_USER_PERMISSIONS',
expect( receiveUserPermission( 'create/media', true ) ).toEqual( {
type: 'RECEIVE_USER_PERMISSION',
key: 'create/media',
isAllowed: true,
} );
Expand Down
2 changes: 1 addition & 1 deletion packages/core-data/src/test/reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ describe( 'userPermissions()', () => {
} );

const state = userPermissions( original, {
type: 'RECEIVE_USER_PERMISSIONS',
type: 'RECEIVE_USER_PERMISSION',
key: 'create/media',
isAllowed: true,
} );
Expand Down
8 changes: 4 additions & 4 deletions packages/core-data/src/test/resolvers.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Internal dependencies
*/
import { getEntityRecord, getEntityRecords, getEmbedPreview, canUser } from '../resolvers';
import { receiveEntityRecords, receiveEmbedPreview, receiveUserPermissions } from '../actions';
import { receiveEntityRecords, receiveEmbedPreview, receiveUserPermission } from '../actions';
import { apiFetch } from '../controls';

describe( 'getEntityRecord', () => {
Expand Down Expand Up @@ -104,7 +104,7 @@ describe( 'canUser', () => {
},
} );
expect( received.done ).toBe( false );
expect( received.value ).toEqual( receiveUserPermissions( 'create/media', false ) );
expect( received.value ).toEqual( receiveUserPermission( 'create/media', false ) );

received = generator.next();
expect( received.done ).toBe( true );
Expand All @@ -128,7 +128,7 @@ describe( 'canUser', () => {
},
} );
expect( received.done ).toBe( false );
expect( received.value ).toEqual( receiveUserPermissions( 'create/media', true ) );
expect( received.value ).toEqual( receiveUserPermission( 'create/media', true ) );

received = generator.next();
expect( received.done ).toBe( true );
Expand All @@ -152,7 +152,7 @@ describe( 'canUser', () => {
},
} );
expect( received.done ).toBe( false );
expect( received.value ).toEqual( receiveUserPermissions( 'update/blocks/123', true ) );
expect( received.value ).toEqual( receiveUserPermission( 'update/blocks/123', true ) );

received = generator.next();
expect( received.done ).toBe( true );
Expand Down

0 comments on commit 02d9502

Please sign in to comment.