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

feat(web): implements projects functionalities #1055

Merged
merged 27 commits into from
Aug 8, 2024
Merged

Conversation

mkumbobeaty
Copy link
Contributor

@mkumbobeaty mkumbobeaty commented Jul 15, 2024

Overview

  • Implement starred project logics
  • implemented search functionality
  • added icon to show published project

What I've done

  • Implement sort projects functionaries it is waiting for the BE improvement

What I haven't done

How I tested

Which point I want you to review particularly

Memo

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features

    • Enhanced project management with dynamic sorting and filtering options.
    • Implemented a breadcrumb component for improved navigation context within projects.
    • Introduced improved project status representation with user-friendly strings.
    • Expanded pagination logic for better project listing management.
  • Bug Fixes

    • Clarified messaging for search results when no members match the query.
  • Documentation

    • Updated translation files to enhance language support for project-related functionalities in both English and Japanese.
  • Style

    • Refined layout and visual organization of project displays for a more user-friendly interface.

Copy link

netlify bot commented Jul 15, 2024

Deploy Preview for reearth-web ready!

Name Link
🔨 Latest commit ef62120
🔍 Latest deploy log https://app.netlify.com/sites/reearth-web/deploys/66b4ab411058050008d62f99
😎 Deploy Preview https://deploy-preview-1055--reearth-web.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@github-actions github-actions bot added the web label Jul 15, 2024
Copy link

coderabbitai bot commented Jul 25, 2024

Warning

Rate limit exceeded

@airslice has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 15 minutes and 19 seconds before requesting another review.

How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

Commits

Files that changed from the base of the PR and between b3cb8ff and ef62120.

Walkthrough

The recent updates significantly enhance the project management dashboard's functionality and user interface. Key improvements include optimized sorting options, enhanced pagination and search capabilities, and streamlined project status management. The layout styling is refined with new components, and internationalization support is improved, collectively aiming to elevate user interaction and streamline project handling within the application.

Changes

Files Change Summary
web/src/beta/features/Dashboard/ContentsContainer/Projects/hooks.ts, web/src/beta/features/Dashboard/ContentsContainer/Projects/index.tsx Enhanced project management with dynamic sorting options, improved pagination, and refined state management for user interactions and display.
web/src/beta/features/Dashboard/ContentsContainer/Projects/Project/ProjectGridViewItem.tsx, web/src/beta/features/Dashboard/ContentsContainer/Projects/Project/ProjectListViewItem.tsx Updated component props for better state management, introduced publish status visualization, and improved layout consistency for a clearer user interface.
web/src/services/i18n/translations/en.yml, web/src/services/i18n/translations/ja.yml Expanded translation keys to support search and project metadata in English and Japanese; clarified search prompts and metadata labels.
web/src/services/theme/reearthTheme/lightTheme/index.ts, web/src/services/theme/reearthTheme/darkTheme/index.ts, web/src/services/theme/reearthTheme/types.ts Added a new publish property to both light and dark themes, providing dedicated color handling for published content.

Poem

🐇
In the dashboard bright and new,
Projects gleam with colors true.
Search and sort with just a click,
Rabbit hops, oh what a trick!
Publish status, all in sight,
Hurray for change, it feels so 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 as 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.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

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.

@github-actions github-actions bot removed the server label Jul 31, 2024
@mkumbobeaty mkumbobeaty marked this pull request as ready for review August 6, 2024 05:43
@github-actions github-actions bot requested a review from m-abe-dev August 6, 2024 05:43
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between b8499cc and bf39d93.

Files selected for processing (18)
  • web/src/beta/features/Dashboard/ContentsContainer/CommonHeader.tsx (4 hunks)
  • web/src/beta/features/Dashboard/ContentsContainer/Projects/Project/ProjectGridViewItem.tsx (4 hunks)
  • web/src/beta/features/Dashboard/ContentsContainer/Projects/Project/ProjectListViewItem.tsx (5 hunks)
  • web/src/beta/features/Dashboard/ContentsContainer/Projects/Project/hooks.ts (4 hunks)
  • web/src/beta/features/Dashboard/ContentsContainer/Projects/Project/types.ts (1 hunks)
  • web/src/beta/features/Dashboard/ContentsContainer/Projects/hooks.ts (5 hunks)
  • web/src/beta/features/Dashboard/ContentsContainer/Projects/index.tsx (6 hunks)
  • web/src/beta/features/Dashboard/type.ts (1 hunks)
  • web/src/beta/lib/reearth-ui/components/Breadcrumb/index.tsx (1 hunks)
  • web/src/services/api/projectApi.ts (2 hunks)
  • web/src/services/gql/gen/gql.ts (2 hunks)
  • web/src/services/gql/gen/graphql.ts (2 hunks)
  • web/src/services/gql/queries/project.ts (2 hunks)
  • web/src/services/i18n/translations/en.yml (1 hunks)
  • web/src/services/i18n/translations/ja.yml (1 hunks)
  • web/src/services/theme/reearthTheme/darkTheme/index.ts (1 hunks)
  • web/src/services/theme/reearthTheme/lightTheme/index.ts (1 hunks)
  • web/src/services/theme/reearthTheme/types.ts (1 hunks)
Additional comments not posted (70)
web/src/services/gql/__gen__/graphql.ts (2)

Line range hint 1-1:
LGTM! The addition of the starred field is correct.

