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

Flow routes with sidebar context #1337

Closed
wants to merge 4 commits into from
Closed

Flow routes with sidebar context #1337

wants to merge 4 commits into from

Conversation

paulfalgout
Copy link
Member

@paulfalgout paulfalgout commented Oct 14, 2024

Shortcut Story ID: [sc-###]

Alternate to #1334

Summary by CodeRabbit

  • New Features

    • Introduced a new route for detailed views of flows, enhancing user navigation.
    • Added functionality to manage sidebar behavior during routing events.
  • Bug Fixes

    • Improved event handling to prevent unnecessary navigation when the sidebar is closed.
  • Documentation

    • Updated method signatures to reflect new parameters for better clarity on usage.

@paulfalgout paulfalgout requested a review from nmajor25 October 14, 2024 14:30
Copy link

coderabbitai bot commented Oct 14, 2024

Walkthrough

The changes enhance the routing and event handling within the application, specifically by adding new routes and modifying existing methods to better manage sidebar interactions during routing events. The flow_app.js file introduces a new editFlow method and updates existing methods to accommodate routing logic. The patients-main_app.js file adds a route for flow:details, while routerapp.js and sidebar.js files modify methods to include an isRouting parameter for improved sidebar management.

Changes

File Path Change Summary
src/js/apps/patients/patient/... Added editFlow() method, updated stop() and onEditFlow() methods, and included a new route for 'flow:details'.
src/js/apps/patients/patients-... Introduced a new event route for flow:details mapped to showFlow action and route pattern.
src/js/base/routerapp.js Modified routeAction method to include { isRouting: true } in the sidebar close request.
src/js/services/sidebar.js Updated closeSidebar and stopSidebarApp methods to accept an optional isRouting parameter.
test/integration/patients/patient/... Expanded test cases for patient flow, added new import for testTsAdd, and updated assertions for sidebar actions.

Possibly related PRs

Suggested reviewers

  • DrechslerDerek
  • nmajor25

🐇 In the flow where we roam,
New routes lead us safely home.
With sidebar whispers, routing clear,
Our paths are bright, no need to fear.
A hop, a skip, in code we play,
Enhancing journeys, day by day! 🌼


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

cypress bot commented Oct 14, 2024

RoundingWell Care Ops Frontend    Run #6879

Run Properties:  status check failed Failed #6879  •  git commit c66d0fafe6: Add flow sidebar tests
Project RoundingWell Care Ops Frontend
Run status status check failed Failed #6879
Run duration 02m 57s
Commit git commit c66d0fafe6: Add flow sidebar tests
Committer Paul Falgout
View all properties for this run ↗︎

Test results
Tests that failed  Failures 1
Tests that were flaky  Flaky 0
Tests that did not run due to a developer annotating a test with .skip  Pending 0
Tests that did not run due to a failure in a mocha hook  Skipped 0
Tests that passed  Passing 312

Tests for review

Failed  test/integration/patients/worklist/worklist.js • 1 failed test • care-ops-e2e

View Output

Test Artifacts
worklist page > action list Test Replay Screenshots

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 and nitpick comments (3)
src/js/services/sidebar.js (2)

54-57: LGTM! Consider adding JSDoc for clarity.

The changes to the closeSidebar method look good. The new isRouting parameter allows for more flexible handling of routing-related scenarios.

Consider adding JSDoc to clarify the purpose of the isRouting parameter:

/**
 * Closes the sidebar.
 * @param {Object} options - The options object.
 * @param {boolean} [options.isRouting=false] - Indicates if the sidebar is being closed due to routing.
 */
closeSidebar({ isRouting } = {}) {
  // ... existing implementation ...
}

64-67: LGTM! Consider adding JSDoc and a safety check.

The changes to the stopSidebarApp method look good. The new isRouting parameter allows for more flexible handling of routing-related scenarios.

Consider adding JSDoc to clarify the purpose of the isRouting parameter:

/**
 * Stops the current sidebar app.
 * @param {Object} options - The options object.
 * @param {boolean} [options.isRouting=false] - Indicates if the app is being stopped due to routing.
 */
stopSidebarApp({ isRouting } = {}) {
  // ... existing implementation ...
}

Additionally, consider adding a safety check to ensure currentApp.stop can handle an object parameter:

stopSidebarApp({ isRouting } = {}) {
  if (!this.currentApp) return;

  if (typeof this.currentApp.stop === 'function') {
    this.currentApp.stop({ isRouting });
  } else {
    this.currentApp.stop();
  }

  delete this.currentApp;
}

This change ensures backwards compatibility if currentApp.stop doesn't expect an object parameter in some cases.

src/js/apps/patients/patients-main_app.js (1)

46-49: LGTM! Consider adding a comment for clarity.

The new 'flow:details' route is well-integrated and consistent with the existing routing structure. It logically extends the flow functionality to include a details view.

Consider adding a brief comment above this new route to explain its purpose, e.g.:

// Route for displaying detailed view of a specific flow
'flow:details': {
  action: 'showFlow',
  route: 'flow/:id/details',
},

This would enhance code readability and maintainability.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 2301a0d and c8c457d.

📒 Files selected for processing (4)
  • src/js/apps/patients/patient/flow/flow_app.js (3 hunks)
  • src/js/apps/patients/patients-main_app.js (1 hunks)
  • src/js/base/routerapp.js (1 hunks)
  • src/js/services/sidebar.js (1 hunks)
🧰 Additional context used
🔇 Additional comments (8)
src/js/apps/patients/patients-main_app.js (1)

46-49: Verify handling of 'flow:details' in FlowApp

The new 'flow:details' route uses the existing showFlow action. To ensure complete functionality:

  1. Verify that the FlowApp (imported at the top of this file) is prepared to handle this new detailed view.
  2. Confirm that the showFlow method in this file or its parent class can differentiate between the main flow view and the details view based on the route.

To assist in this verification, you can run the following script:

This script will help identify if and how the new route is handled in the FlowApp and the showFlow method implementation.

src/js/base/routerapp.js (1)

84-84: LGTM! Consider verifying sidebar handling and updating docs.

The addition of { isRouting: true } to the sidebar close request is a good improvement. It provides context to the sidebar component about the reason for closing, which aligns with the PR objectives of "Flow routes with sidebar context".

To ensure this change is properly handled, please verify:

  1. The sidebar component correctly interprets the isRouting parameter.
  2. Any relevant documentation is updated to reflect this new behavior.

Run the following script to check for corresponding changes in the sidebar component:

If no results are found, consider updating the sidebar component to handle this new parameter.

✅ Verification successful

Let's locate the actual path of the sidebar component to verify the handling of the isRouting parameter.

[/run_scripts]


Let's verify if the isRouting parameter is handled in any of the sidebar components.

[/run_scripts]


Verified Sidebar Handling of isRouting Parameter

The isRouting parameter is successfully handled in src/js/services/sidebar.js, ensuring that sidebar closing operations are context-aware during routing actions.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for handling of isRouting parameter in sidebar component

# Test: Search for isRouting parameter usage in sidebar-related files
rg --type js 'isRouting' src/js/views/globals/sidebar

Length of output: 122


Script:

#!/bin/bash
# Description: Locate all sidebar-related JavaScript files in the codebase

fd sidebar src/js --type f --extension js

Length of output: 1473


Script:

#!/bin/bash
# Description: Search for usage of 'isRouting' parameter in all identified sidebar-related JavaScript files

rg --type js 'isRouting' src/js/apps/clinicians/sidebar/clinician-sidebar_app.js \
src/js/apps/patients/patient/sidebar/sidebar_app.js \
src/js/apps/patients/sidebar/action-sidebar_app.js \
src/js/apps/patients/sidebar/filters-sidebar_app.js \
src/js/apps/patients/sidebar/flow-sidebar_app.js \
src/js/apps/patients/sidebar/patient-sidebar_app.js \
src/js/apps/programs/sidebar/action-sidebar_app.js \
src/js/apps/programs/sidebar/flow-sidebar_app.js \
src/js/apps/programs/sidebar/program-sidebar_app.js \
src/js/services/sidebar.js \
src/js/views/clinicians/sidebar/clinician-sidebar_views.js \
src/js/views/patients/patient/sidebar/sidebar_views.js \
src/js/views/patients/sidebar/action/action-sidebar-action_views.js \
src/js/views/patients/sidebar/action/action-sidebar-activity-views.js \
src/js/views/patients/sidebar/action/action-sidebar-attachments-views.js \
src/js/views/patients/sidebar/action/action-sidebar-forms_views.js \
src/js/views/patients/sidebar/action/action-sidebar_views.js \
src/js/views/patients/sidebar/filters/filters-sidebar_views.js \
src/js/views/patients/sidebar/flow/flow-sidebar-activity-views.js \
src/js/views/patients/sidebar/flow/flow-sidebar_views.js \
src/js/views/patients/sidebar/patient/patient-sidebar_views.js \
src/js/views/programs/program/sidebar/sidebar-views.js \
src/js/views/programs/sidebar/action/action-sidebar_views.js \
src/js/views/programs/sidebar/flow/flow-sidebar_views.js \
src/js/views/programs/sidebar/program/programs-sidebar_views.js

Length of output: 1719

src/js/apps/patients/patient/flow/flow_app.js (6)

1-1: Importing noop from 'underscore' is appropriate

The addition of noop is necessary as it is used in the eventRoutes.


28-30: Enhancement of routing with new event routes

Adding 'flow': noop and 'flow:details': 'editFlow' to eventRoutes effectively handles new routing scenarios.


291-296: Proper handling of isRouting in stop event

The inclusion of the isRouting parameter in the 'stop' event handler allows conditional navigation, preventing unnecessary route triggers when routing is in progress.


300-300: Correct invocation of startCurrent with actionId

Ensures that the action app starts with the correct action ID, maintaining expected functionality.


304-305: Updated onEditFlow to trigger flow:details event

Changing onEditFlow to trigger 'flow:details' enhances the routing flow when editing a flow.


307-314: Implementation of editFlow method is accurate

The new editFlow method correctly starts the sidebar for editing the flow and handles the 'stop' event with proper consideration of the isRouting parameter.

@@ -1,6 +1,6 @@
import _ from 'underscore';

import { testTs, testTsSubtract } from 'helpers/test-timestamp';
import { testTs, testTsSubtract, testTsAdd } from 'helpers/test-timestamp';

Check notice

Code scanning / CodeQL

Unused variable, import, function or class Note test

Unused import testTsAdd.
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 UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between c8c457d and c66d0fa.

📒 Files selected for processing (3)
  • src/js/apps/patients/patient/flow/flow_app.js (3 hunks)
  • src/js/apps/patients/patients-main_app.js (1 hunks)
  • test/integration/patients/patient/patient-flow.js (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/js/apps/patients/patient/flow/flow_app.js
  • src/js/apps/patients/patients-main_app.js
🧰 Additional context used
🪛 GitHub Check: CodeQL
test/integration/patients/patient/patient-flow.js

[notice] 3-3: Unused variable, import, function or class
Unused import testTsAdd.

@@ -1,6 +1,6 @@
import _ from 'underscore';

import { testTs, testTsSubtract } from 'helpers/test-timestamp';
import { testTs, testTsSubtract, testTsAdd } from 'helpers/test-timestamp';
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Remove unused import testTsAdd

The import testTsAdd is unused in this file. Removing it will clean up the code.

Apply this diff to remove the unused import:

-import { testTs, testTsSubtract, testTsAdd } from 'helpers/test-timestamp';
+import { testTs, testTsSubtract } from 'helpers/test-timestamp';
📝 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
import { testTs, testTsSubtract, testTsAdd } from 'helpers/test-timestamp';
import { testTs, testTsSubtract } from 'helpers/test-timestamp';
🧰 Tools
🪛 GitHub Check: CodeQL

[notice] 3-3: Unused variable, import, function or class
Unused import testTsAdd.

Comment on lines +164 to +165
.find('[data-action-region] .action-sidebar__name')
.should('contain', 'First Action');
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Correct the sidebar assertion to match the updated action

After updating fx.data to testFlowActions[1] (which is "Second Action"), the assertion should check for "Second Action" instead of "First Action".

Apply this diff to fix the assertion:

           .find('[data-action-region] .action-sidebar__name')
-          .should('contain', 'First Action');
+          .should('contain', 'Second Action');
📝 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
.find('[data-action-region] .action-sidebar__name')
.should('contain', 'First Action');
.find('[data-action-region] .action-sidebar__name')
.should('contain', 'Second Action');

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.

1 participant