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

Add banner about updating default email address to email action #2239

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

AbdiTolesa
Copy link
Contributor

@AbdiTolesa AbdiTolesa commented Feb 3, 2025

Fix https://github.com/Strategy11/formidable-pro/issues/5453
Design: https://www.figma.com/design/QnMV8Njb7k5hDSdgrvNveY/Form-Actions-(Explorations)?node-id=6-207&t=Y9cwZI7PmScrnuVF-0

image

Test procedure

  1. Go to form actions tab of your form and open an email action.
  2. Confirm that a banner is implemented as per the design in the url above.
  3. Confirm that clicking Got it dismisses the banner and it would never be displayed for that user again, even after form reload.
  4. Confirm that Setup emails redirects user to the email setup page.

Copy link
Contributor

coderabbitai bot commented Feb 3, 2025

Warning

Rate limit exceeded

@AbdiTolesa has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 1 minutes and 5 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between d5a82af and 8426162.

📒 Files selected for processing (1)
  • classes/controllers/FrmFormsController.php (1 hunks)

Walkthrough

This pull request adds a feature to display a warning regarding potential email delivery issues when the 'To' and 'From' addresses are the same. A new conditional block in the view renders this warning along with buttons for acknowledgment or redirection to the email setup. New CSS rules enhance its visual styling. Additionally, AJAX functionality is implemented—with an action hook, a new controller method, and a corresponding JS event handler—to allow users to dismiss the warning message.

Changes

File(s) Change Summary
classes/views/frm-form-actions/_action_inside.php
css/frm_admin.css
Added a conditional block in the view to display an email warning message with acknowledge and redirect buttons; introduced new CSS styling for the default email message container.
classes/controllers/FrmHooksController.php
js/admin/settings.js
classes/controllers/FrmFormsController.php
Added an AJAX action hook and a corresponding public static method (dismiss_default_email_message) to handle dismiss requests; enhanced JS by adding an event listener that sends an AJAX request to dismiss the default email message and removes the message from the DOM on success.

Sequence Diagram(s)

sequenceDiagram
  participant U as User
  participant B as Browser (JS)
  participant H as FrmHooksController
  participant F as FrmFormsController

  U->>B: Clicks dismiss button on email warning
  B->>B: Executes handleClickEvent()
  B->>+H: Sends AJAX request (frm_dismiss_default_email_message)
  H->>+F: Calls dismiss_default_email_message()
  F-->>-H: Returns dismiss status (after nonce check and meta update)
  H-->>-B: AJAX response received
  B->>B: Removes the warning element from the DOM
Loading

Possibly related PRs

Suggested labels

run analysis, deploy, action: needs qa

Suggested reviewers

  • truongwp
  • Crabcyborg

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (3)
classes/views/frm-form-actions/_action_inside.php (2)

14-14: Remove empty style attribute.

The <p> tag contains an empty style attribute that should be removed.

-	<p class="frm10" style="">
+	<p class="frm10">

13-22: Improve semantic HTML structure and error handling.

The notice should use more semantic HTML elements and include error handling for translation functions.

-<div class="frm_grid_container frm_no_p_margin frm_default_email_notice">
-	<p class="frm10">
-		<b><?php esc_html_e( 'Heads up!', 'formidable' ); ?></b>
-		<?php esc_html_e( 'Using the same \'To\' and \'From\' email address can sometimes cause delivery issues. We recommend updating your default email addresses to maximize deliverability.', 'formidable' ); ?>
-	</p>
-	<p class="frm2">
+<div class="frm_grid_container frm_no_p_margin frm_default_email_notice" role="alert">
+	<div class="frm10">
+		<h4 class="frm_warning_heading">
+			<?php 
+			$heading = esc_html__( 'Heads up!', 'formidable' );
+			if ( false === $heading ) {
+				$heading = 'Heads up!'; // Fallback if translation fails
+			}
+			echo $heading;
+			?>
+		</h4>
+		<?php
+		$message = esc_html__( 'Using the same \'To\' and \'From\' email address can sometimes cause delivery issues. We recommend updating your default email addresses to maximize deliverability.', 'formidable' );
+		if ( false === $message ) {
+			$message = 'Please update your email settings to ensure proper delivery.'; // Fallback if translation fails
+		}
+		echo $message;
+		?>
+	</div>
+	<div class="frm2">
css/frm_admin.css (1)

5447-5451: Consider adding a hover/focus state for better interactivity.

If this notice contains any interactive elements like buttons or links, consider adding hover/focus states to provide visual feedback.

.frm_email_settings .frm_default_email_notice {
    background-color: var(--primary-25);
    padding:var(--gap-sm) var(--gap-md);
    border-radius:var(--small-radius);
+   transition: background-color 0.2s ease;
}

+.frm_email_settings .frm_default_email_notice:hover {
+   background-color: var(--primary-50);
+}

+.frm_email_settings .frm_default_email_notice:focus-within {
+   outline: 2px solid var(--primary-500);
+   outline-offset: 2px;
+}
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between cf5222c and 5a4b1a8.

📒 Files selected for processing (2)
  • classes/views/frm-form-actions/_action_inside.php (1 hunks)
  • css/frm_admin.css (1 hunks)
🔇 Additional comments (4)
classes/views/frm-form-actions/_action_inside.php (2)

10-24: LGTM! Well-placed notice block.

The placement of the email notice block at the beginning of the form action settings is appropriate and follows a logical flow.


19-20: ⚠️ Potential issue

Add click handlers and improve accessibility for buttons.

The buttons have href="#" but no JavaScript handlers to process the clicks. Additionally, they need ARIA labels for better accessibility.

-		<a href="#" class="button frm-button-secondary"><?php esc_html_e( 'Got it', 'formidable' ); ?></a>
-		<a href="#" class="button frm-button-primary"><?php esc_html_e( 'Setup emails', 'formidable' ); ?></a>
+		<a href="#" 
+			class="button frm-button-secondary" 
+			onclick="frmDismissEmailNotice(this); return false;" 
+			aria-label="<?php esc_attr_e( 'Dismiss email setup notice', 'formidable' ); ?>">
+			<?php esc_html_e( 'Got it', 'formidable' ); ?>
+		</a>
+		<a href="#" 
+			class="button frm-button-primary" 
+			onclick="frmShowEmailSetup(this); return false;" 
+			aria-label="<?php esc_attr_e( 'Open email setup configuration', 'formidable' ); ?>">
+			<?php esc_html_e( 'Setup emails', 'formidable' ); ?>
+		</a>

Please ensure the JavaScript functions frmDismissEmailNotice and frmShowEmailSetup are defined in your JS files:

css/frm_admin.css (2)

5447-5451: LGTM! The styling for the default email notice is well-structured.

The new CSS rule for .frm_email_settings .frm_default_email_notice uses appropriate variables for consistent styling and follows best practices:

  • Uses the primary color variable for background
  • Applies consistent padding using gap variables
  • Uses border-radius variable for rounded corners

5447-5451: Verify the background color contrast meets accessibility standards.

The background color uses var(--primary-25) which appears to be a light blue. Let's verify that this provides sufficient contrast with the text color for accessibility.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
classes/controllers/FrmFormsController.php (1)

2528-2537: LGTM! The implementation looks secure and follows WordPress best practices.

The function properly verifies the AJAX nonce before updating user meta. However, the @since version tag is not defined yet.

Update the @since x.x version number to the actual version this feature will be released in.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 22e4d5f and d5a82af.

📒 Files selected for processing (2)
  • classes/controllers/FrmFormsController.php (1 hunks)
  • classes/controllers/FrmHooksController.php (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • classes/controllers/FrmHooksController.php
🔇 Additional comments (1)
classes/controllers/FrmFormsController.php (1)

2549-2576: LGTM! The validation logic is thorough and handles different action types appropriately.

The function properly validates:

  • Redirect URLs through the frm_redirect_url filter
  • Page existence and status for page actions

@Crabcyborg Crabcyborg requested a review from truongwp February 14, 2025 18:04
@Crabcyborg Crabcyborg added this to the 6.19 milestone Feb 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants