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

[WEB-2577] improvement: use common create/update issue modal for accepting intake issues for consistency #5830

Merged
merged 4 commits into from
Oct 15, 2024

Conversation

prateekshourya29
Copy link
Member

@prateekshourya29 prateekshourya29 commented Oct 14, 2024

Issue link: WEB-2577

Summary by CodeRabbit

  • New Features

    • Introduced a new modal for creating inbox issues with enhanced configuration options.
    • Updated the issue header to reflect current project details and improved modal handling.
  • Bug Fixes

    • Improved clarity in success messages for issue creation and updates.
  • Refactor

    • Replaced outdated modal components with new, more functional alternatives.
    • Consolidated logic for filtering archived issues in the issue store.
  • Documentation

    • Updated component signatures to include new props for better configurability.

Copy link
Contributor

coderabbitai bot commented Oct 14, 2024

Caution

Review failed

The head commit changed during the review from 1d244f0 to c6e8b19.

Walkthrough

The changes in this pull request involve significant modifications to several components related to issue management in the application. Key updates include the renaming and replacement of modal components, the introduction of new props for enhanced configurability, and the removal of obsolete components. Additionally, adjustments to existing interfaces and methods improve the handling of issue properties and user interactions. Overall, the changes streamline the modal functionality and improve the user experience without altering the underlying logic.

Changes

File Change Summary
web/app/[workspaceSlug]/(projects)/projects/(detail)/[projectId]/inbox/header.tsx Renamed component from InboxIssueCreateEditModalRoot to InboxIssueCreateModalRoot; removed issue prop.
web/core/components/inbox/content/inbox-issue-header.tsx Replaced InboxIssueCreateEditModalRoot with CreateUpdateIssueModal; added new props and updated modal title.
web/core/components/inbox/modals/create-edit-modal/edit-root.tsx Removed InboxIssueEditRoot component.
web/core/components/inbox/modals/create-edit-modal/modal.tsx Removed InboxIssueCreateEditModalRoot component.
web/core/components/inbox/modals/create-modal/create-root.tsx Updated import paths for components; minor JSX adjustments.
web/core/components/inbox/modals/create-modal/index.ts Removed export statement for edit-root.
web/core/components/inbox/modals/create-modal/issue-properties.tsx Minor change in setIsOpen prop formatting.
web/core/components/inbox/modals/create-modal/modal.tsx Introduced new component InboxIssueCreateModalRoot for creating inbox issues.
web/core/components/inbox/modals/index.ts Replaced export of create-edit-modal with create-modal.
web/core/components/issues/issue-modal/base.tsx Updated props in CreateUpdateIssueModalBase for enhanced configurability.
web/core/components/issues/issue-modal/context/issue-modal.tsx Added issueTypeId to TCreateUpdatePropertyValuesProps type.
web/core/components/issues/issue-modal/draft-issue-layout.tsx Added modalTitle and primaryButtonText to DraftIssueProps interface.
web/core/components/issues/issue-modal/form.tsx Added modalTitle and primaryButtonText to IssueFormProps interface.
web/core/components/issues/issue-modal/modal.tsx Added beforeFormSubmit, modalTitle, and primaryButtonText to IssuesModalProps interface.
web/core/components/issues/workspace-draft/delete-modal.tsx Minor text formatting change in AlertModalCore content prop.
web/core/store/issue/issue.store.ts Refined conditional logic in getIssuesByIds method for filtering archived issues.

Possibly related PRs

Suggested labels

🌟enhancement, 🌐frontend, 🧹chore

Suggested reviewers

  • sriramveeraghanta
  • SatishGandham

🐰✨ In the meadow, changes bloom,
New modals rise, dispelling gloom.
With titles bright and buttons fair,
Creating issues, a breeze in the air!
Hopping forth, we celebrate,
Enhancements made, oh, isn’t it great? 🌼🌟


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

🧹 Outside diff range and nitpick comments (12)
web/core/components/inbox/modals/create-modal/modal.tsx (2)

14-27: LGTM: Component implementation is clean and aligns with PR objectives.

The InboxIssueCreateModalRoot component is well-structured and correctly implements the modal for creating inbox issues. It aligns with the PR objectives of using a common modal for consistency.

Consider adding a brief JSDoc comment above the component to describe its purpose and props. This can improve code documentation and help other developers understand the component's role more quickly.

Example:

/**
 * Modal component for creating inbox issues.
 * @param {string} workspaceSlug - The slug of the current workspace.
 * @param {string} projectId - The ID of the current project.
 * @param {boolean} modalState - Whether the modal is open or closed.
 * @param {() => void} handleModalClose - Function to close the modal.
 */
export const InboxIssueCreateModalRoot: FC<TInboxIssueCreateModalRoot> = (props) => {
  // ... (rest of the component code)
};

1-27: Overall, excellent implementation that meets PR objectives.

This new InboxIssueCreateModalRoot component successfully implements a common modal for creating inbox issues, which aligns perfectly with the PR objectives of improving consistency across the application. The code is clean, well-structured, and follows React and TypeScript best practices.

To further enhance the component's reusability and flexibility, consider the following suggestions for future improvements:

  1. If this modal pattern is used in multiple places, you might want to create a more generic IssueCreateModal component that can be configured for different contexts (inbox, backlog, etc.).
  2. Consider using a context provider for workspace and project information if these are frequently passed down to many components. This could help reduce prop drilling in larger component trees.
web/core/components/issues/issue-modal/modal.tsx (1)

18-29: LGTM! Consider adding JSDoc comments for better documentation.

The new properties beforeFormSubmit, modalTitle, and primaryButtonText enhance the flexibility and customization of the modal, aligning well with the PR objective of improving consistency and reusability. The changes are backwards compatible as all new properties are optional.

Consider adding JSDoc comments to describe the purpose and usage of these new properties. This would improve the self-documentation of the code. For example:

/**
 * Function to be called before form submission. Can be used for validation or data preparation.
 * @returns A Promise that resolves when the pre-submission tasks are complete.
 */
beforeFormSubmit?: () => Promise<void>;

/** Custom title for the modal. */
modalTitle?: string;

/**
 * Custom text for the primary button in different states.
 * @property {string} default - Text to display in the default state.
 * @property {string} loading - Text to display when the form is being submitted.
 */
primaryButtonText?: {
  default: string;
  loading: string;
};
web/app/[workspaceSlug]/(projects)/projects/(detail)/[projectId]/inbox/header.tsx (2)

72-77: Update documentation to reflect changes in modal functionality.

The changes in the component usage are consistent with the renaming of InboxIssueCreateEditModalRoot to InboxIssueCreateModalRoot. The removal of the issue prop suggests that this modal is now specifically for creating new issues, not editing existing ones.

Consider updating any relevant documentation or comments to reflect this change in functionality. This will help maintain clear and accurate documentation for the development team.


Line range hint 1-85: Summary of changes and potential impact

The changes in this file are part of a larger refactoring effort to separate the creation and editing functionalities for inbox issues. The main changes include:

  1. Renaming InboxIssueCreateEditModalRoot to InboxIssueCreateModalRoot.
  2. Removing the issue prop from the modal component usage.

These changes align with the PR objective of using a common modal for creating and updating issues related to intake processes.

Consider the following points:

  1. Ensure that the separation of create and edit functionalities is consistently applied across the entire application.
  2. Update user documentation to reflect any changes in the user interface or workflow.
  3. If not already done, consider adding or updating unit tests to cover the new functionality of the InboxIssueCreateModalRoot component.
web/core/store/issue/issue.store.ts (1)

128-128: Approve changes with a minor suggestion for consistency

The consolidation of the conditional logic improves code readability and potentially performance. The new implementation correctly filters issues based on their archived status for both "archived" and "un-archived" types.

For consistency, consider removing the optional chaining operator (?.) from the "un-archived" condition, as it's not used in the "archived" condition. This change would make the code more uniform:

- if (issue && ((type === "archived" && issue.archived_at) || (type === "un-archived" && !issue?.archived_at))) {
+ if (issue && ((type === "archived" && issue.archived_at) || (type === "un-archived" && !issue.archived_at))) {

This minor adjustment doesn't affect functionality but enhances code consistency.

web/core/components/issues/issue-modal/base.tsx (3)

31-39: LGTM! Consider updating documentation for new props.

The addition of beforeFormSubmit, modalTitle, and primaryButtonText props enhances the component's flexibility. This change allows for better customization of the modal's behavior and appearance.

Consider updating the component's documentation or adding JSDoc comments to describe these new props and their usage.


257-259: LGTM! Consider refactoring for consistency.

The addition of issueTypeId to handleCreateUpdatePropertyValues in the update flow is consistent with the earlier change in the create flow. This ensures that issue type is considered when updating property values for existing issues.

For better maintainability, consider extracting the call to handleCreateUpdatePropertyValues into a separate function, as it's used in both handleCreateIssue and handleUpdateIssue. This would reduce code duplication and make future changes easier. For example:

const updatePropertyValues = async (issueId: string, projectId: string, issueTypeId: string) => {
  await handleCreateUpdatePropertyValues({
    issueId,
    issueTypeId,
    projectId,
    workspaceSlug: workspaceSlug.toString(),
  });
};

Then you can call this function in both handleCreateIssue and handleUpdateIssue.


296-298: LGTM! Consider adding error handling for beforeFormSubmit.

The addition of beforeFormSubmit in handleFormSubmit and passing modalTitle and primaryButtonText to IssueFormRoot are good improvements. These changes enhance the component's flexibility and customization options.

Consider adding error handling for beforeFormSubmit to gracefully handle any errors that might occur during its execution. For example:

if (beforeFormSubmit) {
  try {
    await beforeFormSubmit();
  } catch (error) {
    console.error("Error in beforeFormSubmit:", error);
    // Optionally, you could set an error state or show a toast notification here
  }
}

This would prevent any errors in beforeFormSubmit from silently breaking the form submission process.

Also applies to: 357-358

web/core/components/issues/issue-modal/form.tsx (2)

84-88: LGTM! Default values for new props enhance usability.

The default values for modalTitle and primaryButtonText are well-implemented, providing context-appropriate text based on the issue's state. This ensures the component works well even without custom prop values.

For consistency, consider extracting the condition data?.id ? "Update" : isDraft ? "Create draft" : "Create new" into a variable, as it's used multiple times. This would make future modifications easier and reduce the risk of inconsistencies.


427-427: LGTM! Dynamic submit button text enhances user feedback.

The use of primaryButtonText for the submit button improves user feedback by clearly indicating the current state (submitting or ready to submit). This change enhances the overall user experience.

Consider adding an aria-live="polite" attribute to the button or a nearby element to ensure screen readers announce the change in button text when the form submission state changes. This would further improve accessibility for users relying on assistive technologies.

web/core/components/inbox/content/inbox-issue-header.tsx (1)

237-248: LGTM: Improved modal implementation with suggestion

The replacement of InboxIssueCreateEditModalRoot with CreateUpdateIssueModal is a positive change. The new implementation provides more flexibility and reusability, with custom props for better control over the modal's behavior.

Consider extracting the modal title to a constant or a function for better readability:

const getModalTitle = () => `Move ${currentProjectDetails?.identifier}-${issue?.sequence_id} to project issues`;

// Then use it in the component
modalTitle={getModalTitle()}

This change would improve code readability and make it easier to modify the title in the future if needed.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between ee823d2 and 9173d5f.

📒 Files selected for processing (16)
  • web/app/[workspaceSlug]/(projects)/projects/(detail)/[projectId]/inbox/header.tsx (2 hunks)
  • web/core/components/inbox/content/inbox-issue-header.tsx (3 hunks)
  • web/core/components/inbox/modals/create-edit-modal/edit-root.tsx (0 hunks)
  • web/core/components/inbox/modals/create-edit-modal/modal.tsx (0 hunks)
  • web/core/components/inbox/modals/create-modal/create-root.tsx (2 hunks)
  • web/core/components/inbox/modals/create-modal/index.ts (0 hunks)
  • web/core/components/inbox/modals/create-modal/issue-properties.tsx (1 hunks)
  • web/core/components/inbox/modals/create-modal/modal.tsx (1 hunks)
  • web/core/components/inbox/modals/index.ts (1 hunks)
  • web/core/components/issues/issue-modal/base.tsx (6 hunks)
  • web/core/components/issues/issue-modal/context/issue-modal.tsx (1 hunks)
  • web/core/components/issues/issue-modal/draft-issue-layout.tsx (5 hunks)
  • web/core/components/issues/issue-modal/form.tsx (5 hunks)
  • web/core/components/issues/issue-modal/modal.tsx (1 hunks)
  • web/core/components/issues/workspace-draft/delete-modal.tsx (1 hunks)
  • web/core/store/issue/issue.store.ts (1 hunks)
💤 Files with no reviewable changes (3)
  • web/core/components/inbox/modals/create-edit-modal/edit-root.tsx
  • web/core/components/inbox/modals/create-edit-modal/modal.tsx
  • web/core/components/inbox/modals/create-modal/index.ts
✅ Files skipped from review due to trivial changes (3)
  • web/core/components/inbox/modals/create-modal/issue-properties.tsx
  • web/core/components/inbox/modals/index.ts
  • web/core/components/issues/workspace-draft/delete-modal.tsx
🧰 Additional context used
🔇 Additional comments (20)
web/core/components/inbox/modals/create-modal/modal.tsx (2)

1-5: LGTM: Imports are appropriate and well-structured.

The imports are concise and relevant to the component's requirements. Using an absolute path for the custom component import is a good practice for maintainability.


7-12: LGTM: Type definition is clear and comprehensive.

The TInboxIssueCreateModalRoot type is well-defined, including all necessary props for the modal component. The naming convention follows TypeScript best practices.

web/core/components/issues/issue-modal/context/issue-modal.tsx (1)

24-24: Approved: Type expansion for issueTypeId enhances flexibility.

The change to allow issueTypeId to be string | null | undefined instead of just string provides more flexibility in handling different states of the issue type. This aligns well with the PR objective of improving consistency for accepting intake issues.

To ensure this change doesn't introduce any unintended side effects, please run the following script to verify the usage of issueTypeId across the codebase:

This script will help identify any places where issueTypeId is used, set, or checked, allowing you to verify that the new type is handled correctly throughout the codebase.

web/app/[workspaceSlug]/(projects)/projects/(detail)/[projectId]/inbox/header.tsx (1)

11-11: Verify the impact of component renaming across the codebase.

The import statement has been updated from InboxIssueCreateEditModalRoot to InboxIssueCreateModalRoot. This change aligns with the renaming mentioned in the AI-generated summary.

To ensure this change has been consistently applied throughout the codebase, please run the following script:

This script will help identify any places where the old component name might still be in use and verify the implementation of the new component.

web/core/components/issues/issue-modal/draft-issue-layout.tsx (5)

34-38: LGTM! Enhances component flexibility.

The addition of modalTitle and primaryButtonText properties to the DraftIssueProps interface improves the component's customizability. This change aligns well with the PR objective of improving consistency for accepting intake issues by allowing for context-specific UI text.


55-56: LGTM! Proper implementation of new props.

The destructuring of modalTitle and primaryButtonText from props is correctly implemented, making these new properties available for use within the component.


114-114: LGTM! Improved success message clarity.

The updated success message "Draft Issue created successfully." is more specific and informative than the previous version. It clearly indicates the type of item created (a draft issue) and confirms the successful completion of the action.


142-142: LGTM, but additional context needed.

The addition of issueTypeId to the payload in handleCreateUpdatePropertyValues is a good improvement for maintaining consistency in issue type information. However, it would be helpful to have some additional context or documentation explaining the necessity of this change and how it relates to the PR objectives.

Could you provide more information about why this change was made and how it contributes to the goal of using a common create/update issue modal for accepting intake issues?


173-174: LGTM! Proper implementation of new props in child component.

The addition of modalTitle and primaryButtonText props to the IssueFormRoot component correctly implements the new customization options. This change aligns well with the PR objective of improving consistency in the UI for accepting intake issues by allowing for context-specific customization of the modal title and primary button text.

web/core/components/inbox/modals/create-modal/create-root.tsx (3)

200-200: Minor formatting improvement.

The unnecessary space in the onChange prop of the ToggleSwitch component has been removed. This small change improves code consistency and readability.


Line range hint 1-238: Overall assessment: Changes align with PR objectives.

The modifications in this file are minimal and focused:

  1. Updated import path for issue-related components.
  2. Minor formatting improvement in the ToggleSwitch component.

These changes align well with the PR objective of improving consistency in the issue modal usage. The core functionality of the component remains intact, which is a positive sign for this refactoring effort.

To ensure the refactoring hasn't introduced any regressions, consider the following:

  1. Verify that the new import path is correct and the imported components exist in the new location.
  2. Run the component's associated unit tests, if any, to confirm that the functionality remains unchanged.
  3. Perform a quick manual test of the inbox issue creation flow to ensure everything works as expected.

To help with the manual testing, you can use the following command to find the relevant test files:

#!/bin/bash
# Find test files related to inbox issue creation
fd -t f "create.*test.tsx" web/core/components/inbox

This will help locate the test files that should be run to verify the functionality of the inbox issue creation process.


12-12: LGTM! Verify the new import path.

The import statement has been updated to reflect the new location of the components, which aligns with the PR objective of using a common create/update issue modal. This change improves consistency in the codebase structure.

To ensure the new import path is correct, please run the following command:

This command will search for the component files in the new directory. If the files are found, it confirms that the import path is correct.

web/core/components/issues/issue-modal/base.tsx (2)

213-213: LGTM! Improved user feedback for issue creation.

The updated success message now differentiates between draft issues and regular issues. This change provides more specific feedback to the user, enhancing the overall user experience.


204-206: Verify the impact of adding issueTypeId to handleCreateUpdatePropertyValues.

The addition of issueTypeId to the parameters of handleCreateUpdatePropertyValues is a good improvement. It suggests that issue type is now being considered when creating or updating property values.

Please ensure that this change is consistent with any new features or requirements related to issue types. You may want to verify that:

  1. The handleCreateUpdatePropertyValues function in the useIssueModal hook correctly handles the new issueTypeId parameter.
  2. This change doesn't break any existing functionality.
web/core/components/issues/issue-modal/form.tsx (3)

64-68: LGTM! Improved customization for modal title and button text.

The addition of modalTitle and primaryButtonText props enhances the reusability and flexibility of the IssueFormRoot component. These new props allow for dynamic customization of the modal title and submit button text, which can improve user experience by providing more context-specific information.


285-285: LGTM! Dynamic modal title improves context-awareness.

The replacement of the static title with the dynamic modalTitle prop enhances the component's flexibility. This change allows for more context-specific titles, improving the user experience by providing clearer information about the current action being performed.


Line range hint 64-427: Overall, these changes significantly improve the component's flexibility and user experience.

The additions of modalTitle and primaryButtonText props, along with their implementation in the component, enhance the reusability and context-awareness of the IssueFormRoot. These changes allow for more dynamic and informative UI elements, which can lead to a better user experience across different use cases of this component.

A few minor suggestions have been made to further improve consistency and accessibility, but the overall implementation is solid and well-thought-out.

web/core/components/inbox/content/inbox-issue-header.tsx (3)

28-28: LGTM: Import changes align with component updates

The import changes correctly reflect the replacement of InboxIssueCreateEditModalRoot with CreateUpdateIssueModal. This update suggests a move towards a more standardized issue management system, which is a positive change.


72-72: LGTM: Enhanced context with project details

The introduction of currentProjectDetails from the useProject hook is a good addition. It provides more context for the modal title and potentially for other parts of the component. This change enhances the user interface by including project-specific information.


Line range hint 1-448: Summary: Improved consistency and flexibility in issue management

The changes in this file successfully implement a more consistent and flexible approach to managing intake issues. Key improvements include:

  1. Replacing the custom InboxIssueCreateEditModalRoot with a more standardized CreateUpdateIssueModal.
  2. Enhanced context through the use of project-specific details in the UI.
  3. Improved flexibility with new props for better control over the modal's behavior.

These changes align well with the PR objectives and contribute to a more consistent user experience when accepting intake issues. The overall structure and logic of the component have been preserved, ensuring that existing functionality remains intact while introducing these improvements.

@prateekshourya29 prateekshourya29 added this to the v0.24.0 milestone Oct 14, 2024
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.

2 participants