Skip to content

Improve Pending Trusted Publishers UX when project already exists#16515

Merged
di merged 2 commits intopypi:mainfrom
trail-of-forks:pending-publisher-existing-project
Aug 19, 2024
Merged

Improve Pending Trusted Publishers UX when project already exists#16515
di merged 2 commits intopypi:mainfrom
trail-of-forks:pending-publisher-existing-project

Conversation

@facutuesca
Copy link
Copy Markdown
Contributor

@facutuesca facutuesca commented Aug 19, 2024

This PR changes the error message displayed when a user tries to create a Pending Trusted Publisher for a project that already exists. The new error message includes a link to the regular Trusted Publisher form for that project, with URL parameters that will pre-fill the form with the values the user already input in the Pending form:

The link will be something like:

https://pypi.org/manage/project/ruff/settings/publishing/?project_name=ruff&owner=my_user&repository=my_project&workflow_filename=release.yml&provider=github

The main logic change is in forms/_core.py. The validator for the project_name field (validate_project_name()) is changed so that the link to the pre-filled Trusted Publisher form is included in the error message when the project already exists.

Creating the link requires us to have access to the request.route_url method, which we pass the same way the project_factory parameter is currently passed to the validator (through the form constructor)

See the comment in #14232 (comment) for more context on why we use this approach rather than implicitly creating a Trusted Publisher for the existing project.

Fixes #14232

cc @woodruffw

@facutuesca facutuesca force-pushed the pending-publisher-existing-project branch from 8ec4158 to f6b455a Compare August 19, 2024 18:26
@facutuesca facutuesca marked this pull request as ready for review August 19, 2024 18:26
@facutuesca facutuesca requested a review from a team as a code owner August 19, 2024 18:26
@di di enabled auto-merge (squash) August 19, 2024 22:26
@di di merged commit d502d5e into pypi:main Aug 19, 2024
Comment on lines +45 to +48
markupsafe.Markup(
f"This project already exists, use the project's publishing"
f" settings <a href='{url}'>here</a> to create a Trusted"
f" Publisher for it."
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Shouldn't this be translated?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yeah -- I think we need to either push this down a layer, or make sure the snippet generated here passes through _(...) correctly.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'm looking into it now

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed here: #16526

@woodruffw woodruffw deleted the pending-publisher-existing-project branch August 20, 2024 03:37
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.

Improve PendingPublisher UX when project already exists

4 participants