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

Side component #1410

Merged
merged 9 commits into from
Sep 20, 2024
Merged

Side component #1410

merged 9 commits into from
Sep 20, 2024

Conversation

aaradhya-egov
Copy link
Contributor

No description provided.

@aaradhya-egov aaradhya-egov requested a review from a team as a code owner September 20, 2024 08:45
Copy link
Contributor

coderabbitai bot commented Sep 20, 2024

Walkthrough

Walkthrough

The pull request introduces several new components and CSS styles to enhance the employee interface within a sandbox environment. Key changes include the addition of the QuickSetupConfigComponent and QuickSetupComponent, which facilitate a quick setup interface for employees. The CSS file sandbox.scss is updated to include a new .homeWrapper class for responsive layout, along with modifications to existing styles for employee cards and quick links. Additionally, the changelog and stylesheet link are updated to reflect these changes.

Changes

File Change Summary
micro-ui/web/micro-ui-internals/packages/css/src/pages/employee/sandbox.scss Introduced a new CSS class .homeWrapper for Flexbox layout, added styles for .digit-employee-card, and defined a new class .quickLink with specific text styles.
micro-ui/web/micro-ui-internals/packages/modules/core/src/components/Home.js Added QuickSetupConfigComponent import and conditional rendering logic based on user access rights. Wrapped RoleBasedEmployeeHome in a div with specific class based on access. Minor JSX formatting adjustments made.
micro-ui/web/micro-ui-internals/packages/modules/core/src/pages/employee/QuickStart/Config.js Introduced QuickSetupConfigComponent, which manages quick setup interface logic, integrates internationalization, and constructs a sidebar configuration based on access control data.
micro-ui/web/micro-ui-internals/packages/modules/core/src/pages/employee/QuickStart/index.js Added QuickSetupComponent, which renders a structured interface for quick setup links with internationalization support, utilizing Card components for display.
micro-ui/web/micro-ui-internals/packages/css/README.md Updated changelog for CSS package to include a new entry for version 1.8.2-beta.25, indicating the addition of CSS for the side component.
micro-ui/web/public/index.html Updated stylesheet link for @egovernments/digit-ui-css package from version 1.8.2-beta.24 to 1.8.2-beta.25.
micro-ui/web/micro-ui-internals/packages/libraries/src/utils/index.js Added a new utility function isContextPathMissing to check if a URL lacks a specified context path, enhancing the module's public API.

Possibly related PRs

  • Application Management Updated #1359: Updates to the application management system that may relate to the layout and styling of components, similar to the CSS changes in this PR.
  • side bar #1384: Modifications to EmployeeSideBar.js that enhance navigation, relevant to the layout management introduced in this PR.
  • css fix  #1399: CSS enhancements including updates to sandbox.scss, directly relating to the changes made in this PR regarding styling and layout.
  • Sandbox landing page #1406: Changes in sandbox.scss that introduce new styles and enhance the user interface for an overlay component, connected to the styling updates in this PR.
  • sandbox enhancement #1411: CSS enhancements and the introduction of new components that may relate to the layout and styling changes made in this PR.

🐇 In the meadow, changes bloom,
New components chase away the gloom.
With styles that flex and cards that shine,
Quick setups now, oh how divine!
Hopping through code, we celebrate,
A brighter UI, oh, isn’t it great? 🌼✨


Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between a24b5c2 and 2b186fb.

Files selected for processing (3)
  • micro-ui/web/micro-ui-internals/packages/libraries/src/utils/index.js (3 hunks)
  • micro-ui/web/micro-ui-internals/packages/modules/core/src/pages/employee/QuickStart/Config.js (1 hunks)
  • micro-ui/web/micro-ui-internals/packages/modules/core/src/pages/employee/QuickStart/index.js (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • micro-ui/web/micro-ui-internals/packages/modules/core/src/pages/employee/QuickStart/Config.js
Additional context used
Path-based instructions (2)
micro-ui/web/micro-ui-internals/packages/libraries/src/utils/index.js (1)

Pattern **/*.js: check

micro-ui/web/micro-ui-internals/packages/modules/core/src/pages/employee/QuickStart/index.js (1)

Pattern **/*.js: check

Biome
micro-ui/web/micro-ui-internals/packages/modules/core/src/pages/employee/QuickStart/index.js

[error] 14-16: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)

Additional comments not posted (3)
micro-ui/web/micro-ui-internals/packages/modules/core/src/pages/employee/QuickStart/index.js (1)

14-16: Use optional chaining for section.sections.

The static analysis hint and the past review comment suggest using optional chaining for section.sections to prevent potential errors and simplify the code.

Apply this diff to use optional chaining:

-{section.sections && section.sections.map((item, itemIndex) => (
+{section.sections?.map((item, itemIndex) => (
   <CardText key={itemIndex}>{t(item.label)}</CardText>
 ))}
Tools
Biome

[error] 14-16: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)

micro-ui/web/micro-ui-internals/packages/libraries/src/utils/index.js (2)

127-130: LGTM!

The function logic is correct, and the implementation is accurate. It correctly checks if the given URL lacks the specified context path.


364-381: LGTM!

The function logic is correct, and the implementation is accurate. It correctly transforms the URL based on the specified conditions.


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

Outside diff range and nitpick comments (6)
micro-ui/web/micro-ui-internals/packages/css/src/pages/employee/sandbox.scss (2)

374-389: LGTM! Consider responsive behavior for smaller screens.

The Flexbox styles for the .homeWrapper class ensure proper spacing and alignment of the child components. The use of flex-grow and flex-shrink properties allows the first child to take up the remaining space while the second child maintains a fixed width.

However, the fixed width of 20.688rem for the second child may cause layout issues on smaller screens. Consider adding responsive styles or using media queries to adjust the width for smaller screen sizes to ensure optimal layout and prevent overflow.


391-400: LGTM! Be cautious with !important.

The styles for the .digit-card-header class within the context of the .homeWrapper and .digit-employee-card classes modify the appearance of the card header as intended. The color, font size, text alignment, and font weight are set appropriately.

However, the use of !important should be considered carefully. While it ensures that these styles take precedence, it can lead to specificity issues and make the styles harder to override if needed in the future. Consider whether the specific styles need to be !important or if they can be achieved through more specific selectors or by adjusting the order of the styles.

micro-ui/web/micro-ui-internals/packages/modules/core/src/pages/employee/QuickStart/Config.js (3)

55-57: Avoid returning an empty string in a React component

Returning an empty string from a component (line 56) may cause rendering issues. If there's nothing to display, consider returning null instead.

Apply this diff:

   if (!configEmployeeSideBar) {
-    return "";
+    return null;
   }

79-80: Use self-closing tag for component without children

The QuickSetupComponent is used without any children (lines 79-80). For clarity, use a self-closing tag.

Apply this diff:

-   <QuickSetupComponent config={QuickSetupConfig}></QuickSetupComponent>
+   <QuickSetupComponent config={QuickSetupConfig} />

6-6: Unused props in component definition

The QuickSetupConfigComponent receives props (onSelect, formData, control, formState, ...props) that are not used within the component. This can lead to confusion about the component's API.

If these props are not needed, remove them to simplify the code:

-const QuickSetupConfigComponent = ({ onSelect, formData, control, formState, ...props }) => {
+const QuickSetupConfigComponent = () => {

If they are intended for future use, consider adding a comment to indicate that.

micro-ui/web/micro-ui-internals/packages/modules/core/src/components/Home.js (1)

125-132: Consider moving inline styles to a CSS class for consistency.

The inline styles applied to CitizenInfoLabel component can be moved to a CSS class to maintain consistency across the application and improve maintainability.

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between ff2e006 and 9520786.

Files selected for processing (4)
  • micro-ui/web/micro-ui-internals/packages/css/src/pages/employee/sandbox.scss (1 hunks)
  • micro-ui/web/micro-ui-internals/packages/modules/core/src/components/Home.js (5 hunks)
  • micro-ui/web/micro-ui-internals/packages/modules/core/src/pages/employee/QuickStart/Config.js (1 hunks)
  • micro-ui/web/micro-ui-internals/packages/modules/core/src/pages/employee/QuickStart/index.js (1 hunks)
Additional context used
Path-based instructions (3)
micro-ui/web/micro-ui-internals/packages/modules/core/src/components/Home.js (1)

Pattern **/*.js: check

micro-ui/web/micro-ui-internals/packages/modules/core/src/pages/employee/QuickStart/Config.js (1)

Pattern **/*.js: check

micro-ui/web/micro-ui-internals/packages/modules/core/src/pages/employee/QuickStart/index.js (1)

Pattern **/*.js: check

Biome
micro-ui/web/micro-ui-internals/packages/modules/core/src/pages/employee/QuickStart/index.js

[error] 16-18: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)

Additional comments not posted (6)
micro-ui/web/micro-ui-internals/packages/modules/core/src/pages/employee/QuickStart/index.js (1)

1-37: LGTM!

The QuickSetupComponent is implemented correctly and should render the card content based on the provided config prop. The use of the useTranslation hook for internationalization is appropriate.

Tools
Biome

[error] 16-18: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)

micro-ui/web/micro-ui-internals/packages/css/src/pages/employee/sandbox.scss (2)

402-409: LGTM!

The styles for the .digit-card-text class within the context of the .homeWrapper and .digit-employee-card classes modify the font size and font weight of the card text as intended. The font size is set to 1rem (16px) and the font weight is set to bold (700).


410-415: LGTM!

The .quickLink class defines appropriate styles for quick navigation links. The text color is set to a specific shade of orange (#c84c0e), text decoration is removed to ensure a clean link appearance, font weight is set to bold (700), and font size is set to 1.5rem (24px). These styles provide a consistent and visually distinct appearance for the quick links.

micro-ui/web/micro-ui-internals/packages/modules/core/src/pages/employee/QuickStart/Config.js (1)

41-47: Ensure translation keys are correct

In the links array (lines 43-47), the translation keys constructed using item.displayName may not match existing keys, leading to missing translations.

Please confirm that item.displayName correctly maps to the translation keys. Run the following script to list the translation keys used:

Verification successful

To gather more comprehensive information about the translation keys and their usage, I'll generate a new script to search for the full lines containing the translation key pattern and look for the definition of item.displayName. This will help us understand how the translation keys are constructed and used throughout the project.

This script will provide us with more context about how the translation keys are used and defined, allowing us to better assess whether they are correct or if there are any potential issues.


Based on the analysis of the gathered information, I can now provide a final response regarding the translation keys.

Translation keys appear to be consistent with project conventions

The translation key pattern ${module}_LINK_${item.displayName} is used consistently in both the file under review (QuickStart/Config.js) and another file (RoleBasedEmployeeHome.js). This suggests that it's an intentional design choice and likely correct. However, to ensure full accuracy:

  • Manually verify that the actual values of module and item.displayName correspond to existing translation keys in your localization files.
  • Consider documenting this translation key pattern in your project documentation to help future developers understand and maintain this convention.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: List all translation keys used in the links configuration.

# Extract translation keys from the code
rg 'Digit\.Utils\.locale\.getTransformedLocale\(`\$\{module}_LINK_\$\{item\.displayName' -o -r '$0' micro-ui/web/micro-ui-internals/packages/modules/core/src/pages/employee/QuickStart/Config.js | sort | uniq

Length of output: 284


Script:

#!/bin/bash
# Search for full lines containing the translation key pattern and related code

# Search for translation key usage
echo "Translation key usage:"
rg 'Digit\.Utils\.locale\.getTransformedLocale\(`\$\{module}_LINK_\$\{item\.displayName.*\)`' -g '*.js' --no-heading

# Search for the definition of links array or item.displayName
echo -e "\nDefinition of links array or item.displayName:"
rg '(links\s*=|item\.displayName\s*=)' -g '*.js' --no-heading

# Search for similar translation patterns in other files
echo -e "\nSimilar translation patterns in other files:"
rg 'Digit\.Utils\.locale\.getTransformedLocale\(`.*_LINK_.*`\)' -g '*.js' --no-heading

Length of output: 5690

micro-ui/web/micro-ui-internals/packages/modules/core/src/components/Home.js (2)

12-12: Import statement is correct.

The QuickSetupConfigComponent is imported correctly from the specified path.


125-132: Verify localization keys for CitizenInfoLabel.

Please ensure that the localization keys CS_FILE_APPLICATION_INFO_LABEL and BPA_CITIZEN_HOME_STAKEHOLDER_INCLUDES_INFO_LABEL are correctly defined in the localization files. This will ensure that the information labels display the intended text to the users.

Comment on lines 196 to 199
<div className={Digit.UserService.hasAccess("SUPERUSER") && Digit.Utils.getMultiRootTenant() ? "homeWrapper" : ""}>
<RoleBasedEmployeeHome modules={modules} additionalComponent={additionalComponent} />
{Digit.UserService.hasAccess("SUPERUSER") && Digit.Utils.getMultiRootTenant() && <QuickSetupConfigComponent/>}
</div>
Copy link
Contributor

@coderabbitai coderabbitai bot Sep 20, 2024

Choose a reason for hiding this comment

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

Refactor repeated condition into a variable to enhance readability.

The condition Digit.UserService.hasAccess("SUPERUSER") && Digit.Utils.getMultiRootTenant() is used multiple times. Consider assigning it to a variable to adhere to the DRY (Don't Repeat Yourself) principle and improve code readability.

Apply this diff to refactor the condition:

+ const isSuperUserWithMultiRootTenant = Digit.UserService.hasAccess("SUPERUSER") && Digit.Utils.getMultiRootTenant();

Committable suggestion was skipped due to low confidence.

Copy link
Collaborator

Choose a reason for hiding this comment

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

@nabeelmd-eGov can u check this as well

Copy link
Contributor

Choose a reason for hiding this comment

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

Seems like the humans are having a chat. I'll hop back into my burrow for now. If you need me again, just tag @coderabbitai in a new comment, and I'll come hopping out!

Copy link
Contributor

Choose a reason for hiding this comment

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

fix

nabeelmd-eGov
nabeelmd-eGov previously approved these changes Sep 20, 2024
Copy link
Contributor

@nabeelmd-eGov nabeelmd-eGov left a comment

Choose a reason for hiding this comment

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

Looks fine

}
if (url?.indexOf(`/${window?.contextPath}`) === -1) {
let updatedUrl = null;
if (isMultiRootTenant) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can u make this as util function since many places same logic gets repeated

Copy link
Contributor

Choose a reason for hiding this comment

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

added

Copy link
Collaborator

Choose a reason for hiding this comment

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

this complete transform url funtion @nabeelmd-eGov

Comment on lines 196 to 199
<div className={Digit.UserService.hasAccess("SUPERUSER") && Digit.Utils.getMultiRootTenant() ? "homeWrapper" : ""}>
<RoleBasedEmployeeHome modules={modules} additionalComponent={additionalComponent} />
{Digit.UserService.hasAccess("SUPERUSER") && Digit.Utils.getMultiRootTenant() && <QuickSetupConfigComponent/>}
</div>
Copy link
Collaborator

Choose a reason for hiding this comment

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

@nabeelmd-eGov can u check this as well

@jagankumar-egov jagankumar-egov merged commit ecce3f8 into develop Sep 20, 2024
2 checks passed
@jagankumar-egov jagankumar-egov deleted the side-component branch September 20, 2024 10:15
nabeelmd-eGov added a commit that referenced this pull request Sep 20, 2024
nabeelmd-eGov added a commit that referenced this pull request Sep 20, 2024
@coderabbitai coderabbitai bot mentioned this pull request Oct 8, 2024
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.

3 participants