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

mix gen.auth creates live views in parent folder instead of using its own like the other #5869

Open
ponychicken opened this issue Jul 17, 2024 · 4 comments · May be fixed by #5908
Open

mix gen.auth creates live views in parent folder instead of using its own like the other #5869

ponychicken opened this issue Jul 17, 2024 · 4 comments · May be fixed by #5908

Comments

@ponychicken
Copy link
Contributor

ponychicken commented Jul 17, 2024

Environment

  • Elixir version (elixir -v): Elixir 1.16.2 (compiled with Erlang/OTP 26)
  • Phoenix version (mix deps): 1.7.14

Actual behavior

When using mix gen.auth it polutes the live folder instead of putting its files into a seperate one, like all the other gen tools do.

$ mix phx.new test
$ mix phx.gen.live TestObject [...]
$ mix phx.gen.auth Access User users

➜ test_web tree

.
├── components
│   ├── core_components.ex
│   ├── layouts
│   │   ├── app.html.heex
│   │   └── root.html.heex
│   └── layouts.ex
├── controllers
│   ├── error_html.ex
│   ├── error_json.ex
│   ├── page_controller.ex
│   ├── page_html
│   │   └── home.html.heex
│   ├── page_html.ex
│   └── user_session_controller.ex
├── endpoint.ex
├── gettext.ex
├── live
│   ├── other_object_live
│   │   ├── form_component.ex
│   │   ├── index.ex
│   │   ├── index.html.heex
│   │   ├── show.ex
│   │   └── show.html.heex
│   ├── test_object_live
│   │   ├── form_component.ex
│   │   ├── index.ex
│   │   ├── index.html.heex
│   │   ├── show.ex
│   │   └── show.html.heex
│   ├── user_confirmation_instructions_live.ex
│   ├── user_confirmation_live.ex
│   ├── user_forgot_password_live.ex
│   ├── user_login_live.ex
│   ├── user_registration_live.ex
│   ├── user_reset_password_live.ex
│   └── user_settings_live.ex
├── router.ex
├── telemetry.ex
└── user_auth.ex

Expected behavior

Use a seperate folder

@rhcarvalho
Copy link
Contributor

I think that's by design. The code in test_object_live and other_object_live are variations of the same page, CRUD for a single entity. On the other hand, those user_*_live.ex are conceptually different.

They could be grouped into a common directory, but no sure what improvement it would make in practice. Or even how to name such directory?!

Maybe some git-archeology can help us understand how it came to be, or maybe someone on the Phoenix team is quick at clarifying it :)

@ponychicken
Copy link
Contributor Author

In the end the users are just another data point in the DB. Right now it doesn't come with a view to list all users but that view would be conceptually the same as listing all items of another object.

Regarding naming, i think it would be straighforward to use the passed context attribute (accounts in the example)

@ponychicken
Copy link
Contributor Author

It also states quite clearly in the docs itself:
The mix phx.gen.auth generator is similar to mix phx.gen.html except it does not accept a list of additional fields to add to the schema, and it generates many more context functions.

@josevalim
Copy link
Member

The docs are meant to say it is similar in the arguments, but not necessarily in all of its outputs (which cannot be true).

If we wanted though, we could namespace all of those under the user_live folder. So we have, UserLive.Login, and so on. It feels this would make it more consistent.

ponychicken added a commit to ponychicken/phoenix that referenced this issue Aug 24, 2024
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 a pull request may close this issue.

3 participants