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-2421] chore: issue display properties and issue identifier improvements. #5577

Merged
merged 2 commits into from
Sep 10, 2024

Conversation

prateekshourya29
Copy link
Member

@prateekshourya29 prateekshourya29 commented Sep 10, 2024

Summary by CodeRabbit

  • New Features

    • Introduced an optional issue_type property for enhanced issue display flexibility.
    • Added displayProperties to the IssueIdentifier component for dynamic rendering.
    • Implemented a new helper for managing issue display properties and filters.
  • Enhancements

    • Improved conditional rendering logic in various components to optimize UI performance.
    • Expanded the display_properties management from boolean to an array of keys for greater configurability.
  • Refactor

    • Streamlined component structures by removing unnecessary higher-order components.
    • Enhanced type safety and modularity by exporting key types across components.
  • Bug Fixes

    • Adjusted rendering conditions to ensure relevant display properties are shown based on available data.

Copy link
Contributor

coderabbitai bot commented Sep 10, 2024

Walkthrough

The changes involve the addition of new properties and modifications to existing interfaces and components within the codebase, primarily related to issue display properties. A new optional property, issue_type, has been introduced to the IIssueDisplayProperties interface, enhancing the flexibility of how issues are rendered. Various components have been updated to utilize these new properties, including conditional rendering logic based on the presence of display properties. Additionally, several types have been exported to improve modularity and accessibility across the application.

Changes

