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

Back to the app from admin mode without fab_button #150

Open
anpefi opened this issue Sep 6, 2022 · 1 comment
Open

Back to the app from admin mode without fab_button #150

anpefi opened this issue Sep 6, 2022 · 1 comment
Labels
enhancement New feature or request

Comments

@anpefi
Copy link

anpefi commented Sep 6, 2022

Hi!

I'm using shinymanager in a app served company-wide. Using shinydashboardPlus, I created custom buttons for logout and enter admin mode in the user profile menu, setting the fab-button (position="none), as this way is more intuitive for my users. Both buttons works great.

in app_ui.R:

secured_ui <- shinymanager::secure_app(
    app_ui,
    enable_admin = T,
    fab_position = 'none',
    language = "es",
    tags_top =
      tags$div(
        golem_add_external_resources(),
        tags$h2("My app", style = "align:center"),
        tags$br(),
        tags$img(src = "www/appLogo.png", width = 150),
        tags$br()
      )
  )

in app_server.R:

output$user <- shinydashboardPlus::renderUser(
        shinydashboardPlus::dashboardUser(
          name = creds_reactive()$user,
          image = "www/user_icon.png",
          title = NULL,
          subtitle = paste0("Grupo: ", creds_reactive()$userGroup),
          footer = NULL,
          column( width = 12,
            shinydashboardPlus::dashboardUserItem(actionButton(".shinymanager_logout", label = "Cerrar sesión"), width = 6),
            if(creds_reactive()$admin) {
              shinydashboardPlus::dashboardUserItem(actionButton(".shinymanager_admin", label = "Administración"), width = 6)
            } else {NULL}
          )
        )
      )

The issue arise when I want to come back from the admin mode to the main app given that the only way was using the fab_button and now this is not shown.
I think it would be useful to have another button/link to go back to app in the admin ui for those cases where fab_button is hide.

Anyway, could I add a button for such a task from my code into the admin ui (maybe using shinyjs)? Or any other workaround?

Thanks for this awesome package,

Andrés.

@anpefi
Copy link
Author

anpefi commented Sep 7, 2022

Hi again,
I've solved this issue with the following workaround in app_server.R (and keeping fab_position="none"):

  observe({
    if (!is.null(input$shinymanager_where) &&
          input$shinymanager_where %in% "admin"
        ) {

      insertUI(selector = ".container-fluid",
               where = "beforeEnd",
               ui = fab_button(position = "bottom-left",
                                             actionButton(
                                               inputId = ".shinymanager_app",
                                               label = NULL,
                                               icon = icon("share")
                                             ))
              )
    }
  })

However, I think it would be nice to have a "native" solution to go back to te app from the admin console when fab_position="none".

Cheers!
Andrés.

@bthieurmel bthieurmel added the enhancement New feature or request label Sep 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: No status
Development

No branches or pull requests

2 participants