-
Notifications
You must be signed in to change notification settings - Fork 19
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
ui fixes. #1897
ui fixes. #1897
Conversation
📝 Walkthrough📝 WalkthroughWalkthroughThe pull request introduces modifications to the Changes
Possibly related PRs
Suggested reviewers
Poem
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? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this 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
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
📒 Files selected for processing (2)
health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/BoundaryRelationCreate.js
(2 hunks)health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/ViewHierarchy.js
(6 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/BoundaryRelationCreate.js (1)
Pattern **/*.js
: check
health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/ViewHierarchy.js (1)
Pattern **/*.js
: check
🪛 Biome (1.9.4)
health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/BoundaryRelationCreate.js
[error] 347-347: Template literals are preferred over string concatenation.
Unsafe fix: Use a template literal.
(lint/style/useTemplate)
health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/ViewHierarchy.js
[error] 400-400: Template literals are preferred over string concatenation.
Unsafe fix: Use a template literal.
(lint/style/useTemplate)
[error] 419-419: Template literals are preferred over string concatenation.
Unsafe fix: Use a template literal.
(lint/style/useTemplate)
[error] 451-451: Template literals are preferred over string concatenation.
Unsafe fix: Use a template literal.
(lint/style/useTemplate)
🔇 Additional comments (1)
health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/BoundaryRelationCreate.js (1)
343-343
: 🛠️ Refactor suggestion
Add error handling for empty boundary types
The code should validate boundary types before processing.
Add validation before processing:
+ const validateBoundaryType = (type) => {
+ if (!type?.trim()) {
+ throw new Error(t("INVALID_BOUNDARY_TYPE"));
+ }
+ return type;
+ };
const local = [
Also applies to: 344-344
...-ui-internals/packages/modules/campaign-manager/src/pages/employee/BoundaryRelationCreate.js
Show resolved
Hide resolved
...-ui-internals/packages/modules/campaign-manager/src/pages/employee/BoundaryRelationCreate.js
Outdated
Show resolved
Hide resolved
...-ui-internals/packages/modules/campaign-manager/src/pages/employee/BoundaryRelationCreate.js
Outdated
Show resolved
Hide resolved
...web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/ViewHierarchy.js
Outdated
Show resolved
Hide resolved
...web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/ViewHierarchy.js
Outdated
Show resolved
Hide resolved
...web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/ViewHierarchy.js
Show resolved
Hide resolved
...web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/ViewHierarchy.js
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
put al these trim and formating in a single function
...-ui-internals/packages/modules/campaign-manager/src/pages/employee/BoundaryRelationCreate.js
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 4
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
📒 Files selected for processing (2)
health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/BoundaryRelationCreate.js
(3 hunks)health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/ViewHierarchy.js
(7 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/BoundaryRelationCreate.js (1)
Pattern **/*.js
: check
health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/ViewHierarchy.js (1)
Pattern **/*.js
: check
🪛 Biome (1.9.4)
health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/BoundaryRelationCreate.js
[error] 350-350: Template literals are preferred over string concatenation.
Unsafe fix: Use a template literal.
(lint/style/useTemplate)
health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/ViewHierarchy.js
[error] 374-374: Template literals are preferred over string concatenation.
Unsafe fix: Use a template literal.
(lint/style/useTemplate)
🔇 Additional comments (3)
health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/ViewHierarchy.js (2)
545-546
: LGTM: Back button enabled
The back button is now correctly enabled, allowing users to navigate back to the boundary home page.
356-363
:
Reintroduce polling timeout to prevent resource leaks
The removal of the polling timeout could lead to resource leaks if the operation hangs. The timeout provides a safety net to ensure the polling eventually terminates.
Apply this diff to reintroduce the polling timeout:
- // const timeoutDuration = (maxRetries + 1) * pollInterval;
- // setTimeout(() => {
- // if (retries < maxRetries) {
- // // Only reject if not already resolved
- // setDataCreationGoing(false);
- // reject(new Error("Polling timeout"));
- // }
- // }, timeoutDuration);
+ const timeoutDuration = (maxRetries + 1) * pollInterval;
+ setTimeout(() => {
+ if (retries < maxRetries) {
+ // Only reject if not already resolved
+ setDataCreationGoing(false);
+ reject(new Error("Polling timeout"));
+ }
+ }, timeoutDuration);
Likely invalid or redundant comment.
health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/BoundaryRelationCreate.js (1)
423-434
: Parent boundary type assignment needs improvement
...web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/ViewHierarchy.js
Show resolved
Hide resolved
...web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/ViewHierarchy.js
Show resolved
Hide resolved
...-ui-internals/packages/modules/campaign-manager/src/pages/employee/BoundaryRelationCreate.js
Outdated
Show resolved
Hide resolved
...-ui-internals/packages/modules/campaign-manager/src/pages/employee/BoundaryRelationCreate.js
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 3
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
📒 Files selected for processing (2)
health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/BoundaryRelationCreate.js
(3 hunks)health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/ViewHierarchy.js
(8 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/BoundaryRelationCreate.js (1)
Pattern **/*.js
: check
health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/ViewHierarchy.js (1)
Pattern **/*.js
: check
🪛 Biome (1.9.4)
health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/BoundaryRelationCreate.js
[error] 350-350: Template literals are preferred over string concatenation.
Unsafe fix: Use a template literal.
(lint/style/useTemplate)
health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/ViewHierarchy.js
[error] 374-374: Template literals are preferred over string concatenation.
Unsafe fix: Use a template literal.
(lint/style/useTemplate)
🔇 Additional comments (5)
health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/ViewHierarchy.js (5)
112-112
: LGTM: Improved error handling with localized message
The error handling has been enhanced with a proper localized message for the "in progress" state.
545-546
: LGTM: Enabled back button navigation
The back button has been correctly enabled to allow navigation to the boundary home page.
310-314
:
Reintroduce maximum retries check
Removing the maximum retries check could lead to infinite polling if the operation never completes or fails silently. This may cause unnecessary server load and poor user experience.
Apply this diff to reintroduce the maximum retries check:
- // if (retries >= maxRetries) {
- // setDataCreationGoing(false);
- // reject(new Error("Max retries reached"));
- // return;
- // }
+ if (retries >= maxRetries) {
+ setDataCreationGoing(false);
+ reject(new Error("Max retries reached"));
+ return;
+ }
356-363
:
Reintroduce polling timeout
By commenting out the timeout for the polling operation, the promise may never resolve or reject if the operation does not complete. This can result in resource leaks and a poor user experience.
Apply this diff to reintroduce the polling timeout:
- // const timeoutDuration = (maxRetries + 1) * pollInterval;
- // setTimeout(() => {
- // if (retries < maxRetries) {
- // // Only reject if not already resolved
- // setDataCreationGoing(false);
- // reject(new Error("Polling timeout"));
- // }
- // }, timeoutDuration);
+ const timeoutDuration = (maxRetries + 1) * pollInterval;
+ setTimeout(() => {
+ if (retries < maxRetries) {
+ // Only reject if not already resolved
+ setDataCreationGoing(false);
+ reject(new Error("Polling timeout"));
+ }
+ }, timeoutDuration);
373-375
: 🛠️ Refactor suggestion
Use template literals for string interpolation
The string concatenation in the trimming
function can be simplified using template literals for better readability and maintainability.
Apply this diff to use template literals:
const trimming = (val)=>{
- return `${t(( hierarchyType + "_" + val.trim().replace(/[\s_]+/g, '')).toUpperCase())}`;
+ return t(`${hierarchyType}_${val.trim().replace(/[\s_]+/g, '')}`.toUpperCase());
}
🧰 Tools
🪛 Biome (1.9.4)
[error] 374-374: Template literals are preferred over string concatenation.
Unsafe fix: Use a template literal.
(lint/style/useTemplate)
const trimming = (val) => { | ||
return val.trim().replace(/[\s_]+/g, ''); | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Add input validation and documentation to the trimming function
The function should handle edge cases and document its purpose.
+/**
+ * Standardizes boundary type strings by removing whitespace and underscores
+ * @param {string} val - The boundary type string to format
+ * @returns {string} The formatted boundary type string
+ * @throws {Error} If the input is null, undefined, or empty
+ */
const trimming = (val) => {
+ if (!val) {
+ throw new Error('Boundary type cannot be empty');
+ }
return val.trim().replace(/[\s_]+/g, '');
};
📝 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.
const trimming = (val) => { | |
return val.trim().replace(/[\s_]+/g, ''); | |
}; | |
/** | |
* Standardizes boundary type strings by removing whitespace and underscores | |
* @param {string} val - The boundary type string to format | |
* @returns {string} The formatted boundary type string | |
* @throws {Error} If the input is null, undefined, or empty | |
*/ | |
const trimming = (val) => { | |
if (!val) { | |
throw new Error('Boundary type cannot be empty'); | |
} | |
return val.trim().replace(/[\s_]+/g, ''); | |
}; |
item.boundaryType = trimming(item.boundaryType).toUpperCase(); | ||
if (idx === 0) { | ||
if (newHierarchy) item.parentBoundaryType = null; | ||
else { | ||
if (boundaryData.length === 0) item.parentBoundaryType = null; | ||
else item.parentBoundaryType = boundaryData[boundaryData.length - 1].boundaryType.trim(); | ||
else item.parentBoundaryType = boundaryData[boundaryData.length - 1].boundaryType; | ||
|
||
} | ||
} | ||
if (idx > 0) { | ||
item.parentBoundaryType = prevItems[idx - 1].boundaryType.trim(); | ||
item.parentBoundaryType = trimming(prevItems[idx - 1].boundaryType); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧹 Nitpick (assertive)
Simplify parent boundary type assignment logic
The current implementation can be made more concise while maintaining the same functionality.
-item.boundaryType = trimming(item.boundaryType).toUpperCase();
+const formatBoundaryType = (type) => trimming(type).toUpperCase();
+item.boundaryType = formatBoundaryType(item.boundaryType);
if (idx === 0) {
- if (newHierarchy) item.parentBoundaryType = null;
- else {
- if (boundaryData.length === 0) item.parentBoundaryType = null;
- else item.parentBoundaryType = boundaryData[boundaryData.length - 1].boundaryType;
- }
+ item.parentBoundaryType = (!newHierarchy && boundaryData.length > 0)
+ ? boundaryData[boundaryData.length - 1].boundaryType
+ : null;
}
if (idx > 0) {
- item.parentBoundaryType = trimming(prevItems[idx - 1].boundaryType);
+ item.parentBoundaryType = formatBoundaryType(prevItems[idx - 1].boundaryType);
}
📝 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.
item.boundaryType = trimming(item.boundaryType).toUpperCase(); | |
if (idx === 0) { | |
if (newHierarchy) item.parentBoundaryType = null; | |
else { | |
if (boundaryData.length === 0) item.parentBoundaryType = null; | |
else item.parentBoundaryType = boundaryData[boundaryData.length - 1].boundaryType.trim(); | |
else item.parentBoundaryType = boundaryData[boundaryData.length - 1].boundaryType; | |
} | |
} | |
if (idx > 0) { | |
item.parentBoundaryType = prevItems[idx - 1].boundaryType.trim(); | |
item.parentBoundaryType = trimming(prevItems[idx - 1].boundaryType); | |
const formatBoundaryType = (type) => trimming(type).toUpperCase(); | |
item.boundaryType = formatBoundaryType(item.boundaryType); | |
if (idx === 0) { | |
item.parentBoundaryType = (!newHierarchy && boundaryData.length > 0) | |
? boundaryData[boundaryData.length - 1].boundaryType | |
: null; | |
} | |
if (idx > 0) { | |
item.parentBoundaryType = formatBoundaryType(prevItems[idx - 1].boundaryType); | |
} |
const local = [ | ||
...boundaryData.map(item => ({ | ||
code: `${hierarchyType}_${trimming(item.boundaryType)}`.toUpperCase(), | ||
message: `${t((defaultHierarchyType + "_" + item?.boundaryType).toUpperCase())}`, | ||
module: `hcm-boundary-${hierarchyType.toLowerCase()}`, | ||
locale: locale | ||
})), | ||
...newBoundaryData.map(item => ({ | ||
code: `${hierarchyType}_${trimming(item.boundaryType)}`.toUpperCase(), | ||
message: item.boundaryType.trim(), | ||
module: `hcm-boundary-${hierarchyType.toLowerCase()}`, | ||
locale: locale | ||
})) | ||
]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Improve consistency and readability in message formatting
- The message formatting is inconsistent between boundaryData and newBoundaryData items
- String concatenation should be replaced with template literals
const local = [
...boundaryData.map(item => ({
- code: `${hierarchyType}_${trimming(item.boundaryType)}`.toUpperCase(),
- message: `${t((defaultHierarchyType + "_" + item?.boundaryType).toUpperCase())}`,
+ code: `${hierarchyType}_${trimming(item.boundaryType)}`.toUpperCase(),
+ message: t(`${defaultHierarchyType}_${item?.boundaryType}`.toUpperCase()),
module: `hcm-boundary-${hierarchyType.toLowerCase()}`,
locale: locale
})),
...newBoundaryData.map(item => ({
code: `${hierarchyType}_${trimming(item.boundaryType)}`.toUpperCase(),
- message: item.boundaryType.trim(),
+ message: t(`${defaultHierarchyType}_${item.boundaryType}`.toUpperCase()),
module: `hcm-boundary-${hierarchyType.toLowerCase()}`,
locale: locale
}))
];
📝 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.
const local = [ | |
...boundaryData.map(item => ({ | |
code: `${hierarchyType}_${trimming(item.boundaryType)}`.toUpperCase(), | |
message: `${t((defaultHierarchyType + "_" + item?.boundaryType).toUpperCase())}`, | |
module: `hcm-boundary-${hierarchyType.toLowerCase()}`, | |
locale: locale | |
})), | |
...newBoundaryData.map(item => ({ | |
code: `${hierarchyType}_${trimming(item.boundaryType)}`.toUpperCase(), | |
message: item.boundaryType.trim(), | |
module: `hcm-boundary-${hierarchyType.toLowerCase()}`, | |
locale: locale | |
})) | |
]; | |
const local = [ | |
...boundaryData.map(item => ({ | |
code: `${hierarchyType}_${trimming(item.boundaryType)}`.toUpperCase(), | |
message: t(`${defaultHierarchyType}_${item?.boundaryType}`.toUpperCase()), | |
module: `hcm-boundary-${hierarchyType.toLowerCase()}`, | |
locale: locale | |
})), | |
...newBoundaryData.map(item => ({ | |
code: `${hierarchyType}_${trimming(item.boundaryType)}`.toUpperCase(), | |
message: t(`${defaultHierarchyType}_${item.boundaryType}`.toUpperCase()), | |
module: `hcm-boundary-${hierarchyType.toLowerCase()}`, | |
locale: locale | |
})) | |
]; |
🧰 Tools
🪛 Biome (1.9.4)
[error] 350-350: Template literals are preferred over string concatenation.
Unsafe fix: Use a template literal.
(lint/style/useTemplate)
Choose the appropriate template for your PR:
Summary by CodeRabbit
New Features
Bug Fixes
Improvements