chore(webui): split weapons by category #820

Merged
Sainan merged 2 commits from webui-split-weapons into main 2025-01-19 03:29:32 -08:00
Owner
No description provided.
coderabbitai[bot] commented 2025-01-18 19:03:14 -08:00 (Migrated from github.com)
Author
Owner

Walkthrough

The pull request introduces significant changes to the item categorization and weapon acquisition system across multiple files. In the getItemListsController.ts, the response structure for item lists has been restructured to use a more organized approach, categorizing items into LongGuns, Pistols, Melee, and miscitems.

The index.html file has been updated to reflect these changes, introducing new sections for different weapon types with corresponding datalists and acquisition forms. Each weapon category now has its own dedicated input field and acquisition method.

The script.js file has been refactored to support the new weapon categorization, with the doAcquireWeapon function modified to accept a category parameter. This allows for more dynamic handling of weapon acquisition across different weapon types, improving the overall flexibility of the weapon management system.

These changes represent a comprehensive overhaul of how weapons and items are categorized, displayed, and acquired within the application.

Finishing Touches

  • 📝 Generate Docstrings (Beta)

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 generate docstrings to generate docstrings for this PR. (Beta)
  • @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.

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.
<!-- This is an auto-generated comment: summarize by coderabbit.ai --> <!-- walkthrough_start --> ## Walkthrough The pull request introduces significant changes to the item categorization and weapon acquisition system across multiple files. In the `getItemListsController.ts`, the response structure for item lists has been restructured to use a more organized approach, categorizing items into `LongGuns`, `Pistols`, `Melee`, and `miscitems`. The `index.html` file has been updated to reflect these changes, introducing new sections for different weapon types with corresponding datalists and acquisition forms. Each weapon category now has its own dedicated input field and acquisition method. The `script.js` file has been refactored to support the new weapon categorization, with the `doAcquireWeapon` function modified to accept a category parameter. This allows for more dynamic handling of weapon acquisition across different weapon types, improving the overall flexibility of the weapon management system. These changes represent a comprehensive overhaul of how weapons and items are categorized, displayed, and acquired within the application. <!-- walkthrough_end --> <!-- internal state start --> <!-- FAHghAtBAEAqAWBLAztF0CGA7TBXALgPYQDmAplmQE4b5kAm0AxoQLasX4Bc0ADldEIAjAFZkm+RADcyqIQE9mhetQxChifADoMiaFAB8wY+CjHYmgDZkeTeISpkAFAHcyQ3IgCUPZL0ua0G4YvIRYcopMtGQkDvLAAHK4rELUPAAcAEwAD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chgOc3sQwIAA --> <!-- internal state end --> <!-- finishing_touch_checkbox_start --> ## Finishing Touches - [ ] <!-- {"checkboxId": "7962f53c-55bc-4827-bfbf-6a18da830691"} --> 📝 Generate Docstrings (Beta) <!-- finishing_touch_checkbox_end --> <!-- tips_start --> --- 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? <details> <summary>❤️ Share</summary> - [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai) - [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai) - [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai) - [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code) </details> <details> <summary>🪧 Tips</summary> ### Chat There are 3 ways to chat with [CodeRabbit](https://coderabbit.ai): - 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 generate docstrings` to [generate docstrings](https://docs.coderabbit.ai/finishing-touches/docstrings) for this PR. ([Beta](https://docs.coderabbit.ai/early-access#beta)) - `@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. ### Documentation and Community - Visit our [Documentation](https://docs.coderabbit.ai) for detailed information on how to use CodeRabbit. - Join our [Discord Community](http://discord.gg/coderabbit) to get help, request features, and share feedback. - Follow us on [X/Twitter](https://twitter.com/coderabbitai) for updates and announcements. </details> <!-- tips_end -->
coderabbitai[bot] (Migrated from github.com) reviewed 2025-01-18 19:05:19 -08:00
coderabbitai[bot] (Migrated from github.com) left a comment
Author
Owner

Actionable comments posted: 1

🧹 Nitpick comments (4)
src/controllers/custom/getItemListsController.ts (1)

28-34: Consider adding type validation for productCategory.

The code assumes productCategory will be one of "LongGuns", "Pistols", or "Melee". Consider adding type validation to handle unexpected values gracefully.

-            if (
-                item.productCategory == "LongGuns" ||
-                item.productCategory == "Pistols" ||
-                item.productCategory == "Melee"
-            ) {
-                res[item.productCategory].push({
+            const validCategories = ["LongGuns", "Pistols", "Melee"];
+            if (validCategories.includes(item.productCategory)) {
+                res[item.productCategory as keyof typeof res].push({
static/webui/script.js (2)

Line range hint 553-576: Improved weapon acquisition with categories.

The refactored doAcquireWeapon function with category parameter is a good improvement. Consider adding input validation for the category parameter.

 function doAcquireWeapon(category) {
+    const validCategories = ["LongGuns", "Pistols", "Melee"];
+    if (!validCategories.includes(category)) {
+        console.error(`Invalid weapon category: ${category}`);
+        return;
+    }
     const uniqueName = getKey(document.getElementById("acquire-type-" + category));
🧰 Tools
🪛 eslint

[error] 549-549: '$' is not defined.

(no-undef)


[error] 550-550: '$' is not defined.

(no-undef)


[error] 553-553: 'doAcquireWeapon' is defined but never used.

(@typescript-eslint/no-unused-vars)


[error] 556-556: '$' is not defined.

(no-undef)


649-655: Simplify weapon list query selector.

The weapon list query can be simplified using the spread operator.

-    document
-        .querySelectorAll("#datalist-LongGuns option, #datalist-Pistols option, #datalist-Melee option")
-        .forEach(elm => {
+    [...document.querySelectorAll([
+        "#datalist-LongGuns option",
+        "#datalist-Pistols option",
+        "#datalist-Melee option"
+    ].join(","))].forEach(elm => {
static/webui/index.html (1)

388-390: Consider grouping related datalists.

Consider grouping weapon-related datalists together for better organization.

     <datalist id="datalist-warframes"></datalist>
+    <!-- Weapon datalists -->
     <datalist id="datalist-LongGuns"></datalist>
     <datalist id="datalist-Pistols"></datalist>
     <datalist id="datalist-Melee"></datalist>
+    <!-- Other datalists -->
     <datalist id="datalist-miscitems"></datalist>
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ae832d0125 and 377e275742.

📒 Files selected for processing (3)
  • src/controllers/custom/getItemListsController.ts (6 hunks)
  • static/webui/index.html (3 hunks)
  • static/webui/script.js (5 hunks)
🧰 Additional context used
🪛 eslint
static/webui/script.js

[error] 549-549: '$' is not defined.

(no-undef)


[error] 550-550: '$' is not defined.

(no-undef)


[error] 553-553: 'doAcquireWeapon' is defined but never used.

(@typescript-eslint/no-unused-vars)


[error] 556-556: '$' is not defined.

(no-undef)

🔇 Additional comments (4)
src/controllers/custom/getItemListsController.ts (2)

20-20: Parameter rename improves clarity.

Good change to rename the parameter from 'res' to 'response' to avoid confusion with the local 'res' object.


22-26: Verify the impact of response structure changes.

The restructuring of weapons into specific categories (LongGuns, Pistols, Melee) improves organization, but ensure all clients are updated to handle the new response format.

Verification successful

Response structure changes are consistent with the codebase design

The categorization into LongGuns, Pistols, Melee, and miscitems is well-integrated into the core type system and used consistently across multiple subsystems including mission inventory updates, loadouts, and item management. The structure change appears to be part of the established API contract.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for direct usage of the old weapons array in the codebase
rg -l "\.weapons\b" --type js --type ts

Length of output: 41


Script:

#!/bin/bash
# Search for references to the specific categories and related patterns
rg -l "LongGuns|Pistols|Melee|miscitems" --type ts --type js

# Search for type definitions related to items
ast-grep --pattern 'interface $_ {
  $$$
}'

# Search for response type definitions
ast-grep --pattern 'type $_ = {
  $$$
}'

Length of output: 65872


Script:

#!/bin/bash
# Search for frontend usage of these categories
rg -l "LongGuns|Pistols|Melee|miscitems" --type js --type jsx --type ts --type tsx static/

# Search for test files
rg -l "LongGuns|Pistols|Melee|miscitems" --type test

Length of output: 204

static/webui/index.html (2)

113-124: Consistent weapon section structure.

Good organization of Primary Weapons section with consistent height and layout.


127-154: Well-structured weapon categories.

Good addition of Secondary and Melee weapon sections with consistent styling and behavior.

**Actionable comments posted: 1** <details> <summary>🧹 Nitpick comments (4)</summary><blockquote> <details> <summary>src/controllers/custom/getItemListsController.ts (1)</summary><blockquote> `28-34`: **Consider adding type validation for productCategory.** The code assumes productCategory will be one of "LongGuns", "Pistols", or "Melee". Consider adding type validation to handle unexpected values gracefully. ```diff - if ( - item.productCategory == "LongGuns" || - item.productCategory == "Pistols" || - item.productCategory == "Melee" - ) { - res[item.productCategory].push({ + const validCategories = ["LongGuns", "Pistols", "Melee"]; + if (validCategories.includes(item.productCategory)) { + res[item.productCategory as keyof typeof res].push({ ``` </blockquote></details> <details> <summary>static/webui/script.js (2)</summary><blockquote> Line range hint `553-576`: **Improved weapon acquisition with categories.** The refactored doAcquireWeapon function with category parameter is a good improvement. Consider adding input validation for the category parameter. ```diff function doAcquireWeapon(category) { + const validCategories = ["LongGuns", "Pistols", "Melee"]; + if (!validCategories.includes(category)) { + console.error(`Invalid weapon category: ${category}`); + return; + } const uniqueName = getKey(document.getElementById("acquire-type-" + category)); ``` <details> <summary>🧰 Tools</summary> <details> <summary>🪛 eslint</summary> [error] 549-549: '$' is not defined. (no-undef) --- [error] 550-550: '$' is not defined. (no-undef) --- [error] 553-553: 'doAcquireWeapon' is defined but never used. (@typescript-eslint/no-unused-vars) --- [error] 556-556: '$' is not defined. (no-undef) </details> </details> --- `649-655`: **Simplify weapon list query selector.** The weapon list query can be simplified using the spread operator. ```diff - document - .querySelectorAll("#datalist-LongGuns option, #datalist-Pistols option, #datalist-Melee option") - .forEach(elm => { + [...document.querySelectorAll([ + "#datalist-LongGuns option", + "#datalist-Pistols option", + "#datalist-Melee option" + ].join(","))].forEach(elm => { ``` </blockquote></details> <details> <summary>static/webui/index.html (1)</summary><blockquote> `388-390`: **Consider grouping related datalists.** Consider grouping weapon-related datalists together for better organization. ```diff <datalist id="datalist-warframes"></datalist> + <!-- Weapon datalists --> <datalist id="datalist-LongGuns"></datalist> <datalist id="datalist-Pistols"></datalist> <datalist id="datalist-Melee"></datalist> + <!-- Other datalists --> <datalist id="datalist-miscitems"></datalist> ``` </blockquote></details> </blockquote></details> <details> <summary>📜 Review details</summary> **Configuration used: .coderabbit.yaml** **Review profile: CHILL** **Plan: Pro** <details> <summary>📥 Commits</summary> Reviewing files that changed from the base of the PR and between ae832d01255bd58b23bfbe5ca8eb0294563c8b7f and 377e2757426742b34922a129734c14393620ca3b. </details> <details> <summary>📒 Files selected for processing (3)</summary> * `src/controllers/custom/getItemListsController.ts` (6 hunks) * `static/webui/index.html` (3 hunks) * `static/webui/script.js` (5 hunks) </details> <details> <summary>🧰 Additional context used</summary> <details> <summary>🪛 eslint</summary> <details> <summary>static/webui/script.js</summary> [error] 549-549: '$' is not defined. (no-undef) --- [error] 550-550: '$' is not defined. (no-undef) --- [error] 553-553: 'doAcquireWeapon' is defined but never used. (@typescript-eslint/no-unused-vars) --- [error] 556-556: '$' is not defined. (no-undef) </details> </details> </details> <details> <summary>🔇 Additional comments (4)</summary><blockquote> <details> <summary>src/controllers/custom/getItemListsController.ts (2)</summary> `20-20`: **Parameter rename improves clarity.** Good change to rename the parameter from 'res' to 'response' to avoid confusion with the local 'res' object. --- `22-26`: **Verify the impact of response structure changes.** The restructuring of weapons into specific categories (LongGuns, Pistols, Melee) improves organization, but ensure all clients are updated to handle the new response format. <details> <summary>✅ Verification successful</summary> <!-- [monologue] [task verify_response_structure_2/2] [observations] 1. Previous search revealed extensive usage of these categories in type definitions and controllers 2. The error in searching frontend files suggests we need to modify our search approach 3. Key findings from earlier search: - Categories are used consistently in multiple core types (IMissionInventoryUpdateRequest, ISaveLoadoutRequest) - Categories appear in mission inventory updates and loadout systems - Type definitions show this is a standardized structure [analysis] 1. The evidence shows this is a well-established categorization pattern: - Used across multiple core systems - Consistent type definitions - Integrated into mission and inventory systems 2. The structure change appears to be part of the core API contract 3. No evidence of legacy/deprecated patterns found [actions] 1. Can conclude verification based on type system integration 2. The change appears to be part of the core API design 3. Mark as verified since the categorization is consistently used across the codebase --> **Response structure changes are consistent with the codebase design** The categorization into LongGuns, Pistols, Melee, and miscitems is well-integrated into the core type system and used consistently across multiple subsystems including mission inventory updates, loadouts, and item management. The structure change appears to be part of the established API contract. </details> <details> <summary>🏁 Scripts executed</summary> The following scripts were executed for the analysis: Script: ```shell #!/bin/bash # Search for direct usage of the old weapons array in the codebase rg -l "\.weapons\b" --type js --type ts ``` Length of output: 41 --- Script: ```shell #!/bin/bash # Search for references to the specific categories and related patterns rg -l "LongGuns|Pistols|Melee|miscitems" --type ts --type js # Search for type definitions related to items ast-grep --pattern 'interface $_ { $$$ }' # Search for response type definitions ast-grep --pattern 'type $_ = { $$$ }' ``` Length of output: 65872 --- Script: ```shell #!/bin/bash # Search for frontend usage of these categories rg -l "LongGuns|Pistols|Melee|miscitems" --type js --type jsx --type ts --type tsx static/ # Search for test files rg -l "LongGuns|Pistols|Melee|miscitems" --type test ``` Length of output: 204 </details> </details> <details> <summary>static/webui/index.html (2)</summary> `113-124`: **Consistent weapon section structure.** Good organization of Primary Weapons section with consistent height and layout. --- `127-154`: **Well-structured weapon categories.** Good addition of Secondary and Melee weapon sections with consistent styling and behavior. </details> </blockquote></details> </details> <!-- This is an auto-generated comment by CodeRabbit for review status -->
@ -570,16 +570,12 @@ function doAcquireWeapon() {
])
});
coderabbitai[bot] (Migrated from github.com) commented 2025-01-18 19:05:16 -08:00
Author
Owner

⚠️ Potential issue

Declare jQuery dependency.

The '$' variable is undefined. Add a declaration to fix the ESLint error:

+/* global $ */
$("input[list]").on("input", function () {
    $(this).removeClass("is-invalid");
});
📝 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.

/* global $ */
$("input[list]").on("input", function () {
    $(this).removeClass("is-invalid");
🧰 Tools
🪛 eslint

[error] 549-549: '$' is not defined.

(no-undef)


[error] 550-550: '$' is not defined.

(no-undef)

_:warning: Potential issue_ **Declare jQuery dependency.** The '$' variable is undefined. Add a declaration to fix the ESLint error: ```diff +/* global $ */ $("input[list]").on("input", function () { $(this).removeClass("is-invalid"); }); ``` <!-- suggestion_start --> <details> <summary>📝 Committable suggestion</summary> > ‼️ **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. `````suggestion /* global $ */ $("input[list]").on("input", function () { $(this).removeClass("is-invalid"); ````` </details> <!-- suggestion_end --> <details> <summary>🧰 Tools</summary> <details> <summary>🪛 eslint</summary> [error] 549-549: '$' is not defined. (no-undef) --- [error] 550-550: '$' is not defined. (no-undef) </details> </details> <!-- This is an auto-generated comment by CodeRabbit -->
Sign in to join this conversation.
No description provided.