The new optional field starred enhances the mutation's capability to handle starred status.


Line range hint 1-1:
LGTM! The mutation update is correct.

The inclusion of the starred variable in the mutation definition is consistent with the type changes.

web/src/beta/features/Dashboard/ContentsContainer/Projects/Project/types.ts (1)

Line range hint 1-1:
LGTM! The removal of isStarred and onProjectStarClick is correct.

The changes simplify the ProjectProps type and align with the new approach to handling starred projects.

web/src/beta/features/Dashboard/type.ts (1)

15-15: LGTM! The addition of the starred property is correct.

The new optional property starred enhances the Project type to convey project importance.

web/src/services/theme/reearthTheme/types.ts (1)

68-70: LGTM!

The addition of the publish property to the Theme type is consistent with the existing structure and enhances the theming capabilities.

web/src/services/theme/reearthTheme/lightTheme/index.ts (1)

65-67: LGTM!

The addition of the publish property to the lightTheme object is consistent with the existing structure and enhances the theming capabilities.

web/src/services/theme/reearthTheme/darkTheme/index.ts (1)

65-67: LGTM!

The addition of the publish property to the darkTheme object is consistent with the existing structure and enhances the theming capabilities.

web/src/beta/lib/reearth-ui/components/Breadcrumb/index.tsx (2)

30-32: LGTM!

The addition of the color property to the Typography component enhances the visual consistency and readability of the breadcrumb titles.


38-38: LGTM!

The updated logic for rendering the Separator component ensures consistent visual layout, even with a single breadcrumb item.

web/src/beta/features/Dashboard/ContentsContainer/Projects/Project/hooks.ts (4)

22-22: LGTM!

The addition of the isStarred state variable is necessary for managing the starred status of a project.


43-45: LGTM!

The useEffect hook ensures that the component dynamically reflects the current starred status of the project.


78-89: LGTM!

The handleProjectStarClick callback function enhances user interactivity by allowing users to star or unstar projects directly within the UI.


101-107: LGTM!

The addition of the isStarred and publishStatus properties to the return statement is necessary to expose the new state and computed properties to the component's consumer.

web/src/beta/features/Dashboard/ContentsContainer/CommonHeader.tsx (5)

19-21: LGTM!

The addition of new properties to the HeaderProps type extends its functionality to support search capabilities.

Also applies to: 27-27


45-45: LGTM!

The initialization of the searchInputValue state variable is necessary to manage the search input value.


54-59: LGTM!

The handleSearchInputChange callback function is necessary to handle user input for the search functionality.


61-65: LGTM!

The SearchIcon component enhances the interactivity of the search functionality by providing a clickable icon to initiate the search.


71-81: LGTM!

The rendering logic integrates the search functionality into the header component, allowing users to type keywords and trigger a search action both on change and on blur.

web/src/services/gql/queries/project.ts (2)

101-101: Ensure the new parameter is optional.

The new starred parameter should be optional to maintain backward compatibility.

Ensure that the backend can handle cases where starred is not provided.


116-116: LGTM!

The starred parameter is correctly added to the mutation input.

web/src/beta/features/Dashboard/ContentsContainer/Projects/Project/ProjectGridViewItem.tsx (5)

23-24: Ensure the new props are correctly derived.

The isStarred and publishStatus props are now derived from useHooks. Ensure that the useHooks function correctly provides these values.

Check the implementation of useHooks to ensure it correctly provides isStarred and publishStatus.


29-29: Ensure the new event handler is correctly implemented.

The handleProjectStarClick event handler is now derived from useHooks. Ensure that the useHooks function correctly provides this handler.

Check the implementation of useHooks to ensure it correctly provides handleProjectStarClick.


61-61: Ensure the new prop is correctly used.

The publishStatus prop is now used in the component. Ensure that it is correctly passed and used in the PublishStatus component.

Check the usage of publishStatus in the PublishStatus component to ensure it is correctly implemented.


122-127: Styling changes look good.

The addition of gap and padding in the CardFooter improves layout consistency.


129-134: New styled component looks good.

The PublishStatus styled component is correctly implemented to visually represent the publish status.

web/src/beta/features/Dashboard/ContentsContainer/Projects/hooks.ts (11)

1-7: Ensure all imports are necessary.

Review if all imported modules are being used in the file to avoid unnecessary imports.


13-20: Confirm the completeness of SortType.

Ensure that all necessary sort types are covered in the SortType union type.


29-63: Review the completeness of the pagination logic.

Ensure that all necessary sort types are handled correctly in the pagination function.


102-103: Review the pagination parameters.

Ensure that first, last, and sortBy are correctly derived from the pagination function.


119-125: Ensure proper refetching after project update.

Verify that the refetch function is correctly called after a project update.


128-130: Confirm the cache eviction logic.

Ensure that evicting the projects field from the cache is necessary and correctly implemented.


157-159: Optimize the favarateProjects memoization.

Ensure that favarateProjects is memoized correctly to avoid unnecessary recalculations.


215-217: Ensure proper refetching on dependency changes.

Verify that the refetch function is correctly called when sort, refetch, or searchTerm changes.


219-225: Review the sort change handler.

Ensure that the handleProjectSortChange function correctly updates the sort state.


227-233: Review the search handler.

Ensure that the handleSearch function correctly updates the search term state.


234-255: Ensure all returned values are necessary.

Review if all returned state variables and handler functions are necessary and used in the component.

web/src/beta/features/Dashboard/ContentsContainer/Projects/index.tsx (12)

Line range hint 1-12:
Ensure all imports are necessary.

Review if all imported modules are being used in the file to avoid unnecessary imports.


23-35: Ensure correct state management.

Verify that all state variables and handler functions are correctly managed and used within the component.


40-52: Optimize the sortOptions memoization.

Ensure that sortOptions is memoized correctly to avoid unnecessary recalculations.


61-67: Review the CommonHeader component.

Ensure that the CommonHeader component correctly handles the new sorting and search functionalities.


74-113: Ensure proper rendering of favorite projects.

Verify that favorite projects are correctly rendered in the grid view.


115-127: Ensure proper rendering of all projects.

Verify that all projects are correctly rendered in the grid view.


129-198: Ensure proper rendering in list view.

Verify that projects are correctly rendered in the list view.


200-207: Ensure proper loading state handling.

Verify that the loading state is correctly handled and displayed.


Line range hint 208-218:
Ensure proper handling of project creation modal.

Verify that the project creation modal is correctly handled and displayed.


235-239: Ensure correct styling and responsiveness.

Verify that the ProjectsContainer styled component is correctly styled and responsive.


270-273: Ensure correct styling and responsiveness.

Verify that the FlexTableRow styled component is correctly styled and responsive.


288-290: Ensure correct styling and responsiveness.

Verify that the StyledLoading styled component is correctly styled and responsive.

web/src/services/api/projectApi.ts (4)

Line range hint 1-5:
Ensure all imports are necessary.

Review if all imported modules are being used in the file to avoid unnecessary imports.


57-74: Ensure correct handling of the new input parameter.

Verify that the input parameter is correctly handled and used within the useProjectsQuery hook.


65-72: Ensure correct handling of pagination properties.

Verify that hasMoreProjects and endCursor are correctly derived and used.


74-74: Ensure all returned values are necessary.

Review if all returned properties are necessary and used in the component.

web/src/services/i18n/translations/ja.yml (5)

52-52: Translation entry added: Type key word to search.

The translation entry for Type key word to search has been correctly added.


53-53: Translation entry added: Sort.

The translation entry for Sort has been correctly added.


54-54: Translation entry added: Use Name or Email.

The translation entry for Use Name or Email has been correctly added.


55-55: Translation entry added: Find Member.

The translation entry for Find Member has been correctly added.


57-60: Translation entries added: First Created At, Last Created At, First Updated, Last Updated.

The translation entries for project timestamps have been correctly added.

web/src/services/i18n/translations/en.yml (6)

52-52: Translation entry added: Type key word to search.

The translation entry for Type key word to search has been correctly added.


53-53: Translation entry added: Sort.

The translation entry for Sort has been correctly added.


54-54: Translation entry added: Use Name or Email.

The translation entry for Use Name or Email has been correctly added.


55-55: Translation entry added: Find Member.

The translation entry for Find Member has been correctly added.


56-56: Translation entry added: No Member match your search.

The translation entry for No Member match your search has been correctly added.


57-60: Translation entries added: First Created At, Last Created At, First Updated, Last Updated.

The translation entries for project timestamps have been correctly added.

web/src/services/gql/__gen__/gql.ts (2)

54-54: Verify the correctness of the added starred parameter.

The starred parameter has been added to the mutation definition. Ensure that this parameter is correctly handled in the backend and aligns with the existing structure.


258-258: Verify the correctness of the added starred parameter.

The starred parameter has been added to the mutation function. Ensure that this parameter is correctly handled in the backend and aligns with the existing structure.

web/src/beta/features/Dashboard/ContentsContainer/Projects/Project/ProjectListViewItem.tsx (5)

39-39: LGTM! Verify the consistency of the prop name change.

The onProjectStarClick prop has been replaced with handleProjectStarClick.

Ensure that all instances of onProjectStarClick have been updated to handleProjectStarClick.

Verification successful

LGTM! Verify the consistency of the prop name change.

The onProjectStarClick prop has been successfully replaced with handleProjectStarClick across the codebase.

  • No instances of onProjectStarClick were found, confirming the consistency of the change.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the consistency of the prop name change from `onProjectStarClick` to `handleProjectStarClick`.

# Test: Search for any remaining instances of `onProjectStarClick`. Expect: No occurrences.
rg --type tsx 'onProjectStarClick'

Length of output: 62


Script:

#!/bin/bash
# Description: Verify the consistency of the prop name change from `onProjectStarClick` to `handleProjectStarClick`.

# Test: Search for any remaining instances of `onProjectStarClick`. Expect: No occurrences.
rg 'onProjectStarClick'

Length of output: 23


70-70: LGTM! Verify the correctness and styling of the PublishStatus component.

The PublishStatus component has been added to visually convey the project's publish status.

Ensure that the component is correctly styled and integrated.


64-64: LGTM! Verify the correctness of the event handler.

The onClick event handler for the star button has been updated to use handleProjectStarClick.

Ensure that the event handler works correctly and triggers the expected behavior.

Verification successful

