Skip to content

Comments

[WEB-2917] Fix home widget#6560

Merged
sriramveeraghanta merged 6 commits intopreviewfrom
fix-home-widget
Feb 7, 2025
Merged

[WEB-2917] Fix home widget#6560
sriramveeraghanta merged 6 commits intopreviewfrom
fix-home-widget

Conversation

@gakshita
Copy link
Collaborator

@gakshita gakshita commented Feb 6, 2025

Description

This PR has the following changes:

  • Quickstart guide widget
  • Loading state fix on home page

Summary by CodeRabbit

  • New Features
    • Enhanced the home interface by adding new guidance labels ("Quickstart Guide" and "Not right now") across multiple languages.
    • Introduced a refreshed loading indicator and interactive empty state, so users can now easily manage quickstart guidance.
  • Bug Fixes
    • Improved error notifications during link creation to provide clearer, more specific feedback.
  • Style
    • Adjusted layout styling for sticky notes to ensure a more consistent visual presentation.

@gakshita gakshita marked this pull request as draft February 6, 2025 14:38
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 6, 2025

Walkthrough

This pull request adds two new translation keys ("quickstart_guide" and "not_right_now") to the localized JSON files for English, Spanish, French, Japanese, and Chinese. It also introduces several UI component modifications in the home dashboard area, including new hooks for routing and project state, improved error handling, and adjustments to empty state rendering. Additionally, a new HomeLoader component is added, the MobX observer pattern is implemented in the NoProjectsEmptyState component, and a loading state is integrated into the home workspace store.

Changes

File(s) Summary
packages/i18n/src/locales/{en,es,fr,ja,zh-CN}/translations.json Added new keys "quickstart_guide" and "not_right_now" to the "home" section for localized user interface text.
web/core/components/home/home-dashboard-widgets.tsx Updated component to import/use usePathname and useProject; added conditional rendering with HomeLoader and NoProjectsEmptyState based on routing and loader state.
web/core/components/home/widgets/empty-states/no-projects.tsx Modified to use MobX observer and local storage; introduced interactive quickstart guide handling and conditional rendering based on completion status.
web/core/components/home/widgets/links/use-links.tsx Refined error handling in the create method by logging and displaying a more specific error message from error.data.url.error.
web/core/components/home/widgets/loaders/home-loader.tsx, web/core/components/home/widgets/loaders/index.ts Introduced new HomeLoader component for displaying loading state and updated exports to include loader functionalities.
web/core/components/home/widgets/recents/index.tsx Removed usePathname and useProject hooks along with associated project-related logic, simplifying component rendering.
web/core/components/stickies/layout/stickies-list.tsx Adjusted container styling by removing the minimum height constraint from the CSS class.
web/core/store/workspace/home.ts Added a new observable property "loading" to the HomeStore and updated fetchWidgets to manage loading state during API calls.
web/core/store/workspace/link.store.ts Removed an extraneous debug log statement from the createLink method.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant DashboardWidgets
    participant Nav as usePathname
    participant Project as useProject
    participant Loader as HomeLoader
    participant Empty as NoProjectsEmptyState

    User->>DashboardWidgets: Navigate to home dashboard
    DashboardWidgets->>Nav: Get current pathname
    DashboardWidgets->>Project: Retrieve project loader state
    alt Loader active (not "loaded")
         Project-->>DashboardWidgets: Return loader status
         DashboardWidgets->>Loader: Render HomeLoader
    else Loader complete ("loaded")
         Project-->>DashboardWidgets: Return loader status
         DashboardWidgets->>Empty: Conditionally render NoProjectsEmptyState
    end
Loading

Possibly related PRs

Suggested labels

🐛bug, 🌐frontend

Suggested reviewers

  • rahulramesha
  • sriramveeraghanta

Poem

Oh, I’m a rabbit hopping through code,
Adding keys in every language mode.
Translations bloom like springtime cheer,
UI flows smooth, nothing to fear.
With a twirl of hooks and a gentle nod,
I celebrate changes—let’s applaud! 🐇✨
Hop along, the updates are here!

✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@gakshita gakshita marked this pull request as ready for review February 7, 2025 09:23
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (6)
web/core/components/home/widgets/empty-states/no-projects.tsx (2)

