[WEB-4479] feat: enable/disable SMTP configuration#7393
[WEB-4479] feat: enable/disable SMTP configuration#7393sriramveeraghanta merged 12 commits intopreviewfrom
Conversation
WalkthroughThis 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 Changes
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
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ 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)
✨ Finishing Touches
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed 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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
…lane/plane into chore-disable-enable-email
|
Pull Request Linked with Plane Work Items Comment Automatically Generated by Plane |
There was a problem hiding this comment.
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_SMTPconfiguration 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
useEffectimport 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
runInActionfor 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
📒 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
DisableEmailFeatureEndpointand follows the established formatting pattern.packages/services/src/instance/instance.service.ts (1)
126-137: LGTM!The new
disableEmailmethod 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_SMTPfield 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
disableEmailmethod.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
disableEmailmethod 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
useEffectcorrectly 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.
…ne into chore-disable-enable-email
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 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.
…lane/plane into chore-disable-enable-email
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 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
disableEmailfrom the store andisLoadingfrom 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.
* 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>
Description
Added a toggle button to enable/disable smtp
Summary by CodeRabbit
New Features
Bug Fixes
Chores