Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { useSelect, useDispatch } from '@wordpress/data';
* Internal dependencies
*/
import { store as blockEditorStore } from '../../store';
import { unlock } from '../../lock-unlock';

/**
* Custom hook for managing List View panel state.
Expand All @@ -17,13 +18,12 @@ import { store as blockEditorStore } from '../../store';
export default function useListViewPanelState( clientId ) {
const { isOpened, expandRevision } = useSelect(
( select ) => {
const {
__unstableIsListViewPanelOpened,
__unstableGetListViewExpandRevision,
} = select( blockEditorStore );
const { isListViewPanelOpened, getListViewExpandRevision } = unlock(
select( blockEditorStore )
);
return {
isOpened: __unstableIsListViewPanelOpened( clientId ),
expandRevision: __unstableGetListViewExpandRevision(),
isOpened: isListViewPanelOpened( clientId ),
expandRevision: getListViewExpandRevision(),
};
},
[ clientId ]
Expand Down
27 changes: 27 additions & 0 deletions packages/block-editor/src/store/private-selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -961,3 +961,30 @@ export function isLockedBlock( state, clientId ) {
export function isListViewContentPanelOpen( state ) {
return state.listViewContentPanelOpen;
}

/**
* Returns whether a List View panel is opened.
*
* @param {Object} state Global application state.
* @param {string} clientId Client ID of the block.
*
* @return {boolean} Whether the panel is opened.
*/
export function isListViewPanelOpened( state, clientId ) {
// If allOpen flag is set, all panels are open
if ( state.openedListViewPanels?.allOpen ) {
return true;
}
return state.openedListViewPanels?.panels?.[ clientId ] === true;
}

/**
* Returns the List View expand revision number.
*
* @param {Object} state Global application state.
*
* @return {number} The expand revision number.
*/
export function getListViewExpandRevision( state ) {
return state.listViewExpandRevision || 0;
}
27 changes: 0 additions & 27 deletions packages/block-editor/src/store/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -3286,30 +3286,3 @@ export function __unstableGetTemporarilyEditingAsBlocks( state ) {
);
return getEditedContentOnlySection( state );
}

/**
* Returns whether a List View panel is opened.
*
* @param {Object} state Global application state.
* @param {string} clientId Client ID of the block.
*
* @return {boolean} Whether the panel is opened.
*/
export function __unstableIsListViewPanelOpened( state, clientId ) {
// If allOpen flag is set, all panels are open
if ( state.openedListViewPanels?.allOpen ) {
return true;
}
return state.openedListViewPanels?.panels?.[ clientId ] === true;
}

/**
* Returns the List View expand revision number.
*
* @param {Object} state Global application state.
*
* @return {number} The expand revision number.
*/
export function __unstableGetListViewExpandRevision( state ) {
return state.listViewExpandRevision || 0;
}
Loading