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: channel updates and fixes. #678

Merged
merged 12 commits into from
Sep 16, 2024

Conversation

marvinIsSacul
Copy link
Collaborator

@marvinIsSacul marvinIsSacul commented Sep 13, 2024

Summary by CodeRabbit

Release Notes

  • New Features

    • Added interactive action button in the AlertDialog for easier dismissal of alerts.
    • Enhanced error handling in the Charts component with a retry option.
    • Introduced conditional rendering for input adornments based on channel settings in RequestMatching.
  • Improvements

    • Improved validation logic in AddChannelScreen and EditChannelScreen for primary routes.
    • Streamlined navigation methods in AddChannelScreen to enhance user experience.
    • Enhanced user interface by adding tooltips for primary routes in ChannelRoutes.
  • Bug Fixes

    • Adjusted error messages for better clarity during channel creation failures.
  • Chores

    • Removed several configuration files related to linting, testing, and building in the sidebar-app, which may affect project setup.

@marvinIsSacul marvinIsSacul added enhancement microfrontend-poc OpenHIM Console Microfrontend Proof of Concept labels Sep 13, 2024
@marvinIsSacul marvinIsSacul self-assigned this Sep 13, 2024
Copy link

coderabbitai bot commented Sep 13, 2024

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

The pull request introduces several enhancements across multiple components in the application. Key changes include the addition of interactive buttons in alert dialogs, improved error handling and validation in channel screens, and modifications to the routing configuration. Additionally, several files related to the sidebar application, including configurations and components, have been removed, indicating a significant restructuring of that part of the application.

Changes

File Path Change Summary
packages/channels-app/src/components/dialogs/... Added an action prop to the Alert component in AlertDialog, allowing for an interactive button.
packages/channels-app/src/screens/add.channel... Removed useNavigate, updated navigation to window.location.href, enhanced error handling, and adjusted layout.
packages/channels-app/src/screens/edit.channel... Introduced validation to ensure exactly one primary route exists before editing a channel.
packages/channels-app/src/screens/manage.chann... Modified onActionDisableChannel function to remove the channel parameter, relying on component state.
packages/channels-app/src/screens/steps/Request... Added conditional rendering for input adornments based on channel.addAutoRewriteRules.
packages/channels-app/src/screens/steps/routes/... Introduced a Tooltip and Chip for primary routes in the routes table.
packages/dashboard-app/src/components/charts.c... Added error handling in the Charts component, replacing alert dialogs with an ErrorMessage component.
packages/dashboard-app/src/components/ux/error... Introduced a new ErrorMessage component for displaying error messages with retry functionality.
packages/rbac-app/src/components/dialogs/alert... Similar to the channels app, added an action prop to the Alert component in AlertDialog.
packages/root-config/src/microfrontend-layout... Modified routing configuration by removing the exact attribute from the #!/channels route.
packages/sidebar-app/... Removed multiple configuration and component files, indicating a restructuring of the sidebar application.

Possibly related PRs

  • Updating validation for form #670: Enhances validation mechanisms for a form, which may relate to the user experience improvements mentioned in the main PR regarding the AlertDialog component's new button action.
  • Fix footer to be in fixed position and styling issues in apps #677: Modifies the AddChannelScreen, EditChannelScreen, and ManageChannelsScreen components, which are part of the same application structure as the AlertDialog component, indicating potential shared styling or user interaction patterns.

Poem

🐰 In the meadow where changes bloom,
Buttons now dance, dispelling gloom.
Alerts with actions, channels refined,
A clearer path for all to find.
With every hop, new features grow,
In our code garden, watch it flow! 🌼


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 generate interesting stats about this repository and render them as a table.
    -- @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
Collaborator

@drizzentic drizzentic left a comment

Choose a reason for hiding this comment

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

LGTM! left a few comments

showAlert(
'Error creating a new channel. ' + error?.response?.data,
'Channel must have exactly only 1 primary route.',
Copy link
Collaborator

Choose a reason for hiding this comment

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

Shouldn't we handle this on the add route modal?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It's only at this component whereby we have all the information that we need about all of the channels and their respective routes.

At the deeper nested components, we only have access to the 1 individual route that we're modifying and/or adding.

@drizzentic drizzentic marked this pull request as ready for review September 13, 2024 09:43
@drizzentic
Copy link
Collaborator

@coderabbitai review

Copy link

coderabbitai bot commented Sep 13, 2024

Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

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: 5

Outside diff range and nitpick comments (1)
packages/dashboard-app/src/components/ux/error.component.tsx (1)

13-20: Consider using a responsive height for the component.

The component uses a fixed height of 300px, which may not be responsive on different screen sizes. Consider using a more flexible height value or a minimum height to ensure the component adapts to various screen sizes.

Apply this diff to use a minimum height:

<Box
  display="flex"
  flexDirection="column"
  justifyContent="center"
  alignItems="center"
- height="300px"
+ minHeight="300px"
  padding={2}
>
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 6cb6bf2 and 4358ba3.

Files ignored due to path filters (1)
  • packages/sidebar-app/package-lock.json is excluded by !**/package-lock.json
Files selected for processing (23)
  • packages/channels-app/src/components/dialogs/alert.dialog.component.tsx (2 hunks)
  • packages/channels-app/src/screens/add.channel.screen.tsx (3 hunks)
  • packages/channels-app/src/screens/edit.channel.screen.tsx (2 hunks)
  • packages/channels-app/src/screens/manage.channels.screen.tsx (2 hunks)
  • packages/channels-app/src/screens/steps/RequestMatching.tsx (1 hunks)
  • packages/channels-app/src/screens/steps/routes/ChannelRoutes.tsx (2 hunks)
  • packages/dashboard-app/src/components/charts.component.tsx (5 hunks)
  • packages/dashboard-app/src/components/ux/error.component.tsx (1 hunks)
  • packages/rbac-app/src/components/dialogs/alert.dialog.component.tsx (2 hunks)
  • packages/root-config/src/microfrontend-layout.html (1 hunks)
  • packages/sidebar-app/.eslintrc (0 hunks)
  • packages/sidebar-app/.gitignore (0 hunks)
  • packages/sidebar-app/.prettierignore (0 hunks)
  • packages/sidebar-app/babel.config.json (0 hunks)
  • packages/sidebar-app/jest.config.js (0 hunks)
  • packages/sidebar-app/package.json (0 hunks)
  • packages/sidebar-app/src/declarations.d.ts (0 hunks)
  • packages/sidebar-app/src/jembi-openhim-sidebar.tsx (0 hunks)
  • packages/sidebar-app/src/menu.component.tsx (0 hunks)
  • packages/sidebar-app/src/root.component.tsx (0 hunks)
  • packages/sidebar-app/tsconfig.json (0 hunks)
  • packages/sidebar-app/webpack.config.js (0 hunks)
  • packages/users-app/src/components/dialogs/alert.dialog.component.tsx (2 hunks)
Files not reviewed due to no reviewable changes (12)
  • packages/sidebar-app/.eslintrc
  • packages/sidebar-app/.gitignore
  • packages/sidebar-app/.prettierignore
  • packages/sidebar-app/babel.config.json
  • packages/sidebar-app/jest.config.js
  • packages/sidebar-app/package.json
  • packages/sidebar-app/src/declarations.d.ts
  • packages/sidebar-app/src/jembi-openhim-sidebar.tsx
  • packages/sidebar-app/src/menu.component.tsx
  • packages/sidebar-app/src/root.component.tsx
  • packages/sidebar-app/tsconfig.json
  • packages/sidebar-app/webpack.config.js
Additional comments not posted (17)
packages/channels-app/src/components/dialogs/alert.dialog.component.tsx (1)

23-36: LGTM!

The changes enhance the functionality of the AlertDialog component by providing a clear action to acknowledge the alert. The button style and color are appropriately configured based on the severity of the alert, and it correctly triggers the onClose function to dismiss the alert dialog. The changes improve the user experience by providing a more interactive way to dismiss the alert dialog.

packages/rbac-app/src/components/dialogs/alert.dialog.component.tsx (1)

23-36: LGTM!

The addition of the action button within the Alert component is a great enhancement to the user experience. It provides a clear and accessible way for users to acknowledge and dismiss the alert.

The code follows best practices by:

  • Utilizing the Button component from Material-UI for consistent styling and behavior.
  • Dynamically setting the button's color based on the severity prop, ensuring visual consistency with the alert's severity.
  • Correctly linking the button's onClick event to the onClose prop of the AlertDialog, allowing the alert to be dismissed when clicked.

Overall, the changes are well-implemented and improve the usability of the AlertDialog component.

packages/users-app/src/components/dialogs/alert.dialog.component.tsx (1)

23-36: LGTM!

The addition of the action prop to the Alert component is a great enhancement to the user experience. It provides a clear and intuitive way for users to acknowledge and dismiss the alert.

Some key observations:

  • Setting the color of the button based on the severity prop effectively communicates the nature of the alert to the user.
  • The onClick handler being set to the onClose prop ensures that the alert is dismissed when the button is clicked.
  • The button text "OK" is a standard and intuitive label for acknowledging an alert.

Overall, these changes improve the usability and clarity of the AlertDialog component.

packages/root-config/src/microfrontend-layout.html (1)

80-80: LGTM!

The removal of the exact attribute from the route configuration for channels is a good change. It allows for more flexible navigation within the channels section of the application by matching any URL that starts with #!/channels.

This change is consistent with the removal of the earlier instance of the #!/channels route and simplifies the routing logic.

packages/dashboard-app/src/components/charts.component.tsx (4)

11-11: LGTM!

The import statement for the ErrorMessage component is correctly written.


24-24: LGTM!

The error state variable is correctly declared and initialized with the appropriate type annotation.


40-40: LGTM!

Resetting the error state to null before making the API call is a good practice to ensure that any previous error state is cleared.


51-51: LGTM!

The error handling logic is implemented correctly:

  • The error state is set when an error occurs during data fetching.
  • The ErrorMessage component is rendered when an error exists, providing a clear indication to the user.
  • The getFilteredTransactions function is passed as the onRetry prop, allowing the user to retry fetching the transactions if an error occurs.

Also applies to: 68-71

packages/channels-app/src/screens/edit.channel.screen.tsx (2)

47-58: LGTM!

The validation check to ensure that a channel has exactly one primary route is a good addition. It prevents invalid channel configurations and maintains data integrity. The code correctly filters the routes, checks the count of primary routes, and displays an informative alert message if the validation fails. The early return also prevents the mutation from being executed in case of validation failure.


88-88: Looks good!

The minor adjustment to the width of the Paper component from 600px to 680px is acceptable. It provides more space for the content within the component and does not affect its functionality.

packages/channels-app/src/screens/add.channel.screen.tsx (3)

74-78: LGTM!

The improved error handling provides a more informative error message to the user, enhancing the user experience.


81-92: The past review comment is still valid.

The comment by drizzentic on line 88 suggests handling this validation on the add route modal. Please consider addressing this suggestion.


132-132: LGTM!

The increased width of the Paper component may improve the visual presentation of the screen.

packages/channels-app/src/screens/steps/routes/ChannelRoutes.tsx (1)

159-170: LGTM!

The code changes enhance the user interface by clearly distinguishing primary routes from others using a "primary" chip. The Tooltip component improves usability by providing additional context about the "primary" label. The implementation is correct and follows best practices.

packages/channels-app/src/screens/manage.channels.screen.tsx (1)

Line range hint 92-117: Verify that selectedChannel is always set correctly.

The function logic for disabling or enabling a channel based on its current status is correct. However, the function now relies on the selectedChannel state variable to determine the channel to modify.

Ensure that selectedChannel is always set correctly before invoking onActionDisableChannel. You can run the following script to verify this:

Also applies to: 183-183

Verification successful

Add a null check for selectedChannel in onActionDisableChannel

The usage of selectedChannel appears to be correct within the context menu scenario. However, to improve robustness and prevent potential errors, consider adding a null check at the beginning of the onActionDisableChannel function:

const onActionDisableChannel = () => {
  if (!selectedChannel) return; // Add this line
  const channel = selectedChannel;
  // ... rest of the function
}

This change will ensure that the function gracefully handles cases where selectedChannel might be null.

Additionally, verify that the context menu can only be opened when a channel is selected, which should be the case based on the current implementation.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that `selectedChannel` is always set correctly before invoking `onActionDisableChannel`.

# Test: Search for invocations of `onActionDisableChannel`. Expect: `selectedChannel` is always set before invoking `onActionDisableChannel`.
rg --type typescript -A 5 $'onActionDisableChannel'

Length of output: 85


Script:

#!/bin/bash
# Description: Search for `onActionDisableChannel` and `selectedChannel` in TypeScript files

# Find TypeScript files and search for `onActionDisableChannel`
echo "Searching for onActionDisableChannel:"
fd -e ts -e tsx | xargs grep -n -A 5 "onActionDisableChannel"

echo -e "\nSearching for selectedChannel:"
# Find TypeScript files and search for `selectedChannel`
fd -e ts -e tsx | xargs grep -n -B 5 -A 5 "selectedChannel"

Length of output: 4968

packages/channels-app/src/screens/steps/RequestMatching.tsx (2)

65-70: LGTM!

The conditional rendering of the start and end adornments based on channel.addAutoRewriteRules is implemented correctly. The adornments provide clear visual cues to the user about the automatic addition of regex delimiters when the feature is enabled.


72-79: LGTM!

The modification of the urlPattern input value based on channel.addAutoRewriteRules is implemented correctly. Trimming the urlPattern and removing the leading ^ and trailing $ characters when addAutoRewriteRules is enabled ensures a cleaner input format and aligns with the visual cues provided by the adornments. Using the original urlPattern when addAutoRewriteRules is disabled maintains the expected behavior for manual regex input.

height="300px"
padding={2}
>
<ErrorOutlineIcon color="error" sx={{fontSize: 60}} />
Copy link

Choose a reason for hiding this comment

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

Add accessibility attributes to the error icon.

The error icon does not have an aria-label or alt text, which can make it difficult for screen reader users to understand its purpose.

Apply this diff to add an aria-label:

-<ErrorOutlineIcon color="error" sx={{fontSize: 60}} />
+<ErrorOutlineIcon color="error" sx={{fontSize: 60}} aria-label="Error icon" />
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
<ErrorOutlineIcon color="error" sx={{fontSize: 60}} />
<ErrorOutlineIcon color="error" sx={{fontSize: 60}} aria-label="Error icon" />

Comment on lines +22 to +27
<Typography variant="h6" color="error" align="center" gutterBottom>
Oops! Something went wrong.
</Typography>
<Typography variant="body1" align="center" gutterBottom>
An error occurred while loading the data. Please try again.
</Typography>
Copy link

Choose a reason for hiding this comment

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

Use the title and message props for customization.

The title and message props are not being utilized in the component. Instead, hardcoded values are being rendered. To make the component more reusable and customizable, consider using the prop values.

Apply this diff to use the prop values:

-<Typography variant="h6" color="error" align="center" gutterBottom>
-  Oops! Something went wrong.
+<Typography variant="h6" color="error" align="center" gutterBottom>
+  {title || 'Oops! Something went wrong.'}
</Typography>
<Typography variant="body1" align="center" gutterBottom>
-  An error occurred while loading the data. Please try again.
+  {message || 'An error occurred while loading the data. Please try again.'}
</Typography>
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
<Typography variant="h6" color="error" align="center" gutterBottom>
Oops! Something went wrong.
</Typography>
<Typography variant="body1" align="center" gutterBottom>
An error occurred while loading the data. Please try again.
</Typography>
<Typography variant="h6" color="error" align="center" gutterBottom>
{title || 'Oops! Something went wrong.'}
</Typography>
<Typography variant="body1" align="center" gutterBottom>
{message || 'An error occurred while loading the data. Please try again.'}
</Typography>

Comment on lines +28 to +30
<Button variant="contained" color="primary" onClick={onRetry}>
Retry
</Button>
Copy link

Choose a reason for hiding this comment

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

Improve the retry button's accessibility.

The retry button does not have an aria-label, which can make it less descriptive for users relying on assistive technologies. Adding an aria-label can provide more context about the button's action.

Apply this diff to add an aria-label:

-<Button variant="contained" color="primary" onClick={onRetry}>
+<Button variant="contained" color="primary" onClick={onRetry} aria-label="Retry loading data">
  Retry
</Button>
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
<Button variant="contained" color="primary" onClick={onRetry}>
Retry
</Button>
<Button variant="contained" color="primary" onClick={onRetry} aria-label="Retry loading data">
Retry
</Button>

@@ -71,20 +68,30 @@ function AddChannelScreen() {
},
onSuccess: () => {
hideBackdrop()
navigate(Routes.MANAGE_CHANNELS)
window.location.href = `/#${Routes.MANAGE_CHANNELS}`
Copy link

Choose a reason for hiding this comment

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

Use React Router's navigate function for navigation.

Directly setting window.location.href bypasses React Router's navigation capabilities and may impact the user experience. Consider using the navigate function from React Router for a more seamless navigation experience.

- window.location.href = `/#${Routes.MANAGE_CHANNELS}`
+ navigate(`${Routes.MANAGE_CHANNELS}`)

Committable suggestion was skipped due to low confidence.

@@ -170,7 +177,7 @@ function AddChannelScreen() {
<Button
variant="outlined"
color="primary"
onClick={() => navigate(-1)}
href={`/#${Routes.MANAGE_CHANNELS}`}
Copy link

Choose a reason for hiding this comment

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

Use React Router's navigate function for navigation.

Directly setting the href attribute bypasses React Router's navigation capabilities and may impact the user experience. Consider using the navigate function from React Router for a more seamless navigation experience.

- href={`/#${Routes.MANAGE_CHANNELS}`}
+ onClick={() => navigate(`${Routes.MANAGE_CHANNELS}`)}

Committable suggestion was skipped due to low confidence.

Copy link
Collaborator

@drizzentic drizzentic left a comment

Choose a reason for hiding this comment

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

LGTM!

@drizzentic drizzentic merged commit 4813ff6 into poc-microfrontends Sep 16, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement microfrontend-poc OpenHIM Console Microfrontend Proof of Concept
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants