Skip to content

Commit bf51429

Browse files
committed
added file_extensions arg to import_modal()
1 parent 162f4d8 commit bf51429

File tree

2 files changed

+27
-6
lines changed

2 files changed

+27
-6
lines changed

R/import-modal.R

+11-4
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#' @param id Module's id
77
#' @param from The import_ui & server to use, i.e. the method.
88
#' There are 5 options to choose from. ("env", "file", "copypaste", "googlesheets", "url")
9+
#' @inheritParams import-file
910
#'
1011
#' @template module-import
1112
#'
@@ -18,7 +19,9 @@
1819
#'
1920
#' @example examples/modal.R
2021
#'
21-
import_ui <- function(id, from = c("env", "file", "copypaste", "googlesheets", "url")) {
22+
import_ui <- function(id,
23+
from = c("env", "file", "copypaste", "googlesheets", "url"),
24+
file_extensions = c(".csv", ".txt", ".xls", ".xlsx", ".rds", ".fst", ".sas7bdat", ".sav")) {
2225
ns <- NS(id)
2326
from <- match.arg(from, several.ok = TRUE)
2427

@@ -34,7 +37,7 @@ import_ui <- function(id, from = c("env", "file", "copypaste", "googlesheets", "
3437
tabPanelBody(
3538
value = "file",
3639
tags$br(),
37-
import_file_ui(id = ns("file"), title = NULL)
40+
import_file_ui(id = ns("file"), title = NULL, file_extensions = file_extensions)
3841
)
3942
}
4043

@@ -392,7 +395,11 @@ import_server <- function(id,
392395
#' @rdname import-modal
393396
#' @importFrom shiny modalDialog showModal
394397
#' @importFrom htmltools tags css
395-
import_modal <- function(id, from, title = "Import data", size = "l") {
398+
import_modal <- function(id,
399+
from,
400+
title = "Import data",
401+
size = "l",
402+
file_extensions = c(".csv", ".txt", ".xls", ".xlsx", ".rds", ".fst", ".sas7bdat", ".sav")) {
396403
showModal(modalDialog(
397404
title = tagList(
398405
tags$button(
@@ -405,7 +412,7 @@ import_modal <- function(id, from, title = "Import data", size = "l") {
405412
),
406413
title
407414
),
408-
import_ui(id, from),
415+
import_ui(id, from, file_extensions = file_extensions),
409416
size = size,
410417
footer = NULL
411418
))

man/import-modal.Rd

+16-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)