Skip to content

Show check results on admin page#115

Merged
felixarntz merged 13 commits into
trunkfrom
feature/ajax-show-check-results
Apr 3, 2023
Merged

Show check results on admin page#115
felixarntz merged 13 commits into
trunkfrom
feature/ajax-show-check-results

Conversation

@jjgrainger
Copy link
Copy Markdown
Contributor

Addresses acceptance criteria in #35

Closes #35

@jjgrainger jjgrainger requested a review from felixarntz March 30, 2023 18:39
@jjgrainger jjgrainger marked this pull request as ready for review March 31, 2023 13:16
Comment thread templates/results-table.php Outdated
Comment thread assets/js/plugin-check-admin.js
@spacedmonkey
Copy link
Copy Markdown
Member

@jjgrainger There is no styling on the table. Is this expected?

Screenshot 2023-03-31 at 14 48 59

Comment thread templates/results-table.php Outdated
Comment thread templates/results-table.php Outdated
@spacedmonkey
Copy link
Copy Markdown
Member

Screenshot 2023-03-31 at 14 53 06

When I click on a plugin without an error or warning, I see no message at all. It seems like the plugin checker has done nothing here. This maybe hard to test, if plugin even works.

Comment thread includes/Admin/Admin_Page.php Outdated
Comment thread templates/results-table.php Outdated
@jjgrainger
Copy link
Copy Markdown
Contributor Author

Thanks @spacedmonkey

I've updated the PR based on your feedback. As for your comment...

When I click on a plugin without an error or warning, I see no message at all. It seems like the plugin checker has done nothing here. This maybe hard to test, if plugin even works.

I agree, and for now I've added a simple 'Checks complete' message once the process is done. I think it would be good to discuss what output through the process we'd want to display as part of the milestone review. Can you create an issue for this one?

@spacedmonkey
Copy link
Copy Markdown
Member

spacedmonkey commented Mar 31, 2023

Screenshot 2023-03-31 at 18 10 39

This is looking a lot better!

Couple of things. If I run this a couple of times, I see complete message twice, I don't know why this is.

Another nitpic, but would not take long to implement, when you click the button, if you a spinner could show, then go away when request is complete that would be amazing. Jetpack took a while to process and did not know when it was complete. To add a spinner in WP is very simple.

Next to the submit button add this.

<span class="spinner"></span>

It will look like this.
Screenshot 2023-03-31 at 18 17 30

Add a html id to it. When the button is clicked, add is-active class to the id and remove when the requests are complete. Should not take more than a couple of minutes to add and will make it clear to the user that something is happening.

Comment thread templates/results-table.php Outdated
Comment thread assets/js/plugin-check-admin.js Outdated
Comment thread assets/js/plugin-check-admin.js Outdated
Copy link
Copy Markdown
Member

@spacedmonkey spacedmonkey left a comment

Choose a reason for hiding this comment

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

I think barring the spinner, this is nearly there.

Copy link
Copy Markdown
Member

@felixarntz felixarntz left a comment

Choose a reason for hiding this comment

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

@jjgrainger Left some feedback here and above, but most of it looks good so far.

Comment thread assets/js/plugin-check-admin.js Outdated
Comment thread assets/js/plugin-check-admin.js Outdated
Comment thread includes/Admin/Admin_Page.php Outdated
Comment on lines +167 to +168
require_once WP_PLUGIN_CHECK_PLUGIN_DIR_PATH . '/templates/results-table.php';
require_once WP_PLUGIN_CHECK_PLUGIN_DIR_PATH . '/templates/results-row.php';
Copy link
Copy Markdown
Member

@felixarntz felixarntz Mar 31, 2023

Choose a reason for hiding this comment

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

A few things here:

  • These files should preferably only include the templates themselves, not the surrounding script tag. For that we should use the wp_print_inline_script_tag() function. To pass the output of these templates into the function, we can then use an output buffer.
  • No need for require_once, this file doesn't contain PHP functions or anything like that and therefore is okay to be included multiple times.
Suggested change
require_once WP_PLUGIN_CHECK_PLUGIN_DIR_PATH . '/templates/results-table.php';
require_once WP_PLUGIN_CHECK_PLUGIN_DIR_PATH . '/templates/results-row.php';
ob_start();
require WP_PLUGIN_CHECK_PLUGIN_DIR_PATH . '/templates/results-table.php';
$results_table_template = ob_get_clean();
wp_print_inline_script_tag(
$results_table_template,
array(
'id' => 'tmpl-plugin-check-results-table',
'type' => 'text/template',
)
);
ob_start();
require WP_PLUGIN_CHECK_PLUGIN_DIR_PATH . '/templates/results-row.php';
$results_row_template = ob_get_clean();
wp_print_inline_script_tag(
$results_row_template,
array(
'id' => 'tmpl-plugin-check-results-row',
'type' => 'text/template',
)
);

@jjgrainger jjgrainger requested a review from felixarntz April 3, 2023 15:13
Copy link
Copy Markdown
Member

@felixarntz felixarntz left a comment

Choose a reason for hiding this comment

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

@jjgrainger One last comment here, but this is pretty much good to go.

Comment thread assets/js/plugin-check-admin.js Outdated
Copy link
Copy Markdown
Member

@joemcgill joemcgill left a comment

Choose a reason for hiding this comment

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

This is looking good to me. I may have found a small bug that we could improve. It looks like if you click the button more than once wild checks are running, you will end up with multiple instances of the results. Probably the best way to handle this is to disable the button while the spinner is active.

image

Copy link
Copy Markdown
Member

@felixarntz felixarntz left a comment

Choose a reason for hiding this comment

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

@jjgrainger Thank you for the updates. Approved, pending the feedback from @joemcgill, it would be great to make the button temporarily disabled until the process is complete (or has terminated due to an error).

Copy link
Copy Markdown
Member

@joemcgill joemcgill left a comment

Choose a reason for hiding this comment

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

The latest commit fixes the double results issue for me. Thanks, @jjgrainger!

@felixarntz felixarntz dismissed spacedmonkey’s stale review April 3, 2023 17:14

Jonny is OOO, and his feedback has been addressed.

@felixarntz felixarntz merged commit 36afe97 into trunk Apr 3, 2023
@felixarntz felixarntz deleted the feature/ajax-show-check-results branch April 3, 2023 17:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Show check results on the page

4 participants