-
Notifications
You must be signed in to change notification settings - Fork 1k
Multi project token #6373
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
base: main
Are you sure you want to change the base?
Multi project token #6373
Conversation
CI seems to have some transient issues with |
e5e26c6
to
8a8332d
Compare
8a8332d
to
6d184bd
Compare
HI @Sterbic - thank you for this PR! I have a suggestion regarding the user interface. Instead of throwing an error when a user makes a mistake with the token scope, we can prevent it by not allowing users to select their entire account and a project at the same time. I was thinking something like this would work well: For accounts with fewer than 10 projects
For accounts with more than 10 projects
|
Thanks @nlhkabu, that design looks pretty neat! Would you be ok with it going into a separate pull request since it would be touching only the UI? This PR has all the backend logic and tests so I'd rather merge it as is so it's easier to review the UI changes afterwards. |
Hi @Sterbic - my strong preference is to include the UI improvements in this PR, rather than ship as is and fix it later. My reason: there is no guarantee we'll actually "fix it later". Did you want some help with the HTML/CSS/JS here? |
Fair enough, I'll amend this PR. Is there a similar example in the codebase for such a UI? I have zero JS experience tbh. |
Just a nitpick: we still need to perform this validation on the backend, since a user could use |
@yeraydiazdiaz do you think you could help @Sterbic here? |
@@ -35,7 +35,9 @@ <h2>Token for "{{ macaroon.description }}"</h2> | |||
{% if macaroon.caveats.permissions == "user" %} | |||
<strong>Scope:</strong> Entire account (all projects) | |||
{% else %} | |||
<strong>Scope:</strong> Project "{{ macaroon.caveats.permissions.projects[0] }}" | |||
{% for project in macaroon.caveats.permissions.projects %} | |||
<strong>Scope:</strong> Project "{{ project }}"<br> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit-pick: We probably shouldn't add a "Scope:" for every project and instead have it just once, with the project names in a comma-separated-with-and-for-final-join manner.
@Sterbic do you want to have a go at the JavaScript for this or should I tackle it myself? |
Have been a bit swamped at work since I started working on this at PyCon AU but definitely want to finish it. |
That's fine, let me know if you need help 🙂 |
Note: |
@yeraydiazdiaz, if you want to take a stab at the JS part go for it. I have a fire at work and won't have any cycles to spend learning JS any time soon 😭 I can rebase this PR on master if it helps. |
Hey @Sterbic no worries, I can rebase myself and take it from here. Thanks so much for starting this PR 🌟 |
@Sterbic, I created a PR on your fork merging If you don't have time or don't want the noise let me know. 🙂 |
Render multiselect or checkboxes depending on number of projects
I've implemented the changes suggested by @nlhkabu, here's the capture using checkboxes: And another using multi-select, note this should only happen if the number of projects it greater than 10, I changed the code in the template to use it in this example: Once the PR in @Sterbic's repo is merged this should be ready for review. |
Merging master onto your branch
Finishing off token multi project
#Triage @Sterbic are you still interested in pursuing this effort? It's okay if not! |
is this still planed or not? would be very useful. |
It's still planned in the sense that there's desire for it, but it needs an owner unless @Sterbic comes back to it. In the mean time, you can use a Trusted Publisher to perform multi-project publishing -- that's built natively into the TP flow. |
This PR adds support for multi project tokens. The backend was mostly ready for this it seems, I just had to make the forms and other UI components compatible wit it.
Thanks to @ip4368 for the help with the CSS so that the multi select doesn't look as if it were from the 90s.
Screen capture: https://www.dropbox.com/s/ukyqp5ag0ocrbd2/multi-proj-token.mov?dl=0
Closes: #6292