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

Add admin crud UI #626

Draft
wants to merge 3 commits into
base: add-authentication-via-devise
Choose a base branch
from
Draft

Conversation

murny
Copy link
Collaborator

@murny murny commented Aug 15, 2024

This PR builds off of #625 to add a CRUD UI for our new Admins resource

Most of this code was largely generated off the scaffold generator from ComfortableMexicanSofa.

In the CMS admin area, you will now have Admins and Log out links:
image

Clicking on the Admins link will take you to a full CRUD (create, read (index/show), update, delete) of the Admins resource.

Index:
image

Show:
image

Update:
image

New:
image

And you can delete users.

This is obviously very basic and simple, but should give you a foundation to add upon this and make it better.

You could later expand on this and include ability to invite admins (and remove the "new" admins stuff), ability to disable admins, add audit trail information and so forth (can take inspiration from Jupiter maybe for some of this, but by using Devise you have lots of guides/examples/solutions from the community you could adopt).

For the time being, this gives you an easy way to:

  • add new admins (not great honestly because you have to create an account for them and then message/email them their email/password, which they would have to reset themselves etc. Which it is nice to quickly add a way to invite users instead, or look into Ualberta Login integration via SAML)
  • Can view and manage admins
  • Can remove admins

Improvements:

  • Add tests for these new screens (comfy generator added controller tests but these probably need to be fixed and refactored to work, but might be a great starting point)
  • Make UI more petterier/functional
  • Some forms might not be ideal (Edit form I believe is useless unless you know the users password, but this could be fixed/tweaked)

Future work:

@@ -23,6 +23,8 @@ gem "stimulus-rails"

gem "rollbar"

gem "kaminari"
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Scaffold uses .page helper and assumes pagination. Comfy mexican suggests either Will Paginate or Kaminari gems:

https://github.com/comfy/comfortable-mexican-sofa?tab=readme-ov-file#dependencies

Pagination is handled by kaminari or will_paginate. Please add one of those to your Gemfile.

So brought in Kaminari just because we use it in Jupiter (no strong opinions otherwise)

@@ -0,0 +1,63 @@
# frozen_string_literal: true

class Admin::AdminsController < Comfy::Admin::BaseController
Copy link
Collaborator Author

@murny murny Aug 15, 2024

Choose a reason for hiding this comment

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

Mainly all this code below is from the scaffold generator: https://github.com/comfy/comfortable-mexican-sofa/wiki/HowTo:-Reusing-Admin-Area

@murny murny force-pushed the add-admin-crud-ui branch from ed2018c to 8562438 Compare August 24, 2024 04:59
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.

1 participant