Verified: The handleProjectStarClick event handler is correctly implemented and functions as expected.

  • The function stops the propagation of the click event.
  • It toggles the isStarred state.
  • It updates the project object with the new star status.
  • It calls the onProjectUpdate callback with the updated project.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the correctness of the `handleProjectStarClick` event handler.

# Test: Search for the implementation of `handleProjectStarClick`. Expect: Correct implementation and expected behavior.
rg --type tsx 'handleProjectStarClick'

Length of output: 66


Script:

#!/bin/bash
# Description: Verify the correctness of the `handleProjectStarClick` event handler.

# Test: Search for the implementation of `handleProjectStarClick`. Expect: Correct implementation and expected behavior.
rg 'handleProjectStarClick'

Length of output: 785


Script:

#!/bin/bash
# Description: Extract the implementation details of `handleProjectStarClick` from `hooks.ts`.

# Test: Retrieve the implementation of `handleProjectStarClick`. Expect: Correct implementation and expected behavior.
rg -A 20 'const handleProjectStarClick' web/src/beta/features/Dashboard/ContentsContainer/Projects/Project/hooks.ts

Length of output: 636


144-150: LGTM! Verify the correctness of the styles.

The PublishStatus styled component is defined with specific styles to convey the status through color coding.

Ensure that the styles are correctly applied and render as expected.

Verification successful

LGTM!

The PublishStatus styled component is correctly applied in both ProjectListViewItem.tsx and ProjectGridViewItem.tsx. The styles are conditionally applied based on the status prop in ProjectListViewItem.tsx, and static styles are used in ProjectGridViewItem.tsx. Both usages align with the intended design of the component.

  • ProjectListViewItem.tsx: Conditional styles based on status prop.
  • ProjectGridViewItem.tsx: Static styles.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the correctness of the styles for the `PublishStatus` component.

# Test: Search for the usage of the `PublishStatus` component. Expect: Correct application of styles.
rg --type tsx 'PublishStatus'

Length of output: 57


Script:

#!/bin/bash
# Description: Verify the correctness of the styles for the `PublishStatus` component.

# Test: Search for the usage of the `PublishStatus` component within TypeScript files.
rg 'PublishStatus' --glob '*.tsx'

Length of output: 1289


Script:

#!/bin/bash
# Description: Extract relevant lines of code for `PublishStatus` usage in `ProjectListViewItem.tsx` and `ProjectGridViewItem.tsx`.

# Extract lines around the usage of `PublishStatus` in `ProjectListViewItem.tsx`
rg 'PublishStatus' -A 5 -B 5 web/src/beta/features/Dashboard/ContentsContainer/Projects/Project/ProjectListViewItem.tsx

# Extract lines around the usage of `PublishStatus` in `ProjectGridViewItem.tsx`
rg 'PublishStatus' -A 5 -B 5 web/src/beta/features/Dashboard/ContentsContainer/Projects/Project/ProjectGridViewItem.tsx

Length of output: 1642


33-34: LGTM! Verify the integration of new props.

The isStarred and publishStatus props are correctly destructured from the useHooks call.

Ensure that these props are correctly integrated and used throughout the component.

Verification successful

Verified: Integration of isStarred and publishStatus props

The isStarred and publishStatus props are correctly integrated and used throughout the codebase.

  • isStarred is used in various files, including hooks.ts, ProjectGridViewItem.tsx, and ProjectListViewItem.tsx.
  • publishStatus is used in files such as PublishToolsPanel/index.tsx, PublishToolsPanel/PublishModal/index.tsx, and hooks.ts.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the integration of `isStarred` and `publishStatus` props in the codebase.

# Test: Search for the usage of `isStarred` and `publishStatus` props. Expect: Proper integration and usage.
rg --type tsx 'isStarred'
rg --type tsx 'publishStatus'

Length of output: 111


Script:

#!/bin/bash
# Description: Verify the integration of `isStarred` and `publishStatus` props in the codebase.

# Test: Search for the usage of `isStarred` and `publishStatus` props. Expect: Proper integration and usage.
rg 'isStarred'
rg 'publishStatus'

Length of output: 5599

Copy link

@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, codebase verification and nitpick comments (1)
web/src/beta/features/Dashboard/ContentsContainer/Projects/hooks.ts (1)

14-14: Consider renaming name-reverse to name-reversed for consistency.

The other sort types use the -reversed suffix, so for consistency, name-reverse should be renamed to name-reversed.

- export type SortType = "date" | "date-reversed" | "name" | "name-reverse" | "date-updated";
+ export type SortType = "date" | "date-reversed" | "name" | "name-reversed" | "date-updated";
Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between bf39d93 and 4deda76.

Files selected for processing (6)
  • web/src/beta/features/Dashboard/ContentsContainer/Projects/hooks.ts (5 hunks)
  • web/src/beta/features/Dashboard/ContentsContainer/Projects/index.tsx (5 hunks)
  • web/src/services/gql/gen/gql.ts (2 hunks)
  • web/src/services/gql/gen/graphql.ts (2 hunks)
  • web/src/services/i18n/translations/en.yml (1 hunks)
  • web/src/services/i18n/translations/ja.yml (2 hunks)
Files skipped from review as they are similar to previous changes (5)
  • web/src/beta/features/Dashboard/ContentsContainer/Projects/index.tsx
  • web/src/services/gql/gen/gql.ts
  • web/src/services/gql/gen/graphql.ts
  • web/src/services/i18n/translations/en.yml
  • web/src/services/i18n/translations/ja.yml
