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

component: Improve duplication of components #11079

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ParthS007
Copy link
Contributor

@ParthS007 ParthS007 commented Feb 22, 2024

WIP

Proposed changes

closes #10896

Checklist

  • Lint and unit tests pass locally with my changes.
  • I have tested that my improvement is effective and works.
  • I have added documentation to describe my feature.
  • I have squashed my commits into logic units.
  • I have described the changes in the commit messages.

Duplicate Functionality in Dropdown

Screenshot 2024-05-10 at 11 13 14

Pre-selected Component in dropdown
Screenshot 2024-05-29 at 12 27 13

Summary by CodeRabbit

Release Notes

  • New Features

    • Enhanced duplication process for components, allowing automatic cloning of additional settings.
    • Added a direct link for users with edit permissions to duplicate existing components in the management interface.
  • Improvements

    • Updates to the form handling for language translations, improving metadata management.
    • Enhanced component selection during creation, making it easier to duplicate components with relevant attributes retained.

These updates aim to streamline workflows and improve user experience.

@ParthS007 ParthS007 changed the title component: add licence, agreement and commit _message info component: Improve duplication of components Feb 22, 2024
Copy link

codecov bot commented Feb 23, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 90.74%. Comparing base (6aee586) to head (57bf259).
Report is 353 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main   #11079      +/-   ##
==========================================
- Coverage   90.82%   90.74%   -0.08%     
==========================================
  Files         554      559       +5     
  Lines       57306    57618     +312     
  Branches     9122     9200      +78     
==========================================
+ Hits        52046    52285     +239     
- Misses       3640     3696      +56     
- Partials     1620     1637      +17     
Files Coverage Δ
weblate/trans/views/create.py 88.95% <ø> (ø)

... and 58 files with indirect coverage changes

Copy link

This pull request has been automatically marked as stale because there wasn’t any recent activity.

It will be closed soon if no further action occurs.

Thank you for your contributions!

@github-actions github-actions bot added the wontfix Nobody will work on this. label Apr 11, 2024
@github-actions github-actions bot closed this Apr 25, 2024
@ParthS007 ParthS007 reopened this Apr 29, 2024
@github-actions github-actions bot removed the wontfix Nobody will work on this. label Apr 30, 2024
@ParthS007 ParthS007 marked this pull request as ready for review May 10, 2024 09:25
@ParthS007 ParthS007 requested a review from nijel May 16, 2024 10:00
weblate/templates/component.html Outdated Show resolved Hide resolved
weblate/trans/views/create.py Outdated Show resolved Hide resolved
weblate/trans/views/create.py Show resolved Hide resolved
]
widgets = {
"source_language": SortedSelect,
"language_code_style": SortedSelect,
"license": forms.HiddenInput(),
Copy link
Member

Choose a reason for hiding this comment

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

Why this is hidden input now? This is not supposed to remove choices which were present before.

Comment on lines +197 to +198
if "category" not in kwargs:
kwargs["category"] = self.create_category(project=kwargs["project"])
Copy link
Member

Choose a reason for hiding this comment

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

It is okay for category to be not set. If you need it for a specific test, just create it there.

Suggested change
if "category" not in kwargs:
kwargs["category"] = self.create_category(project=kwargs["project"])

Copy link

This pull request has been automatically marked as stale because there wasn’t any recent activity.

It will be closed soon if no further action occurs.

Thank you for your contributions!

@github-actions github-actions bot added the wontfix Nobody will work on this. label Jul 19, 2024
@nijel nijel marked this pull request as draft July 30, 2024 10:57
@github-actions github-actions bot removed the wontfix Nobody will work on this. label Jul 31, 2024
@orangesunny orangesunny removed their request for review August 12, 2024 12:19
Copy link

This pull request has been automatically marked as stale because there wasn’t any recent activity.

It will be closed soon if no further action occurs.

Thank you for your contributions!

@github-actions github-actions bot added the wontfix Nobody will work on this. label Sep 12, 2024
Copy link

coderabbitai bot commented Sep 12, 2024

Walkthrough

The recent update introduces a feature that enhances the duplication process of components by allowing automatic cloning of additional settings, specifically in the :ref:transsection. It also adds a link in the component management interface for users to duplicate components directly. Additionally, several new fields are added to the form'sMeta` class for improved metadata handling, and the testing utilities are enhanced to support category creation. Lastly, modifications in the component selection process ensure relevant attributes from the duplicated component are preserved.

Changes

Files Change Summary
docs/changes.rst Added a section on automatic duplication of more settings during component cloning and updated :ref:subscriptions` for compatibility with password managers.
weblate/templates/component.html Added a link for users to duplicate an existing component directly in the HTML template.
weblate/trans/forms.py Introduced new fields in the Meta class to handle additional metadata related to language translation processes.
weblate/trans/tests/utils.py Added a method to create a test category and modified a function to ensure components are associated with a category.
weblate/trans/views/create.py Enhanced the CreateComponentSelection class to support component duplication, including fetching and preserving relevant attributes from the duplicated component.

Assessment against linked issues

Objective Addressed Explanation
Make duplication of components more discoverable (Issue #10896)
Duplicate key settings from the source component (Issue #10896)
Improve user interface for component duplication (Issue #10896) No visual indicators or icons were added.

Possibly related PRs


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.
    • @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.

Copy link

@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 (1)
weblate/trans/tests/utils.py (1)

170-174: Add a docstring that documents the return value.

The create_category function is missing a docstring that documents the return value.

Add a docstring that documents the return value as follows:

def create_category(self, project, **kwargs):
    """Create test category.

    :param project: Project object
    :param kwargs: Additional arguments for Category creation
    :return: Created Category object
    """
    return Category.objects.create(
        name="Test", slug="test", project=project, **kwargs
    )
Tools
Ruff

172-174: return is not documented in docstring

(DOC201)

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between ac044a3 and 7b0e24d.

Files selected for processing (5)
  • docs/changes.rst (1 hunks)
  • weblate/templates/component.html (1 hunks)
  • weblate/trans/forms.py (1 hunks)
  • weblate/trans/tests/utils.py (3 hunks)
  • weblate/trans/views/create.py (4 hunks)
Additional context used
Ruff
weblate/trans/tests/utils.py

172-174: return is not documented in docstring

(DOC201)

Additional comments not posted (8)
weblate/templates/component.html (1)

99-99: LGTM, but pre-select the current component.

The code change is approved as it adds a direct link to duplicate the component, making the duplication option more discoverable.

However, as mentioned in the past review comment, the current component should be pre-selected when clicking the link. You can set the initial value of the component field in the get_form method to pre-select the current component.

weblate/trans/views/create.py (5)

435-435: LGTM!

The code changes are approved.


467-475: LGTM!

The code changes are approved.


472-476: LGTM!

The code changes are approved.


507-510: LGTM!

The code changes are approved.


536-551: LGTM!

The code changes are approved.

weblate/trans/forms.py (2)

1689-1709: LGTM!

The new fields agreement, merge_style, commit_message, add_message, delete_message, merge_message, addon_message, pull_message are added correctly to the Meta class of ComponentSettingsForm.

Setting their widgets to forms.HiddenInput() is appropriate to hide these preset fields in the component settings form.


1701-1701: LGTM!

Changing the license field widget to forms.HiddenInput() in ComponentCreateForm is consistent with hiding preset fields in the component settings and creation forms.

@github-actions github-actions bot removed the wontfix Nobody will work on this. label Sep 13, 2024
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.

Issues when duplicating a component
2 participants