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

pipeline error fixes #38

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 @@ -11,13 +11,14 @@ import BlockCommentToolbar from '../collab/toolbar';

export function BlockSettingsMenu( { clientIds, ...props } ) {
const selectedBlockClientId = clientIds[ 0 ];
const commentID = useSelect( ( select ) => {
// eslint-disable-next-line @wordpress/data-no-store-string-literals
const commentID = useSelect((select) => {
return (
select( 'core/block-editor' ).getBlock( selectedBlockClientId )
?.attributes?.blockCommentId || null
// eslint-disable-next-line @wordpress/data-no-store-string-literals
select('core/block-editor')
.getBlock(selectedBlockClientId)
?.attributes?.blockCommentId || null
);
}, [] );
},);

return (
<ToolbarGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* WordPress dependencies
*/
import { __, _x } from '@wordpress/i18n';
import { _x } from '@wordpress/i18n';
import { MenuItem } from '@wordpress/components';
import { collabComment } from '@wordpress/icons';
import { useSelect, useDispatch } from '@wordpress/data';
Expand Down Expand Up @@ -34,9 +34,9 @@ export default function BlockCommentMenuItem( { onClose } ) {
aria-haspopup="dialog"
>
{ _x(
'Add Comment',
'Click to open comment sidebar and add comment'
) }
'Add Comment',
'Click to open comment sidebar and add comment'
) }
</MenuItem>
);
}
6 changes: 3 additions & 3 deletions packages/block-editor/src/components/collab/toolbar.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* WordPress dependencies
*/
import { __, _x } from '@wordpress/i18n';
import { _x } from '@wordpress/i18n';
import { ToolbarButton } from '@wordpress/components';
import { collabComment } from '@wordpress/icons';
import { useSelect, useDispatch } from '@wordpress/data';
Expand Down Expand Up @@ -31,9 +31,9 @@ export default function BlockCommentToolbar() {
accessibleWhenDisabled
icon={ collabComment }
label={ _x(
'Comment',
'Comment',
'Click to open sidebar and highlight comment board'
) }
) }
onClick={ openCollabBoard }
/>
);
Expand Down
102 changes: 72 additions & 30 deletions packages/editor/src/components/collab-sidebar/comments.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,14 @@ export function Comments( {
} ) {
const [ actionState, setActionState ] = useState( false );

const blockCommentId = useSelect( ( select ) => {
const clientID = select( blockEditorStore ).getSelectedBlockClientId();
const blockCommentId = useSelect((select) => {
const clientID = select(blockEditorStore).getSelectedBlockClientId();
return (
select( blockEditorStore ).getBlock( clientID )?.attributes
?.blockCommentId ?? false
select(blockEditorStore)
.getBlock(clientID)
?.attributes?.blockCommentId ?? false
);
}, [] );
}, []);

const CommentBoard = ( { thread, parentThread } ) => {
return (
Expand Down Expand Up @@ -132,7 +133,9 @@ export function Comments( {
>
{
// translators: message displayed when there are no comments available
__( 'No comments available' )
__(
'No comments available'
)
}
</VStack>
)
Expand All @@ -143,14 +146,13 @@ export function Comments( {
threads.map( ( thread ) => (
<VStack
key={ thread.id }
className={ clsx(
className={clsx(
'editor-collab-sidebar-panel__thread',
{
'editor-collab-sidebar-panel__active-thread':
blockCommentId &&
blockCommentId === thread.id,
blockCommentId && blockCommentId === thread.id,
}
) }
)}
id={ thread.id }
spacing="3"
>
Expand Down Expand Up @@ -190,7 +192,7 @@ export function Comments( {
// translators: message displayed when deleting a comment
__(
'Are you sure you want to delete this thread?'
)
)
}
confirmAction={ () => {
onCommentDelete( thread.id );
Expand Down Expand Up @@ -273,14 +275,22 @@ function EditComment( { thread, onUpdate, onCancel } ) {
0 === sanitizeCommentString( inputComment ).length
}
>
{ _x( 'Update', 'Update comment' ) }
{
_x(
'Update',
'Update comment'
)
}
</Button>
<Button
__next40pxDefaultSize
onClick={ onCancel }
size="compact"
>
{ _x( 'Cancel', 'Cancel comment edit' ) }
{ _x(
'Cancel',
'Cancel comment edit'
) }
</Button>
</HStack>
</VStack>
Expand Down Expand Up @@ -325,14 +335,24 @@ function AddReply( { onSubmit, onCancel } ) {
sanitizeCommentString( inputComment ).length
}
>
{ _x( 'Reply', 'Add reply comment' ) }
{
_x(
'Reply',
'Add reply comment'
)
}
</Button>
<Button
__next40pxDefaultSize
onClick={ onCancel }
size="compact"
>
{ _x( 'Cancel', 'Cancel adding a reply comment' ) }
{
_x(
'Cancel',
'Cancel adding a reply comment'
)
}
</Button>
</HStack>
</VStack>
Expand All @@ -359,26 +379,37 @@ function ConfirmNotice( { cofirmMessage, confirmAction, discardAction } ) {
spacing="0"
justify="space-between"
>
<p>
{ cofirmMessage ??
// translators: message displayed when confirming an action
__( 'Are you sure?' ) }
</p>
<p>{ cofirmMessage ??
// translators: message displayed when confirming an action
__(
'Are you sure?'
)
}</p>
<HStack>
<Button
__next40pxDefaultSize
variant="primary"
onClick={ confirmAction }
size="compact"
>
{ _x( 'Yes', 'confirm action' ) }
{
_x(
'Yes',
'confirm action'
)
}
</Button>
<Button
__next40pxDefaultSize
onClick={ discardAction }
size="compact"
>
{ _x( 'No', 'deny action' ) }
{
_x(
'No',
'deny action'
)
}
</Button>
</HStack>
</VStack>
Expand Down Expand Up @@ -415,18 +446,27 @@ function CommentHeader( {
const memorizedMoreActions = useMemo( () => {
return [
{
title: _x( 'Edit', 'Edit comment' ),
onClick: onEdit,
title: _x(
'Edit',
'Edit comment'
),
onClick: onEdit,
},
{
title: _x( 'Delete', 'Delete comment' ),
onClick: onDelete,
title: _x(
'Delete',
'Delete comment'
),
onClick: onDelete,
},
{
title: _x( 'Reply', 'Reply on a comment' ),
onClick: onReply,
title: _x(
'Reply',
'Reply on a comment'
),
onClick: onReply,
},
];
];
}, [] );

const moreActions = memorizedMoreActions.filter( ( item ) => item.onClick );
Expand Down Expand Up @@ -480,7 +520,9 @@ function CommentHeader( {
) }
{ status === 'approved' && (
// translators: tooltip for resolved comment
<Tooltip text={ __( 'Resolved' ) }>
<Tooltip text={ __(
'Resolved'
) }>
<Icon icon={ check } />
</Tooltip>
) }
Expand Down
28 changes: 20 additions & 8 deletions packages/editor/src/components/collab-sidebar/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,16 @@ export default function CollabSidebar() {
updateBlockAttributes( clientId, {
blockCommentId: savedRecord?.id,
} );
createNotice( 'snackbar', __( 'New comment added.' ), {
type: 'snackbar',
isDismissible: true,
} );
createNotice(
'snackbar',
__(
'New comment added.'
),
{
type: 'snackbar',
isDismissible: true,
}
);
fetchComments();
}
};
Expand All @@ -106,10 +112,16 @@ export default function CollabSidebar() {

if ( savedRecord ) {
// translators: Comment resolved successfully
createNotice( 'snackbar', __( 'Thread marked as resolved.' ), {
type: 'snackbar',
isDismissible: true,
} );
createNotice(
'snackbar',
__(
'Thread marked as resolved.'
),
{
type: 'snackbar',
isDismissible: true,
}
);

fetchComments();
}
Expand Down
Loading