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

Fix: [Software update notification overlapping] #9128

Conversation

ANIR1604
Copy link
Contributor

@ANIR1604 ANIR1604 commented Nov 15, 2024

Changes :

  • Conditional Display of "Update Available" Button
  • Conditional Display of "Check for Update" Button:
  • Separate "Checking for Update" Button:

This code improves user experience by clearly differentiating button states. It ensures users see the "Update Available" button only when applicable, while "Check for Update" and "Checking for Update" buttons guide actions intuitively. This separation prevents overlap, avoids confusion, and provides visual feedback during update checks, making the interface more responsive and user-friendly.

Screenshot from 2024-11-15 13-22-38

Summary by CodeRabbit

  • New Features

    • Introduced a new Info notification type for informational messages.
    • Enhanced the UserProfile component to notify users when a new update is available.
  • Bug Fixes

    • Improved button functionality for checking updates to prevent multiple simultaneous checks and provide better visual feedback.
  • User Interface Improvements

    • Added an animated spinner icon during update checks for enhanced user experience.

@ANIR1604 ANIR1604 requested a review from a team as a code owner November 15, 2024 10:04
Copy link
Contributor

coderabbitai bot commented Nov 15, 2024

Walkthrough

The pull request introduces a new function Info in the Notifications.js module to handle informational notifications. Additionally, it modifies the UserProfile component to improve update notification handling, ensuring that users receive clear messages about software updates and that buttons are displayed appropriately based on the update status. These changes enhance the notification system's capabilities and improve user experience in the update process.

Changes

File Change Summary
src/Utils/Notifications.js Added a new function Info to handle informational notifications.
src/components/Users/UserProfile.tsx Enhanced update notification functionality, refined button rendering logic, and improved user feedback during update checks.

Assessment against linked issues

Objective Addressed Explanation
Show update available notification first (9039)
Show updated notification after clicking the update button (9039) The PR does not implement the required order of notifications.

Possibly related PRs

Suggested labels

needs review, tested

Suggested reviewers

  • shivankacker
  • khavinshankar

Poem

🐇 In the meadow where updates bloom,
A new message clears the gloom.
Click to update, don’t delay,
Notifications guide the way!
With buttons bright and spinners spin,
A seamless journey to begin! 🌼

Warning

There were issues while running some tools. Please review the errors and either fix the tool’s configuration or disable the tool if it’s a critical failure.

🔧 eslint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

src/Utils/Notifications.js

Oops! Something went wrong! :(

ESLint: 8.57.1

Error: Failed to load parser '@typescript-eslint/parser' declared in '.eslintrc.json': Cannot find module '@typescript-eslint/parser'
Require stack:

  • /.eslintrc.json
    at Module._resolveFilename (node:internal/modules/cjs/loader:1248:15)
    at Function.resolve (node:internal/modules/helpers:145:19)
    at Object.resolve (/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:2346:46)
    at ConfigArrayFactory._loadParser (/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3325:39)
    at ConfigArrayFactory._normalizeObjectConfigDataBody (/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3099:43)
    at _normalizeObjectConfigDataBody.next ()
    at ConfigArrayFactory._normalizeObjectConfigData (/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3040:20)
    at _normalizeObjectConfigData.next ()
    at ConfigArrayFactory.loadInDirectory (/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:2886:28)
    at CascadingConfigArrayFactory._loadConfigInAncestors (/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3871:46)

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

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

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

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

CodeRabbit Commands (Invoked using PR comments)

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

Other keywords and placeholders

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

CodeRabbit Configuration File (.coderabbit.yaml)

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

Documentation and Community

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

Copy link

netlify bot commented Nov 15, 2024

Deploy Preview for care-ohc ready!

Name Link
🔨 Latest commit 62e20db
🔍 Latest deploy log https://app.netlify.com/sites/care-ohc/deploys/67371cbe81e943000889ab79
😎 Deploy Preview https://deploy-preview-9128--care-ohc.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.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Outside diff range and nitpick comments (3)
src/Utils/Notifications.js (2)

72-75: Maintain consistent JSDoc comment style.

The implementation looks good, but let's maintain consistency with other handlers' documentation style.

Apply this diff to match the documentation style:

-/*Info message Handler*/
+/** Info message handler */
export const Info = ({ msg }) => {
  notify(msg, "info");
};

72-75: LGTM! The notification stack configuration aligns with PR objectives.

The new Info notification handler is well-integrated with the existing notification system. The stack configuration (maxOpen: 3, maxStrategy: "close") helps prevent notification overlap, which directly addresses the issue of overlapping update notifications mentioned in #9039.

Consider these notification stack behaviors that support your objectives:

  • maxOpen: 3 prevents too many notifications from appearing simultaneously
  • maxStrategy: "close" ensures older notifications are closed when new ones appear
  • delay: 3000 auto-closes notifications after 3 seconds
    These configurations will help maintain a clean notification experience during the update process.
src/components/Users/UserProfile.tsx (1)

1011-1040: LGTM: Well-structured update button states

The implementation effectively prevents overlapping notifications by using conditional rendering for different update states. The loading indicator provides good visual feedback.

However, there's an opportunity to reduce code duplication in the button structure.

Consider refactoring the repeated button structure into a reusable component:

+interface UpdateButtonProps {
+  icon: string;
+  text: string;
+  onClick?: () => void;
+  disabled?: boolean;
+  animate?: boolean;
+}
+
+const UpdateButton: React.FC<UpdateButtonProps> = ({
+  icon,
+  text,
+  onClick,
+  disabled = false,
+  animate = false,
+}) => (
+  <ButtonV2 onClick={onClick} disabled={disabled}>
+    <div className="flex items-center gap-4">
+      <CareIcon
+        icon={icon}
+        className={`text-2xl ${animate ? 'animate-spin' : ''}`}
+      />
+      {text}
+    </div>
+  </ButtonV2>
+);

 {updateStatus.isUpdateAvailable && !updateStatus.isChecking && (
   <UpdatableApp silentlyAutoUpdate={false}>
-    <ButtonV2 onClick={checkUpdates} disabled={false}>
-      <div className="flex items-center gap-4">
-        <CareIcon icon="l-exclamation" className="text-2xl" />
-        {t("update_available")}
-      </div>
-    </ButtonV2>
+    <UpdateButton
+      icon="l-exclamation"
+      text={t("update_available")}
+      onClick={checkUpdates}
+    />
   </UpdatableApp>
 )}

 {!updateStatus.isUpdateAvailable && !updateStatus.isChecking && (
-  <ButtonV2 onClick={checkUpdates}>
-    <div className="flex items-center gap-4">
-      <CareIcon icon="l-sync" className="text-2xl" />
-      {t("check_for_update")}
-    </div>
-  </ButtonV2>
+  <UpdateButton
+    icon="l-sync"
+    text={t("check_for_update")}
+    onClick={checkUpdates}
+  />
 )}

 {updateStatus.isChecking && (
-  <ButtonV2 disabled={true}>
-    <div className="flex items-center gap-4">
-      <CareIcon icon="l-sync" className="text-2xl animate-spin" />
-      {t("checking_for_update")}
-    </div>
-  </ButtonV2>
+  <UpdateButton
+    icon="l-sync"
+    text={t("checking_for_update")}
+    disabled={true}
+    animate={true}
+  />
 )}
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between da5d576 and 62e20db.

📒 Files selected for processing (2)
  • src/Utils/Notifications.js (1 hunks)
  • src/components/Users/UserProfile.tsx (2 hunks)
🔇 Additional comments (1)
src/components/Users/UserProfile.tsx (1)

455-457: LGTM: Clear and actionable notification message

The implementation provides clear guidance to users about the available update and next steps.

@ANIR1604 ANIR1604 closed this Nov 16, 2024
@ANIR1604 ANIR1604 deleted the fix/software-notification-overlapping branch November 16, 2024 12:37
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.

Software Update notification badges are overlapping
2 participants