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

feat: quick preset editor values must be set on creation (#2028) #2039

Merged

Conversation

stolpeo
Copy link
Contributor

@stolpeo stolpeo commented Oct 21, 2024

Summary by CodeRabbit

  • New Features

    • Introduced a computed property for filtering quick presets to ensure only complete options are available.
    • Added a warning message for incomplete query settings in the user interface.
  • Enhancements

    • Updated preset management to include a new property for better attribute handling in preset categories.
  • Bug Fixes

    • Ensured that only complete presets are considered during selection, improving the robustness of the component functionality.

@stolpeo stolpeo linked an issue Oct 21, 2024 that may be closed by this pull request
Copy link
Contributor

coderabbitai bot commented Oct 21, 2024

Walkthrough

The changes across the components QuickPresets.vue, SetEditor.vue, and SetQuickPresets.vue introduce new computed properties and modify existing functionalities to improve the handling of quick presets and preset categories. QuickPresets.vue adds a computed property to filter complete presets, while SetEditor.vue updates the payload structure to include a new inheritance property for certain preset categories. Additionally, SetQuickPresets.vue introduces a computed property to check for incomplete query settings, enhancing user feedback.

Changes

File Path Change Summary
frontend/src/variants/components/FilterForm/QuickPresets.vue Added computed property quickPresetsComplete to filter complete presets; modified refreshQuickPreset to use this property.
frontend/src/variants/components/QueryPresets/SetEditor.vue Updated handleAddClicked to include inheritance: null in the payload for frequencypresets and quickpresets.
frontend/src/variants/components/QueryPresets/SetQuickPresets.vue Added computed property isIncomplete to check for missing keys in querySettings and conditionally render a warning message.

Poem

🐰 In the garden of presets, we hop and we play,
With filters and checks, we brighten the day.
A new quickPresetsComplete, oh what a delight,
Ensuring all keys are present and right!
So gather your settings, let nothing be amiss,
For a complete little query is pure rabbit bliss! 🥕✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@stolpeo stolpeo enabled auto-merge (squash) October 21, 2024 14:26
Copy link

deps-report 🔍

Commit scanned: ee015f5
ℹ️ Python version 3.10 is used by your project but the latest version is 3.13.

Vulnerable dependencies

4 dependencies have vulnerabilities 😱
Dependency Advisory Versions impacted
djangorestframework (transitive) Affected versions of the package djangorestframework are vulnerable to Cross-site Scripting (XSS) via the break_long_headers template filter due to improper input sanitization before splitting and joining with
tags.
<3.15.2
jinja2 (transitive) In Jinja2, the from_string function is prone to Server Side Template Injection (SSTI) where it takes the source parameter as a template object, renders it, and then returns it. The attacker can exploit it with INJECTION COMMANDS in a URI. NOTE: The maintainer and multiple third parties believe that this vulnerability isn't valid because users shouldn't use untrusted templates without sandboxing. >=0
setuptools (transitive) Affected versions of Setuptools allow for remote code execution via its download functions. These functions, which are used to download packages from URLs provided by users or retrieved from package index servers, are susceptible to code injection. If these functions are exposed to user-controlled inputs, such as package URLs, they can execute arbitrary commands on the system. <70.0.0
sqlalchemy Sqlalchemy 2.0.0b1 avoids leaking cleartext passwords to the open for careless uses of str(engine.URL()) in logs and prints. sqlalchemy/sqlalchemy#8563 <2.0.0b1

Outdated dependencies

51 outdated dependencies found (including 20 outdated major versions)😢
Dependency Installed version Latest version
alabaster (transitive) 0.7.16 1.0.0
argon2-cffi (transitive) 21.3.0 23.1.0
billiard (transitive) 3.6.4.0 4.2.1
crispy-bootstrap4 (transitive) 2022.1 2024.10
django 3.2.25 5.1.2
django-model-utils (transitive) 4.3.1 5.0.0
django-rest-knox (transitive) 4.2.0 5.0.2
django-sodar-core 0.13.4 1.0.2
jsonschema-specifications (transitive) 2023.12.1 2024.10.1
markupsafe (transitive) 2.1.5 3.0.2
mistune (transitive) 2.0.5 3.0.2
packaging (transitive) 23.2 24.1
pillow (transitive) 10.4.0 11.0.0
protobuf 3.20.3 5.28.2
setuptools (transitive) 67.6.1 75.2.0
sphinx (transitive) 6.2.1 8.1.3
sphinx-rtd-theme (transitive) 1.2.2 3.0.1
sqlalchemy 1.4.54 2.0.36
unidecode (transitive) 0.4.21 1.3.8
xmlschema (transitive) 2.5.1 3.4.2
Dependency Installed version Latest version
anyio (transitive) 4.6.0 4.6.2.post1
botocore (transitive) 1.35.36 1.35.44
celery (transitive) 5.2.7 5.4.0
charset-normalizer (transitive) 3.3.2 3.4.0
coverage (dev,transitive) 7.6.1 7.6.4
cryptography (transitive) 43.0.1 43.0.3
django-autocomplete-light (transitive) 3.9.4 3.11.0
django-crispy-forms (transitive) 2.0 2.3
django-db-file-storage (transitive) 0.5.5 0.5.6.1
django-debug-toolbar 4.3.0 4.4.6
django-environ (transitive) 0.10.0 0.11.2
django-iconify (transitive) 0.1.1 0.4
django-plugins-bihealth 0.4.0 0.5.2
django-postgres-copy 2.3.7 2.7.6
djangorestframework (transitive) 3.14.0 3.15.2
docutils (transitive) 0.18.1 0.21.2
drf-keyed-list-bihealth 0.1.1 0.2.1
faker 30.6.0 30.8.0
markdown (transitive) 3.4.1 3.7
mypy-protobuf (dev) 3.3.0 3.6.0
psutil 6.0.0 6.1.0
psycopg2 (transitive) 2.9.9 2.9.10
psycopg2-binary (transitive) 2.9.9 2.9.10
pydantic-core (transitive) 2.23.4 2.24.2
requests-http-signature 0.2.0 0.7.1
rules (transitive) 3.3 3.5
trio (dev,transitive) 0.26.2 0.27.0
types-psycopg2 (dev,transitive) 2.9.21.20240819 2.9.21.20241019
versioneer (transitive) 0.28 0.29
wheel (transitive) 0.40.0 0.44.0
xmltodict (transitive) 0.13.0 0.14.2

Logs

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

🧹 Outside diff range and nitpick comments (3)
frontend/src/variants/components/QueryPresets/SetQuickPresets.vue (2)

4-4: LGTM! Consider a minor optimization.

The new isIncomplete computed property effectively checks for the completeness of query settings, aligning well with the PR objective. The implementation is correct and efficient.

Consider using Object.keys(props.querySettings).length to quickly check if all required keys are present, potentially improving performance for larger objects:

const requiredKeys = ['inheritance', 'frequency', 'impact', 'quality', 'chromosome', 'flagsetc'];
const isIncomplete = computed(() => 
  Object.keys(props.querySettings).length !== requiredKeys.length || 
  requiredKeys.some(key => !props.querySettings[key])
);

This approach first checks the total number of keys, potentially avoiding the need to iterate through all keys for incomplete objects.

Also applies to: 21-35


41-44: LGTM! Consider enhancing accessibility.

The new warning message effectively informs users about incomplete settings and their implications. It's well-integrated with the isIncomplete computed property and uses appropriate Bootstrap classes for styling.

To enhance accessibility, consider adding an aria-live attribute to the warning div:

- <div class="alert alert-warning" v-if="isIncomplete">
+ <div class="alert alert-warning" v-if="isIncomplete" aria-live="polite">

This change ensures that screen readers announce the warning when it appears, improving the experience for users relying on assistive technologies.

frontend/src/variants/components/FilterForm/QuickPresets.vue (1)

326-348: LGTM! Consider a minor optimization.

The new quickPresetsComplete computed property effectively filters out incomplete presets, improving the robustness of the component. The implementation is clear and aligns with the intended functionality.

Consider using Object.entries(props.quickPresets).reduce() for a more concise implementation:

const quickPresetsComplete = computed(() => {
  const requiredKeys = ['inheritance', 'frequency', 'impact', 'quality', 'chromosomes', 'flagsetc'];
  return Object.entries(props.quickPresets).reduce((result, [name, preset]) => {
    if (requiredKeys.every(key => preset[key])) {
      result[name] = preset;
    }
    return result;
  }, {});
});

This approach reduces the number of lines and eliminates the need for the skip variable.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 6a7b1f7 and ee015f5.

📒 Files selected for processing (3)
  • frontend/src/variants/components/FilterForm/QuickPresets.vue (2 hunks)
  • frontend/src/variants/components/QueryPresets/SetEditor.vue (0 hunks)
  • frontend/src/variants/components/QueryPresets/SetQuickPresets.vue (2 hunks)
💤 Files with no reviewable changes (1)
  • frontend/src/variants/components/QueryPresets/SetEditor.vue
🧰 Additional context used
🔇 Additional comments (3)
frontend/src/variants/components/QueryPresets/SetQuickPresets.vue (1)

Line range hint 1-180: Overall, excellent implementation addressing the PR objective.

The changes in this file effectively ensure that quick preset editor values are set on creation. The new isIncomplete computed property and the warning message work together to provide clear feedback to users, enhancing the overall user experience.

The suggestions provided for optimization and accessibility are minor improvements to an already solid implementation. Great job!

frontend/src/variants/components/FilterForm/QuickPresets.vue (2)

393-393: LGTM! Consistent use of the new computed property.

The template has been correctly updated to use quickPresetsComplete instead of quickPresets. This change ensures that only complete presets are displayed in the dropdown, which is consistent with the introduction of the quickPresetsComplete computed property.


Line range hint 326-393: Summary: Improved handling of quick presets

The changes in this file effectively enhance the handling of quick presets by introducing a filtering mechanism for incomplete presets. The new quickPresetsComplete computed property ensures that only fully defined presets are used in the component, which aligns with the PR objective of setting quick preset editor values on creation.

These modifications improve the robustness of the component and enhance the user experience by preventing the selection of incomplete presets. The implementation is consistent throughout the component, with the template correctly updated to use the new computed property.

Overall, these changes represent a valuable improvement to the QuickPresets component.

@stolpeo stolpeo merged commit b945adb into main Oct 21, 2024
17 checks passed
@stolpeo stolpeo deleted the 2028-quick-preset-editor-must-force-values-to-be-set-on-creation branch October 21, 2024 14:40
Copy link

codecov bot commented Oct 21, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91%. Comparing base (6a7b1f7) to head (ee015f5).
Report is 1 commits behind head on main.

Additional details and impacted files
@@          Coverage Diff          @@
##            main   #2039   +/-   ##
=====================================
  Coverage     91%     91%           
=====================================
  Files        674     674           
  Lines      38408   38408           
=====================================
  Hits       35067   35067           
  Misses      3341    3341           

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.

quick preset editor must force values to be set on creation
1 participant