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

Added selected connection count #1020

Merged
merged 32 commits into from
Mar 7, 2023
Merged

Conversation

roshniahuja
Copy link
Contributor

@roshniahuja roshniahuja commented Feb 21, 2023

Fixes for issue #592

Description of the Change

Issue mentioned URL - #592

Added selected connection count

Closes

How to test the Change

To test this feature - Need to select connection from dropdown and it will increase count in Selected connection

Changelog Entry

Added - Show count of selected connections in Push menu.

Credits

Props @roshniahuja

Checklist:

  • I agree to follow this project's Code of Conduct.
  • I have updated the documentation accordingly.
  • I have added tests to cover my change.
  • All new and existing tests pass.

@roshniahuja roshniahuja requested a review from a team as a code owner February 21, 2023 10:03
@roshniahuja roshniahuja requested review from Sidsector9 and removed request for a team February 21, 2023 10:03
@roshniahuja
Copy link
Contributor Author

@peterwilsoncc,

I have few ESLint errors and I already tried to resolve by installing ESLint and Prettier ESLint extension but still nothing works so If anyone can take a look then it will be appreciated.

@peterwilsoncc
Copy link
Collaborator

@roshniahuja I've pushed 22a5031 which fixes the linting errors.

Getting the lints set up in your IDE can be luck as much as anything else. If you use VS Code, I can share my extensions with you if you reach out via Slack.

Copy link
Collaborator

@peterwilsoncc peterwilsoncc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple of inline notes about consistency with layout/spacing within the brackets.

I'm wondering if it would be better to use the string Selected connections (%d) to ensure the strings are translatable in to all language formats.

The HTML could become:

<header class="with-selected">
	<span class="selected-connections-text"><?php esc_html_e( 'Selected connections', 'distributor' ); ?></span>
	<button class="button button-link selectno-connections unavailable"><?php esc_html_e( 'Clear', 'distributor' ); ?></button>
</header>

And the text in selected-connections-text replaced in full via the JavaScript. @ravinderk, do you have an opinion on what would be best?

assets/js/push.js Outdated Show resolved Hide resolved
assets/js/push.js Outdated Show resolved Hide resolved
assets/js/push.js Outdated Show resolved Hide resolved
@jeffpaul jeffpaul linked an issue Feb 23, 2023 that may be closed by this pull request
1 task
@jeffpaul jeffpaul added this to the 2.0.0 milestone Feb 23, 2023
@roshniahuja roshniahuja added needs:code-review This requires code review. and removed help wanted labels Mar 2, 2023
Copy link
Collaborator

@peterwilsoncc peterwilsoncc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great, thank you!

One minor note about translator comments for _n but otherwise it looks good.

@@ -580,7 +581,19 @@ jQuery( window ).on( 'load', () => {
deleteNode.parentNode.removeChild( deleteNode );

delete selectedConnections[ type + id ];

selectedText = sprintf(
/* translators: 1) Selected connection content singular name. 2) Selected connection content plural name. */
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/* translators: 1) Selected connection content singular name. 2) Selected connection content plural name. */
/* translators: %d: Number of selected connections. */

For _n translator notes are a little odd, the comment applies to both strings as the placeholders need to be identical.

@@ -602,6 +615,19 @@ jQuery( window ).on( 'load', () => {
selectedConnections[ type + id ] = dtConnections[ type + id ];

const element = event.currentTarget.cloneNode( true );
selectedText = sprintf(
/* translators: 1) Selected connection content singular name. 2) Selected connection content plural name. */
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/* translators: 1) Selected connection content singular name. 2) Selected connection content plural name. */
/* translators: %d: Number of selected connections. */

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment Updated.

@@ -660,6 +686,19 @@ jQuery( window ).on( 'load', () => {

element.appendChild( removeLink );
element.classList = 'added-connection';
selectedText = sprintf(
/* translators: 1) Selected connection content singular name. 2) Selected connection content plural name. */
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/* translators: 1) Selected connection content singular name. 2) Selected connection content plural name. */
/* translators: %d: Number of selected connections. */

@@ -691,6 +730,19 @@ jQuery( window ).on( 'load', () => {
);

delete selectedConnections[ type + id ];
selectedText = sprintf(
/* translators: 1) Selected connection content singular name. 2) Selected connection content plural name. */
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/* translators: 1) Selected connection content singular name. 2) Selected connection content plural name. */
/* translators: %d: Number of selected connections. */

@@ -721,7 +773,18 @@ jQuery( window ).on( 'load', () => {
const id = event.currentTarget.getAttribute( 'data-connection-id' );

delete selectedConnections[ type + id ];

selectedText = sprintf(
/* translators: 1) Selected connection content singular name. 2) Selected connection content plural name. */
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/* translators: 1) Selected connection content singular name. 2) Selected connection content plural name. */
/* translators: %d: Number of selected connections. */

Copy link
Collaborator

@peterwilsoncc peterwilsoncc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, thank you!

@peterwilsoncc peterwilsoncc merged commit 7744348 into develop Mar 7, 2023
@peterwilsoncc peterwilsoncc deleted the feature/connection-count branch March 7, 2023 03:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs:code-review This requires code review.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Show count of selected connections in Push menu
4 participants