Skip to content

[WEB-4479] feat: enable/disable SMTP configuration#7393

Merged
sriramveeraghanta merged 12 commits intopreviewfrom
chore-disable-enable-email
Jul 15, 2025
Merged

[WEB-4479] feat: enable/disable SMTP configuration#7393
sriramveeraghanta merged 12 commits intopreviewfrom
chore-disable-enable-email

Conversation

@sangeethailango
Copy link
Member

@sangeethailango sangeethailango commented Jul 11, 2025

Description

Added a toggle button to enable/disable smtp

Summary by CodeRabbit

  • New Features

    • Added the ability to enable or disable the email (SMTP) feature from the admin dashboard using a toggle switch.
    • Introduced an API endpoint and backend support to fully disable email by clearing related configuration settings.
    • Added visual feedback and improved UI for managing email configuration, including loading states and success notifications.
    • Ensured the email feature is always enabled upon form submission.
  • Bug Fixes

    • Ensured the email feature state is accurately reflected and updated in the UI.
  • Chores

    • Added a new configuration key for controlling SMTP enablement.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jul 11, 2025

Walkthrough

This change introduces the ability to enable or disable the SMTP email feature from the admin dashboard. It adds a toggle UI, backend API endpoint, and supporting logic to clear or set email configuration values accordingly. The configuration key ENABLE_SMTP is now explicitly managed across frontend, backend, and environment setup.

Changes

File(s) Change Summary
apps/admin/app/(all)/(dashboard)/email/email-config-form.tsx Added handling for ENABLE_SMTP in form state and submission payload.
apps/admin/app/(all)/(dashboard)/email/page.tsx Introduced toggle UI for enabling/disabling SMTP; added state management and handler logic.
apps/admin/core/store/instance.store.ts Added disableEmail method to clear email-related config values and update state via API.
apps/api/plane/license/api/views/init.py Imported new endpoint DisableEmailFeatureEndpoint.
apps/api/plane/license/api/views/configuration.py Added DisableEmailFeatureEndpoint to clear email config values via DELETE request.
apps/api/plane/license/management/commands/configure_instance.py Registered ENABLE_SMTP as a config key with default value and metadata.
apps/api/plane/license/urls.py Registered API route for disabling email configuration.
packages/services/src/instance/instance.service.ts Added disableEmail method to call backend API for disabling email feature.
packages/types/src/instance/email.ts Added "ENABLE_SMTP" to email configuration key types.

Sequence Diagram(s)

sequenceDiagram
    participant AdminUser
    participant UI (Email Page)
    participant Store
    participant Service
    participant API

    AdminUser->>UI (Email Page): Clicks "Disable Email" toggle
    UI (Email Page)->>Store: handleToggle() calls disableEmail()
    Store->>Service: disableEmail()
    Service->>API: DELETE /api/instances/configurations/disable-email-feature/
    API->>Service: 200 OK
    Service->>Store: Promise resolved
    Store->>UI (Email Page): State updated, toast shown
Loading

Poem

In the dashboard’s gentle glow,
A toggle switch now steals the show.
SMTP on, SMTP gone—
With a flick, the configs are withdrawn.
Rabbits cheer, their inboxes clear,
For email control is finally here!
🐇✉️


📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 8ac5244 and 20a32f3.

📒 Files selected for processing (1)
  • apps/admin/app/(all)/(dashboard)/email/email-config-form.tsx (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/admin/app/(all)/(dashboard)/email/email-config-form.tsx
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Analyze (javascript)
✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ 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.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @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.

@gakshita gakshita changed the title feat: enable/disable SMTP configuration [WEB-4479] feat: enable/disable SMTP configuration Jul 11, 2025
@makeplane
Copy link

makeplane bot commented Jul 11, 2025

Pull Request Linked with Plane Work Items

Comment Automatically Generated by Plane

@gakshita gakshita marked this pull request as ready for review July 11, 2025 13:25
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: 4

🧹 Nitpick comments (3)
apps/api/plane/license/management/commands/configure_instance.py (1)

92-97: LGTM with positioning suggestion.

The new ENABLE_SMTP configuration key is correctly implemented with appropriate defaults and categorization. However, consider relocating this configuration closer to other SMTP keys (after line 145) to maintain logical grouping of related configuration keys.

apps/admin/app/(all)/(dashboard)/email/email-config-form.tsx (1)

3-3: Remove unused import.

The useEffect import is not used anywhere in the component.

-import React, { FC, useEffect, useMemo, useState } from "react";
+import React, { FC, useMemo, useState } from "react";
apps/admin/core/store/instance.store.ts (1)

192-216: Enhance error handling with more detailed logging.

The implementation is solid with proper state management and error recovery. Consider adding more specific error information for debugging.

   } catch (error) {
-    console.error("Error disabling the email");
+    console.error("Error disabling the email:", error);
     this.instanceConfigurations = instanceConfigurations;
+    throw error; // Re-throw to allow caller to handle
   }

The current implementation correctly:

  • Uses MobX runInAction for state updates
  • Maintains backup state for error recovery
  • Clears all relevant email configuration keys
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between f661e06 and e470559.

📒 Files selected for processing (9)
  • apps/admin/app/(all)/(dashboard)/email/email-config-form.tsx (3 hunks)
  • apps/admin/app/(all)/(dashboard)/email/page.tsx (1 hunks)
  • apps/admin/core/store/instance.store.ts (2 hunks)
  • apps/api/plane/license/api/views/__init__.py (1 hunks)
  • apps/api/plane/license/api/views/configuration.py (2 hunks)
  • apps/api/plane/license/management/commands/configure_instance.py (1 hunks)
  • apps/api/plane/license/urls.py (2 hunks)
  • packages/services/src/instance/instance.service.ts (1 hunks)
  • packages/types/src/instance/email.ts (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
apps/admin/app/(all)/(dashboard)/email/email-config-form.tsx (1)
Learnt from: prateekshourya29
PR: makeplane/plane#7363
File: apps/web/helpers/react-hook-form.helper.ts:9-19
Timestamp: 2025-07-08T13:41:19.928Z
Learning: In the apps/web/helpers/react-hook-form.helper.ts file, the getNestedError function's FieldError detection logic using "message" property check is sufficient for their use case, and more robust type checking is not required.
🧬 Code Graph Analysis (2)
apps/api/plane/license/api/views/__init__.py (1)
apps/api/plane/license/api/views/configuration.py (3)
  • EmailCredentialCheckEndpoint (83-172)
  • InstanceConfigurationEndpoint (28-58)
  • DisableEmailFeatureEndpoint (61-80)
apps/api/plane/license/urls.py (1)
apps/api/plane/license/api/views/configuration.py (1)
  • DisableEmailFeatureEndpoint (61-80)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Analyze (javascript)
🔇 Additional comments (12)
apps/api/plane/license/api/views/__init__.py (1)

4-8: LGTM!

The import addition correctly includes the new DisableEmailFeatureEndpoint and follows the established formatting pattern.

packages/services/src/instance/instance.service.ts (1)

126-137: LGTM!

The new disableEmail method is well-implemented with proper error handling, documentation, and follows the established patterns in the class.

apps/api/plane/license/urls.py (1)

39-43: LGTM!

The new URL pattern is correctly implemented and follows RESTful conventions. The endpoint path matches the service method's API call.

apps/admin/app/(all)/(dashboard)/email/email-config-form.tsx (1)

52-52: LGTM: Properly integrated ENABLE_SMTP into form state.

The form correctly initializes the ENABLE_SMTP field from the configuration.

apps/api/plane/license/api/views/configuration.py (1)

12-12: LGTM: Proper imports for conditional database updates.

The added Django ORM imports are correctly used for the conditional update logic.

apps/admin/core/store/instance.store.ts (1)

35-35: LGTM: Proper interface extension.

The interface correctly declares the new disableEmail method.

apps/admin/app/(all)/(dashboard)/email/page.tsx (6)

3-3: LGTM: Proper React hooks import.

The added hooks are correctly used throughout the component.


6-6: LGTM: Proper UI component imports.

The imported components are correctly used for the toggle functionality.


14-14: LGTM: Proper store hook usage.

The disableEmail method is correctly destructured from the store.


18-19: LGTM: Appropriate state management.

The state variables are properly initialized and used throughout the component.


41-45: LGTM: Proper state synchronization.

The useEffect correctly synchronizes the toggle state with the configuration.


50-83: LGTM: Well-structured UI with conditional rendering.

The UI properly handles different states (loading, enabled/disabled) and provides good user experience with appropriate loading indicators.

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: 1

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between e470559 and dd34fe6.

📒 Files selected for processing (1)
  • apps/api/plane/license/api/views/configuration.py (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Analyze (javascript)
🔇 Additional comments (1)
apps/api/plane/license/api/views/configuration.py (1)

12-12: LGTM: Required imports added correctly.

The Django ORM imports are properly added to support the conditional database update logic in the new endpoint.

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: 1

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between dd34fe6 and b14cafa.

📒 Files selected for processing (2)
  • apps/admin/app/(all)/(dashboard)/email/page.tsx (1 hunks)
  • packages/types/src/instance/email.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/types/src/instance/email.ts
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: gakshita
PR: makeplane/plane#7393
File: apps/admin/app/(all)/(dashboard)/email/email-config-form.tsx:104-104
Timestamp: 2025-07-14T11:22:43.947Z
Learning: In the Plane project's SMTP configuration implementation, the email configuration form (email-config-form.tsx) hardcodes ENABLE_SMTP to "1" in form submission because the form is only rendered when SMTP is enabled. The enable/disable functionality is managed at the page level (page.tsx) with a toggle, and the form only handles configuration details when SMTP is already enabled.
apps/admin/app/(all)/(dashboard)/email/page.tsx (1)
Learnt from: gakshita
PR: makeplane/plane#7393
File: apps/admin/app/(all)/(dashboard)/email/email-config-form.tsx:104-104
Timestamp: 2025-07-14T11:22:43.947Z
Learning: In the Plane project's SMTP configuration implementation, the email configuration form (email-config-form.tsx) hardcodes ENABLE_SMTP to "1" in form submission because the form is only rendered when SMTP is enabled. The enable/disable functionality is managed at the page level (page.tsx) with a toggle, and the form only handles configuration details when SMTP is already enabled.
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Analyze (javascript)
🔇 Additional comments (6)
apps/admin/app/(all)/(dashboard)/email/page.tsx (6)

3-3: LGTM: Clean imports for the new functionality.

The additional imports for React hooks and UI components are appropriate for the toggle feature implementation.

Also applies to: 6-6


14-14: LGTM: Store integration looks correct.

The destructuring of disableEmail from the store and isLoading from the SWR hook aligns well with the new toggle functionality.

Also applies to: 16-16


18-19: LGTM: Appropriate state management for the toggle.

The local state variables for submission status and SMTP enabled state are well-chosen for managing the toggle interaction.


50-54: LGTM: Proper state synchronization.

The useEffect correctly synchronizes the local toggle state with the server configuration, ensuring consistency after data fetching.


59-77: LGTM: Well-implemented toggle UI.

The toggle switch is properly integrated with loading states and disabled during submission to prevent race conditions.


78-92: LGTM: Logical conditional rendering.

The form is appropriately shown only when SMTP is enabled and data is loaded, with a proper loading state fallback.

@pushya22 pushya22 requested a review from gakshita July 15, 2025 13:38
@sriramveeraghanta sriramveeraghanta merged commit 99127ff into preview Jul 15, 2025
5 of 6 checks passed
@sriramveeraghanta sriramveeraghanta deleted the chore-disable-enable-email branch July 15, 2025 19:34
@coderabbitai coderabbitai bot mentioned this pull request Jul 22, 2025
2 tasks
lifeiscontent pushed a commit that referenced this pull request Aug 18, 2025
* feat: api update instance configuration

* chore: add enable_smtp key

* fix: empty string for enable_smtp key

* chore: update email_port and email_from

* fix: handled smtp enable disable

* fix: error handling

* fix: refactor

* fix: removed enabled toast

* fix: refactor

---------

Co-authored-by: gakshita <akshitagoyal1516@gmail.com>
Co-authored-by: Akshita Goyal <36129505+gakshita@users.noreply.github.com>
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.

7 participants