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

Beautify Portal TraceLog UI interface #5149

Merged

Conversation

BlackBear2003
Copy link
Contributor

@BlackBear2003 BlackBear2003 commented May 24, 2024

What's the purpose of this PR

Beautify Portal TraceLog UI interface

Which issue(s) this PR fixes:

Fixes ##5147

Brief changelog

XXXXX

Follow this checklist to help us incorporate your contribution quickly and easily:

  • Read the Contributing Guide before making this pull request.
  • Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
  • Write necessary unit tests to verify the code.
  • Run mvn clean test to make sure this pull request doesn't break anything.
  • Update the CHANGES log.

Summary by CodeRabbit

  • New Features

    • Introduced a new treeview element in the audit log trace details page for better visualization.
  • Style

    • Updated styling for horizontal rules and table elements.
    • Added new styles for treeview components to enhance user interface.
  • Chores

    • Included a new script for bootstrap-treeview.min.js to support the treeview functionality.

@dosubot dosubot bot added the size:L This PR changes 100-499 lines, ignoring generated files. label May 24, 2024
Copy link
Contributor

coderabbitai bot commented May 24, 2024

Walkthrough

The recent changes in the Apollo Portal involve enhancing the audit log trace detail UI by integrating a treeview element. This update replaces an existing section with a more visually structured tree view, leveraging bootstrap-treeview.min.js. Additionally, styling adjustments were made to support the new tree view, including changes to border-radius and the addition of specific classes for tree view elements.

Changes

File Path Change Summary
.../static/audit_log_trace_detail.html Removed trace details section, added treeview element, adjusted <hr> styling, modified class attribute indentation in <table>, added bootstrap-treeview.min.js script.
.../static/scripts/controller/AuditLogTraceDetailController.js Minor function signature formatting adjustment.
.../static/styles/audit-log.css Adjusted border-radius, added styles for .treeview, .node-treeview, and #treeview .list-group .list-group-item including background colors and padding.

Possibly related issues

In the garden of code, a tree did grow,
With branches of logs, in a structured flow.
Styled with care, and colors so bright,
It brought clarity and ease, a coder's delight.
🌳✨

Tip

New Features and Improvements

Review Settings

Introduced new personality profiles for code reviews. Users can now select between "Chill" and "Assertive" review tones to tailor feedback styles according to their preferences. The "Assertive" profile posts more comments and nitpicks the code more aggressively, while the "Chill" profile is more relaxed and posts fewer comments.

AST-based Instructions

CodeRabbit offers customizing reviews based on the Abstract Syntax Tree (AST) pattern matching. Read more about AST-based instructions in the documentation.

Community-driven AST-based Rules

We are kicking off a community-driven initiative to create and share AST-based rules. Users can now contribute their AST-based rules to detect security vulnerabilities, code smells, and anti-patterns. Please see the ast-grep-essentials repository for more information.

New Static Analysis Tools

We are continually expanding our support for static analysis tools. We have added support for biome, hadolint, and ast-grep. Update the settings in your .coderabbit.yaml file or head over to the settings page to enable or disable the tools you want to use.

Tone Settings

Users can now customize CodeRabbit to review code in the style of their favorite characters or personalities. Here are some of our favorite examples:

  • Mr. T: "You must talk like Mr. T in all your code reviews. I pity the fool who doesn't!"
  • Pirate: "Arr, matey! Ye must talk like a pirate in all yer code reviews. Yarrr!"
  • Snarky: "You must be snarky in all your code reviews. Snark, snark, snark!"

Revamped Settings Page

We have redesigned the settings page for a more intuitive layout, enabling users to find and adjust settings quickly. This change was long overdue; it not only improves the user experience but also allows our development team to add more settings in the future with ease. Going forward, the changes to .coderabbit.yaml will be reflected in the settings page, and vice versa.

