Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
2d11a45
Show warning on critical block removal
tellthemachines Jun 1, 2023
c1912d9
Extract prompt display logic into a hook
tellthemachines Jun 5, 2023
405c26b
Revert formatting change.
tellthemachines Jun 6, 2023
79ba8ad
Prompt for removal of all the blocks
tellthemachines Jun 6, 2023
15959b5
Move prompt state handling out of BlockList and into self
mcsf Jun 6, 2023
ce307ad
findCriticalBlocks: don't dismiss children of matching node
mcsf Jun 6, 2023
e5ddee6
findCriticalBlocks -> getBlocksToPromptFor
mcsf Jun 6, 2023
df68c00
Drop isBlockCritical()
mcsf Jun 6, 2023
042063a
Redesign removal modal
mcsf Jun 6, 2023
fb4c79d
Move prompt into site editor.
tellthemachines Jun 7, 2023
d3a12c8
Reset removalPromptExists upon listener unmount
mcsf Jun 20, 2023
c9952f1
Let action removeBlocks handle prompts and confirmations
mcsf Jun 20, 2023
33afda6
Add private action `privateRemoveBlocks` to hide extended interface
mcsf Jun 20, 2023
7482ba3
Fix unit tests
tellthemachines Jun 21, 2023
a5cce0a
Try: Dispatch setRemovalPromptStatus in edit-site init
mcsf Jun 21, 2023
b26efc4
Revert "Try: Dispatch setRemovalPromptStatus in edit-site init"
mcsf Jun 21, 2023
0e88e1a
Make all actions & selectors private. Rename things.
mcsf Jun 21, 2023
29f99c1
Make BlockRemovalWarningModal private
mcsf Jun 21, 2023
bb0cd7c
Cleanup: Remove BlockList changes from branch
mcsf Jun 22, 2023
c27ab49
Tweak removal message for Query. Tweak comments.
mcsf Jun 22, 2023
65df9cf
Split action into displayRemovalPrompt & clearRemovalPrompt
mcsf Jun 22, 2023
02df539
Rename setRemovalPromptStatus to toggleRemovalPromptSupport
mcsf Jun 22, 2023
d2b6a9f
Rename isRemovalPromptDisplayed to getRemovalPromptData
mcsf Jun 22, 2023
5d1c3e2
Add missing @return to displayRemovalPrompt
mcsf Jun 22, 2023
e180954
Tweak modal copy per feedback
mcsf Jun 22, 2023
23f034d
Turns out private selectors are attached to the thunk proxy!
mcsf Jun 22, 2023
6a0a806
Don't export the new reducers
mcsf Jun 22, 2023
628207a
Fix tests
mcsf Jun 22, 2023
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
Prev Previous commit
Next Next commit
Turns out private selectors are attached to the thunk proxy!
Well that was easy. :)
  • Loading branch information
mcsf committed Jun 22, 2023
commit 23f034de68359f860d474b714b4b1f60ee097a1c
8 changes: 1 addition & 7 deletions packages/block-editor/src/store/private-actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { Platform } from '@wordpress/element';
* Internal dependencies
*/
import { blockTypePromptMessages } from '../components/block-removal-warning-modal';
import { isRemovalPromptSupported } from './private-selectors';

const castArray = ( maybeArray ) =>
Array.isArray( maybeArray ) ? maybeArray : [ maybeArray ];
Expand Down Expand Up @@ -156,12 +155,7 @@ export const privateRemoveBlocks =
// register using `toggleRemovalPromptSupport()`.
//
// @see https://github.com/WordPress/gutenberg/pull/51145
if (
! forceRemove &&
// FIXME what's the best way to unlock a private selector in this
// context?
select( ( state ) => isRemovalPromptSupported( state.root ) )
) {
if ( ! forceRemove && select.isRemovalPromptSupported() ) {
const blockNamesForPrompt = new Set();

// Given a list of client IDs of blocks that the user intended to
Expand Down
12 changes: 3 additions & 9 deletions packages/block-editor/src/store/test/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -614,13 +614,11 @@ describe( 'actions', () => {
const clientId = 'clientId';
const clientIds = [ clientId ];

// FIXME: Once the private action `privateRemoveBlocks` is properly
// unlocking the private selector `isRemovalPromptSupported`, this test
// should rewritten to do the right thing.
const select = Object.assign(
( selector ) =>
selector( { root: { isRemovalPromptSupported: false } } ),
{
isRemovalPromptSupported: () => false,
getBlockRootClientId: () => undefined,
canRemoveBlocks: () => true,
}
Expand Down Expand Up @@ -731,13 +729,11 @@ describe( 'actions', () => {
it( 'should dispatch REMOVE_BLOCKS action', () => {
const clientId = 'myclientid';

// FIXME: Once the private action `privateRemoveBlocks` is properly
// unlocking the private selector `isRemovalPromptSupported`, this test
// should rewritten to do the right thing.
const select = Object.assign(
( selector ) =>
selector( { root: { isRemovalPromptSupported: false } } ),
{
isRemovalPromptSupported: () => false,
getBlockRootClientId: () => null,
canRemoveBlocks: () => true,
}
Expand All @@ -762,13 +758,11 @@ describe( 'actions', () => {
it( 'should dispatch REMOVE_BLOCKS action, opting out of select previous', () => {
const clientId = 'myclientid';

// FIXME: Once the private action `privateRemoveBlocks` is properly
// unlocking the private selector `isRemovalPromptSupported`, this test
// should rewritten to do the right thing.
const select = Object.assign(
( selector ) =>
selector( { root: { isRemovalPromptSupported: false } } ),
{
isRemovalPromptSupported: () => false,
getBlockRootClientId: () => null,
canRemoveBlocks: () => true,
}
Expand Down