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

Remove Breadcrumbs #10322

Closed
wants to merge 12 commits into from

Conversation

AdityaJ2305
Copy link
Contributor

@AdityaJ2305 AdityaJ2305 commented Jan 31, 2025

Proposed Changes

@ohcnetwork/care-fe-code-reviewers

Merge Checklist

  • Add specs that demonstrate bug / test a new feature.
  • Update product documentation.
  • Ensure that UI text is kept in I18n files.
  • Prep screenshot or demo video for changelog entry, and attach it to issue.
  • Request for Peer Reviews
  • Completion of QA

Summary by CodeRabbit

  • Refactor

    • Removed breadcrumbs functionality across multiple components
    • Simplified page navigation and component props
    • Removed unused query parameter and data fetching logic in several components
  • Bug Fixes

    • Streamlined page rendering by removing unnecessary breadcrumb-related code
    • Cleaned up unused imports and commented-out code segments
  • Chores

    • Updated component prop handling
    • Removed deprecated navigation-related code

Copy link
Contributor

coderabbitai bot commented Jan 31, 2025

Walkthrough

The pull request focuses on removing breadcrumb functionality across multiple components in the frontend application. The changes involve deleting the Breadcrumbs.tsx component, removing breadcrumb-related props from various page and component files, and simplifying the navigation structure. The modifications span across different sections of the application, including patient, resource, user, and appointment-related components, indicating a systematic approach to eliminating breadcrumb navigation.

Changes

File Change Summary
src/components/Common/Breadcrumbs.tsx Entire file removed
src/components/Common/Page.tsx Removed breadcrumbs and crumbsReplacements props from PageTitle
src/components/Common/PageTitle.tsx Removed breadcrumb-related props, added back button functionality
src/components/Patient/FileUploadPage.tsx Removed patient data fetching and breadcrumb-related imports
src/components/Resource/ResourceBoard.tsx Removed breadcrumbs prop from PageTitle
src/components/Resource/ResourceCreate.tsx Commented out facility data fetching logic
src/components/Resource/ResourceDetails.tsx Removed crumbsReplacements and backUrl props from Page
src/components/Resource/ResourceDetailsUpdate.tsx Commented out query parameters logic
src/components/Resource/ResourceList.tsx Removed breadcrumbs prop from Page
src/components/Users/UserHome.tsx Removed breadcrumb navigation logic
src/pages/Appointments/AppointmentDetail.tsx Removed formatAppointmentSlotTime function and crumbsReplacements prop
src/pages/Appointments/AppointmentsPage.tsx Removed breadcrumbs prop from Page
src/pages/Encounters/EncounterShow.tsx Removed breadcrumb-related props from PageTitle
src/pages/Facility/settings/organizations/FacilityOrganizationIndex.tsx Removed breadcrumbs prop from Page
src/pages/Facility/settings/organizations/components/FacilityOrganizationLayout.tsx Removed breadcrumbs={false} prop from Page
src/pages/Organization/components/OrganizationLayout.tsx Removed breadcrumbs={false} prop from Page
src/hooks/useAppHistory.ts Added comment for further examination in goBack function

Assessment against linked issues

Objective Addressed Explanation
Remove Breadcrumbs from FE [#10305]

Possibly related PRs

Suggested reviewers

  • rithviknishad
  • Jacobjeevan

Poem

🐰 Hop, hop, away with crumbs so neat,
Navigation simplified, a coding feat!
Breadcrumbs trail now vanished from sight,
Our UI journey becomes sleek and light.
Code refactored with rabbit-like grace,
Simplicity now takes breadcrumbs' place! 🚀


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.

Copy link

netlify bot commented Jan 31, 2025

Deploy Preview for care-ohc ready!

Name Link
🔨 Latest commit 06e53fc
🔍 Latest deploy log https://app.netlify.com/sites/care-ohc/deploys/679c3f21eb98f70008057484
😎 Deploy Preview https://deploy-preview-10322--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

netlify bot commented Jan 31, 2025

Deploy Preview for care-ohc ready!

Name Link
🔨 Latest commit b35f03c
🔍 Latest deploy log https://app.netlify.com/sites/care-ohc/deploys/679ccffbde2dc70008319912
😎 Deploy Preview https://deploy-preview-10322--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.

@AdityaJ2305
Copy link
Contributor Author

@rithviknishad, it’s not done yet, but I just want to confirm if this is the right approach ?

@github-actions github-actions bot added needs-triage question Further information is requested labels Jan 31, 2025
@rithviknishad
Copy link
Member

yeah

@rithviknishad
Copy link
Member

delete the shadcn's breadcrumbs too if they are not used

@AdityaJ2305
Copy link
Contributor Author

delete the shadcn's breadcrumbs too if they are not used

the organization layout is using that

@AdityaJ2305
Copy link
Contributor Author

@rithviknishad @Jacobjeevan

I think we should keep the Back button. What do you think ? 🤔

Screenshot 2025-01-31 at 10 48 13 AM

We can embed it in Page Component directly

@rithviknishad
Copy link
Member

yup

@nihal467
Copy link
Member

@AdityaJ2305 what is the update on this PR :)

