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

Make it easier to customize admin and main layouts #5063

Merged
merged 8 commits into from
Jan 16, 2023

Conversation

javierm
Copy link
Member

@javierm javierm commented Jan 11, 2023

References

Objectives

  • Fix a couple of minor issues in the management section header
  • Remove duplication in admin header view
  • Remove duplication in layouts rendering account links
  • Make it easier to customize when to render the navigation and footer

@javierm javierm self-assigned this Jan 11, 2023
@javierm javierm added this to Reviewing in Consul Democracy Jan 11, 2023
@javierm javierm force-pushed the admin_menu_links branch 3 times, most recently from 562558b to dbca3b5 Compare January 12, 2023 12:45
Base automatically changed from admin_menu_links to master January 12, 2023 14:03
@javierm javierm force-pushed the refactor_layout_components branch 5 times, most recently from ad7f4f9 to 45a8447 Compare January 12, 2023 17:55
@taitus taitus self-assigned this Jan 16, 2023
This way it's easier to refactor it.

Note we're using `with_request_url` in the tests because the component
renders the locale switcher, which needs a URL in order to work. This
doesn't affect whether we're in the management section or not.
This way we remove the duplication in the layouts which had these links.

Since we're now passing the `current_user` option to partials in all
cases, IMHO the code is easier to follow if we use the
`Layout::NotificationItemComponent` instead of its partial.
This way it'll be easier to decide when they should be rendered.

In order to be consistent, we're using the `Layout` module for both
components; previously, the navigation partial was in the `shared`
folder while the footer partial was in the `layout` folder, which IMHO
didn't make much sense.
In the management section, `current_user` is the user impersonated by
the manager. We were deciding whether to show the admin menu depending
on the privileges of the current user, but this menu should be shown
according to the privileges of the manager who is impersonating the
user.

We're doing a similar (very subtle) change in the login items. We were
rendering the `login_items` partial passing `current_user: user`.
However, inside this method, we were using `user_signed_in`, which
ignored the `current_user` we were passing. The result was always the
same expect in tests where we manually sign in users, but we're changing
it anyway in order to reduce confusion.
This menu isn't rendered in this case, so the "menu" button to toggle it
did nothing.
We're trying to be consistent; in the past, we had the partials
"shared/admin_login_items", "layouts/notification_item" and
"devise/menu/login_items". Now we're moving all these partials to
components in the `Layout` namespace.
This way it's easier to customize this menu.
Consul Democracy automation moved this from Reviewing to Testing Jan 16, 2023
@javierm javierm added the Bug label Jan 16, 2023
@javierm javierm merged commit 1287055 into master Jan 16, 2023
@javierm javierm deleted the refactor_layout_components branch January 16, 2023 18:52
Consul Democracy automation moved this from Testing to Release 2.0.0 Jan 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants