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

Enhanced Project Creation Functionality: Dynamic Default ValuesNew feature #1741

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

NyuydineBill
Copy link
Contributor

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

Updated the Flask route '/get_default_values_for_backend' to dynamically provide default values for project creation/editing based on the selected backend.
Added logic in the Python backend to determine and return default values such as name, homepage, version URL, version scheme, version pattern, version prefix, pre-release filter, and version filter.
Integrated JavaScript code to handle AJAX requests and populate form fields with default values retrieved from the server based on the selected backend.
Improved user experience by enabling users to effortlessly fill in project details with default values, enhancing efficiency and ease of use.
@NyuydineBill NyuydineBill requested a review from a team as a code owner March 15, 2024 15:47
@NyuydineBill NyuydineBill changed the title Enhanced Project Creation/Edit Functionality: Dynamic Default ValuesNew feature Enhanced Project Creation Functionality: Dynamic Default ValuesNew feature Mar 15, 2024
anitya/ui.py Fixed Show fixed Hide fixed
Copy link

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

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

Copy link
Contributor

@Zlopez Zlopez left a comment

Choose a reason for hiding this comment

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

It isn't what I have in mind, but you can use it as base for future work.

news/1723.other Outdated
Copy link
Contributor

Choose a reason for hiding this comment

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

This file shouldn't be here.

Copy link
Contributor

Choose a reason for hiding this comment

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

This file shouldn't be here.

@@ -13,7 +13,7 @@ <h1>{{ context }} project</h1>
<form method="POST" action="{{ url_for('anitya_ui.new_project') }}" >
{%- elif context == 'Edit' -%}
<form method="POST" action="{{ url_for('anitya_ui.edit_project', project_id=project.id) }}" >
{%- endif %}
{%- endif %}
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't change indentation of existing files. It will report changes in lines that don't have any changes.

anitya/templates/project_new.html Outdated Show resolved Hide resolved
anitya/ui.py Outdated
@@ -567,6 +566,44 @@ def new_project():
400,
)

from flask import Flask, request, jsonify
@ui_blueprint.route('/get_default_values_for_backend', methods=['GET'])
def get_default_values_for_backend():
Copy link
Contributor

Choose a reason for hiding this comment

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

This isn't what I wanted in this feature.
It should be a new API endpoint, which will scan the project on the server and fills in the values obtained from the backend.

Like for example, user adds URL https://pypi.org/project/<name> and you fill the new_project page with all the data obtained by the API call.

To see what I have in mind, look at the https://www.protondb.com/contribute and how they can find the game based on the AppID, URL etc.

Copy link
Contributor Author

@NyuydineBill NyuydineBill Mar 15, 2024

Choose a reason for hiding this comment

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

OKkay if I get You well, then the user should enter the url, then the API is called and retrieves data related to that url entered,
And which field is responsible for the url here, homepage?

I will try that out
image

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 Author

Choose a reason for hiding this comment

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

I've read through the docs and I was looking for the API endpoint that could query through the projects and return their data maybe as JSON, but happens not to be there.
Any idea please?

@NyuydineBill
Copy link
Contributor Author

@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
Copy link
Contributor Author

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

Now is such that, the homepage is entered by user as a url
and then that is sent to the backend to get the project with that url
then fields are autofilled with the data received
</div>
{% endblock %}
</div>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>

Check warning

Code scanning / CodeQL

Inclusion of functionality from an untrusted source Medium

Script loaded from content delivery network with no integrity check.
Copy link

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

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

Copy link

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

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

@Zlopez
Copy link
Contributor

Zlopez commented Mar 18, 2024

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
Copy link
Contributor

Zlopez commented Mar 18, 2024

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
Copy link
Contributor Author

Okay on it

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.

None yet

2 participants