110-121: Add a default case in the switch statement.
The isComplete() function relies on matching specific strings. Consider adding a default case to ensure a boolean is always returned, even if a new flag is introduced in the future.

 const isComplete = (type: string) => {
   switch (type) {
     case "projects":
       return joinedProjectIds?.length > 0;
     case "visited_members":
       return storedValue?.visited_members;
     case "visited_workspace":
       return storedValue?.visited_workspace;
     case "visited_profile":
       return storedValue?.visited_profile;
+    default:
+      return false; // or handle in another appropriate way
   }
 };

123-123: Optional early return check.
Returning null if storedValue.hide is true is a concise approach. Just be sure that transitioning from "hide: true" back to "false" is accounted for if the user wants the guide again.

web/core/components/home/widgets/links/use-links.tsx (1)

45-87: Consider standardizing error handling across methods.

The error handling pattern differs between methods:

  • create: uses error?.data?.url?.error
  • update and remove: use error?.data?.error

Consider standardizing the error handling approach across all methods for better maintainability.

  // in update method
  setToast({
-   message: error?.data?.error ?? t("links.toasts.not_updated.message"),
+   message: error?.data?.url?.error ?? t("links.toasts.not_updated.message"),
    type: TOAST_TYPE.ERROR,
    title: t("links.toasts.not_updated.title"),
  });

  // in remove method
  setToast({
-   message: error?.data?.error ?? t("links.toasts.not_removed.message"),
+   message: error?.data?.url?.error ?? t("links.toasts.not_removed.message"),
    type: TOAST_TYPE.ERROR,
    title: t("links.toasts.not_removed.title"),
  });
web/core/components/home/home-dashboard-widgets.tsx (1)

68-68: Consider using a more robust way to check for wiki app context.

The current check pathname.includes(/${workspaceSlug.toString()}/pages) might be fragile if the URL structure changes. Consider using a dedicated constant or route configuration.

+ const WIKI_PATH_SUFFIX = '/pages';
+ const isWikiApp = pathname.endsWith(`/${workspaceSlug.toString()}${WIKI_PATH_SUFFIX}`);
- const isWikiApp = pathname.includes(`/${workspaceSlug.toString()}/pages`);
web/core/store/workspace/home.ts (1)

83-87: Consider improving error handling.

The error handling could be improved by cleaning up the state before rethrowing the error.

  } catch (error) {
+   runInAction(() => {
+     // Reset state on error
+     this.widgets = [];
+     this.widgetsMap = {};
+     this.loading = false;
+   });
-   console.error("Failed to fetch widgets");
-   this.loading = false;
    throw error;
  }
packages/i18n/src/locales/fr/translations.json (1)

549-550: New French Translation Keys for Home Empty State
The new keys "quickstart_guide" and "not_right_now" have been added with appropriate French translations ("Guide de démarrage rapide" and "Pas maintenant"). This update is consistent with similar changes made in the other locale files and enhances user guidance in the home empty state.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 2b595cf and 5031f80.

📒 Files selected for processing (14)
  • packages/i18n/src/locales/en/translations.json (1 hunks)
  • packages/i18n/src/locales/es/translations.json (1 hunks)
  • packages/i18n/src/locales/fr/translations.json (1 hunks)
  • packages/i18n/src/locales/ja/translations.json (1 hunks)
  • packages/i18n/src/locales/zh-CN/translations.json (1 hunks)
  • web/core/components/home/home-dashboard-widgets.tsx (3 hunks)
  • web/core/components/home/widgets/empty-states/no-projects.tsx (5 hunks)
  • web/core/components/home/widgets/links/use-links.tsx (1 hunks)
  • web/core/components/home/widgets/loaders/home-loader.tsx (1 hunks)
  • web/core/components/home/widgets/loaders/index.ts (1 hunks)
  • web/core/components/home/widgets/recents/index.tsx (2 hunks)
  • web/core/components/stickies/layout/stickies-list.tsx (1 hunks)
  • web/core/store/workspace/home.ts (4 hunks)
  • web/core/store/workspace/link.store.ts (0 hunks)
💤 Files with no reviewable changes (1)
  • web/core/store/workspace/link.store.ts
✅ Files skipped from review due to trivial changes (1)
  • web/core/components/stickies/layout/stickies-list.tsx
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Analyze (javascript)
🔇 Additional comments (18)
web/core/components/home/widgets/empty-states/no-projects.tsx (7)