@AdityaJ2305
Copy link
Contributor Author

@AdityaJ2305 what is the update on this PR :)

Just going to push the final commit

@AdityaJ2305 AdityaJ2305 marked this pull request as ready for review January 31, 2025 13:07
@AdityaJ2305 AdityaJ2305 requested a review from a team as a code owner January 31, 2025 13:07
@AdityaJ2305
Copy link
Contributor Author

Hey Team, I have commented some code snippets just let me know if it is fine or remove them ?

@nihal467 nihal467 removed question Further information is requested needs-triage labels Jan 31, 2025
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: 2

🧹 Nitpick comments (1)
src/components/Common/PageTitle.tsx (1)

54-69: LGTM! Well-implemented back button.

The back button implementation is clean and includes:

  1. Proper conditional rendering
  2. Correct handling of custom back click behavior
  3. Appropriate styling and accessibility attributes

Consider adding an aria-label to improve accessibility:

 <Button
   variant="link"
   type="button"
   className="rounded bg-gray-200/50 px-1 text-sm font-normal text-gray-800 transition hover:bg-gray-200/75 hover:no-underline"
   size="xs"
+  aria-label="Go back to previous page"
   onClick={() => {
     if (onBackClick && onBackClick() === false) return;
     goBack(backUrl);
   }}
 >
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 7b61652 and 74d83b7.

📒 Files selected for processing (16)
  • src/components/Common/Breadcrumbs.tsx (0 hunks)
  • src/components/Common/Page.tsx (0 hunks)
  • src/components/Common/PageTitle.tsx (3 hunks)
  • src/components/Patient/FileUploadPage.tsx (0 hunks)
  • src/components/Resource/ResourceBoard.tsx (0 hunks)
  • src/components/Resource/ResourceCreate.tsx (3 hunks)
  • src/components/Resource/ResourceDetails.tsx (1 hunks)
  • src/components/Resource/ResourceDetailsUpdate.tsx (4 hunks)
  • src/components/Resource/ResourceList.tsx (0 hunks)
  • src/components/Users/UserHome.tsx (0 hunks)
  • src/pages/Appointments/AppointmentDetail.tsx (2 hunks)
  • src/pages/Appointments/AppointmentsPage.tsx (0 hunks)
  • src/pages/Encounters/EncounterShow.tsx (1 hunks)
  • src/pages/Facility/settings/organizations/FacilityOrganizationIndex.tsx (2 hunks)
  • src/pages/Facility/settings/organizations/components/FacilityOrganizationLayout.tsx (1 hunks)
  • src/pages/Organization/components/OrganizationLayout.tsx (1 hunks)
💤 Files with no reviewable changes (7)
  • src/pages/Appointments/AppointmentsPage.tsx
  • src/components/Common/Page.tsx
  • src/components/Users/UserHome.tsx
  • src/components/Resource/ResourceBoard.tsx
  • src/components/Resource/ResourceList.tsx
  • src/components/Patient/FileUploadPage.tsx
  • src/components/Common/Breadcrumbs.tsx
✅ Files skipped from review due to trivial changes (3)
  • src/pages/Organization/components/OrganizationLayout.tsx
  • src/pages/Facility/settings/organizations/FacilityOrganizationIndex.tsx
  • src/components/Resource/ResourceCreate.tsx
🔇 Additional comments (7)
src/pages/Facility/settings/organizations/components/FacilityOrganizationLayout.tsx (1)

92-92: Consider removing the custom breadcrumb implementation.

The PR's objective is to remove breadcrumb functionality, but this file still contains a custom breadcrumb implementation. However, since these breadcrumbs are used to display the organization hierarchy and provide essential navigation context, we should discuss whether to keep this implementation as an exception.

Let me check if this breadcrumb implementation is used elsewhere in the codebase:

Also applies to: 93-117

✅ Verification successful

Keep the organization hierarchy breadcrumb as an exception

This breadcrumb implementation is specifically designed for navigating the organization hierarchy, showing parent-child relationships and providing essential navigation context. It's consistently used across organization-related layouts and should be retained as an exception to the general breadcrumb removal.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for similar breadcrumb implementations
ast-grep --pattern 'import { Breadcrumb, BreadcrumbItem, BreadcrumbLink, BreadcrumbList, BreadcrumbSeparator } from "@/components/ui/breadcrumb"'

Length of output: 1444


Script:

#!/bin/bash
# Check the breadcrumb implementation in both files
echo "=== FacilityOrganizationLayout.tsx ==="
ast-grep --pattern 'const $_ = () => {
  $$$
  return (
    $$$
    <Breadcrumb$$$>
      $$$
    </Breadcrumb>
    $$$
  )
}'

echo -e "\n=== OrganizationLayout.tsx ==="
ast-grep --pattern '<Breadcrumb$$$>
  $$$
</Breadcrumb>'

Length of output: 351


Script:

#!/bin/bash
echo "=== FacilityOrganizationLayout.tsx ==="
rg -A 10 "<Breadcrumb" src/pages/Facility/settings/organizations/components/FacilityOrganizationLayout.tsx

echo -e "\n=== OrganizationLayout.tsx ==="
rg -A 10 "<Breadcrumb" src/pages/Organization/components/OrganizationLayout.tsx

Length of output: 2403

src/pages/Encounters/EncounterShow.tsx (1)

100-100: LGTM!

The changes align with the PR objectives by removing breadcrumb functionality while maintaining proper navigation using the backUrl.

src/components/Resource/ResourceDetails.tsx (1)

120-120: LGTM!

The changes align with the PR objectives by removing breadcrumb functionality while maintaining proper page structure.

src/pages/Appointments/AppointmentDetail.tsx (1)

60-60: LGTM! Changes align with PR objective.

The removal of breadcrumb-related functionality is consistent with the PR's goal. The changes include:

  1. Removing the formatAppointmentSlotTime import
  2. Commenting out the appointmentDate variable
  3. Simplifying the Page component's props

Also applies to: 138-138, 141-141

src/components/Common/PageTitle.tsx (3)

3-9: LGTM! Import changes are well-organized.

The new imports are properly organized and provide the necessary components and utilities for the back button functionality.

Also applies to: 12-12


40-40: LGTM! Proper use of navigation hook.

The useAppHistory hook is correctly used to handle back navigation.


51-51: LGTM! Improved class name management.

The switch to the cn utility function for managing class names is a good improvement, making the code more maintainable.

Also applies to: 75-79

@@ -62,7 +62,7 @@ const initialState = {

export const ResourceDetailsUpdate = (props: resourceProps) => {
const { goBack } = useAppHistory();
const [qParams, _] = useQueryParams();
// const [qParams, _] = useQueryParams();
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Remove commented-out code.

Instead of keeping the commented-out code, we should remove it since it's no longer needed.

-  // const [qParams, _] = useQueryParams();

Comment on lines +134 to +147
// const { data: resourceDetails } = useTanStackQueryInstead(
// routes.getResourceDetails,
// {
// pathParams: { id: props.id },
// onResponse: ({ res, data }) => {
// if (res && data) {
// const d = data;
// d["status"] = qParams.status || data.status;
// dispatch({ type: "set_form", form: d });
// }
// setIsLoading(false);
// },
// },
// );
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Remove commented-out resource details fetching logic.

The commented-out resource details fetching logic should be removed. If this functionality is needed, it should be reimplemented without relying on query parameters.

-  // const { data: resourceDetails } = useTanStackQueryInstead(
-  //   routes.getResourceDetails,
-  //   {
-  //     pathParams: { id: props.id },
-  //     onResponse: ({ res, data }) => {
-  //       if (res && data) {
-  //         const d = data;
-  //         d["status"] = qParams.status || data.status;
-  //         dispatch({ type: "set_form", form: d });
-  //       }
-  //       setIsLoading(false);
-  //     },
-  //   },
-  // );
+  const { data: resourceDetails } = useTanStackQueryInstead(
+    routes.getResourceDetails,
+    {
+      pathParams: { id: props.id },
+      onResponse: ({ res, data }) => {
+        if (res && data) {
+          dispatch({ type: "set_form", form: data });
+        }
+        setIsLoading(false);
+      },
+    },
+  );
📝 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 { data: resourceDetails } = useTanStackQueryInstead(
// routes.getResourceDetails,
// {
// pathParams: { id: props.id },
// onResponse: ({ res, data }) => {
// if (res && data) {
// const d = data;
// d["status"] = qParams.status || data.status;
// dispatch({ type: "set_form", form: d });
// }
// setIsLoading(false);
// },
// },
// );
const { data: resourceDetails } = useTanStackQueryInstead(
routes.getResourceDetails,
{
pathParams: { id: props.id },
onResponse: ({ res, data }) => {
if (res && data) {
dispatch({ type: "set_form", form: data });
}
setIsLoading(false);
},
},
);

@nihal467
Copy link
Member

nihal467 commented Jan 31, 2025

In general test, it looks good and cypress passed

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 (3)
src/components/Common/PageTitle.tsx (3)

7-7: Consider removing unused breadcrumb imports.

Since the PR's objective is to remove breadcrumbs functionality, importing BreadcrumbItem seems inconsistent. If it's only being used as a wrapper for styling purposes, consider using a more semantic element or creating a dedicated navigation component.


63-63: Remove commented console.log statement.

Remove the commented debug statement to maintain clean code.

-                // console.log(backUrl);

56-69: Consider enhancing button accessibility.

While the back button implementation is good, consider adding aria-label for better screen reader support.

 <Button
   variant="link"
   type="button"
   className="rounded bg-gray-200/50 px-1 text-sm font-normal text-gray-800 transition hover:bg-gray-200/75 hover:no-underline"
   size="xs"
+  aria-label="Go back to previous page"
   onClick={() => {
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 74d83b7 and b35f03c.

📒 Files selected for processing (6)
  • src/components/Common/PageTitle.tsx (3 hunks)
  • src/components/Resource/ResourceCreate.tsx (3 hunks)
  • src/components/Resource/ResourceDetails.tsx (1 hunks)
  • src/hooks/useAppHistory.ts (1 hunks)
  • src/pages/Encounters/EncounterShow.tsx (1 hunks)
  • src/pages/Facility/settings/organizations/FacilityOrganizationIndex.tsx (2 hunks)
✅ Files skipped from review due to trivial changes (1)
  • src/hooks/useAppHistory.ts
🚧 Files skipped from review as they are similar to previous changes (4)
  • src/pages/Facility/settings/organizations/FacilityOrganizationIndex.tsx
  • src/components/Resource/ResourceDetails.tsx
  • src/pages/Encounters/EncounterShow.tsx
  • src/components/Resource/ResourceCreate.tsx
🔇 Additional comments (3)
src/components/Common/PageTitle.tsx (3)

Line range hint 76-80: LGTM! Well-structured responsive styling.

The className conditions are well organized and follow mobile-first responsive design patterns. The use of the cn utility for class merging is a good practice.


Line range hint 14-24: LGTM! Well-defined props interface.

The props interface is well-structured with proper TypeScript types and follows React naming conventions. The removal of breadcrumb-related props and addition of back navigation props aligns well with the PR objectives.


Line range hint 27-89: LGTM! Clean and maintainable implementation.

The component is well-structured with:

  • Clean separation of concerns
  • Proper use of React hooks
  • Maintainable implementation
  • Good error handling

The changes successfully transition from breadcrumbs to a simpler back navigation pattern as intended by the PR.

@rithviknishad
Copy link
Member

Change of decision, we need breadcrumbs.... :/

@AdityaJ2305
Copy link
Contributor Author

@rithviknishad , I can make the changes in this PR according to final required behaviour

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.

Remove Breadcrumbs
3 participants