Skip to content

Conversation

@prateekshourya29
Copy link
Member

@prateekshourya29 prateekshourya29 commented Mar 6, 2025

Description

In this PR, I have made various improvements across the platform to enhance code scalability and overall quality. These changes aim to optimize performance, maintainability, and consistency throughout the codebase.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • Feature (non-breaking change which adds functionality)
  • Improvement (change that would cause existing functionality to not work as expected)
  • Code refactoring
  • Performance improvements
  • Documentation update

References

WEB-3482

Summary by CodeRabbit

  • New Features
    • Introduced work item template selection in the issue modal, streamlining issue creation.
    • Improved issue form behavior with standardized default values and enhanced reset handling.
    • Enhanced interactions for assignee, member, and label selections, ensuring more reliable user inputs.
    • Upgraded editor handling to better determine empty content during issue description editing.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 6, 2025

Walkthrough

This pull request introduces several enhancements and new exports across multiple packages. It adds exports for additional modules, new type definitions, and utility functions in various directories. The changes also update components and context providers—especially in the issue modal—and refine store methods for handling labels, members, modules, and states. Additionally, the pull request adjusts numerous import paths and form handling logic in the frontend while streamlining helper functions for editor content and issue field changes.

Changes

File(s) Summary
packages/constants/src/issue/index.ts
packages/constants/src/issue/modal.ts
Added export for the modal module and introduced the DEFAULT_WORK_ITEM_FORM_VALUES constant.
packages/types/src/index.d.ts
packages/types/src/utils.d.ts
Added a new export for the utils module and defined new types: PartialDeep<K> and CompleteOrEmpty<T>.
packages/utils/src/common.ts
packages/utils/src/index.ts
packages/utils/src/work-item/index.ts
packages/utils/src/work-item/modal.ts
Introduced new ID management functions, updated exports to include work-item modules, and added work-item modal functions for form data reset and conversion.
web/app/[workspaceSlug]/(projects)/.../layout.tsx Modified import paths for header components in both Project and Workspace settings layouts.
web/ce/components/issues/issue-modal/index.ts
web/ce/components/issues/issue-modal/issue-type-select.tsx
web/ce/components/issues/issue-modal/provider.tsx
web/ce/components/issues/issue-modal/template-select.tsx
Added export for template-select, introduced a new optional editorRef prop, enhanced the IssueModalProvider with additional state and handler methods, and introduced the WorkItemTemplateSelect component.
web/core/components/command-palette/actions/issue-actions/change-assignee.tsx
web/core/components/dropdowns/member/member-options.tsx
Updated getProjectMemberIds invocations to include an extra boolean parameter.
web/core/components/empty-state/detailed-empty-state-root.tsx Added an optional className prop for extra styling.
web/core/components/issues/issue-modal/components/title-input.tsx Updated prop type from errors to formState in the IssueTitleInput component.
web/core/components/issues/issue-modal/context/issue-modal-context.tsx Enhanced context types with new properties and methods for template and parent issue handling.
web/core/components/issues/issue-modal/form.tsx Updated form logic to use imported default work item form values and integrated the WorkItemTemplateSelect component.
web/core/components/issues/issue-modal/modal.tsx Added an optional templateId prop to the IssuesModalProps interface.
web/core/components/issues/select/label.tsx Introduced new props for button container styling and dynamic placement using the popper configuration.
web/core/components/labels/create-label-modal.tsx Modified form submission to inline prevent default behavior.
web/core/store/label.store.ts Added new method getProjectLabelIds to retrieve label IDs for a project.
web/core/store/member/index.ts Added computed action getMemberIds to extract member IDs from the member map.
web/core/store/member/project-member.store.ts Introduced projectMemberFetchStatusMap, a computed action for fetch status, and updated getProjectMemberIds to filter guest users based on a boolean flag.
web/core/store/module.store.ts Added method getModulesFetchStatusByProjectId to check module fetch status by project.
web/core/store/state.store.ts Introduced getProjectStateIds and getProjectDefaultStateId methods for handling project states.
web/helpers/editor.helper.ts Added new function isEditorEmpty to determine if editor content is effectively empty.
web/helpers/issue-modal.helper.ts Introduced new function getChangedIssuefields to extract changed form fields.
web/helpers/issue.helper.ts Removed the existing getChangedIssuefields function and replaced direct empty-checks with a call to isEditorEmpty.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Form as IssueFormRoot
    participant Provider as IssueModalProvider
    participant Util as Modal Utils

    User->>Form: Input data/select template
    Form->>Provider: Trigger template change (handleTemplateChange)
    Provider->>Util: Call getUpdateFormDataForReset
    Util-->>Provider: Return updated form data
    Provider->>Form: Update form state with new default values
Loading

Possibly related PRs

Suggested labels

🌟improvement, 🧹chore, 🌐frontend

Suggested reviewers

  • sriramveeraghanta

Poem

I’m a little rabbit, bouncing with cheer,
New exports and functions, now everything’s clear.
Code hops along with defaults and state,
In a dashing sequence, oh isn’t it great?
With tweaks and changes making the day bright—
Hop on over, code world, and delight!
🐇✨

✨ 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.
    • 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.
  • @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.

@sriramveeraghanta sriramveeraghanta changed the title [WEB-3482] improvement: platform components and mobx stores [WEB-3482] refactor: platform components and mobx stores Mar 6, 2025
@sriramveeraghanta sriramveeraghanta merged commit 6d216f2 into preview Mar 6, 2025
4 of 6 checks passed
@sriramveeraghanta sriramveeraghanta deleted the improvement-platform branch March 6, 2025 10:17
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

🧹 Nitpick comments (9)
packages/utils/src/index.ts (1)

6-6: Duplicate export detected

There's a duplicate export for the datetime module (lines 3 and 6).

 export * from "./datetime";
 export * from "./color";
 export * from "./common";
-export * from "./datetime";
 export * from "./emoji";
web/core/components/command-palette/actions/issue-actions/change-assignee.tsx (1)

29-29: Function parameter update accommodates API change

The function call has been updated to include the new includeInactive parameter set to false, which means only active project members will be included as potential assignees. This aligns with the updated function signature in the project member store.

Consider documenting this parameter choice in a comment to clarify the intention behind excluding inactive members.

-  const projectMemberIds = getProjectMemberIds(projectId, false);
+  // Only include active members as potential assignees
+  const projectMemberIds = getProjectMemberIds(projectId, false);
web/helpers/issue-modal.helper.ts (1)

5-16: Helper function for tracking changed form fields

This utility function effectively identifies and extracts only the fields that have been modified in a form, which is useful for optimizing API calls by sending only changed data.

There's a minor improvement that can be made to the conditional check:

-    if (!!dirtyFields[dirtyField]) {
+    if (dirtyFields[dirtyField]) {

The double negation operator (!!) is redundant since the condition already coerces the value to a boolean.

🧰 Tools
🪛 Biome (1.9.4)

[error] 10-10: Avoid redundant double-negation.

It is not necessary to use double-negation when a value will already be coerced to a boolean.
Unsafe fix: Remove redundant double-negation

(lint/complexity/noExtraBooleanCast)

web/ce/components/issues/issue-modal/template-select.tsx (1)

14-15: Placeholder component implementation.

This appears to be a placeholder implementation that will be expanded later. Consider adding a TODO comment to indicate what functionality should be implemented or link to a relevant ticket.

-// eslint-disable-next-line @typescript-eslint/no-unused-vars
-export const WorkItemTemplateSelect = (props: TWorkItemTemplateSelect) => <></>;
+// TODO: Implement WorkItemTemplateSelect component functionality
+// eslint-disable-next-line @typescript-eslint/no-unused-vars
+export const WorkItemTemplateSelect = (props: TWorkItemTemplateSelect) => <></>;
web/ce/components/issues/issue-modal/provider.tsx (1)

21-24: Template management placeholders

The template-related properties are initialized with empty functions. Consider implementing these functions based on the templateId prop that's now available.

-        workItemTemplateId: null,
-        setWorkItemTemplateId: () => {},
-        isApplyingTemplate: false,
-        setIsApplyingTemplate: () => {},
+        workItemTemplateId: props.templateId || null,
+        setWorkItemTemplateId: (id) => {
+          // Implementation for setting template ID
+        },
+        isApplyingTemplate: false,
+        setIsApplyingTemplate: (value) => {
+          // Implementation for setting applying template state
+        },
web/core/store/state.store.ts (1)

141-152: Validate return structure consistency.

The method getProjectStateIds can return both undefined and an array. If downstream code expects an array, it may need a fallback to avoid errors. Consider consistently returning [] instead of undefined to simplify usage and reduce null checks, if that aligns with store conventions.

 getProjectStateIds = computedFn((projectId: string | null | undefined) => {
   const workspaceSlug = this.router.workspaceSlug;
   if (!workspaceSlug || !projectId || !(this.fetchedMap[projectId] || this.fetchedMap[workspaceSlug]))
-    return undefined;
+    return [];

   const projectStates = this.getProjectStates(projectId);
   return projectStates?.map((state) => state.id) ?? [];
 });
web/core/store/member/project-member.store.ts (2)

29-31: Track fetch status with error handling.

Defining projectMemberFetchStatusMap is helpful for distinguishing which projects have fetched data. However, if the fetch call fails, the status remains true and is never reverted. Consider resetting it to false in a catch block for consistency.

 fetchProjectMembers = async (workspaceSlug: string, projectId: string) =>
   await this.projectMemberService.fetchProjectMembers(workspaceSlug, projectId).then((response) => {
     runInAction(() => {
       response.forEach((member) => {
         set(this.projectMemberMap, [projectId, member.member], member);
       });
       set(this.projectMemberFetchStatusMap, [projectId], true);
     });
     return response;
   }).catch((error) => {
+    runInAction(() => {
+      set(this.projectMemberFetchStatusMap, [projectId], false);
+    });
     throw error;
   });

Also applies to: 61-63


160-162: Setting fetch status directly to true.

After a successful fetch, marking projectMemberFetchStatusMap[projectId] = true is good. Just confirm the store logic or watchers handle any potential re-fetch scenarios, so that these statuses are not stale if repeated or partial loads occur.

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

144-144: Neat destructuring.

The updated destructuring for methods is consistent. Keep an eye on any changes that might outgrow direct destructuring and require a rename for clarity, but for now it’s good.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 4958be7 and 3af598d.

📒 Files selected for processing (31)
  • packages/constants/src/issue/index.ts (1 hunks)
  • packages/constants/src/issue/modal.ts (1 hunks)
  • packages/types/src/index.d.ts (1 hunks)
  • packages/types/src/utils.d.ts (1 hunks)
  • packages/utils/src/common.ts (1 hunks)
  • packages/utils/src/index.ts (1 hunks)
  • packages/utils/src/work-item/index.ts (1 hunks)
  • packages/utils/src/work-item/modal.ts (1 hunks)
  • web/app/[workspaceSlug]/(projects)/projects/(detail)/[projectId]/settings/(with-sidebar)/layout.tsx (1 hunks)
  • web/app/[workspaceSlug]/(projects)/settings/(with-sidebar)/layout.tsx (1 hunks)
  • web/ce/components/issues/issue-modal/index.ts (1 hunks)
  • web/ce/components/issues/issue-modal/issue-type-select.tsx (2 hunks)
  • web/ce/components/issues/issue-modal/provider.tsx (2 hunks)
  • web/ce/components/issues/issue-modal/template-select.tsx (1 hunks)
  • web/core/components/command-palette/actions/issue-actions/change-assignee.tsx (1 hunks)
  • web/core/components/dropdowns/member/member-options.tsx (1 hunks)
  • web/core/components/empty-state/detailed-empty-state-root.tsx (2 hunks)
  • web/core/components/issues/issue-modal/components/title-input.tsx (2 hunks)
  • web/core/components/issues/issue-modal/context/issue-modal-context.tsx (3 hunks)
  • web/core/components/issues/issue-modal/form.tsx (14 hunks)
  • web/core/components/issues/issue-modal/modal.tsx (2 hunks)
  • web/core/components/issues/select/label.tsx (5 hunks)
  • web/core/components/labels/create-label-modal.tsx (1 hunks)
  • web/core/store/label.store.ts (2 hunks)
  • web/core/store/member/index.ts (2 hunks)
  • web/core/store/member/project-member.store.ts (5 hunks)
  • web/core/store/module.store.ts (2 hunks)
  • web/core/store/state.store.ts (2 hunks)
  • web/helpers/editor.helper.ts (1 hunks)
  • web/helpers/issue-modal.helper.ts (1 hunks)
  • web/helpers/issue.helper.ts (2 hunks)
✅ Files skipped from review due to trivial changes (3)
  • packages/utils/src/work-item/index.ts
  • web/app/[workspaceSlug]/(projects)/projects/(detail)/[projectId]/settings/(with-sidebar)/layout.tsx
  • web/app/[workspaceSlug]/(projects)/settings/(with-sidebar)/layout.tsx
🧰 Additional context used
🪛 Biome (1.9.4)
web/helpers/issue-modal.helper.ts

[error] 10-10: Avoid redundant double-negation.

It is not necessary to use double-negation when a value will already be coerced to a boolean.
Unsafe fix: Remove redundant double-negation

(lint/complexity/noExtraBooleanCast)

⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Analyze (javascript)
  • GitHub Check: Analyze (python)
🔇 Additional comments (65)
packages/types/src/utils.d.ts (2)

1-3: Well-defined recursive type utility

The PartialDeep<K> type definition creates a recursive partial type that makes all properties optional, including nested objects. This is a useful utility type for scenarios requiring flexible partial representations of complex objects.


5-5: Good addition of CompleteOrEmpty utility type

The CompleteOrEmpty<T> type provides a clean way to represent either a complete object of type T or an empty object. This is useful for optional configurations or parameters that can be either fully specified or omitted entirely.

packages/utils/src/index.ts (1)

14-14: Appropriate export of work-item utilities

Exporting the work-item module makes these utilities available to the rest of the application, which is appropriate for a shared utils package.

packages/types/src/index.d.ts (1)

43-43: Appropriate export of utility types

Exporting the utility types from the main index file makes them easily accessible to consumers of this package, which is good for discoverability and usability.

web/ce/components/issues/issue-modal/index.ts (1)

4-5: Good addition of template selection component exports

Exporting the template-select module makes the work item template selection component available for use in other parts of the application, which enhances the reusability of this component.

packages/constants/src/issue/index.ts (1)

4-4: Export addition looks good!

Adding the modal exports follows the existing pattern of the file and improves the module's organization by making modal-related constants accessible through the main issue index.

web/ce/components/issues/issue-modal/issue-type-select.tsx (2)

2-3: Import organization looks good

The code follows the project's convention of separating imports with comments for better organization.


14-14: New editorRef prop enhances component flexibility

Adding the optional editorRef property allows the component to interact with the editor, which aligns with the PR's goal of improving platform components. This will enable template-related functionality to modify editor content.

packages/constants/src/issue/modal.ts (1)

1-19: Well-structured default values for work item form

The DEFAULT_WORK_ITEM_FORM_VALUES constant provides a centralized definition of default form values, which is a good practice for maintaining consistency across the application. The structure matches the TIssue type, and all properties are appropriately initialized with sensible defaults.

This approach will help reduce duplication of default values and make future changes easier to manage.

web/helpers/editor.helper.ts (1)

33-37: Good utility function for checking empty editor content

The isEditorEmpty function consolidates the logic for determining whether an editor is effectively empty, considering various edge cases (null values, empty paragraph tags, whitespace-only content). This is a valuable abstraction that will help maintain consistency across the application.

This is a good example of the DRY principle by centralizing the empty-check logic in one place.

web/core/components/empty-state/detailed-empty-state-root.tsx (2)

30-30: Props extension looks good!

Adding the optional className prop enhances component customization flexibility.


70-70: Proper implementation of the className prop

Good use of the cn utility function to combine class names. This allows for external styling while preserving the component's base styles.

Also applies to: 76-81

web/core/components/labels/create-label-modal.tsx (1)

118-124: Form submission handling has been enhanced

The form submission now explicitly prevents default behavior and stops event propagation before handling the submit action. This is a good defensive programming practice that can prevent potential event bubbling issues.

web/core/store/member/index.ts (4)

14-14: Interface updated to include new method.

Good addition of the getMemberIds method to the IMemberRootStore interface. This provides a clean way to access all member IDs from the member map.


39-41: Clear JSDoc documentation.

Proper documentation of the new function with a descriptive comment helps maintain code readability and clarity for other developers.


41-41: Well-implemented computed function.

Good use of computedFn to create a memoized function that returns the member IDs. The implementation is concise and efficient, using Object.keys to extract IDs from the map.


43-45: Updated documentation for existing method.

Improved documentation for the getUserDetails method provides better clarity on its purpose.

web/core/components/dropdowns/member/member-options.tsx (1)

71-75:

Details

❓ Verification inconclusive

Parameter added to getProjectMemberIds function call.

The addition of the second parameter true to getProjectMemberIds() looks intentional for including guest users. Ensure this aligns with the updated implementation in the project member store.


🏁 Script executed:

#!/bin/bash
# Checking the implementation of getProjectMemberIds to confirm it accepts the boolean parameter
rg -A 10 "getProjectMemberIds.*=.*\(.*\:.*boolean\)" --glob "**/*.ts"

Length of output: 207


🏁 Script executed:

#!/bin/bash
# Re-run search to fetch the declaration of getProjectMemberIds
# This search locates its exported declaration in the project member store to verify it accepts a boolean parameter.
rg -A 10 'export function getProjectMemberIds\(' --glob '**/*.ts'

Length of output: 67


Attention: Please verify the getProjectMemberIds parameter handling

The second parameter (true) added to the getProjectMemberIds() call appears to be intended for including guest users. However, our automated search did not yield clear evidence of the updated function signature in the project member store. Please manually verify that the implementation of getProjectMemberIds accepts and correctly processes a boolean parameter to include guest users in its logic.

  • Confirm the updated function signature in the project member store.
  • Ensure the logic handles the boolean flag as expected.
web/core/store/module.store.ts (2)

31-31: New method added to interface.

Good addition of the getModulesFetchStatusByProjectId method to the interface. This provides a way to check if modules for a specific project have been fetched.


156-161: Well-documented computed function.

The implementation is clean and includes proper JSDoc documentation with parameter and return types. Good use of the nullish coalescing operator (??) to provide a default value when the project ID is not found in the fetch map.

web/ce/components/issues/issue-modal/template-select.tsx (2)

1-2: Good type definition.

Clear and concise type definition for the dropdown size options.


3-12: Well-structured prop interface.

The TWorkItemTemplateSelect interface clearly defines all the props needed for the component, with appropriate optional properties marked.

web/helpers/issue.helper.ts (2)

23-23: Good refactoring: Improved maintainability with helper import.

The addition of the isEditorEmpty import from the editor helper improves code organization by centralizing the logic for checking empty editor content.


202-202: Nice improvement: Using dedicated helper instead of inline checks.

Replacing inline empty description checks with the isEditorEmpty helper function enhances code maintainability and ensures consistent validation logic across the application.

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

5-5: Better form state management with FormState.

The changes to use FormState from react-hook-form instead of directly passing errors is a more maintainable approach that:

  • Aligns with react-hook-form best practices
  • Provides access to the complete form state context
  • Makes the component more flexible for future enhancements

This is a good architectural improvement.

Also applies to: 21-21, 26-31

web/core/store/label.store.ts (1)

26-26: Good addition: Utility method for extracting label IDs.

The new getProjectLabelIds method is a useful utility that:

  • Properly handles edge cases (undefined/null values)
  • Reuses existing logic from getProjectLabels
  • Follows the pattern of other getter methods in the store
  • Is well-documented with JSDoc comments

This addition will simplify code elsewhere that needs access to just the label IDs.

Also applies to: 124-134

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

30-30: Enhanced functionality: Added template support to issue modal.

The addition of the optional templateId prop and passing it to the IssueModalProvider enables template-based issue creation, which should improve user experience by allowing pre-filled issue forms based on templates.

Also applies to: 36-36

packages/utils/src/work-item/modal.ts (2)

5-13: Well-structured utility function for form reset

The getUpdateFormDataForReset function provides a clear approach to preserving specific fields while resetting others to default values. It properly handles the projectId parameter which can be null or undefined.


15-33: Good type safety implementation for search response conversion

This utility function correctly handles potentially undefined values with nullish coalescing operators, ensuring the returned object always has valid values. The function signature with proper TypeScript types enhances maintainability.

web/core/components/issues/select/label.tsx (7)

2-2: Appropriate import for enhanced functionality

Adding the Placement type from @popperjs/core enables proper typing for the new placement functionality.


28-30: Good enhancement to component props

The addition of buttonContainerClassName and placement props increases the component's flexibility, allowing for better customization by consumers.


43-45: Props destructuring updated consistently

The destructuring pattern has been updated to include the new props, maintaining consistency with the component's interface.


63-63: Flexible popper placement configuration

Using the placement prop with a fallback to "bottom-start" improves the component's adaptability to different UI contexts while maintaining backward compatibility.


123-126: Enhanced styling customization

The updated className implementation properly utilizes the tailwind utility functions with the new buttonContainerClassName prop, improving the component's styling flexibility.


132-132: Consistent styling approach for button content

The span element's className now properly incorporates the buttonClassName prop, maintaining styling consistency throughout the component.


140-140: Improved default styling with flexibility

The default styling for the button includes appropriate flexbox and border utilities, while still allowing customization through the buttonClassName prop.

packages/utils/src/common.ts (4)

9-12: Well-documented utility for ID extraction

The extractIds function is properly typed with generics and includes clear JSDoc documentation, making it a useful utility for working with arrays of objects.


14-17: Robust ID validation utility

The isValidId function handles nullable inputs appropriately and provides a clean interface for checking ID validity against a list.


19-23: Straightforward filtering utility

The filterValidIds function provides a simple and efficient way to filter arrays based on ID validity.


25-41: Comprehensive ID partitioning utility

The partitionValidIds function efficiently separates valid and invalid IDs, returning them in a structured object. The implementation is clear and the function is well-documented.

web/ce/components/issues/issue-modal/provider.tsx (3)

1-4: Updated imports for enhanced functionality

The addition of useState and ISearchIssueResponse imports supports the new state management in the component.


8-10: Exported type with template support

Exporting the TIssueModalProviderProps type and adding the optional templateId property improves the component's API and documentation.


15-16: Parent issue state management

Added state for tracking the selected parent issue, which enhances the component's functionality for issue hierarchies.

web/core/store/state.store.ts (2)

27-28: Excellent addition of interface methods.

The newly introduced methods getProjectStateIds and getProjectDefaultStateId provide clear typed contracts for retrieving project-specific states. Returning undefined when the project or workspace is not fetched is consistent with the store’s existing pattern. Ensure consumers handle the possibility of undefined appropriately.


154-162: Concise default state lookup.

The getProjectDefaultStateId method is straightforward and concise. Just be sure that, if no default state is found, returning undefined is handled properly by the caller to avoid unexpected behavior.

web/core/store/member/project-member.store.ts (2)

38-38: Method signatures updated.

The new getProjectMemberFetchStatus method and updated parameter in getProjectMemberIds offer improved flexibility. Ensure all call sites pass the boolean flag for includeGuestUsers correctly, and handle any default or missing parameter scenarios where downstream usage might omit it.

Also applies to: 40-40


137-142: Conditional guest filtering relies on new parameter.

Filtering out guest users based on includeGuestUsers === false is clear and straightforward. Validate that all external calls to getProjectMemberIds handle this parameter to prevent inadvertent inclusion or exclusion of guest users.

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

6-6: Streamlined imports.

Consolidating and adding new imports like FormProvider, DEFAULT_WORK_ITEM_FORM_VALUES, TWorkspaceDraftIssue, and getChangedIssuefields helps maintain clarity. The references appear correct with no naming conflicts.

Also applies to: 8-8, 13-13, 17-17, 29-29


36-42: Additional plane-web components.

Importing WorkItemTemplateSelect and other components in one place is helpful for discoverability. All references look consistent with the rest of the codebase.


110-114: Enhanced store usage.

Bringing workItemTemplateId, isApplyingTemplate, and selectedParentIssue in from the issue modal context centralizes state management. This approach improves clarity around which global context is driving the form’s data.


119-119: Template change handler.

The single named import handleTemplateChange is straightforward. No issues spotted with naming or invocation scope.


131-134: Applying default form values.

Using DEFAULT_WORK_ITEM_FORM_VALUES merged with data ensures new forms consistently initialize. Overwriting fields with ...data is a valid approach to keep existing data. This is a solid pattern for combining default and dynamic values.

Also applies to: 136-137


155-155: Form disable logic is extended.

Including isApplyingTemplate in the isDisabled condition ensures users cannot continue editing mid-template application. This reduces the risk of accidental concurrency issues during transitions.


163-169: Complete reset upon template changes.

When workItemTemplateId is present, you reset the form with new default values and clear the editor. This can be helpful for brand-new items but be aware this discards partial user progress. If that is intentional, you’re good to go.


190-200: Auto-apply templates in effect.

Automatically handling template changes in a useEffect based on workItemTemplateId is convenient. This logic is concise and effectively uses editorRef for clearing content. No immediate issues found.


350-351: FormProvider usage.

Wrapping the JSX with <FormProvider> is a great approach for nested form inputs. It simplifies passing around form methods without prop drilling.


389-395: Conditional template select.

Showing WorkItemTemplateSelect only when new issues are created (no data?.id or sourceIssueId) is logical. This helps prevent overwriting or confusion for existing items.


424-424: Prop added to IssueTitleInput.

Passing formState may allow more granular form feedback inside the title input. Looks consistent with the pattern in other components.


535-535: Button disability matches form status.

Tying the submit button’s disabled prop to isDisabled ensures a clear user experience. The code is sufficiently descriptive.


571-571: Closing FormProvider.

Everything from FormProvider is properly enclosed inside. Good that you end the provider at the end of the form context.

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

14-14: Type update from TIssue to TIssueFields is a good architectural decision.

Changing the watch type from UseFormWatch<TIssue> to UseFormWatch<TIssueFields> in both places makes the context more focused on watching only relevant issue fields rather than the entire issue object. This should improve type safety and make it clearer which fields are being monitored.

Also applies to: 20-20


31-35: New template change handling type looks good.

The new THandleTemplateChangeProps type is well structured for handling template changes with all necessary parameters - workspace context, form reset capability, and editor reference for content manipulation.


37-40: Well-defined prop types for new handler functions.

Both THandleProjectEntitiesFetchProps and THandleParentWorkItemDetailsProps are well structured with appropriate parameters for their respective functionalities. The parent work item type correctly includes flags to differentiate between regular issues and epics.

Also applies to: 42-47


50-55: Good addition of template and parent issue state management.

Adding template and parent issue state management to the context is a good enhancement that will help centralize this functionality. The state variables and their setters follow React conventions.


64-66:

Details

❓ Verification inconclusive

Verify Promise implementation and error handling in these new methods.

The new methods all return Promises, which is appropriate for asynchronous operations. However, make sure that:

  1. The actual implementations properly handle errors and edge cases
  2. Consumers of these methods use proper error handling (try/catch blocks or .catch())
  3. Loading states are properly managed during these async operations

🏁 Script executed:

#!/bin/bash
# Find implementations of these handler methods to check error handling patterns
rg -A 5 -B 2 "handleParentWorkItemDetails|handleProjectEntitiesFetch|handleTemplateChange" --type tsx

Length of output: 131


Action Required: Re-verify Async Method Implementations
The initial search yielded an error because the file type “tsx” wasn’t recognized. Please run a new search targeting files with a “.tsx” extension to verify the error handling in the implementations of these asynchronous methods. For example, you can use the following script:

Once you have the appropriate output, verify that:

  • Each method’s implementation properly handles errors and edge cases (e.g., using try/catch blocks).
  • Consumers of these methods implement corresponding error handling (e.g., wrapping calls in try/catch or using .catch() for Promises).
  • Loading states are managed correctly during these asynchronous operations.

Please run the above command and review the results manually to ensure the implementations conform to these requirements.


🏁 Script executed:

#!/bin/bash
# Search for implementations of the async handler methods in .tsx files
rg -A 5 -B 2 "handleParentWorkItemDetails|handleProjectEntitiesFetch|handleTemplateChange" -g '*.tsx'

Length of output: 3437


Action: Verify and Enhance Error Handling in Async Methods

The asynchronous handler signatures are correctly typed, but the current implementations (e.g., in web/ce/components/issues/issue-modal/provider.tsx) use minimal stubs like Promise.resolve() without explicit error management. Please ensure that:

  • If these methods evolve beyond basic stubs, you wrap any operations that may fail in try/catch blocks or handle errors using .catch().
  • Consumers invoking these methods (for example, in web/core/components/issues/issue-modal/form.tsx) implement proper error handling, either via try/catch or chaining .catch() on the returned Promises.
  • Loading states and edge cases are managed appropriately during asynchronous operations.

Verify that these safeguards are in place where applicable or plan to enhance error handling as the implementation complexity grows.

Comment on lines +35 to +37
handleParentWorkItemDetails: () => Promise.resolve(undefined),
handleProjectEntitiesFetch: () => Promise.resolve(),
handleTemplateChange: () => Promise.resolve(),
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Empty promise-returning handler methods

The handler methods return resolved promises but don't implement any functionality. These should be properly implemented to support the component's intended behavior.

-        handleParentWorkItemDetails: () => Promise.resolve(undefined),
-        handleProjectEntitiesFetch: () => Promise.resolve(),
-        handleTemplateChange: () => Promise.resolve(),
+        handleParentWorkItemDetails: async (workspaceSlug, projectId, issueId) => {
+          // Implement parent work item details fetching logic
+          return undefined;
+        },
+        handleProjectEntitiesFetch: async (workspaceSlug, projectId) => {
+          // Implement project entities fetching logic
+        },
+        handleTemplateChange: async (templateId) => {
+          // Implement template change logic
+        },
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
handleParentWorkItemDetails: () => Promise.resolve(undefined),
handleProjectEntitiesFetch: () => Promise.resolve(),
handleTemplateChange: () => Promise.resolve(),
handleParentWorkItemDetails: async (workspaceSlug, projectId, issueId) => {
// Implement parent work item details fetching logic
return undefined;
},
handleProjectEntitiesFetch: async (workspaceSlug, projectId) => {
// Implement project entities fetching logic
},
handleTemplateChange: async (templateId) => {
// Implement template change logic
},

@sriramveeraghanta sriramveeraghanta added this to the v0.25.2 milestone Mar 9, 2025
lifeiscontent pushed a commit that referenced this pull request Aug 18, 2025
* improvement: platform componenents and mobx stores

* minor improvements
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