Additional comments not posted (13)
web/src/beta/features/Dashboard/ContentsContainer/Projects/hooks.ts (13)

1-8: Imports and constants look good.

The imports are necessary for the functionality added and the constants are defined correctly.


17-22: Consider using a switch statement for clarity.

Using a switch statement might improve readability and maintainability.

- const toPublishmentStatus = (s: PublishmentStatus) =>
-   s === PublishmentStatus.Public
-     ? "published"
-     : s === PublishmentStatus.Limited
-     ? "limited"
-     : "unpublished";
+ const toPublishmentStatus = (s: PublishmentStatus) => {
+   switch (s) {
+     case PublishmentStatus.Public:
+       return "published";
+     case PublishmentStatus.Limited:
+       return "limited";
+     default:
+       return "unpublished";
+   }
+ };

24-52: Pagination function looks good.

The function correctly handles different sort types and returns appropriate pagination values.


57-70: State and effect hooks look good.

The state and effect hooks are correctly implemented and necessary for the added functionalities.


71-74: Handle layout change function looks good.

The function correctly updates the layout and stores the new layout in local storage.


Line range hint 75-90:
Handle project create function looks good.

The function correctly creates a new project and handles edge cases.


92-108: Use projects query hook looks good.

The hook correctly integrates the new sorting and pagination parameters and handles edge cases.


109-115: Handle project update function looks good.

The function correctly updates the project and triggers a refetch if sorting is applied.


118-120: Cache eviction effect looks good.

The effect correctly evicts the cache for projects.


Line range hint 121-149:
Memoized project nodes and projects look good.

The hooks correctly memoize the values and handle edge cases.


147-149: Memoized favorite projects look good.

The hook correctly memoizes the values and handles edge cases.


151-151: Memoized refetching state looks good.

The hook correctly memoizes the refetching state and handles edge cases.


Line range hint 152-246:
Remaining functions and return statement look good.

The functions correctly handle user interactions and the return statement exports the necessary values and functions.

Copy link

@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, codebase verification and nitpick comments (7)
web/src/beta/features/Dashboard/ContentsContainer/Projects/hooks.ts (4)

28-56: Consider clarifying pagination logic.

Explicitly setting both first and last in each case can improve readability and prevent potential logical errors.

    case "date":
+     first = undefined;
      last = projectsPerPage;
    case "date-reversed":
      first = projectsPerPage;
+     last = undefined;
    // Continue similarly for other cases

114-120: Ensure sortBy is defined when refetching.

Consider adding a check to ensure sortBy is defined before calling refetch.

    async (project: Project, projectId: string) => {
      await useUpdateProject({ projectId, ...project });
-     if (sortBy) refetch();
+     if (sortBy) {
+       refetch();
+     }
    },

123-125: Add a comment to explain cache eviction.

Consider adding a comment to explain why cache eviction is necessary here.

  useEffect(() => {
+   // Evict projects cache to ensure fresh data on component mount.
    gqlCache.evict({ fieldName: "projects" });
  }, [gqlCache]);

214-220: Handle invalid sort values explicitly.

Consider adding a check to ensure the sort value is valid before updating the state.

    (value?: string) => {
      if (!value) return;
-     setSort((value as SortType) ?? sortValue);
+     if (["date", "date-reversed", "name", "name-reverse", "date-updated"].includes(value)) {
+       setSort(value as SortType);
+     }
    },
web/src/services/api/projectApi.ts (3)

Line range hint 89-132: Handle potential null values explicitly.

Consider checking for null values in projectResults and sceneResults before accessing their properties.

      const { data: projectResults, errors: projectErrors } = await createNewProject({
        variables: {
          teamId: workspaceId,
          visualizer,
          name,
          description: description ?? "",
          imageUrl: imageUrl ?? "",
          coreSupport: !!coreSupport,
        },
      });
