* Remove active item from navigation store

* Add changelog entry
This commit is contained in:
Joshua T Flowers 2021-03-03 16:57:00 -05:00 committed by GitHub
parent 7a20e582a3
commit 40a86daf2f
7 changed files with 3 additions and 32 deletions

View File

@ -125,10 +125,9 @@ const Container = ( { menuItems } ) => {
export default compose( export default compose(
withSelect( ( select ) => { withSelect( ( select ) => {
const { getActiveItem, getMenuItems } = select( NAVIGATION_STORE_NAME ); const { getMenuItems } = select( NAVIGATION_STORE_NAME );
return { return {
activeItem: getActiveItem(),
menuItems: getMenuItems(), menuItems: getMenuItems(),
}; };
} ) } )

View File

@ -1,7 +1,6 @@
const TYPES = { const TYPES = {
ADD_MENU_ITEMS: 'ADD_MENU_ITEMS', ADD_MENU_ITEMS: 'ADD_MENU_ITEMS',
SET_MENU_ITEMS: 'SET_MENU_ITEMS', SET_MENU_ITEMS: 'SET_MENU_ITEMS',
SET_ACTIVE_ITEM: 'SET_ACTIVE_ITEM',
ADD_FAVORITE_FAILURE: 'ADD_FAVORITE_FAILURE', ADD_FAVORITE_FAILURE: 'ADD_FAVORITE_FAILURE',
ADD_FAVORITE_REQUEST: 'ADD_FAVORITE_REQUEST', ADD_FAVORITE_REQUEST: 'ADD_FAVORITE_REQUEST',
ADD_FAVORITE_SUCCESS: 'ADD_FAVORITE_SUCCESS', ADD_FAVORITE_SUCCESS: 'ADD_FAVORITE_SUCCESS',

View File

@ -9,13 +9,6 @@ import apiFetch from '@wordpress/api-fetch';
import TYPES from './action-types'; import TYPES from './action-types';
import { WC_ADMIN_NAMESPACE } from '../constants'; import { WC_ADMIN_NAMESPACE } from '../constants';
export function setActiveItem( activeItem ) {
return {
type: TYPES.SET_ACTIVE_ITEM,
activeItem,
};
}
export function setMenuItems( menuItems ) { export function setMenuItems( menuItems ) {
return { return {
type: TYPES.SET_MENU_ITEMS, type: TYPES.SET_MENU_ITEMS,

View File

@ -5,21 +5,14 @@ import TYPES from './action-types';
const reducer = ( const reducer = (
state = { state = {
activeItem: null,
error: null, error: null,
menuItems: [], menuItems: [],
favorites: [], favorites: [],
requesting: {}, requesting: {},
}, },
{ type, activeItem, error, favorite, favorites, menuItems } { type, error, favorite, favorites, menuItems }
) => { ) => {
switch ( type ) { switch ( type ) {
case TYPES.SET_ACTIVE_ITEM:
state = {
...state,
activeItem,
};
break;
case TYPES.SET_MENU_ITEMS: case TYPES.SET_MENU_ITEMS:
state = { state = {
...state, ...state,

View File

@ -9,10 +9,6 @@ export const getMenuItems = ( state ) => {
return applyFilters( MENU_ITEMS_HOOK, state.menuItems ); return applyFilters( MENU_ITEMS_HOOK, state.menuItems );
}; };
export const getActiveItem = ( state ) => {
return state.activeItem || null;
};
export const getFavorites = ( state ) => { export const getFavorites = ( state ) => {
return state.favorites || []; return state.favorites || [];
}; };

View File

@ -5,7 +5,6 @@ import reducer from '../reducer';
import TYPES from '../action-types'; import TYPES from '../action-types';
const defaultState = { const defaultState = {
activeItem: null,
error: null, error: null,
menuItems: [], menuItems: [],
favorites: [], favorites: [],
@ -75,15 +74,6 @@ describe( 'navigation reducer', () => {
expect( state.menuItems[ 1 ].id ).toBe( 'menu-item-2' ); expect( state.menuItems[ 1 ].id ).toBe( 'menu-item-2' );
} ); } );
it( 'should set the active menu item', () => {
const state = reducer( defaultState, {
type: TYPES.SET_ACTIVE_ITEM,
activeItem: 'test-active-item',
} );
expect( state.activeItem ).toBe( 'test-active-item' );
} );
it( 'should set the favorites', () => { it( 'should set the favorites', () => {
const favorites = [ 'favorite1', 'favorite2' ]; const favorites = [ 'favorite1', 'favorite2' ];
const state = reducer( defaultState, { const state = reducer( defaultState, {

View File

@ -76,6 +76,7 @@ Release and roadmap notes are available on the [WooCommerce Developers Blog](htt
== Unreleased == == Unreleased ==
- Dev: Add initial tests for navigation Menu class #6492 - Dev: Add initial tests for navigation Menu class #6492
- Dev: Remove active item from navigation store #6486
- Fix: Add check for navigating being enabled. #6462 - Fix: Add check for navigating being enabled. #6462
- Dev: Add nav favorite button tests #6446 - Dev: Add nav favorite button tests #6446
- Dev: Add a changelog lint check to PRs. #6414 - Dev: Add a changelog lint check to PRs. #6414