Skip to content

[INTERNAL] UI bugs fix#309

Closed
TLabutis wants to merge 0 commit into
SL-330-implement-terminal-id-api-retrievalmain-improvmementfrom
release-2.0.3
Closed

[INTERNAL] UI bugs fix#309
TLabutis wants to merge 0 commit into
SL-330-implement-terminal-id-api-retrievalmain-improvmementfrom
release-2.0.3

Conversation

@TLabutis

Copy link
Copy Markdown
Contributor

Self-Checks

  • I have performed a self-review of my code.
  • I have updated/added necessary technical documentation in the README file.

JIRA task link

Summary

QA Checklist Labels

  • Bug fix?
  • New feature?
  • Improvement?
  • Technical debt?
  • Reusable?
  • Covered by tests?

QA Checklist

Additional Context

Frontend Changes

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @TLabutis, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly upgrades the SaferPay module's administrative configuration by introducing dynamic terminal management. It allows administrators to automatically retrieve and select payment terminals from SaferPay using their credentials, streamlining the setup process and reducing potential configuration errors. The changes encompass both backend logic for handling terminal data and a responsive frontend interface that provides clear feedback and flexibility for manual input when needed.

Highlights

  • Dynamic Terminal Loading: Implemented AJAX functionality to fetch available SaferPay terminals in real-time based on the provided customer credentials (Customer ID, Username, Password).
  • Enhanced User Interface: Redesigned the terminal selection field in the admin settings to include a dynamic dropdown, a refresh button, and an optional manual input field for terminal IDs.
  • Robust Credential Validation & Error Handling: Added server-side validation for SaferPay credentials and comprehensive error logging and user feedback for terminal fetching operations.
  • Optimized Frontend Interaction: Introduced debounced AJAX calls for credential changes and managed the UI state (loading, disabled, error messages) for a smoother user experience.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a dynamic way to fetch SaferPay terminals in the admin settings page, which is a great improvement for user experience. The implementation involves a new AJAX endpoint in the controller, corresponding JavaScript to handle the frontend logic, and template updates.

My review has identified a few critical issues that need to be addressed:

  • There is a fatal error due to a method signature mismatch when calling getAvailableTerminals.
  • A debug alert() is present in the JavaScript which will disrupt users.
  • There is a bug in a form submit handler in the JavaScript.

Additionally, there are several debug console.log statements that should be removed, and a small opportunity for code simplification in the JavaScript.

Please see the detailed comments for each point.

/** @var SaferPayTerminalService $terminalService */
$terminalService = $this->module->getService(SaferPayTerminalService::class);

$terminals = $terminalService->getAvailableTerminals($customerId, $username, $password, $isTestMode);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

critical

The call to getAvailableTerminals provides four arguments, but the method definition in SaferPayTerminalService only accepts one ($customerId). This will result in a fatal error.

To fix this, you need to update the getAvailableTerminals method in src/Service/SaferPayTerminalService.php to accept the customer ID, username, password, and test mode flag as arguments. This will also require updating the private methods it uses (getHeaders, getBaseRestUrl) to use these arguments instead of relying on global Configuration values. This change will make the service stateless and more robust.

Other calls to getAvailableTerminals in the codebase will also need to be updated to pass the required credentials.

Comment thread views/js/admin/saferpay_settings.js Outdated
console.log('[DEBUG] Making AJAX request with params:', Object.assign({}, params, {password: '***'}));
// #endregion

alert('Customer ID before AJAX: ' + customerId); // Temporary debug alert

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

critical

This alert() seems to be for debugging purposes. It's very disruptive to the user experience and must be removed before this code is merged.

Comment thread views/js/admin/saferpay_settings.js Outdated

$('form').on('submit', function() {
if ($manualInput.val() && !$select.val()) {
var manualValue = $(this).val();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

In this form submit event handler, $(this) refers to the form element, not the manual input field. Therefore, $(this).val() will not return the value of the manual input. You should use $manualInput.val() instead to get the correct value.

                var manualValue = $manualInput.val();

Comment thread views/js/admin/saferpay_settings.js Outdated
Comment on lines +24 to +26
// #region agent log
console.log('[DEBUG] saferpay_settings.js loaded');
// #endregion

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

This file contains multiple console.log statements (e.g., lines 25, 42, 54, 112, 125, 137, 171). These appear to be for debugging and should be removed from the production code to keep the browser console clean for users and other developers.

Comment thread views/js/admin/saferpay_settings.js Outdated
Comment on lines +57 to +60
if ($field.attr('type') === 'password') {
return $field.val() || '';
}
return $field.val() || '';

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

This if statement is redundant because both branches return the same value. It can be simplified to a single return statement. Note that this is safe to do after removing the debug console.log on line 54 which treats password fields specially.

                return $field.val() || '';

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.

1 participant