2-3: Well-structured imports.
The newly added imports for "mobx-react," "lucide-react," "useLocalStorage," "cn," and additional store hooks are cohesive and well-organized.

Also applies to: 6-6, 9-9, 12-12, 15-15


18-18: Good use of MobX.
Wrapping the component with observer() ensures reactive updates whenever observable data changes. This is a valid approach for real-time UI updates.


26-26: Potential null check.
When referencing joinedProjectIds, ensure that you handle potential undefined or null values (e.g., if the user or project data fails to load).


28-33: LocalStorage usage.
Storing progress flags for a quickstart guide in local storage is typically safe. However, be mindful not to store sensitive user data or PII here to prevent unintended exposure.


46-47: Consistent icon usage and flag definitions.
Adding the icon elements and flag properties is a clear approach to keep the UI and state tracking in sync. The "size-10" class is consistently applied, which aids style uniformity.

Also applies to: 63-64, 74-75, 103-103


126-190: Great quickstart guide UI structure.
Mapping over EMPTY_STATE_DATA is a clean way to handle multiple steps. The storage updates (setValue) correctly record progress. The layout is visually clear and easy to maintain.


193-193: No concerns regarding the closing block.
Overall, the component's structure is complete and consistent with React best practices.

web/core/components/home/widgets/loaders/index.ts (1)

2-2: Useful expansion of exports.
Exporting from "./home-loader" provides a convenient way to structure and reuse loader functionality outside this file.

web/core/components/home/widgets/loaders/home-loader.tsx (2)

1-5: Client-side loader definition.
Using "use client" ensures this code runs client-side for immediate user feedback. The lodash "range" utility and the "@plane/ui" Loader are an appropriate pairing for rendering skeleton loaders.


7-22: Readable and concise loading structure.
Mapping over three loader items provides a clear approach to display placeholders across multiple sections. This is simple, effective, and aligns well with furnishing a consistent UI skeleton.

web/core/components/home/widgets/links/use-links.tsx (1)

45-47: LGTM! Improved error handling for URL-specific errors.

The changes enhance error handling by providing more specific error messages related to URL validation.

web/core/components/home/home-dashboard-widgets.tsx (1)

70-70: LGTM! Added proper loading state handling.

The addition of loading state handling with HomeLoader improves user experience by providing visual feedback during data fetching.

web/core/components/home/widgets/recents/index.tsx (1)

16-16: LGTM! Improved component responsibility.

The removal of project-related logic and its relocation to the parent component improves separation of concerns and follows the single responsibility principle.

web/core/store/workspace/home.ts (1)

10-10: LGTM! Added proper loading state management.

The addition of the loading observable and its management in fetchWidgets improves state handling and user experience.

Also applies to: 29-29, 40-40, 74-85

packages/i18n/src/locales/zh-CN/translations.json (1)

549-550: New Translation Keys Added: "quickstart_guide" and "not_right_now"
The additions of these two new keys in the "home" empty state are clear and appear to align with the overall localization strategy. Please verify that these Chinese translations mirror the intended tone and meaning from the corresponding entries in other locales to maintain consistency across languages.

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

549-550: New Translation Keys Added for Home Empty State
The addition of "quickstart_guide" with the value "クイックスタートガイド" and "not_right_now" with the value "今はしない" is clear and consistent with similar entries in other locale files. Please verify that these keys are used correctly in the home widget’s empty state UI and that their translations accurately convey the intended meaning.

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

379-380: New Translation Keys Added for Home Widget:
The keys "quickstart_guide" and "not_right_now" have been added under the "home.empty" section. Their messages ("Your quickstart guide" and "Not right now") are clear and concise, matching the tone and style of other UI text in the file. Please ensure that these keys are similarly updated across other locale files for consistency.

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

548-551: New Translation Keys Added for Home Empty State

The new keys "quickstart_guide" with value "Guía de inicio rápido" and "not_right_now" with value "Ahora no" have been accurately added under the "home.empty" section. Their translations are consistent with the corresponding keys in other locale files as described in the AI summary and PR objectives. Please ensure that these keys are used consistently across the different language files to keep the UI uniform.

@sriramveeraghanta sriramveeraghanta merged commit 456c7f5 into preview Feb 7, 2025
18 of 22 checks passed
@sriramveeraghanta sriramveeraghanta deleted the fix-home-widget branch February 7, 2025 14:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants