fedora-infra / anitya

A cross-distribution upstream release monitoring project
https://release-monitoring.org
GNU General Public License v2.0
236 stars 104 forks source link

Enhanced Project Creation Functionality: Dynamic Default ValuesNew feature #1741

Open NyuydineBill opened 4 months ago

NyuydineBill commented 4 months ago

This PR enhances the project creation and editing functionality by introducing dynamic default values based on the selected backend. With this enhancement, users can now enjoy a more streamlined experience when creating or editing projects, as the form fields are automatically filled with relevant default values tailored to the chosen backend.

Key Changes:

Added a button to fill details in project creation page Implemented a Flask route '/get_default_values_for_backend' to dynamically generate default values for project creation/editing. Extended the Python backend logic to calculate and return default values such as project name, homepage URL, version URL, version scheme, version pattern, version prefix, pre-release filter, and version filter. Integrated JavaScript functionality to handle AJAX requests and populate form fields with default values fetched from the server based on the selected backend. This enhancement improves usability and efficiency, contributing to a more user-friendly experience for contributors and project maintainers alike.

This is to solve issue #1421

softwarefactory-project-zuul[bot] commented 4 months ago

Build failed. More information on how to proceed and troubleshoot errors available at https://fedoraproject.org/wiki/Zuul-based-ci https://fedora.softwarefactory-project.io/zuul/buildset/5d1e98ae0baf403ca47d114631bda8e6

:heavy_check_mark: fi-tox-mypy SUCCESS in 5m 55s :x: fi-tox-lint FAILURE in 5m 17s :x: fi-tox-format FAILURE in 5m 39s :heavy_check_mark: fi-tox-python38 SUCCESS in 10m 33s :heavy_check_mark: fi-tox-python39 SUCCESS in 9m 08s :heavy_check_mark: fi-tox-python310 SUCCESS in 9m 17s :heavy_check_mark: fi-tox-python311 SUCCESS in 9m 12s :heavy_check_mark: fi-tox-docs SUCCESS in 7m 50s :heavy_check_mark: fi-tox-bandit SUCCESS in 5m 39s :x: fi-tox-diff-cover FAILURE in 10m 00s

NyuydineBill commented 4 months ago

@Zlopez i am Querying now and getting some data from the API, but is multiple. Should I consider just the last(most recent) object?

image

NyuydineBill commented 4 months ago

@Zlopez this is the data I am retrieving now, the last object image

softwarefactory-project-zuul[bot] commented 4 months ago

Build failed. More information on how to proceed and troubleshoot errors available at https://fedoraproject.org/wiki/Zuul-based-ci https://fedora.softwarefactory-project.io/zuul/buildset/bd08c5497bdd45e1b0f6de1167671c80

:heavy_check_mark: fi-tox-mypy SUCCESS in 5m 35s :x: fi-tox-lint FAILURE in 5m 02s :x: fi-tox-format FAILURE in 5m 20s :heavy_check_mark: fi-tox-python38 SUCCESS in 9m 25s :heavy_check_mark: fi-tox-python39 SUCCESS in 9m 33s :heavy_check_mark: fi-tox-python310 SUCCESS in 9m 32s :heavy_check_mark: fi-tox-python311 SUCCESS in 10m 03s :heavy_check_mark: fi-tox-docs SUCCESS in 7m 35s :x: fi-tox-bandit FAILURE in 5m 15s :x: fi-tox-diff-cover FAILURE in 9m 25s

softwarefactory-project-zuul[bot] commented 4 months ago

Build failed. More information on how to proceed and troubleshoot errors available at https://fedoraproject.org/wiki/Zuul-based-ci https://fedora.softwarefactory-project.io/zuul/buildset/bff988fa2f454c4ebb5ea4d32609ccea

:heavy_check_mark: fi-tox-mypy SUCCESS in 7m 27s :x: fi-tox-lint FAILURE in 4m 43s :x: fi-tox-format FAILURE in 7m 03s :heavy_check_mark: fi-tox-python38 SUCCESS in 9m 45s :heavy_check_mark: fi-tox-python39 SUCCESS in 11m 27s :heavy_check_mark: fi-tox-python310 SUCCESS in 8m 59s :heavy_check_mark: fi-tox-python311 SUCCESS in 11m 03s :heavy_check_mark: fi-tox-docs SUCCESS in 6m 28s :x: fi-tox-bandit FAILURE in 7m 00s :x: fi-tox-diff-cover FAILURE in 9m 56s

Zlopez commented 4 months ago

Looking at the PR, I think that you didn't understood what I want or how complex this feature is. Let me try to explain the workflow and the changes needed for that.

WORKFLOW:

  1. When clicking on Add project menu entry the user will be redirected to a new page, which will ask him for URL to project he want's to add and click 'Add' button on page
  2. User gets redirected to current Add project page prefilled with data obtained from project's page

Changes needed:

  1. New page that will allow user to put the URL
  2. New Flask view that will be called when submitting the URL, this will try to recognize the backend (the best way to do it is probably using domain name checking based on the backends - will probably need some new constant in each backend)
  3. New method in each backend (or at least in those where it's possible) that will obtain data from the URL provided
  4. The redirect to current Add project page with the data obtained in previous step (this will be probably part of the new Flask view)

As you can see there is no need for new javascript code or change in any existing HTML template. I will update the description of the issue as well, so it's more clear what I want.

Zlopez commented 4 months ago

Now I can see that what I described is actually different feature than the one that is in #1421. My bad in this case. But it's still not what you implemented. The new button on Add project page is correct, but how you handle it is not correct. You should have new API endpoint that will return sane defaults based on the backend chosen by user.

For example, if user provides name and says it's PyPi backend, it will fill in the ecosystem, project homepage, versioning schema etc.

The defaults need to be added to each backend. For inspiration how to handle it, you should look at Test check button.

NyuydineBill commented 4 months ago

Okay on it