Files Change Summary
packages/types/src/view-props.d.ts Added optional property issue_type?: boolean; to IIssueDisplayProperties interface.
web/ce/components/issues/issue-details/issue-identifier.tsx Added `displayProperties?: IIssueDisplayProperties
web/ce/helpers/issue-filter.helper.ts Introduced new file defining TShouldRenderDisplayProperty type and shouldRenderDisplayProperty function to manage rendering of issue display properties.
web/core/components/issues/issue-layouts/calendar/base-calendar-root.tsx Added export keyword to CalendarStoreType, making it accessible from other modules.
web/core/components/issues/issue-layouts/calendar/issue-block.tsx Updated imports for useIssues and useIssueStoreType. Integrated storeType and issuesFilter to enhance issue management within the calendar layout.
web/core/components/issues/issue-layouts/filters/header/display-filters/display-filters-selection.tsx Enhanced conditional rendering logic for FilterDisplayProperties based on the length of layoutDisplayFiltersOptions.display_properties. Added displayPropertiesToRender prop.
web/core/components/issues/issue-layouts/filters/header/display-filters/display-properties.tsx Added displayPropertiesToRender prop to FilterDisplayProperties. Updated filtering logic to use workspaceSlug and projectId.
web/core/components/issues/issue-layouts/gantt/base-gantt-root.tsx Added export keyword to GanttStoreType, enhancing its visibility.
web/core/components/issues/issue-layouts/gantt/blocks.tsx Updated to use useIssues and useIssueStoreType. Integrated issuesFilter for conditional rendering of displayProperties.
web/core/components/issues/issue-layouts/kanban/block.tsx Removed WithDisplayPropertiesHOC and passed displayProperties directly to IssueIdentifier.
web/core/components/issues/issue-layouts/list/block.tsx Modified keyMinWidth calculation and rendering logic to include checks for displayProperties.key and displayProperties.issue_type.
web/core/components/issues/issue-layouts/spreadsheet/issue-row.tsx Removed WithDisplayPropertiesHOC and updated rendering logic for IssueIdentifier based on displayProperties.
web/core/constants/issue.ts Added ISSUE_DISPLAY_PROPERTIES_KEYS constant and modified ILayoutDisplayFiltersOptions interface to change display_properties from boolean to an array of keys from IIssueDisplayProperties.
web/ee/helpers/issue-filter.helper.ts Introduced new file as a re-exporting module for ce/helpers/issue-filter.helper.
web/helpers/issue.helper.ts Modified getComputedDisplayProperties function to include new issue_type parameter with a default value.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant IssueIdentifier
    participant IssueFilterHelper
    participant DisplayProperties

    User->>IssueIdentifier: Request Issue Details
    IssueIdentifier->>DisplayProperties: Check display properties
    DisplayProperties-->>IssueIdentifier: Return display properties
    IssueIdentifier->>User: Render Issue Details based on properties
Loading

🐰 In the meadow, where bunnies play,
New features hop in, brightening the day!
With properties added, the issues align,
Displaying details, oh so divine!
A sprinkle of logic, a dash of delight,
Our code's now a garden, blooming just right! 🌼


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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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: 1

Outside diff range, codebase verification and nitpick comments (1)
web/ce/components/issues/issue-details/issue-identifier.tsx (1)

Line range hint 28-42: LGTM, but fix the potential runtime error.

The changes to the IssueIdentifier component are valid and enhance its flexibility in rendering based on the provided display properties.

However, there is a potential issue with the derivation of shouldRenderIssueID. Accessing displayProperties.key directly might lead to a runtime error if displayProperties is undefined.

To fix this issue, apply the following diff:

- const shouldRenderIssueID = displayProperties ? displayProperties.key : true;
+ const shouldRenderIssueID = displayProperties?.key ?? true;

This change uses the optional chaining operator (?.) to safely access key only if displayProperties is defined, and the nullish coalescing operator (??) to default to true if displayProperties?.key is undefined or null.

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 04b10ca and 1c704fe.

Files ignored due to path filters (1)
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
Files selected for processing (15)
  • packages/types/src/view-props.d.ts (1 hunks)
  • web/ce/components/issues/issue-details/issue-identifier.tsx (4 hunks)
  • web/ce/helpers/issue-filter.helper.ts (1 hunks)
  • web/core/components/issues/issue-layouts/calendar/base-calendar-root.tsx (1 hunks)
  • web/core/components/issues/issue-layouts/calendar/issue-block.tsx (3 hunks)
  • web/core/components/issues/issue-layouts/filters/header/display-filters/display-filters-selection.tsx (1 hunks)
  • web/core/components/issues/issue-layouts/filters/header/display-filters/display-properties.tsx (1 hunks)
  • web/core/components/issues/issue-layouts/gantt/base-gantt-root.tsx (1 hunks)
  • web/core/components/issues/issue-layouts/gantt/blocks.tsx (3 hunks)
  • web/core/components/issues/issue-layouts/kanban/block.tsx (2 hunks)
  • web/core/components/issues/issue-layouts/list/block.tsx (2 hunks)
  • web/core/components/issues/issue-layouts/spreadsheet/issue-row.tsx (3 hunks)
  • web/core/constants/issue.ts (14 hunks)
  • web/ee/helpers/issue-filter.helper.ts (1 hunks)
  • web/helpers/issue.helper.ts (1 hunks)
Files skipped from review due to trivial changes (1)
  • web/ee/helpers/issue-filter.helper.ts
Additional context used
Biome
web/core/components/issues/issue-layouts/filters/header/display-filters/display-properties.tsx

[error] 34-34: 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)

Additional comments not posted (29)
web/ce/helpers/issue-filter.helper.ts (2)

4-8: LGTM!

The TShouldRenderDisplayProperty type is correctly defined and serves its purpose.


10-18: LGTM, but please clarify the special handling of issue_type.

The function is correctly implemented but it's not clear why issue_type is being handled differently. This might lead to confusion in the future.

Please provide more context on why issue_type is being treated differently and if there are plans to handle other keys in a similar manner in the future. This will help maintain clarity in the codebase.

web/ce/components/issues/issue-details/issue-identifier.tsx (1)

13-13: LGTM!

The addition of the displayProperties property to the TIssueIdentifierBaseProps type is a valid change that enables the IssueIdentifier component to receive display configurations related to issue properties.

web/core/components/issues/issue-layouts/filters/header/display-filters/display-properties.tsx (2)

15-15: LGTM!

The addition of the displayPropertiesToRender prop to the Props type is a valid change that allows the FilterDisplayProperties component to specify which display properties should be rendered.


22-47: LGTM!

The changes to the FilterDisplayProperties component are valid and enhance its ability to manage display properties dynamically based on the provided parameters and the shouldRenderDisplayProperty function. The use of the useParams hook improves the component's integration with routing.

Tools
Biome

[error] 34-34: 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/core/components/issues/issue-layouts/gantt/blocks.tsx (3)

10-11: LGTM!

The code changes are approved.


86-87: LGTM!

The code changes are approved.


110-110: LGTM!

The code changes are approved.

web/core/components/issues/issue-layouts/filters/header/display-filters/display-filters-selection.tsx (2)

53-53: LGTM!

The code changes are approved.


57-57: LGTM!

The code changes are approved.

web/core/components/issues/issue-layouts/gantt/base-gantt-root.tsx (1)

31-34: LGTM!

The code changes are approved.

packages/types/src/view-props.d.ts (1)

130-130: LGTM!

The addition of the optional issue_type property to the IIssueDisplayProperties interface is a good change that enhances the flexibility of managing issue display properties while maintaining backward compatibility.

web/core/components/issues/issue-layouts/calendar/base-calendar-root.tsx (1)

22-24: LGTM!

Exporting the CalendarStoreType type is a good change that improves the modularity of the code by enabling the type to be imported and utilized in other parts of the application.

web/core/components/issues/issue-layouts/calendar/issue-block.tsx (4)

15-15: LGTM!

Importing the useIssues hook is a good change that allows the component to access a broader set of issue-related data.


16-16: LGTM!

Importing the useIssueStoreType hook is a good change that provides a specific type for the calendar store, enhancing type safety and clarity.


46-47: LGTM!

Initializing the storeType variable using useIssueStoreType() and retrieving issuesFilter from the useIssues hook using storeType are good changes that allow for dynamic updates to the displayed properties of issues based on the current filter state. These changes improve the component's ability to manage and display issues in a calendar layout.


110-110: LGTM!

Passing the displayProperties from issuesFilter.issueFilters to the IssueIdentifier component is a good change that likely alters how issue details are rendered, making the display more responsive to the current filter settings. This change enhances the component's functionality and is consistent with the existing code.

web/core/components/issues/issue-layouts/kanban/block.tsx (1)

64-72: LGTM!

The changes are approved for the following reasons:

  • The component structure is simplified by eliminating the WithDisplayPropertiesHOC higher-order component (HOC).
  • The displayProperties are now directly passed to the IssueIdentifier component, which preserves the core functionality of displaying issue details.
web/helpers/issue.helper.ts (1)

308-308: LGTM!

The changes are approved for the following reasons:

  • The addition of the issue_type parameter enhances the getComputedDisplayProperties function's capability to handle an additional aspect of display properties related to issue types.
  • The default value for issue_type is derived from the displayProperties object using the nullish coalescing operator, which ensures a sensible default value.
web/core/components/issues/issue-layouts/list/block.tsx (3)

129-129: LGTM!

The changes are approved for the following reasons:

  • The modification to the keyMinWidth calculation enhances the component's responsiveness to the displayProperties state.
  • The UI adapts based on the available data, potentially improving user experience.

187-187: LGTM!

The changes are approved for the following reasons:

  • The updated rendering logic for the div that displays the issue identifier improves the flexibility of the UI.
  • The UI can now display relevant information based on additional properties, such as displayProperties.issue_type.

194-194: LGTM!

The changes are approved for the following reasons:

  • Passing the displayProperties to the IssueIdentifier component is consistent with the updated rendering logic for the div that displays the issue identifier.
web/core/constants/issue.ts (4)

111-128: LGTM!

The new constant ISSUE_DISPLAY_PROPERTIES_KEYS is a useful addition that centralizes the keys of the IIssueDisplayProperties interface. This can improve code maintainability and reduce duplication when referencing these keys in other parts of the codebase.


134-135: LGTM!

The new display properties "key" (representing the issue ID) and "issue_type" (representing the type of the issue) are correctly added to the ISSUE_DISPLAY_PROPERTIES array.


208-208: LGTM!

The display_properties property in the ISSUE_DISPLAY_FILTERS_BY_LAYOUT object is consistently updated to use the ISSUE_DISPLAY_PROPERTIES_KEYS constant across multiple layouts. This change aligns with the updated type of display_properties in the ILayoutDisplayFiltersOptions interface and ensures that all the defined issue display properties are used uniformly across the layouts.

Also applies to: 221-221, 247-247, 272-272, 285-285, 310-310, 332-332, 357-357, 382-382, 407-407, 430-430, 454-454


189-189: LGTM, but verify the usage of display_properties.

The change to the display_properties property in the ILayoutDisplayFiltersOptions interface is approved. It now accepts an array of keys from the IIssueDisplayProperties interface, allowing for more granular control over the displayed properties in different layouts.

However, ensure that this change is thoroughly tested and that all usages of display_properties have been updated to match the new type.

Run the following script to verify the usage of display_properties:

Verification successful

Verification Successful: display_properties Usage Updated Correctly

The usage of display_properties throughout the codebase is consistent with its new type as an array of keys from IIssueDisplayProperties. No instances of it being used as a boolean or set to true were found, confirming that the codebase has been updated correctly.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all usages of `display_properties` match the new type.

# Test: Search for the usage of `display_properties`. Expect: No occurrences of `display_properties: boolean` or `display_properties: true`.
rg --type typescript $'display_properties:\s*(boolean|true)'

Length of output: 96


Script:

#!/bin/bash
# Description: Verify all usages of `display_properties` match the new type.

# Test: Search for the usage of `display_properties`. Expect: No occurrences of `display_properties: boolean` or `display_properties: true`.
rg $'display_properties:\s*(boolean|true)'

Length of output: 43


Script:

#!/bin/bash
# Description: Verify that `display_properties` is used as an array of keys from `IIssueDisplayProperties`.

# Test: Search for the usage of `display_properties` to ensure it is used as an array.
rg $'display_properties:\s*\[\]'

Length of output: 33


Script:

#!/bin/bash
# Description: Search for all occurrences of `display_properties` to verify its usage in different contexts.

# Test: Search for all occurrences of `display_properties`.
rg 'display_properties'

Length of output: 9420

web/core/components/issues/issue-layouts/spreadsheet/issue-row.tsx (3)

224-226: LGTM!

The calculation for keyMinWidth is updated to conditionally check for the presence of the key display property. When displayProperties.key is defined, the minimum width is calculated based on the length of the project identifier to ensure proper spacing. If the key property is not available, the minimum width defaults to 0. This change enhances the flexibility of the component by adapting its layout based on the available display properties.


284-284: LGTM!

The rendering logic is updated to conditionally render elements based on the presence of either the key or issue_type display property. This change allows the component to adapt its rendering based on the provided display properties, improving its flexibility and responsiveness.


292-292: LGTM!

The displayProperties are now directly passed as a prop to the IssueIdentifier component. This change ensures that the relevant display properties are available to the IssueIdentifier component, allowing it to render the issue identifier based on the provided properties. This streamlines the component's structure and improves its responsiveness to the display properties.

const [previewEnabled, setPreviewEnabled] = React.useState(true);
// derived values
const projectId = !!routerProjectId ? routerProjectId?.toString() : undefined;
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove the redundant double-negation.

The static analysis tool correctly points out that the double-negation at line 34 is redundant and can be safely removed without changing the behavior of the code.

Apply the following diff to fix the issue:

- const projectId = !!routerProjectId ? routerProjectId?.toString() : undefined;
+ const projectId = routerProjectId?.toString() ?? undefined;

This change uses the nullish coalescing operator (??) to provide the fallback value of undefined if routerProjectId?.toString() evaluates to undefined or null.

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
const projectId = !!routerProjectId ? routerProjectId?.toString() : undefined;
const projectId = routerProjectId?.toString() ?? undefined;
Tools
Biome

[error] 34-34: 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)

yarn.lock Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants