1
votes

I would like to generically produce dashboard menuItems to allow for community contributions in a given Shiny app (using dashboard). The idea is to rely on some conventions and have individual contributions placed in a directory structure like this:

shinyApp/ with the main framework shinyApp/contributions/user1/ui.R shinyApp/contributions/user1/server.R

where I would create e.g. in each "ui.R" file under contributions/ a list called menuList that can be read using :

uiFiles = dir(path = "contributions", pattern = "ui.R", full.names = TRUE, recursive = TRUE)
allMenus = list()
for(fp in uiFiles){
  source(fp)
  allMenus = list(allMenus, menuList)
}
...
shinyUI(dashboardPage(..., dashboardSidebar(allMenus), 
   dashboarBody(**???**)))

the ui.R under contributions would look something like this:

menuList =   list(    
  menuItem("Subcluster analysis", tabName = "subcluster", startExpanded = FALSE,
           menuSubItem("analysis", tabName = "dge")
  ),
  menuItem("Tools", tabName = "tools", startExpanded = FALSE,
           menuSubItem("pheatmap", tabName = "HeatMap")
  )
)

This actually works (if the tabItems in dashboardBody are known). The problem I am running into now is populating the dashboardBody(tabItems(...))

On the server side (which I haven't tackled so far) I don't foresee any problems as I could load/source the output variables and functions from R sources or ".RData" files.

Please let me know if there is a solution to the tabItems problems or there is a better solution that I haven't seen so far.

1

1 Answers

1
votes

After digging a bit further I got the following solution:

It turns out I can create a list of tabs and use that list using tags$div:

inputTab = tabItem(...)
nextTab = tabItem(...)
allTabs = list(inputTab, nextTab)
...
dashboardBody(
  tags$div(
    allTabs,
    class = "tab-content"
  )