Miscellaneous

  • Turn off free summarization: You can switch off free summarization of PRs opened by users not on a paid plan using the enable_free_tier setting.
  • Knowledge-base scope: You can now set the scope of the knowledge base to either the repository (local) or the organization (global) level using the knowledge_base setting. In addition, you can specify Jira project keys and Linear team keys to limit the knowledge base scope for those integrations.
  • High-level summary placement: You can now customize the location of the high-level summary in the PR description using the high_level_summary_placeholder setting (default @coderabbitai summary).
  • Revamped request changes workflow: You can now configure CodeRabbit to auto-approve or request changes on PRs based on the review feedback using the request_changes_workflow setting.

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 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 show all the console.log statements in this repository.
    • @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.

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.
  • 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: 1

Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between 3d14e6f and 913f1e0.
Files selected for processing (3)
  • apollo-portal/src/main/resources/static/audit_log_trace_detail.html (4 hunks)
  • apollo-portal/src/main/resources/static/scripts/controller/AuditLogTraceDetailController.js (3 hunks)
  • apollo-portal/src/main/resources/static/styles/audit-log.css (2 hunks)
Additional Context Used
Biome (20)
apollo-portal/src/main/resources/static/scripts/controller/AuditLogTraceDetailController.js (20)

58-61: This function expression can be turned into an arrow function.


51-64: This function expression can be turned into an arrow function.


47-65: This function expression can be turned into an arrow function.


70-74: Prefer for...of instead of forEach.


78-92: Prefer for...of instead of forEach.


102-105: Prefer for...of instead of forEach.


108-108: Avoid the delete operator which can impact performance.


136-149: This function expression can be turned into an arrow function.


158-170: This function expression can be turned into an arrow function.


172-179: Prefer for...of instead of forEach.


174-176: Template literals are preferred over string concatenation.


172-179: This function expression can be turned into an arrow function.


181-197: Prefer for...of instead of forEach.


183-197: This function expression can be turned into an arrow function.


22-22: Use let or const instead of var.


32-32: Use let or const instead of var.


69-70: Use let or const instead of var.


77-77: Use let or const instead of var.


95-96: Use let or const instead of var.


96-101: Use let or const instead of var.

Additional comments not posted (8)
apollo-portal/src/main/resources/static/styles/audit-log.css (5)

142-145: The new styles for .treeview look good and are consistent with the PR's objective to enhance UI appearance.


147-151: The transition effect added to .node-treeview enhances user experience by providing visual feedback on hover. Good addition!


153-155: Removing the border from the last child of .node-treeview is a thoughtful detail that improves the visual cleanliness of the UI.


157-159: The hover effect on .node-treeview is consistent with modern UI practices, providing immediate visual feedback to the user.


115-115: Ensure the border-radius property change aligns with the design specifications.

apollo-portal/src/main/resources/static/scripts/controller/AuditLogTraceDetailController.js (2)

19-26: Initialization of new data structures for handling treeview data is clear and well-organized.


45-62: The implementation of buildTraceDetailsTree function is robust, ensuring that treeview data is correctly built and displayed.

apollo-portal/src/main/resources/static/audit_log_trace_detail.html (1)

Line range hint 59-81: The integration of the treeview component into the HTML structure is well-executed, enhancing the user interface as intended by the PR. Ensure that all new scripts and styles are correctly linked and loaded.

Also applies to: 145-204

Verification successful

The verification script has successfully identified the inclusion of various scripts and stylesheets in the audit_log_trace_detail.html file. Notably, the bootstrap-treeview.min.js script, which is essential for the treeview component, is included.

  • bootstrap-treeview.min.js is present, ensuring the functionality of the treeview component.
Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that all new scripts and styles are correctly linked and loaded.
# Test: Check the network tab in browser dev tools for any 404 errors on the new resources.
echo "Please check the browser's network tab for any loading issues with new scripts and styles."

Length of output: 193



Script:

#!/bin/bash
# Description: Search for <script> and <link> tags in the audit_log_trace_detail.html file to verify inclusion of new resources.
fd -e html -x grep -E '<script|<link' {}

Length of output: 64608

Comment on lines 67 to 112
function buildTree(data) {
// 构建 spanId 到节点的映射
var nodeMap = new Map();
data.forEach(item => {
nodeMap.set(item.logDTO.spanId, item);
});

// 构建图的根节点列表
var roots = [];

data.forEach(item => {
const log = item.logDTO;
const parentSpanId = log.parentSpanId;

if (parentSpanId && nodeMap.has(parentSpanId)) {
const parent = nodeMap.get(parentSpanId);
if (!parent.children) {
parent.children = [];
}
parent.children.push(item);
} else {
roots.push(item);
}
});

// 递归生成 Treeview 格式的节点
function buildTreeNode(node) {
var log = node.logDTO;
var treeNode = {
text: log.opName,
nodes: [],
metaDetail: node
};
if (node.children) {
node.children.forEach(child => {
treeNode.nodes.push(buildTreeNode(child));
});
}
if (treeNode.nodes.length === 0) {
delete treeNode.nodes;
}
return treeNode;
}

});
return roots.map(root => buildTreeNode(root));
}
Copy link
Contributor

Choose a reason for hiding this comment

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

The buildTree function is well-implemented, with clear logic for constructing the tree nodes. Consider using for...of instead of forEach for better performance.

