Skip to content

Commit

Permalink
resolve eslint error and update blockEditorStore feature
Browse files Browse the repository at this point in the history
  • Loading branch information
rishishah-multidots committed Sep 5, 2024
1 parent f06340a commit 6b8027a
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 25 deletions.
16 changes: 9 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@
"strip-json-comments": "5.0.0",
"style-loader": "3.2.1",
"terser-webpack-plugin": "5.3.9",
"typescript": "5.5.3",
"typescript": "5.1.5",
"uglify-js": "3.13.7",
"uuid": "9.0.1",
"webdriverio": "8.16.20",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@ import { useSelect } from '@wordpress/data';
*/
import BlockSettingsDropdown from './block-settings-dropdown';
import BlockCommentToolbar from '../collab/toolbar';
import { store as blockEditorStore } from '../../store';

export function BlockSettingsMenu( { clientIds, ...props } ) {
const selectedBlockClientId = clientIds[ 0 ];
const commentID = useSelect( ( select ) => {
return (
// eslint-disable-next-line @wordpress/data-no-store-string-literals
select( 'core/block-editor' ).getBlock( selectedBlockClientId )
select( blockEditorStore ).getBlock( selectedBlockClientId )
?.attributes?.blockCommentId || null
);
} );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,21 @@ import { MenuItem } from '@wordpress/components';
import { collabComment } from '@wordpress/icons';
import { useSelect, useDispatch } from '@wordpress/data';

/**
* Internal dependencies
*/
import { store as blockEditorStore } from '../../store';

export default function BlockCommentMenuItem( { onClose } ) {
// eslint-disable-next-line @wordpress/data-no-store-string-literals
const { openGeneralSidebar } = useDispatch( 'core/edit-post' );

// eslint-disable-next-line @wordpress/data-no-store-string-literals
const { updateBlockAttributes } = useDispatch( 'core/block-editor' );
const { updateBlockAttributes } = useDispatch( blockEditorStore );

const clientId = useSelect( ( select ) => {
// eslint-disable-next-line @wordpress/data-no-store-string-literals
const { getSelectedBlockClientId } = select( 'core/block-editor' );
const { getSelectedBlockClientId } = select( blockEditorStore );
return getSelectedBlockClientId();
}, [] );

Expand Down
9 changes: 7 additions & 2 deletions packages/block-editor/src/components/collab/toolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,21 @@ import { ToolbarButton } from '@wordpress/components';
import { collabComment } from '@wordpress/icons';
import { useSelect, useDispatch } from '@wordpress/data';

/**
* Internal dependencies
*/
import { store as blockEditorStore } from '../../store';

export default function BlockCommentToolbar() {
// eslint-disable-next-line @wordpress/data-no-store-string-literals
const { openGeneralSidebar } = useDispatch( 'core/edit-post' );

// eslint-disable-next-line @wordpress/data-no-store-string-literals
const { updateBlockAttributes } = useDispatch( 'core/block-editor' );
const { updateBlockAttributes } = useDispatch( blockEditorStore );

const clientId = useSelect( ( select ) => {
// eslint-disable-next-line @wordpress/data-no-store-string-literals
const { getSelectedBlockClientId } = select( 'core/block-editor' );
const { getSelectedBlockClientId } = select( blockEditorStore );
return getSelectedBlockClientId();
}, [] );

Expand Down
52 changes: 40 additions & 12 deletions packages/editor/src/components/collab-sidebar/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,16 @@ export default function CollabSidebar() {
} );
fetchComments();
} else {
createNotice( 'error', __( 'Something went wrong. Please try publishing the post, or you may have already submitted your comment earlier.' ), {
isDismissible: true,
} );
createNotice(
'error',
// translators: Error message when comment submission fails
__(
'Something went wrong. Please try publishing the post, or you may have already submitted your comment earlier.'
),
{
isDismissible: true,
}
);
}
};

Expand All @@ -113,9 +120,16 @@ export default function CollabSidebar() {

fetchComments();
} else {
createNotice( 'error', __( 'Something went wrong. Please try publishing the post, or you may have already submitted your comment earlier.' ), {
isDismissible: true,
} );
createNotice(
'error',
// translators: Error message when comment submission fails
__(
'Something went wrong. Please try publishing the post, or you may have already submitted your comment earlier.'
),
{
isDismissible: true,
}
);
}
};

Expand All @@ -140,9 +154,16 @@ export default function CollabSidebar() {

fetchComments();
} else {
createNotice( 'error', __( 'Something went wrong. Please try publishing the post, or you may have already submitted your comment earlier.' ), {
isDismissible: true,
} );
createNotice(
'error',
// translators: Error message when comment submission fails
__(
'Something went wrong. Please try publishing the post, or you may have already submitted your comment earlier.'
),
{
isDismissible: true,
}
);
}
};

Expand Down Expand Up @@ -171,9 +192,16 @@ export default function CollabSidebar() {
);
fetchComments();
} else {
createNotice( 'error', __( 'Something went wrong. Please try publishing the post, or you may have already submitted your comment earlier.' ), {
isDismissible: true,
} );
createNotice(
'error',
// translators: Error message when comment submission fails
__(
'Something went wrong. Please try publishing the post, or you may have already submitted your comment earlier.'
),
{
isDismissible: true,
}
);
}
};

Expand Down

0 comments on commit 6b8027a

Please sign in to comment.