-     if (projectErrors || !projectResults?.createProject) {
+     if (projectErrors || !projectResults || !projectResults.createProject) {
        setNotification({ type: "error", text: t("Failed to create project.") });

        return { status: "error" };
      }

      const { data: sceneResults, errors: sceneErrors } = await createScene({
        variables: { projectId: projectResults?.createProject.project.id },
      });
-     if (sceneErrors || !sceneResults?.createScene) {
+     if (sceneErrors || !sceneResults || !sceneResults.createScene) {
        setNotification({ type: "error", text: t("Failed to create project.") });
        return { status: "error" };
      }

Line range hint 176-195: Improve error logging.

Consider providing more context when logging errors to aid in debugging.

      const { data, errors } = await publishProjectMutation({
        variables: { projectId, alias, status: gqlStatus },
      });

-     if (errors || !data?.publishProject) {
-       console.log("GraphQL: Failed to publish project", errors);
+     if (errors || !data || !data.publishProject) {
+       console.log(`GraphQL: Failed to publish project with ID ${projectId}`, errors);
        setNotification({ type: "error", text: t("Failed to publish project.") });

        return { status: "error" };
      }

Line range hint 214-233: Ensure input.projectId is defined.

Consider adding a check to ensure input.projectId is defined before proceeding with the mutation.

    async (input: UpdateProjectInput) => {
-     if (!input.projectId) return { status: "error" };
+     if (!input || !input.projectId) {
+       setNotification({ type: "error", text: t("Project ID is required.") });
+       return { status: "error" };
+     }
      const { data, errors } = await updateProjectMutation({ variables: { ...input } });
Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 4deda76 and 3e5c8bc.

Files selected for processing (5)
  • web/src/beta/features/Dashboard/ContentsContainer/Projects/hooks.ts (5 hunks)
  • web/src/beta/features/Dashboard/ContentsContainer/Projects/index.tsx (5 hunks)
  • web/src/services/api/projectApi.ts (2 hunks)
  • web/src/services/i18n/translations/en.yml (2 hunks)
  • web/src/services/i18n/translations/ja.yml (2 hunks)
Files skipped from review as they are similar to previous changes (3)
  • web/src/beta/features/Dashboard/ContentsContainer/Projects/index.tsx
  • web/src/services/i18n/translations/en.yml
  • web/src/services/i18n/translations/ja.yml
Additional comments not posted (5)
web/src/beta/features/Dashboard/ContentsContainer/Projects/hooks.ts (4)

17-26: LGTM!

The toPublishmentStatus function is clear and correctly implemented using a switch statement.


210-212: LGTM!

The useEffect for refetching projects is correctly implemented.


222-228: LGTM!

The handleSearch function is correctly implemented.


Line range hint 58-239: Ensure naming consistency and state management clarity.

  1. The variable favarateProjects seems to be misspelled; consider renaming it to favoriteProjects.
  2. Consider initializing searchTerm with an empty string for consistency.
  3. Verify that all usages of sortValue and searchTerm are updated correctly across the codebase.
- const [searchTerm, setSearchTerm] = useState<string>();
+ const [searchTerm, setSearchTerm] = useState<string>("");

- const favarateProjects: Project[] = useMemo(() => {
+ const favoriteProjects: Project[] = useMemo(() => {
Verification successful

Ensure Naming Consistency and State Initialization

  • Rename favarateProjects to favoriteProjects to correct the typo.
  • Initialize searchTerm with an empty string for consistency with other parts of the codebase.

These changes align with the current codebase usage patterns and improve code clarity.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that all usages of `sortValue` and `searchTerm` are updated correctly.

# Test: Search for occurrences of `sortValue` and `searchTerm`.
rg --type js 'sortValue|searchTerm'

Length of output: 37


Script:

#!/bin/bash
# Re-run the search with a more focused approach to ensure the presence and usage of `sortValue` and `searchTerm` across the codebase.

# Search for occurrences of `sortValue` in the codebase.
rg 'sortValue' -A 3

# Search for occurrences of `searchTerm` in the codebase.
rg 'searchTerm' -A 3

Length of output: 18436

web/src/services/api/projectApi.ts (1)

57-74: LGTM! But verify the impact of changes.

The useProjectsQuery function enhancements are well-implemented.

Ensure that all usages of useProjectsQuery are updated to accommodate the new input type.

Verification successful

Verified: Usage of useProjectsQuery is consistent with the new input type.

The function is correctly utilized in hooks.ts, with parameters that match the expected input type. No further changes are needed.

  • Location: web/src/beta/features/Dashboard/ContentsContainer/Projects/hooks.ts
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that all usages of `useProjectsQuery` are updated to accommodate the new input type.

# Test: Search for occurrences of `useProjectsQuery`.
rg --type js 'useProjectsQuery'

Length of output: 31


Script:

#!/bin/bash
# Description: Perform a broader search for occurrences of `useProjectsQuery` in both JavaScript and TypeScript files.

# Test: Search for occurrences of `useProjectsQuery` in JavaScript and TypeScript files.
rg 'useProjectsQuery' --type-add 'typescript:*.ts' --type-add 'typescriptreact:*.tsx' --type js --type typescript --type typescriptreact

Length of output: 556


Script:

#!/bin/bash
# Description: Examine the context around the usage of `useProjectsQuery` in `hooks.ts` to verify compatibility with the new input type.

# Test: Display lines around the usage of `useProjectsQuery` in `hooks.ts`.
rg 'useProjectsQuery' -A 5 -B 5 web/src/beta/features/Dashboard/ContentsContainer/Projects/hooks.ts

Length of output: 689

Copy link

@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

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 3e5c8bc and 00b2de5.

Files selected for processing (3)
  • web/src/beta/features/Dashboard/ContentsContainer/Projects/index.tsx (5 hunks)
  • web/src/services/i18n/translations/en.yml (2 hunks)
  • web/src/services/i18n/translations/ja.yml (2 hunks)
Files skipped from review as they are similar to previous changes (3)
  • web/src/beta/features/Dashboard/ContentsContainer/Projects/index.tsx
  • web/src/services/i18n/translations/en.yml
  • web/src/services/i18n/translations/ja.yml

Copy link

@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

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 00b2de5 and 8551905.

Files selected for processing (8)
  • web/src/beta/features/Dashboard/ContentsContainer/Projects/index.tsx (5 hunks)
  • web/src/services/gql/gen/gql.ts (2 hunks)
  • web/src/services/gql/gen/graphql.ts (2 hunks)
  • web/src/services/i18n/translations/en.yml (1 hunks)
  • web/src/services/i18n/translations/ja.yml (1 hunks)
  • web/src/services/theme/reearthTheme/darkTheme/index.ts (1 hunks)
  • web/src/services/theme/reearthTheme/lightTheme/index.ts (1 hunks)
  • web/src/services/theme/reearthTheme/types.ts (1 hunks)
Files skipped from review as they are similar to previous changes (7)
  • web/src/services/gql/gen/gql.ts
  • web/src/services/gql/gen/graphql.ts
  • web/src/services/i18n/translations/en.yml
  • web/src/services/i18n/translations/ja.yml
  • web/src/services/theme/reearthTheme/darkTheme/index.ts
  • web/src/services/theme/reearthTheme/lightTheme/index.ts
  • web/src/services/theme/reearthTheme/types.ts
Additional comments not posted (10)
web/src/beta/features/Dashboard/ContentsContainer/Projects/index.tsx (10)

1-4: Import statements look good.

The necessary imports for useMemo, Breadcrumb, and styled components are correctly added.


40-50: Use of useMemo for sorting options is appropriate.

The useMemo hook is used correctly to optimize the creation of sorting options based on the translation function t.


54-72: Enhancements in ManagerHeader are well-implemented.

The ManagerHeader component now includes sorting and search functionalities, which enhance user interaction.


79-104: Conditional rendering of Breadcrumb is effective.

The Breadcrumb component is conditionally rendered based on favarateProjects, which provides contextual navigation.


105-159: Grid layout logic is clear and functional.

The grid layout for displaying projects is well-structured, and the use of ProjectsGrid enhances visual organization.


Line range hint 161-235: List layout logic is consistent and well-implemented.

The list layout complements the grid view, providing flexibility in how projects are displayed.


239-246: Loading state handling is appropriate.

The loading state is managed effectively, ensuring a smooth user experience when fetching more projects.


274-278: ProjectsContainer styled component is well-defined.

The styling for ProjectsContainer is clear, enhancing the layout's visual appeal.


280-282: BreadcrumbContainer styling is appropriate.

The padding adjustment for BreadcrumbContainer ensures proper spacing.


312-315: FlexTableRow styling update is effective.

The inclusion of gap in FlexTableRow improves spacing and layout consistency.

Copy link

@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

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 8551905 and 76dfaba.

Files selected for processing (2)
  • web/src/beta/features/Dashboard/ContentsContainer/Projects/hooks.ts (5 hunks)
  • web/src/beta/features/Dashboard/ContentsContainer/Projects/index.tsx (5 hunks)
Additional comments not posted (16)
web/src/beta/features/Dashboard/ContentsContainer/Projects/hooks.ts (7)

17-26: LGTM!

The toPublishmentStatus function is well-implemented with a switch statement, enhancing readability.


28-57: LGTM!

The pagination function effectively calculates pagination parameters based on the sort type, covering all necessary cases.


123-125: LGTM!

The useEffect hook for cache eviction is correctly implemented, ensuring data consistency.


Line range hint 128-151: Efficient use of memoization!

The memoization of projects is well-implemented, optimizing performance by reducing unnecessary recalculations.


152-154: Efficient use of memoization!

The memoization of favoriteProjects is well-implemented, optimizing performance by reducing unnecessary recalculations.


156-171: LGTM!

The handleGetMoreProjects function is well-implemented, ensuring additional projects are fetched when needed.


Line range hint 58-251: Well-structured implementation!

The default export function is well-organized, effectively managing project fetching, sorting, and state. The use of hooks and memoization is appropriate for performance optimization.

Ensure that the new sort and pagination logic is correctly integrated throughout the codebase.

Verification successful

Integration of Sort and Pagination Logic Verified

The search results indicate that the pagination function and SortType are consistently used across various parts of the codebase, including the Projects, Assets, and AssetsManager modules. This suggests that the new sort and pagination logic is correctly integrated throughout the codebase.

  • Files with relevant usage:
    • web/src/beta/features/Dashboard/ContentsContainer/Projects/hooks.ts
    • web/src/beta/features/AssetsManager/hooks.ts
    • web/src/beta/features/Assets/hooks.ts
    • web/src/services/gql/queries/project.ts
    • web/src/services/gql/queries/asset.ts

This confirms that the new logic is applied consistently, ensuring proper functionality across different features.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the integration of new sort and pagination logic in the codebase.

# Test: Search for the usage of `pagination` and `SortType`. Expect: Consistent usage across the codebase.
rg --type typescript -A 5 $'pagination'
rg --type typescript -A 5 $'SortType'

Length of output: 145


Script:

#!/bin/bash
# Description: Verify the integration of new sort and pagination logic in the codebase.

# Test: Search for the usage of `pagination` and `SortType`. Expect: Consistent usage across the codebase.
rg --type-add 'ts:*.ts' --type ts -A 5 'pagination'
rg --type-add 'ts:*.ts' --type ts -A 5 'SortType'

Length of output: 76104

web/src/beta/features/Dashboard/ContentsContainer/Projects/index.tsx (9)

Line range hint 10-237: Well-structured component!

The Projects component is well-organized, effectively managing project display, sorting, and user interactions. The use of hooks and memoization is appropriate for performance optimization.


40-50: Efficient use of memoization!

The memoization of sortOptions is well-implemented, optimizing performance and supporting internationalization.


54-72: LGTM!

The ManagerHeader component is correctly used, providing a user-friendly interface for sorting and layout selection.


Line range hint 73-246: LGTM!

The ProjectsWrapper component is correctly used, ensuring smooth scrolling and project display.


274-278: LGTM!

The ProjectsContainer styled component is well-implemented, organizing project display in grid or list layouts.


280-282: LGTM!

The BreadcrumbContainer styled component is well-implemented, providing appropriate spacing for breadcrumbs.


Line range hint 283-291: LGTM!

The ProjectsGrid styled component is well-implemented, providing a responsive grid layout that adapts to different screen sizes.


Line range hint 292-309: LGTM!

The FlexTable and FlexTableBody styled components are well-implemented, organizing projects in a flexible table layout.


312-315: LGTM!

The FlexTableRow styled component is well-implemented, organizing individual project rows with appropriate spacing.

@mkumbobeaty mkumbobeaty changed the title feat(web): implements sort projects functionalities feat(web): implements projects functionalities Aug 8, 2024
Copy link

@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

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 76dfaba and 017564a.

Files selected for processing (4)
  • web/src/beta/features/Dashboard/ContentsContainer/Projects/hooks.ts (5 hunks)
  • web/src/beta/features/Dashboard/ContentsContainer/Projects/index.tsx (5 hunks)
  • web/src/services/i18n/translations/en.yml (1 hunks)
  • web/src/services/i18n/translations/ja.yml (1 hunks)
Files skipped from review as they are similar to previous changes (2)
  • web/src/services/i18n/translations/en.yml
  • web/src/services/i18n/translations/ja.yml
Additional comments not posted (11)
web/src/beta/features/Dashboard/ContentsContainer/Projects/hooks.ts (5)

17-26: LGTM!

The toPublishmentStatus function is well-implemented using a switch statement for clarity.


28-58: LGTM, but note the pending backend fix.

The pagination function is well-structured. The TODO comment indicates a pending backend fix for sorting by Createdat.


100-114: LGTM!

The useProjectsQuery hook is correctly configured with parameters for sorting, pagination, and search functionality.


115-121: LGTM!

The handleProjectUpdate function correctly handles project updates and refetches data to ensure UI accuracy.


211-213: LGTM!

The useEffect hook is appropriately used to refetch projects when the sort value or search term changes.

web/src/beta/features/Dashboard/ContentsContainer/Projects/index.tsx (6)

11-53: LGTM!

The Projects component is well-structured, utilizing hooks and conditional rendering effectively for project management.


40-50: LGTM!

The sortOptions are efficiently generated using useMemo, supporting internationalization with the translation function t.


54-73: LGTM!

The ManagerHeader component is well-configured with sorting, layout, and search functionalities to enhance user interaction.


80-159: LGTM!

The breadcrumb and project display logic is well-implemented, providing clear navigation and enhancing the user experience.


Line range hint 162-236: LGTM!

The FlexTable component is effectively used for list layout, enhancing the visual organization of projects.


Line range hint 275-333: LGTM!

The styled components are well-defined, contributing to a consistent and responsive design.

Copy link

@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

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 017564a and b3cb8ff.

Files selected for processing (3)
  • web/src/beta/features/Dashboard/ContentsContainer/Projects/Project/ProjectGridViewItem.tsx (5 hunks)
  • web/src/beta/features/Dashboard/ContentsContainer/Projects/Project/ProjectListViewItem.tsx (6 hunks)
  • web/src/beta/features/Dashboard/ContentsContainer/Projects/index.tsx (5 hunks)
Files skipped from review as they are similar to previous changes (2)
  • web/src/beta/features/Dashboard/ContentsContainer/Projects/Project/ProjectGridViewItem.tsx
  • web/src/beta/features/Dashboard/ContentsContainer/Projects/Project/ProjectListViewItem.tsx
Additional comments not posted (11)
web/src/beta/features/Dashboard/ContentsContainer/Projects/index.tsx (11)

1-1: Imports look good!

The import of useMemo is appropriate for optimizing the sorting options.

Also applies to: 3-4


20-35: State and handlers look good!

The updated state variables and handlers align well with the new functionalities.


40-50: Efficient use of useMemo for sorting options.

The use of useMemo to optimize sorting options creation is efficient and improves performance.


54-73: UI enhancements are well-implemented!

The updates to the ManagerHeader and breadcrumb navigation enhance user experience and align with the PR objectives.


80-105: Breadcrumb navigation is clear and effective.

The breadcrumb component provides clear navigation, especially with the integration of favorite projects and search terms.


106-160: Grid layout for projects is responsive and well-structured.

The use of ProjectsContainer and ProjectsGrid ensures a responsive and organized display of projects.


Line range hint 162-236: List layout is consistent with grid layout.

The FlexTable and FlexTableBody components maintain consistency in displaying projects in list view.


240-247: Loading indicators are appropriately used.

The loading indicators provide clear feedback to users during data fetching.


275-279: Styled components are well-defined.

The ProjectsContainer styled component effectively organizes the project display.


281-283: BreadcrumbContainer styling is appropriate.

The BreadcrumbContainer styled component provides adequate spacing for breadcrumb elements.


313-316: FlexTableRow styling adjustment is effective.

The inclusion of a gap in FlexTableRow improves the layout's readability and aesthetics.

@airslice airslice merged commit 400b7bb into main Aug 8, 2024
12 checks passed
@airslice airslice deleted the feat/improve-dashboard branch August 8, 2024 11:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants