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

HLM-5342: Inbox Search Composer enhacement for MultiTab #219

Merged
merged 3 commits into from
Mar 19, 2024

Conversation

nabeelmd-eGov
Copy link
Contributor

@nabeelmd-eGov nabeelmd-eGov commented Mar 19, 2024

Summary by CodeRabbit

  • New Features
    • Introduced tab functionality in the Search Component with customizable tab data and handlers for tab changes.
    • Added customization options for pagination in Table components, including custom page sizes.
  • Style Updates
    • Updated styles for the inbox search tabs, including colors, font properties, and margins.
    • Added new styling for the search wrapper within the inbox search composer.
  • Enhancements
    • Improved inbox search composer to support new tab functionality and handle API details more effectively.
    • Modified the inbox search composer reducer to support custom default pagination configurations.

@nabeelmd-eGov nabeelmd-eGov requested a review from a team as a code owner March 19, 2024 10:04
Copy link
Contributor

coderabbitai bot commented Mar 19, 2024

Walkthrough

Walkthrough

The recent updates aim to enhance the user interface and functionality of the inbox and search components within a micro-UI. Changes include customizable tabs, pagination sizes, styling adjustments for visual coherence, and dynamic properties for improved user interaction, offering a flexible and user-friendly experience in managing inbox content.

Changes

Files Summary
.../inboxSearchComposer.scss
.../inbox.scss
Updated styles for tabs and search components, including display, background color, box shadow, and various other properties.
.../SearchComponent.js
.../Table.js
.../InboxSearchComposer.js
.../InboxSearchComposerReducer.js
.../ResultsTable.js
Enhanced functionality with new props for tab display and customization, pagination adjustments, and dynamic handling of API details and state based on configuration.

🐰✨
In the land of code, where the rabbits roam,
Changes abound, in their digital home.
Tabs and pages, now bend to your will,
With colors and sizes, the screens we fill.
So hop along, on this UI quest,
With tweaks and improvements, we aim to impress.
🎉🐾

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>.
    • Generate unit-tests 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 tests 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 show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit tests.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

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 as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • 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/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

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.

Review Status

Actionable comments generated: 1

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 49ca169 and 220229b.
Files selected for processing (7)
  • micro-ui/web/micro-ui-internals/packages/css/src/components/inboxv2/inboxSearchComposer.scss (1 hunks)
  • micro-ui/web/micro-ui-internals/packages/css/src/pages/employee/inbox.scss (1 hunks)
  • micro-ui/web/micro-ui-internals/packages/react-components/src/atoms/SearchComponent.js (2 hunks)
  • micro-ui/web/micro-ui-internals/packages/react-components/src/atoms/Table.js (2 hunks)
  • micro-ui/web/micro-ui-internals/packages/react-components/src/hoc/InboxSearchComposer.js (2 hunks)
  • micro-ui/web/micro-ui-internals/packages/react-components/src/hoc/InboxSearchComposerReducer.js (1 hunks)
  • micro-ui/web/micro-ui-internals/packages/react-components/src/hoc/ResultsTable.js (4 hunks)
Additional comments: 7
micro-ui/web/micro-ui-internals/packages/css/src/components/inboxv2/inboxSearchComposer.scss (1)
  • 102-109: The addition of the .tab class styling is well-implemented, providing clear visual differentiation for tabs within the Inbox Search Composer. The use of box-shadow on the .search-wrapper within the .tab class enhances the UI's depth and focus. Ensure that the color and shadow values align with the project's design system for consistency.
micro-ui/web/micro-ui-internals/packages/react-components/src/atoms/SearchComponent.js (1)
  • 120-140: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [12-137]

The updates to SearchComponent to include showTab, tabData, onTabChange props, and the customDefaultPagination constant are well-implemented. These changes enhance the component's flexibility and functionality within a MultiTab environment. Consider adding PropTypes or TypeScript interfaces to validate the new props and ensure they are used correctly throughout the application.

+ import PropTypes from 'prop-types';

SearchComponent.propTypes = {
  showTab: PropTypes.bool,
  tabData: PropTypes.array,
  onTabChange: PropTypes.func,
  customDefaultPagination: PropTypes.object,
};
micro-ui/web/micro-ui-internals/packages/react-components/src/hoc/ResultsTable.js (1)
  • 92-98: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [79-126]

The introduction of defaultValuesFromSession to set default pagination values and the registration of "offset" and "limit" based on config.customDefaultPagination are significant improvements for customizing pagination behavior. Additionally, the customPageSizesArray prop adds flexibility in defining page sizes. Ensure that these configurations are documented and that default values are provided to maintain backward compatibility and prevent runtime errors.

- const defaultValuesFromSession = config?.customDefaultPagination ? config?.customDefaultPagination : {limit:10,offset:0}
+ const defaultValuesFromSession = config && config.customDefaultPagination ? config.customDefaultPagination : {limit:10,offset:0}
micro-ui/web/micro-ui-internals/packages/react-components/src/atoms/Table.js (1)
  • 228-244: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [67-241]

The addition of the customPageSizesArray prop to customize pagination page sizes in the Table component is a valuable enhancement for flexibility. Ensure that this prop is optional and has a default value to maintain backward compatibility. Also, consider adding prop validation for customPageSizesArray to ensure it receives an array of numbers.

+ Table.propTypes = {
+   customPageSizesArray: PropTypes.arrayOf(PropTypes.number),
+ };
+ Table.defaultProps = {
+   customPageSizesArray: [10, 20, 30, 40, 50],
+ };
micro-ui/web/micro-ui-internals/packages/css/src/pages/employee/inbox.scss (1)
  • 535-554: The styling updates in inbox.scss for .search-tabs-container, .search-tab-head, and .search-tab-head-selected enhance the visual differentiation and interactivity of the search tabs. The use of border-radius, font-weight, and background-color properties aligns with modern UI design principles. Ensure that these styles are consistent with the overall design system of the project, particularly in terms of color and font size.
micro-ui/web/micro-ui-internals/packages/react-components/src/hoc/InboxSearchComposer.js (2)
  • 19-19: The addition of showTab, tabData, and onTabChange parameters to enhance the MultiTab functionality is a good approach. Ensure their usage is optimized and does not introduce side effects or performance issues.
  • 29-33: The handling of apiDetails using useState and useEffect is appropriate for managing external configurations. However, consider verifying its impact on performance to ensure it does not cause unnecessary re-renders.

Comment on lines +1 to +18
export const initialInboxState = (config) => {
if (config?.sections?.searchResult?.uiConfig?.customDefaultPagination) {
return {
searchForm: {},
filterForm: {},
tableForm: {
...config?.sections?.searchResult?.uiConfig?.customDefaultPagination,
},
};
}
return {
searchForm: {},
filterForm: {},
tableForm: {
limit: 10,
offset: 0,
}
};
},
};
Copy link
Contributor

Choose a reason for hiding this comment

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

The modification to initialInboxState to accept a config parameter and conditionally set tableForm based on config?.sections?.searchResult?.uiConfig?.customDefaultPagination is a good approach for making the state initialization more dynamic and configurable. However, ensure that the config object structure is validated or has default values to avoid runtime errors due to undefined properties.

- if (config?.sections?.searchResult?.uiConfig?.customDefaultPagination) {
+ if (config && config.sections && config.sections.searchResult && config.sections.searchResult.uiConfig && config.sections.searchResult.uiConfig.customDefaultPagination) {

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.

Suggested change
export const initialInboxState = (config) => {
if (config?.sections?.searchResult?.uiConfig?.customDefaultPagination) {
return {
searchForm: {},
filterForm: {},
tableForm: {
...config?.sections?.searchResult?.uiConfig?.customDefaultPagination,
},
};
}
return {
searchForm: {},
filterForm: {},
tableForm: {
limit: 10,
offset: 0,
}
};
},
};
export const initialInboxState = (config) => {
if (config && config.sections && config.sections.searchResult && config.sections.searchResult.uiConfig && config.sections.searchResult.uiConfig.customDefaultPagination) {
return {
searchForm: {},
filterForm: {},
tableForm: {
...config?.sections?.searchResult?.uiConfig?.customDefaultPagination,
},
};
}
return {
searchForm: {},
filterForm: {},
tableForm: {
limit: 10,
offset: 0,
},
};

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.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 220229b and 2cfd4f7.
Files ignored due to path filters (1)
  • micro-ui/web/micro-ui-internals/packages/react-components/package.json is excluded by: !**/*.json
Files selected for processing (1)
  • micro-ui/web/micro-ui-internals/packages/react-components/README.md (1 hunks)
Additional comments: 2
micro-ui/web/micro-ui-internals/packages/react-components/README.md (2)
  • 87-131: The instructions for using the InboxSearchComposer component to manage multiple tabs are clear and well-detailed. However, there are a few minor suggestions for improvement:
  • Ensure consistent capitalization for ShowTab in the instruction text to match the code snippet (showTab).
  • Consider clarifying the term "Config array" to specify where this configuration should be defined or how it's used within the application context.
  • In the code snippets, ensure consistency in commenting style and clarity. For example, "This state will by default take the first object from the array config" could be rephrased for better understanding.
  • Typographical error in "updaing" should be corrected to "updating" for clarity in the comments.

These minor adjustments will enhance the readability and accuracy of the documentation.

  • 83-139: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [136-175]

The changelog is well-documented and clearly outlines the new features and fixes introduced in this release. It's a good practice to maintain such detailed records for users and developers to track changes over time.

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.

Review Status

Actionable comments generated: 3

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 2cfd4f7 and 841390f.
Files selected for processing (1)
  • micro-ui/web/micro-ui-internals/packages/react-components/README.md (1 hunks)
Additional comments: 1
micro-ui/web/micro-ui-internals/packages/react-components/README.md (1)
  • 83-143: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [140-168]

The changelog is well-documented and provides a clear history of the changes. No issues found here.

Comment on lines 83 to 143
/>
</React.Fragment>
```


To use the InboxSearchComposer component for managing multiple tabs, follow these steps:
1. Set `ShowTab: true` in the Inboxconfig.
2. In the Config array, include configuration objects for each tab. For example:
```javascript
export const inboxconfig = {
tenantId: "pb",
moduleName: "inboxconfigUiConfig",
showTab: true,
inboxconfig: [
{
...
},
{
...
}
]
```
3. Implement custom limit offset by adding customDefaultPagination under uiConfig in the searchResult:
```javascript
customDefaultPagination: {
limit: 5,
offset: 0,
},
```
4. For custom table sizes, add an array of page sizes in customPageSizesArray under uiConfig in the searchResult:
```javascript
customPageSizesArray: [5, 10, 15, 20],
```
5. In the Inbox Screen, initialize the following states:
This state will by default take first object from array config
```javascript
const [config, setConfig] = useState(myCampaignConfig?.myCampaignConfig?.[0]);
```
TabData state used to fetch which tab is active
```javascript
const [tabData, setTabData] = useState(myCampaignConfig?.myCampaignConfig?.map((i, n) => ({ key: n, label: i.label, active: n === 0 ? true : false })));
```
Add function to perform when tab changes. Here we are setting the respective tab active and updaing its config
```javascript
const onTabChange = (n) => {
setTabData((prev) => prev.map((i, c) => ({ ...i, active: c === n ? true : false })));
setConfig(myCampaignConfig?.myCampaignConfig?.[n]);
};
```
6 At last pass all these in InboxSearchComposer props.

```jsx
<InboxSearchComposer configs={config} showTab={true} tabData={tabData} onTabChange={onTabChange}></InboxSearchComposer>
```

### Changelog

```bash
1.8.1-beta.6 Added feature for Multi Tab in InboxSearchComposer
1.8.1-beta.5 Added without labelfieldpair config for removing default card
1.8.1-beta.4 Added Previous button in From Composer
1.8.1-beta.3 Added XlsPreview component to preview Xls file.
Copy link
Contributor

Choose a reason for hiding this comment

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

📝 NOTE
This review was outside the diff hunks, and no overlapping diff hunk was found. Original lines [5-5]

The sentence "digit-ui-react-components" should start with an uppercase letter for consistency with the rest of the document.

- # digit-ui-react-components
+ # Digit-UI-React-Components

📝 NOTE
This review was outside the diff hunks, and no overlapping diff hunk was found. Original lines [21-21]

Consider adding a comma after "DIGIT-UI's" for grammatical correctness.

- This Package is more specific to DIGIT-UI's can be used across mission's
+ This Package is more specific to DIGIT-UI's, can be used across mission's

Comment on lines +87 to +135
To use the InboxSearchComposer component for managing multiple tabs, follow these steps:
1. Set `ShowTab: true` in the Inboxconfig.
2. In the Config array, include configuration objects for each tab. For example:
```javascript
export const inboxconfig = {
tenantId: "pb",
moduleName: "inboxconfigUiConfig",
showTab: true,
inboxconfig: [
{
...
},
{
...
}
]
```
3. Implement custom limit offset by adding customDefaultPagination under uiConfig in the searchResult:
```javascript
customDefaultPagination: {
limit: 5,
offset: 0,
},
```
4. For custom table sizes, add an array of page sizes in customPageSizesArray under uiConfig in the searchResult:
```javascript
customPageSizesArray: [5, 10, 15, 20],
```
5. In the Inbox Screen, initialize the following states:
This state will by default take first object from array config
```javascript
const [config, setConfig] = useState(myCampaignConfig?.myCampaignConfig?.[0]);
```
TabData state used to fetch which tab is active
```javascript
const [tabData, setTabData] = useState(myCampaignConfig?.myCampaignConfig?.map((i, n) => ({ key: n, label: i.label, active: n === 0 ? true : false })));
```
Add function to perform when tab changes. Here we are setting the respective tab active and updaing its config
```javascript
const onTabChange = (n) => {
setTabData((prev) => prev.map((i, c) => ({ ...i, active: c === n ? true : false })));
setConfig(myCampaignConfig?.myCampaignConfig?.[n]);
};
```
6 At last pass all these in InboxSearchComposer props.

```jsx
<InboxSearchComposer configs={config} showTab={true} tabData={tabData} onTabChange={onTabChange}></InboxSearchComposer>
```
Copy link
Contributor

Choose a reason for hiding this comment

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

The documentation for using the InboxSearchComposer component is clear and well-structured. However, there are a few minor typographical and grammatical issues to address:

  • "ShowTab" should be "showTab" for consistency with JavaScript property naming conventions.
  • "Inboxconfig" should be "inboxConfig" to follow camelCase naming conventions.
  • "updaing" should be corrected to "updating".
  • Ensure that the code snippets are correctly formatted and indented for better readability.
- 1. Set `ShowTab: true` in the Inboxconfig.
+ 1. Set `showTab: true` in the inboxConfig.
...
- Add function to perform when tab changes. Here we are setting the respective tab active and updaing its config
+ Add function to perform when tab changes. Here we are setting the respective tab active and updating its config

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.

Suggested change
To use the InboxSearchComposer component for managing multiple tabs, follow these steps:
1. Set `ShowTab: true` in the Inboxconfig.
2. In the Config array, include configuration objects for each tab. For example:
```javascript
export const inboxconfig = {
tenantId: "pb",
moduleName: "inboxconfigUiConfig",
showTab: true,
inboxconfig: [
{
...
},
{
...
}
]
```
3. Implement custom limit offset by adding customDefaultPagination under uiConfig in the searchResult:
```javascript
customDefaultPagination: {
limit: 5,
offset: 0,
},
```
4. For custom table sizes, add an array of page sizes in customPageSizesArray under uiConfig in the searchResult:
```javascript
customPageSizesArray: [5, 10, 15, 20],
```
5. In the Inbox Screen, initialize the following states:
This state will by default take first object from array config
```javascript
const [config, setConfig] = useState(myCampaignConfig?.myCampaignConfig?.[0]);
```
TabData state used to fetch which tab is active
```javascript
const [tabData, setTabData] = useState(myCampaignConfig?.myCampaignConfig?.map((i, n) => ({ key: n, label: i.label, active: n === 0 ? true : false })));
```
Add function to perform when tab changes. Here we are setting the respective tab active and updaing its config
```javascript
const onTabChange = (n) => {
setTabData((prev) => prev.map((i, c) => ({ ...i, active: c === n ? true : false })));
setConfig(myCampaignConfig?.myCampaignConfig?.[n]);
};
```
6 At last pass all these in InboxSearchComposer props.
```jsx
<InboxSearchComposer configs={config} showTab={true} tabData={tabData} onTabChange={onTabChange}></InboxSearchComposer>
```
To use the InboxSearchComposer component for managing multiple tabs, follow these steps:
1. Set `showTab: true` in the inboxConfig.
2. In the Config array, include configuration objects for each tab. For example:
```javascript
export const inboxconfig = {
tenantId: "pb",
moduleName: "inboxconfigUiConfig",
showTab: true,
inboxconfig: [
{
...
},
{
...
}
]
```
3. Implement custom limit offset by adding customDefaultPagination under uiConfig in the searchResult:
```javascript
customDefaultPagination: {
limit: 5,
offset: 0,
},
```
4. For custom table sizes, add an array of page sizes in customPageSizesArray under uiConfig in the searchResult:
```javascript
customPageSizesArray: [5, 10, 15, 20],
```
5. In the Inbox Screen, initialize the following states:
This state will by default take first object from array config
```javascript
const [config, setConfig] = useState(myCampaignConfig?.myCampaignConfig?.[0]);
```
TabData state used to fetch which tab is active
```javascript
const [tabData, setTabData] = useState(myCampaignConfig?.myCampaignConfig?.map((i, n) => ({ key: n, label: i.label, active: n === 0 ? true : false })));
```
Add function to perform when tab changes. Here we are setting the respective tab active and updating its config
```javascript
const onTabChange = (n) => {
setTabData((prev) => prev.map((i, c) => ({ ...i, active: c === n ? true : false })));
setConfig(myCampaignConfig?.myCampaignConfig?.[n]);
};
```
6 At last pass all these in InboxSearchComposer props.
```jsx
<InboxSearchComposer configs={config} showTab={true} tabData={tabData} onTabChange={onTabChange}></InboxSearchComposer>

@jagankumar-egov jagankumar-egov merged commit 9895ac1 into develop Mar 19, 2024
1 check passed
@jagankumar-egov jagankumar-egov deleted the HLM-5342 branch March 19, 2024 11:17
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.

2 participants