Remove the 'Back to site' link on admin-only sites.

Created on 3 March 2023, almost 2 years ago

Problem/Motivation

For some sites, it doesn't make sense to have a 'Back to site' link in the secondary toolbar. For example headless sites, or admin-only web apps. Let's remove that link if there isn't anything to link to.

Steps to reproduce

Set the front page to /user/login and provide no frontend routes.

Proposed resolution

Remove the 'Back to site' link if the escapeAdminPath session variable is empty, instead of linking it to the front page.

โœจ Feature request
Status

Active

Version

3.0

Component

Code

Created by

๐Ÿ‡ง๐Ÿ‡ชBelgium dieterholvoet Brussels

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @dieterholvoet
  • Status changed to Needs review almost 2 years ago
  • ๐Ÿ‡ง๐Ÿ‡ชBelgium dieterholvoet Brussels
  • ๐Ÿ‡ง๐Ÿ‡ชBelgium dieterholvoet Brussels

    gin_preprocess_breadcrumb contains some logic to set the 'Back to site' link to the canonical (view) route of the current entity if you're e.g. on the entity view/edit/delete pages. That doesn't really make sense IMO since there's always the View tab on these kind of pages, I doubt anyone really uses the 'Back to site' link to go to the canonical route of the current entity.

    I'm removing this logic since it also stands in the way of not showing the 'Back to site' link on admin-only sites, because the data-gin-toolbar-escape-admin data attribute currently isn't always added which means that the JS logic isn't always triggered.

  • ๐Ÿ‡จ๐Ÿ‡ญSwitzerland saschaeggi Zurich

    @DieterHolvoet

    I doubt anyone really uses the 'Back to site' link to go to the canonical route of the current entity.

    So it seems this change is based on your assumption as you don't use this feature (for your use case). But we clearly added this based on content editors feedback.

    The expected logic is as follows:
    โ€“ If you come from a non admin route the ยซBack to siteยป link will lead you back to where you came from
    โ€“ If you're in the admin directly and it leads you to the ยซViewยป of that entity

    If that's not the logic you would like to have it might be better if you handle it for your specific use case requirements in an override/hook instead. But maybe I did misunderstand the efforts here, than letting me know, otherwise I think we should close this request.

    Cheers!

  • Status changed to Needs work almost 2 years ago
  • ๐Ÿ‡ง๐Ÿ‡ชBelgium dieterholvoet Brussels

    Okay, I'll keep the canonical entity route logic and try to work with it. The use case of not showing the 'Back to site' link on admin-only sites still stands.

  • Status changed to Needs review almost 2 years ago
  • ๐Ÿ‡ง๐Ÿ‡ชBelgium dieterholvoet Brussels

    Fixed! In my use case I blocked access to the node/user canonical routes because I didn't need them anyway (admin-only site). Had to do some changes to the template and styles to stop assuming the first breadcrumb item is the 'Back to site' link.

  • Status changed to Needs work over 1 year ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia djsagar

    Getting error while applying patch.

  • First commit to issue fork.
  • Pipeline finished with Failed
    about 1 year ago
    Total: 243s
    #29265
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia Harish1688 India

    Based on the comment #saschaeggi , Tested the comment #9 solution for the issue. points covered in the in comment. attached images for reference.

    1. Remove the 'Back to site' link from js/toolbar.js if the escapeAdminPath session variable is empty.
    2. 'Back to site' link theming fix.
    3. Just 2 commit for issue in MR.

    Before MR

    After MR

  • Status changed to RTBC about 1 year ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia vsheokeen NCR

    This seems to be working after testing. Chaning its status.

  • First commit to issue fork.
  • Pipeline finished with Failed
    about 1 year ago
    Total: 278s
    #53651
  • Status changed to Needs work about 1 year ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia saurabh-2k17

    Hi, I tried to use the diff, but it is not working. Changing the status back to Needs Work.

  • ๐Ÿ‡ง๐Ÿ‡ชBelgium dieterholvoet Brussels

    @saurabh-2k17 can you please elaborate on how you tested and what exactly wasnโ€™t working?

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia saurabh-2k17

    Hi @DieterHolvoet thanks for your quick response! Much Appreciated

    After applying the patch, I referred to the comment on #10. As per that, I should not see the Back to site link after logging in as Administrator and visiting the content listing page or similar, but I could see it. The only time I was not seeing the link was, when I was visiting a 403 page (without logging).

  • First commit to issue fork.
  • Merge request !477Merge 8.x-3.x โ†’ (Open) created by jeffschuler
  • Pipeline finished with Failed
    5 months ago
    Total: 204s
    #231533
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States jeffschuler Boulder, Colorado

    Sorry, I'm a still dumdum when it comes to d.o./gitlab integration. My intent was to merge the latest gin 8.x-3.x into the issue branch after resolving conflicts manually, but it looks like it has created a new MR.

    At any rate these changes are also not removing the Back to Site button for me.

  • Status changed to Needs review 5 months ago
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States jeffschuler Boulder, Colorado

    Ah, I see that the changes in the MR allow me to style that item directly, so in my CSS overrides I can just hide it:

    .gin-breadcrumb__item--back-to-site {
      display: none !important;
    }
  • Assigned to jeffschuler
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States jeffschuler Boulder, Colorado
  • Pipeline finished with Failed
    3 months ago
    Total: 188s
    #294353
  • Pipeline finished with Failed
    3 months ago
    Total: 220s
    #294460
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States jeffschuler Boulder, Colorado

    The addition/modification of classes here in order to enable the removal of Back to site via CSS is useful.

    The change in JS to remove the element entirely if escapeAdminPath is NULL not as clear. There is already logic for determining whether Back to site / etc. is added in gin_preprocess_breadcrumb(). Additional conditional logic for that deserves to be there (instead of JS) if possible.

    And, as evidenced by Sascha's comments in #5, the question of whether to remove the element entirely is a lot more debate-able.

    Incoming commit to MR!231 to remove those JS changes and constrain this issue to just allow styling of the link.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States jeffschuler Boulder, Colorado

    jeffschuler โ†’ changed the visibility of the branch gin-3345842-3345842-remove-the-back to hidden.

  • Pipeline finished with Failed
    3 months ago
    Total: 188s
    #294741
  • there is some issue after switching the branch drupal site stop running so i tried the changes manually and it worked for me RTBC +1


  • ๐Ÿ‡บ๐Ÿ‡ธUnited States jeffschuler Boulder, Colorado

    Thanks @saurav-drupal-dev!

    Just to clarify (& confirm): the patch alone doesn't remove back-to-site button for you, correct?
    Only if-and-when you also add some custom styling?

    If so, and if you do deem it RTBC, please change issue status to RTBC.

    Thanks!

Production build 0.71.5 2024