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

fix: code splitting for workspace delete modal #6581

Merged
merged 3 commits into from
Feb 12, 2025

Conversation

gakshita
Copy link
Collaborator

@gakshita gakshita commented Feb 11, 2025

Description

This PR does code splitting for delete workspace modal

Summary by CodeRabbit

  • New Features

    • Introduced a new modal for deleting workspaces, enhancing user confirmation during the deletion process.
    • Added a deletion form that requires users to confirm their intent by entering specific phrases.
    • Updated translation keys for improved clarity and user experience regarding workspace deletion across multiple languages.
  • Refactor

    • Updated the import structure for workspace deletion components to improve organization and accessibility.

Copy link
Contributor

coderabbitai bot commented Feb 11, 2025

Walkthrough

This pull request introduces a new workspace deletion modal workflow. A new DeleteWorkspaceModal component is added to present a deletion confirmation dialog, while its import path is updated in the corresponding workspace section. The legacy deletion modal is removed and replaced by a new DeleteWorkspaceForm component that handles form validation, deletion confirmation, event capturing, and redirection. Additionally, the Core index export is updated accordingly, and the EE module now re-exports the CE modal component.

Changes

File(s) Change Summary
web/ce/components/workspace/delete-workspace-modal.tsx
web/ce/components/workspace/delete-workspace-section.tsx
Added the new DeleteWorkspaceModal component and updated its import path in the workspace section.
web/core/components/workspace/delete-workspace-form.tsx
web/core/components/workspace/delete-workspace-modal.tsx
web/core/components/workspace/index.ts
Introduced the new DeleteWorkspaceForm component, removed the legacy DeleteWorkspaceModal, and updated export statements accordingly.
web/ee/components/workspace/delete-workspace-modal.tsx Re-exported all entities from the CE DeleteWorkspaceModal component to serve as a proxy.
packages/i18n/src/locales/en/translations.json
packages/i18n/src/locales/es/translations.json
packages/i18n/src/locales/fr/translations.json
packages/i18n/src/locales/ja/translations.json
packages/i18n/src/locales/zh-CN/translations.json
Updated translation keys and added new modal structures for workspace deletion confirmation across multiple languages.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Modal as DeleteWorkspaceModal
    participant Form as DeleteWorkspaceForm
    participant Nav as Navigation/Notification

    User->>Modal: Open deletion modal
    Modal->>Form: Render deletion form with workspace data
    User->>Form: Submit confirmation inputs
    alt Valid Input
      Form->>Nav: Trigger deletion, capture event, navigate, show success toast
    else Invalid Input
      Form->>Nav: Show error toast, capture failure event
    end
    Form->>Modal: Call onClose to close modal
Loading

Possibly related PRs

  • minor improvements for workspace management #6099: The changes in the main PR, which introduce the DeleteWorkspaceModal component, are related to the modifications in the retrieved PR that update the import path for this component in delete-workspace-section.tsx, indicating a direct connection at the code level.

Suggested labels

⚙️backend, 🌐frontend

Suggested reviewers

  • SatishGandham
  • sriramveeraghanta

Poem

I'm a little rabbit, hopping with glee,
Code carrots added in modals, you see!
With forms and modals, our work's a delight,
Validation and toast—everything's right!
Hop along, dear coder, in the coding spree!
🥕🐇 Happy coding and a joyful day!


📜 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 33829d0 and 342a89d.

📒 Files selected for processing (6)
  • packages/i18n/src/locales/en/translations.json (1 hunks)
  • packages/i18n/src/locales/es/translations.json (1 hunks)
  • packages/i18n/src/locales/fr/translations.json (1 hunks)
  • packages/i18n/src/locales/ja/translations.json (1 hunks)
  • packages/i18n/src/locales/zh-CN/translations.json (1 hunks)
  • web/core/components/workspace/delete-workspace-form.tsx (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • web/core/components/workspace/delete-workspace-form.tsx
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Analyze (javascript)
🔇 Additional comments (6)
packages/i18n/src/locales/zh-CN/translations.json (2)

1425-1427: LGTM! Text changes improve clarity and user experience.

The changes to the workspace deletion text are well-considered:

  • "删除工作区" → "删除此工作区" makes the action more specific
  • The description's punctuation change maintains better consistency with Chinese writing standards

1428-1437: LGTM! Comprehensive modal messages for the deletion workflow.

The new delete modal section provides a complete set of user feedback messages:

  • Clear confirmation title and description
  • Appropriate action buttons ("关闭" and "取消试用")
  • Well-structured success/error states with clear next steps
packages/i18n/src/locales/ja/translations.json (1)

1425-1437: LGTM! Complete and well-structured translations for workspace deletion.

The translations for the workspace deletion workflow are comprehensive and cover all necessary UI elements:

  • Clear action button and warning message
  • Modal with title and description for trial cancellation
  • Success and error states with appropriate messages
  • Consistent tone and style with the rest of the translations
packages/i18n/src/locales/en/translations.json (1)

1256-1268: LGTM! The translations are comprehensive and well-structured.

The new translations for the workspace deletion modal cover all necessary states:

  • Confirmation dialog with clear messaging about trial cancellation
  • Success state with user redirection information
  • Error state with retry guidance

The translations follow the established patterns in the codebase and provide clear, user-friendly messages.

packages/i18n/src/locales/es/translations.json (1)

1425-1437: LGTM! The Spanish translations for workspace deletion are clear and consistent.

The translations effectively communicate the workspace deletion workflow while maintaining:

  • Proper formal tone using "usted" form
  • Correct Spanish grammar and punctuation
  • Clear warning about the consequences of deletion
packages/i18n/src/locales/fr/translations.json (1)

1425-1437: LGTM! Well-structured and grammatically correct translations.

The French translations for the workspace deletion modal are accurate, clear, and maintain a consistent tone. The translations effectively convey:

  • The warning message about active trials
  • The modal actions (close, cancel trial)
  • Success/error states with appropriate feedback

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.

@gakshita gakshita changed the title fix: code splitting for delete modal fix: code splitting for workspace delete modal Feb 11, 2025
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: 2

🧹 Nitpick comments (4)
web/ce/components/workspace/delete-workspace-modal.tsx (1)

19-27: Consider adding error boundaries for the modal.

While the implementation is clean and follows good practices, consider wrapping the modal content with error boundaries to gracefully handle any rendering errors in the form component.

 export const DeleteWorkspaceModal: React.FC<Props> = observer((props) => {
   const { isOpen, data, onClose } = props;

   return (
     <ModalCore isOpen={isOpen} handleClose={() => onClose()} position={EModalPosition.CENTER} width={EModalWidth.XL}>
+      <ErrorBoundary fallback={<div>Something went wrong</div>}>
         <DeleteWorkspaceForm data={data} onClose={onClose} />
+      </ErrorBoundary>
     </ModalCore>
   );
 });
web/core/components/workspace/delete-workspace-form.tsx (3)

44-44: Consider extracting validation logic to a separate function.

The validation logic in canDelete could be more readable if extracted to a named function.

-  const canDelete = watch("workspaceName") === data?.name && watch("confirmDelete") === "delete my workspace";
+  const validateDeletion = (workspaceName: string, confirmPhrase: string) => {
+    return workspaceName === data?.name && confirmPhrase === "delete my workspace";
+  };
+  const canDelete = validateDeletion(watch("workspaceName"), watch("confirmDelete"));

167-169: Enhance loading state feedback.

Consider providing more detailed feedback during the deletion process.

-        <Button variant="danger" size="sm" type="submit" disabled={!canDelete} loading={isSubmitting}>
-          {isSubmitting ? "Deleting" : "Confirm"}
+        <Button variant="danger" size="sm" type="submit" disabled={!canDelete || isSubmitting} loading={isSubmitting}>
+          {isSubmitting ? "Deleting workspace..." : "Delete workspace"}
         </Button>

93-172: Consider adding keyboard shortcuts for better UX.

The form could benefit from keyboard shortcuts for common actions like closing the modal with 'Esc'.

+  useEffect(() => {
+    const handleEscape = (e: KeyboardEvent) => {
+      if (e.key === "Escape") {
+        handleClose();
+      }
+    };
+    window.addEventListener("keydown", handleEscape);
+    return () => window.removeEventListener("keydown", handleEscape);
+  }, []);

   return (
     <form onSubmit={handleSubmit(onSubmit)} className="flex flex-col gap-6 p-6">
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 363507f and 51a0bc0.

📒 Files selected for processing (6)
  • web/ce/components/workspace/delete-workspace-modal.tsx (1 hunks)
  • web/ce/components/workspace/delete-workspace-section.tsx (1 hunks)
  • web/core/components/workspace/delete-workspace-form.tsx (1 hunks)
  • web/core/components/workspace/delete-workspace-modal.tsx (0 hunks)
  • web/core/components/workspace/index.ts (0 hunks)
  • web/ee/components/workspace/delete-workspace-modal.tsx (1 hunks)
💤 Files with no reviewable changes (2)
  • web/core/components/workspace/index.ts
  • web/core/components/workspace/delete-workspace-modal.tsx
✅ Files skipped from review due to trivial changes (2)
  • web/ee/components/workspace/delete-workspace-modal.tsx
  • web/ce/components/workspace/delete-workspace-section.tsx
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Analyze (javascript)
  • GitHub Check: Analyze (python)
🔇 Additional comments (1)
web/ce/components/workspace/delete-workspace-modal.tsx (1)

13-17: LGTM! Well-defined props interface.

The props interface clearly defines the required properties with appropriate types.

web/core/components/workspace/delete-workspace-form.tsx Outdated Show resolved Hide resolved
web/core/components/workspace/delete-workspace-form.tsx Outdated Show resolved Hide resolved
@sriramveeraghanta sriramveeraghanta merged commit 6a3ccaf into preview Feb 12, 2025
10 of 14 checks passed
@sriramveeraghanta sriramveeraghanta deleted the fix-workspace-delete-modal branch February 12, 2025 11:45
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.

3 participants