- data.forEach(item => {
+ for (const item of data) {

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
function buildTree(data) {
// 构建 spanId 到节点的映射
var nodeMap = new Map();
data.forEach(item => {
nodeMap.set(item.logDTO.spanId, item);
});
// 构建图的根节点列表
var roots = [];
data.forEach(item => {
const log = item.logDTO;
const parentSpanId = log.parentSpanId;
if (parentSpanId && nodeMap.has(parentSpanId)) {
const parent = nodeMap.get(parentSpanId);
if (!parent.children) {
parent.children = [];
}
parent.children.push(item);
} else {
roots.push(item);
}
});
// 递归生成 Treeview 格式的节点
function buildTreeNode(node) {
var log = node.logDTO;
var treeNode = {
text: log.opName,
nodes: [],
metaDetail: node
};
if (node.children) {
node.children.forEach(child => {
treeNode.nodes.push(buildTreeNode(child));
});
}
if (treeNode.nodes.length === 0) {
delete treeNode.nodes;
}
return treeNode;
}
});
return roots.map(root => buildTreeNode(root));
}
function buildTree(data) {
// 构建 spanId 到节点的映射
var nodeMap = new Map();
for (const item of data) {
nodeMap.set(item.logDTO.spanId, item);
}
// 构建图的根节点列表
var roots = [];
for (const item of data) {
const log = item.logDTO;
const parentSpanId = log.parentSpanId;
if (parentSpanId && nodeMap.has(parentSpanId)) {
const parent = nodeMap.get(parentSpanId);
if (!parent.children) {
parent.children = [];
}
parent.children.push(item);
} else {
roots.push(item);
}
}
// 递归生成 Treeview 格式的节点
function buildTreeNode(node) {
var log = node.logDTO;
var treeNode = {
text: log.opName,
nodes: [],
metaDetail: node
};
if (node.children) {
node.children.forEach(child => {
treeNode.nodes.push(buildTreeNode(child));
});
}
if (treeNode.nodes.length === 0) {
delete treeNode.nodes;
}
return treeNode;
}
return roots.map(root => buildTreeNode(root));
}

@dosubot dosubot bot added size:XL This PR changes 500-999 lines, ignoring generated files. and removed size:L This PR changes 100-499 lines, ignoring generated files. labels May 24, 2024
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: 7

Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between 913f1e0 and 741c6d4.
Files selected for processing (3)
  • apollo-portal/src/main/resources/static/audit_log_trace_detail.html (5 hunks)
  • apollo-portal/src/main/resources/static/scripts/controller/AuditLogMenuController.js (1 hunks)
  • apollo-portal/src/main/resources/static/scripts/controller/AuditLogTraceDetailController.js (1 hunks)
Files not reviewed due to errors (1)
  • apollo-portal/src/main/resources/static/scripts/controller/AuditLogTraceDetailController.js (no review received)
Files skipped from review as they are similar to previous changes (1)
  • apollo-portal/src/main/resources/static/audit_log_trace_detail.html

Comment on lines +45 to +48
$scope.showOptions = function (query) {
$scope.options = [];
searchAuditLogs(query);
};
Copy link
Contributor

@coderabbitai coderabbitai bot May 24, 2024

Choose a reason for hiding this comment

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

Consider using arrow functions for cleaner and more concise syntax.

- $scope.showOptions = function (query) {
-     $scope.options = [];
-     searchAuditLogs(query);
- };
+ $scope.showOptions = (query) => {
+     $scope.options = [];
+     searchAuditLogs(query);
+ };

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
$scope.showOptions = function (query) {
$scope.options = [];
searchAuditLogs(query);
};
$scope.showOptions = (query) => {
$scope.options = [];
searchAuditLogs(query);
};

Copy link
Contributor Author

Choose a reason for hiding this comment

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

😅

Copy link
Contributor

Choose a reason for hiding this comment

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

@BlackBear2003, glad to see the suggestion got a smile! 😄 If you have any questions or need further assistance, feel free to ask. Happy coding!

Comment on lines +63 to +65
AuditLogService.get_properties().then(function (result) {
$scope.auditEnabled = result.enabled;
});
Copy link
Contributor

Choose a reason for hiding this comment

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

Use arrow function for a more concise and modern approach.

- function getAuditProperties() {
-     AuditLogService.get_properties().then(function (result) {
-         $scope.auditEnabled = result.enabled;
-     });
- }
+ const getAuditProperties = () => {
+     AuditLogService.get_properties().then((result) => {
+         $scope.auditEnabled = result.enabled;
+     });
+ };

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
AuditLogService.get_properties().then(function (result) {
$scope.auditEnabled = result.enabled;
});
const getAuditProperties = () => {
AuditLogService.get_properties().then((result) => {
$scope.auditEnabled = result.enabled;
});
};

$window.location.href = AppUtil.prefixPath() + "/audit_log_trace_detail.html?#traceId=" + traceId;
}
function goToTraceDetailsPage(traceId) {
$window.location.href = AppUtil.prefixPath() + "/audit_log_trace_detail.html?#traceId=" + traceId;
Copy link
Contributor

Choose a reason for hiding this comment

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

Use template literals for string concatenation to improve readability and maintainability.

- $window.location.href = AppUtil.prefixPath() + "/audit_log_trace_detail.html?#traceId=" + traceId;
+ $window.location.href = `${AppUtil.prefixPath()}/audit_log_trace_detail.html?#traceId=${traceId}`;

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
$window.location.href = AppUtil.prefixPath() + "/audit_log_trace_detail.html?#traceId=" + traceId;
$window.location.href = `${AppUtil.prefixPath()}/audit_log_trace_detail.html?#traceId=${traceId}`;

Comment on lines +69 to +77
AuditLogService.find_all_logs($scope.page, PAGE_SIZE).then(function (result) {
if (!result || result.length < PAGE_SIZE) {
$scope.hasLoadAll = true;
}
if (endDate !== null) {
$scope.endDateFmt = new Date(endDate).Format("yyyy-MM-dd hh:mm:ss.S");
if (result.length === 0) {
return;
}
$scope.auditLogList = [];
$scope.page = 0;
$scope.opName = opName;
$scope.startDate = startDate;
$scope.endDate = endDate;
$scope.auditLogList = $scope.auditLogList.concat(result);
});
Copy link
Contributor

Choose a reason for hiding this comment

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

Refactor to use arrow functions for asynchronous operations.

- function initSearchingMenu() {
-     AuditLogService.find_all_logs($scope.page, PAGE_SIZE).then(function (result) {
-         if (!result || result.length < PAGE_SIZE) {
-             $scope.hasLoadAll = true;
-         }
-         if (result.length === 0) {
-             return;
-         }
-         $scope.auditLogList = $scope.auditLogList.concat(result);
-     });
- }
+ const initSearchingMenu = () => {
+     AuditLogService.find_all_logs($scope.page, PAGE_SIZE).then((result) => {
+         if (!result || result.length < PAGE_SIZE) {
+             $scope.hasLoadAll = true;
+         }
+         if (result.length === 0) {
+             return;
+         }
+         $scope.auditLogList = $scope.auditLogList.concat(result);
+     });
+ };

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
AuditLogService.find_all_logs($scope.page, PAGE_SIZE).then(function (result) {
if (!result || result.length < PAGE_SIZE) {
$scope.hasLoadAll = true;
}
if (endDate !== null) {
$scope.endDateFmt = new Date(endDate).Format("yyyy-MM-dd hh:mm:ss.S");
if (result.length === 0) {
return;
}
$scope.auditLogList = [];
$scope.page = 0;
$scope.opName = opName;
$scope.startDate = startDate;
$scope.endDate = endDate;
$scope.auditLogList = $scope.auditLogList.concat(result);
});
const initSearchingMenu = () => {
AuditLogService.find_all_logs($scope.page, PAGE_SIZE).then((result) => {
if (!result || result.length < PAGE_SIZE) {
$scope.hasLoadAll = true;
}
if (result.length === 0) {
return;
}
$scope.auditLogList = $scope.auditLogList.concat(result);
});
};

Comment on lines +50 to +53
$scope.selectOption = function (option) {
$scope.opName = option.opName;
$scope.showSearchDropdown = false;
};
Copy link
Contributor

Choose a reason for hiding this comment

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

Convert this function expression to an arrow function for consistency and improved readability.

- $scope.selectOption = function (option) {
-     $scope.opName = option.opName;
-     $scope.showSearchDropdown = false;
- };
+ $scope.selectOption = (option) => {
+     $scope.opName = option.opName;
+     $scope.showSearchDropdown = false;
+ };

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
$scope.selectOption = function (option) {
$scope.opName = option.opName;
$scope.showSearchDropdown = false;
};
$scope.selectOption = (option) => {
$scope.opName = option.opName;
$scope.showSearchDropdown = false;
};

Comment on lines +98 to +106
).then(function (result) {
if (!result || result.length < PAGE_SIZE) {
$scope.hasLoadAll = true;
}
if (result.length === 0) {
return;
}
$scope.auditLogList = $scope.auditLogList.concat(result);
});
Copy link
Contributor

Choose a reason for hiding this comment

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

Convert this function to use arrow syntax for consistency and modern JavaScript practices.

- function searchByOpNameAndDate(opName, startDate, endDate) {
-     if (startDate !== null) {
-         $scope.startDateFmt = new Date(startDate).Format("yyyy-MM-dd hh:mm:ss.S");
-     }
-     if (endDate !== null) {
-         $scope.endDateFmt = new Date(endDate).Format("yyyy-MM-dd hh:mm:ss.S");
-     }
-     $scope.auditLogList = [];
-     $scope.page = 0;
-     $scope.opName = opName;
-     $scope.startDate = startDate;
-     $scope.endDate = endDate;
-     AuditLogService.find_logs_by_opName(
-         $scope.opName,
-         $scope.startDateFmt,
-         $scope.endDateFmt,
-         $scope.page,
-         PAGE_SIZE
-     ).then(function (result) {
-         if (!result || result.length < PAGE_SIZE) {
-             $scope.hasLoadAll = true;
-         }
-         if (result.length === 0) {
-             return;
-         }
-         $scope.auditLogList = $scope.auditLogList.concat(result);
-     });
- }
+ const searchByOpNameAndDate = (opName, startDate, endDate) => {
+     if (startDate !== null) {
+         $scope.startDateFmt = new Date(startDate).Format("yyyy-MM-dd hh:mm:ss.S");
+     }
+     if (endDate !== null) {
+         $scope.endDateFmt = new Date(endDate).Format("yyyy-MM-dd hh:mm:ss.S");
+     }
+     $scope.auditLogList = [];
+     $scope.page = 0;
+     $scope.opName = opName;
+     $scope.startDate = startDate;
+     $scope.endDate = endDate;
+     AuditLogService.find_logs_by_opName(
+         $scope.opName,
+         $scope.startDateFmt,
+         $scope.endDateFmt,
+         $scope.page,
+         PAGE_SIZE
+     ).then((result) => {
+         if (!result || result.length < PAGE_SIZE) {
+             $scope.hasLoadAll = true;
+         }
+         if (result.length === 0) {
+             return;
+         }
+         $scope.auditLogList = $scope.auditLogList.concat(result);
+     });
+ };

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
).then(function (result) {
if (!result || result.length < PAGE_SIZE) {
$scope.hasLoadAll = true;
}
if (result.length === 0) {
return;
}
$scope.auditLogList = $scope.auditLogList.concat(result);
});
).then((result) => {
if (!result || result.length < PAGE_SIZE) {
$scope.hasLoadAll = true;
}
if (result.length === 0) {
return;
}
$scope.auditLogList = $scope.auditLogList.concat(result);
});

