Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move insertionPoint state to block-editor store/rename existing insertionPoint to insertionCue #65098

Merged
merged 25 commits into from
Sep 26, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
3e599d2
Use index instead of insertionIndex
jeryj Sep 5, 2024
458c376
Revert "Use index instead of insertionIndex"
jeryj Sep 5, 2024
aae2353
Move/Add inserterInsertionPoint to block editor
jeryj Sep 6, 2024
269fe53
Update the docs of setIsInserterOpened
jeryj Sep 9, 2024
b17df45
Remove unnecessary props since they won't be set
jeryj Sep 9, 2024
2462257
Discourage use of rootIndex and insertionIndex on setIsInserterOpened
jeryj Sep 9, 2024
b06bddd
Remove note
jeryj Sep 9, 2024
8136045
Use setInserterInsertionPoint in quick inserter
jeryj Sep 9, 2024
a551d83
Insert in correct location for root insertions
jeryj Sep 10, 2024
a1765fe
Add store tests and improve docs and default state
jeryj Sep 10, 2024
5959cd8
Use inserterInsertionPoint for zoom out inserters and zoom out separator
jeryj Sep 11, 2024
3705906
Remove blockInsertionPointVisible from zoom out mode inserters
jeryj Sep 11, 2024
72e8309
Fix dragging vertical displacement on insertion points
jeryj Sep 11, 2024
355a061
Fix inserting at 0 index on zoom out mode
jeryj Sep 11, 2024
136c9a3
Fix insertion point at root level
jeryj Sep 11, 2024
867641e
Deprecate rootClientId and insertionIndex on setIsInserterOpened
jeryj Sep 12, 2024
bfff2d4
Renaming Insertion API for clarity
jeryj Sep 13, 2024
4f262d1
Catch missed renamings
jeryj Sep 13, 2024
24a2aec
More renamings and clarification
jeryj Sep 13, 2024
8d6410c
Fix logic and missing private function in editor store
jeryj Sep 25, 2024
28e1596
Fallback to using setInserterIsOpened if already in use
jeryj Sep 25, 2024
a21fe77
Move actions test within reducer to actions test and test with select…
jeryj Sep 26, 2024
98cf472
Remove unncessary return on dispatch
jeryj Sep 26, 2024
d037772
Update block editor selector state tests from insertionPoint to inser…
jeryj Sep 26, 2024
8c48524
Move code back to previous location
jeryj Sep 26, 2024
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
2 changes: 1 addition & 1 deletion packages/editor/src/store/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -747,7 +747,7 @@ export const setIsInserterOpened =
} );
}

dispatch( {
return dispatch( {
jeryj marked this conversation as resolved.
Show resolved Hide resolved
type: 'SET_IS_INSERTER_OPENED',
value,
} );
Expand Down
76 changes: 76 additions & 0 deletions packages/editor/src/store/test/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -576,4 +576,80 @@ describe( 'Editor actions', () => {
).toBe( true );
} );
} );

describe( 'setIsInserterOpened', () => {
it( 'should open and close the inserter', () => {
const registry = createRegistryWithStores();

registry.dispatch( editorStore ).setIsInserterOpened( true );

expect( registry.select( editorStore ).isInserterOpened() ).toBe(
true
);

registry.dispatch( editorStore ).setIsInserterOpened( false );

expect( registry.select( editorStore ).isInserterOpened() ).toBe(
false
);
} );

it( 'the list view should close when the inserter is opened', () => {
const registry = createRegistryWithStores();

registry.dispatch( editorStore ).setIsListViewOpened( true );
expect( registry.select( editorStore ).isListViewOpened() ).toBe(
true
);
expect( registry.select( editorStore ).isInserterOpened() ).toBe(
false
);

registry.dispatch( editorStore ).setIsInserterOpened( true );
expect( registry.select( editorStore ).isInserterOpened() ).toBe(
true
);
expect( registry.select( editorStore ).isListViewOpened() ).toBe(
false
);
} );
} );

describe( 'setIsListViewOpened', () => {
it( 'should open and close the list view', () => {
const registry = createRegistryWithStores();

registry.dispatch( editorStore ).setIsListViewOpened( true );

expect( registry.select( editorStore ).isListViewOpened() ).toBe(
true
);

registry.dispatch( editorStore ).setIsListViewOpened( false );

expect( registry.select( editorStore ).isListViewOpened() ).toBe(
false
);
} );

it( 'the inserter should close when the list view is opened', () => {
const registry = createRegistryWithStores();

registry.dispatch( editorStore ).setIsInserterOpened( true );
expect( registry.select( editorStore ).isInserterOpened() ).toBe(
true
);
expect( registry.select( editorStore ).isListViewOpened() ).toBe(
false
);

registry.dispatch( editorStore ).setIsListViewOpened( true );
expect( registry.select( editorStore ).isListViewOpened() ).toBe(
true
);
expect( registry.select( editorStore ).isInserterOpened() ).toBe(
false
);
} );
} );
} );
22 changes: 0 additions & 22 deletions packages/editor/src/store/test/reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import {
blockInserterPanel,
listViewPanel,
} from '../reducer';
import { setIsInserterOpened } from '../actions';

describe( 'state', () => {
describe( 'hasSameKeys()', () => {
Expand Down Expand Up @@ -298,15 +297,6 @@ describe( 'state', () => {
expect( blockInserterPanel( true, {} ) ).toBe( true );
} );

it( 'should set the open state of the inserter panel', () => {
expect(
blockInserterPanel( false, setIsInserterOpened( true ) )
).toBe( true );
expect(
blockInserterPanel( true, setIsInserterOpened( false ) )
).toBe( false );
} );

it( 'should close the inserter when opening the list view panel', () => {
expect(
blockInserterPanel( true, {
Expand Down Expand Up @@ -349,17 +339,5 @@ describe( 'state', () => {
} )
).toBe( false );
} );

it( 'should close the list view when opening the inserter panel', () => {
expect( listViewPanel( true, setIsInserterOpened( true ) ) ).toBe(
false
);
} );

it( 'should not change the state when closing the inserter panel', () => {
expect( listViewPanel( true, setIsInserterOpened( false ) ) ).toBe(
true
);
} );
} );
} );
Loading