diff --git a/DESCRIPTION b/DESCRIPTION index 31be815..ca90fcb 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -46,4 +46,4 @@ Config/testthat/edition: 3 Encoding: UTF-8 LazyData: true Roxygen: list(markdown = TRUE) -RoxygenNote: 7.1.2 +RoxygenNote: 7.2.1 diff --git a/R/members.R b/R/members.R index 8f7f84b..5b57032 100644 --- a/R/members.R +++ b/R/members.R @@ -157,25 +157,27 @@ space_member_add.data.frame <- function(space, users, ...) { #' @inheritParams space_info #' @param users ID number or email of the user to be removed, or a data frame #' with either a `user_id` or `email` column. -#' @param remove_projects Whether to remove user's projects from the workspace -#' and move them to their personal space or to keep the projects in the -#' workspace. +#' @param content_action What to do with the users content after they are +#' removed from the space. Options for the content are to: "leave" +#' leaving the content where it is, "archive" moving the content to +#' the space archive, and "trash" moving the content to the spaces +#' trash. #' @param ask Whether to ask user for confirmation of deletion. #' #' @export -space_member_remove <- function(space, users, remove_projects = NULL, ask = TRUE) { +space_member_remove <- function(space, users, content_action = NULL, ask = TRUE) { UseMethod("space_member_remove", users) } #' @rdname space_member_remove #' @export -space_member_remove.numeric <- function(space, users, remove_projects = NULL, ask = TRUE) { +space_member_remove.numeric <- function(space, users, content_action = NULL, ask = TRUE) { if (!rlang::is_scalar_integerish(users)) { usethis::ui_stop("{ui_field('users')} must be a single user ID or email. For removing multiple users please pass a data frame.") } - if (rlang::is_null(remove_projects)) { - usethis::ui_stop("{ui_field('remove_projects')} must be {ui_value(TRUE)} or {ui_value(FALSE)}. If {ui_value(TRUE)} user's projects are moved to their personal space. If {ui_value(FALSE)}, user's projects are left in the workspace.") + if (rlang::is_null(content_action)) { + usethis::ui_stop("{ui_field('content_action')} must be either \"keep\", \"archive\", \"trash\".") } if (ask) { @@ -189,12 +191,16 @@ space_member_remove.numeric <- function(space, users, remove_projects = NULL, as space_id <- space_id(space) - remove_projects_value <- tolower(as.character(remove_projects)) + content_action <- as.character(content_action) + + if (identical(content_action, 'keep')) { + content_action = 'leave' + } req <- rscloud_rest( path = c("spaces", space_id, "members", users), verb = "DELETE", - query = list(remove_projects = remove_projects_value) + query = list(content_action = content_action) ) usethis::ui_done("Removed member with {ui_field('user_id')} {ui_value(users)}.") @@ -204,7 +210,7 @@ space_member_remove.numeric <- function(space, users, remove_projects = NULL, as #' @rdname space_member_remove #' @export -space_member_remove.character <- function(space, users, remove_projects = NULL, ask = TRUE) { +space_member_remove.character <- function(space, users, content_action = NULL, ask = TRUE) { if (!is_valid_email(users)) { usethis::ui_stop("{ui_field('users')} must be a single user ID or email. For removing multiple users please pass a data frame.") } @@ -215,16 +221,16 @@ space_member_remove.character <- function(space, users, remove_projects = NULL, space_member_remove(space, users = id_to_remove, - remove_projects = remove_projects, + content_action = content_action, ask = ask ) } #' @rdname space_member_remove #' @export -space_member_remove.data.frame <- function(space, users, remove_projects = NULL, ask = TRUE) { - if (rlang::is_null(remove_projects)) { - usethis::ui_stop("{ui_field('remove_projects')} must be {ui_value(TRUE)} or {ui_value(FALSE)}. If {ui_value(TRUE)} user's projects are moved to their personal space. If {ui_value(FALSE)}, user's projects are left in the workspace.") +space_member_remove.data.frame <- function(space, users, content_action = NULL, ask = TRUE) { + if (rlang::is_null(content_action)) { + usethis::ui_stop("{ui_field('content_action')} must be either \"keep\", \"archive\", \"trash\".") } users <- if (!is.null(user_id <- users[["user_id"]])) { @@ -248,7 +254,7 @@ space_member_remove.data.frame <- function(space, users, remove_projects = NULL, } } - purrr::walk(users, space_member_remove, space = space, remove_projects = remove_projects, ask = FALSE) + purrr::walk(users, space_member_remove, space = space, content_action = content_action, ask = FALSE) invisible(space) } diff --git a/README.Rmd b/README.Rmd index 156ea4f..d430e0c 100644 --- a/README.Rmd +++ b/README.Rmd @@ -52,7 +52,7 @@ members <- space %>% space_member_list() %>% dplyr::filter(email != "rscloud.test.01@gmail.com") space %>% - purrr::safely(space_member_remove)(members, remove_projects = TRUE, ask = FALSE) + purrr::safely(space_member_remove)(members, content_action = "leave", ask = FALSE) space %>% purrr::possibly(space_invitation_list, otherwise = NULL)() %>% diff --git a/man/space_member_remove.Rd b/man/space_member_remove.Rd index 0a8c2b5..55d3e81 100644 --- a/man/space_member_remove.Rd +++ b/man/space_member_remove.Rd @@ -7,13 +7,13 @@ \alias{space_member_remove.data.frame} \title{Remove Members} \usage{ -space_member_remove(space, users, remove_projects = NULL, ask = TRUE) +space_member_remove(space, users, content_action = NULL, ask = TRUE) -\method{space_member_remove}{numeric}(space, users, remove_projects = NULL, ask = TRUE) +\method{space_member_remove}{numeric}(space, users, content_action = NULL, ask = TRUE) -\method{space_member_remove}{character}(space, users, remove_projects = NULL, ask = TRUE) +\method{space_member_remove}{character}(space, users, content_action = NULL, ask = TRUE) -\method{space_member_remove}{data.frame}(space, users, remove_projects = NULL, ask = TRUE) +\method{space_member_remove}{data.frame}(space, users, content_action = NULL, ask = TRUE) } \arguments{ \item{space}{A space object created using \code{rscloud_space()}.} @@ -21,9 +21,11 @@ space_member_remove(space, users, remove_projects = NULL, ask = TRUE) \item{users}{ID number or email of the user to be removed, or a data frame with either a \code{user_id} or \code{email} column.} -\item{remove_projects}{Whether to remove user's projects from the workspace -and move them to their personal space or to keep the projects in the -workspace.} +\item{content_action}{What to do with the users content after they are +removed from the space. Options for the content are to: "leave" +leaving the content where it is, "archive" moving the content to +the space archive, and "trash" moving the content to the spaces +trash.} \item{ask}{Whether to ask user for confirmation of deletion.} } diff --git a/tests/testthat/helper-initialize.R b/tests/testthat/helper-initialize.R index 817f4c0..87ba7dd 100644 --- a/tests/testthat/helper-initialize.R +++ b/tests/testthat/helper-initialize.R @@ -7,7 +7,7 @@ clean_up <- function() { space_member_list() %>% dplyr::filter(email != "rscloud.test.01@gmail.com") space %>% - purrr::safely(space_member_remove)(members, remove_projects = TRUE, ask = FALSE) + purrr::safely(space_member_remove)(members, content_action = "leave", ask = FALSE) space %>% purrr::possibly(space_invitation_list, otherwise = NULL)() %>%