Comment on lines +141 to +152
AuditLogService.search_by_name_or_type_or_operator(query, 0, 20).then(function (result) {
result.forEach(function (log) {
var optionDisplay = log.opName + '-(' + log.opType + ').by:' + log.operator;
var option = {
id: log.id,
display: optionDisplay,
opName: log.opName
};
$scope.options.push(option);
});
}
$scope.showSearchDropdown = $scope.options.length > 0;
});
Copy link
Contributor

Choose a reason for hiding this comment

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

Prefer using for...of instead of forEach for better performance and readability.

- result.forEach(function (log) {
-     var optionDisplay = log.opName + '-(' + log.opType + ').by:' + log.operator;
-     var option = {
-         id: log.id,
-         display: optionDisplay,
-         opName: log.opName
-     };
-     $scope.options.push(option);
- });
+ for (const log of result) {
+     const optionDisplay = `${log.opName}-(${log.opType}).by:${log.operator}`;
+     const option = {
+         id: log.id,
+         display: optionDisplay,
+         opName: log.opName
+     };
+     $scope.options.push(option);
+ }

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
AuditLogService.search_by_name_or_type_or_operator(query, 0, 20).then(function (result) {
result.forEach(function (log) {
var optionDisplay = log.opName + '-(' + log.opType + ').by:' + log.operator;
var option = {
id: log.id,
display: optionDisplay,
opName: log.opName
};
$scope.options.push(option);
});
}
$scope.showSearchDropdown = $scope.options.length > 0;
});
AuditLogService.search_by_name_or_type_or_operator(query, 0, 20).then(function (result) {
for (const log of result) {
const optionDisplay = `${log.opName}-(${log.opType}).by:${log.operator}`;
const option = {
id: log.id,
display: optionDisplay,
opName: log.opName
};
$scope.options.push(option);
}
$scope.showSearchDropdown = $scope.options.length > 0;
});

Copy link
Member

@nobodyiam nobodyiam left a comment

Choose a reason for hiding this comment

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

LGTM

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label May 25, 2024
@nobodyiam nobodyiam merged commit 39cd381 into apolloconfig:master May 25, 2024
7 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators May 25, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lgtm This PR has been approved by a maintainer size:XL This PR changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants