warehouse icon indicating copy to clipboard operation
warehouse copied to clipboard

Multi project token

Open Sterbic opened this issue 6 years ago • 20 comments

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

Sterbic avatar Aug 06 '19 06:08 Sterbic

CI seems to have some transient issues with apt get but can't find a way of retrying it myself :/

Sterbic avatar Aug 06 '19 06:08 Sterbic

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

  • No radio selected by default
  • Checkboxes disabled unless "by project" is selected.

Screenshot from 2019-08-08 08-58-56

For accounts with more than 10 projects

  • No radio selected by default
  • Select disabled unless "by project" is selected

more-than-10

nlhkabu avatar Aug 09 '19 05:08 nlhkabu

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.

Sterbic avatar Aug 09 '19 08:08 Sterbic

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?

nlhkabu avatar Aug 09 '19 16:08 nlhkabu

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.

Sterbic avatar Aug 09 '19 16:08 Sterbic

Agreed w/ @nlhkabu.

As an alternative to adding the commits here, someone else could create a PR against your branch.

We use Stimulus for our JS framework, this should be a pretty straightforward controller.

di avatar Aug 09 '19 18:08 di

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.

Just a nitpick: we still need to perform this validation on the backend, since a user could use curl or another client to bypass the client-side restriction on what they're allowed to select. But it'll be good to also have it on the frontend :smile:

woodruffw avatar Aug 10 '19 15:08 woodruffw

@yeraydiazdiaz do you think you could help @Sterbic here?

brainwane avatar Aug 22 '19 17:08 brainwane

@Sterbic do you want to have a go at the JavaScript for this or should I tackle it myself?

yeraydiazdiaz avatar Sep 04 '19 11:09 yeraydiazdiaz

Have been a bit swamped at work since I started working on this at PyCon AU but definitely want to finish it.

Sterbic avatar Sep 04 '19 19:09 Sterbic

That's fine, let me know if you need help 🙂

yeraydiazdiaz avatar Sep 05 '19 07:09 yeraydiazdiaz

Note: If / when this PR is re-reviewed, we will need to ensure that the template is appropriately translated.

nlhkabu avatar Sep 15 '19 11:09 nlhkabu

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

Sterbic avatar Oct 01 '19 22:10 Sterbic

Hey @Sterbic no worries, I can rebase myself and take it from here. Thanks so much for starting this PR 🌟

yeraydiazdiaz avatar Oct 02 '19 08:10 yeraydiazdiaz

@Sterbic, I created a PR on your fork merging master onto your branch to bring this PR up to date. I was planning on creating an additional one with the JavaScripts changes as suggested by @di.

If you don't have time or don't want the noise let me know. 🙂

yeraydiazdiaz avatar Jan 09 '20 09:01 yeraydiazdiaz

I've implemented the changes suggested by @nlhkabu, here's the capture using checkboxes:

token-multi-project-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:

token-multi-project-multiselect

Once the PR in @Sterbic's repo is merged this should be ready for review.

yeraydiazdiaz avatar Jan 09 '20 18:01 yeraydiazdiaz

@Sterbic has merged https://github.com/Sterbic/warehouse/pull/2 so this is now ready for review.

yeraydiazdiaz avatar Feb 15 '20 10:02 yeraydiazdiaz

#Triage This PR currently has merge conflicts that would need to be addressed before proceeding.

@Sterbic are you still interested in pursuing this effort? It's okay if not!

miketheman avatar Jan 09 '23 21:01 miketheman