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

Remove unused/broken UI and addin functionality #679

Merged
merged 8 commits into from
Nov 21, 2022
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,4 @@ VignetteBuilder:
Config/testthat/edition: 3
Encoding: UTF-8
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.2.1
RoxygenNote: 7.2.2
7 changes: 0 additions & 7 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,6 @@ S3method(pin_meta,pins_board_ms365)
S3method(pin_meta,pins_board_rsconnect)
S3method(pin_meta,pins_board_s3)
S3method(pin_meta,pins_board_url)
S3method(pin_preview,data.frame)
S3method(pin_preview,default)
S3method(pin_preview,files)
S3method(pin_search,pins_board)
S3method(pin_search,pins_board_kaggle_competition)
S3method(pin_search,pins_board_kaggle_dataset)
Expand Down Expand Up @@ -144,12 +141,10 @@ export("%>%")
export(board_azure)
export(board_browse)
export(board_cache_path)
export(board_connect)
export(board_default)
export(board_deparse)
export(board_deregister)
export(board_desc)
export(board_disconnect)
export(board_folder)
export(board_get)
export(board_initialize)
Expand Down Expand Up @@ -220,8 +215,6 @@ export(pin_versions)
export(pin_versions_prune)
export(pin_write)
export(required_pkgs)
export(ui_addin_pin_find)
export(ui_connection_create)
export(write_board_manifest)
export(write_board_manifest_yaml)
import(rlang)
Expand Down
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
* Changed `type = "csv"` to use R's default value for `stringsAsFactors` i.e.
`FALSE` (#664).

* Functions for viewing legacy API pins in the RStudio Viewer pane are now
deprecated (when possible) or removed (#679).

## Other improvements

* Added vignette describing how to manage custom formats (#631, @ijlyttle).
Expand Down
8 changes: 1 addition & 7 deletions R/legacy_board_registry.R
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,8 @@ board_register_rsconnect <- function(name = "rsconnect",
board_register2(board)
}

board_register2 <- function(board, connect = TRUE) {
board_register2 <- function(board) {
board_registry_set(board$name, board)
if (connect && !is_testing()) {
# ui_viewer_register(board, "")
}
invisible(board)
}

Expand Down Expand Up @@ -113,10 +110,7 @@ board_deregister <- function(name, ...) {
if (!name %in% board_registry_list()) stop("Board '", name, "' is not registered.")

board <- board_get(name)

if (!identical(list(...)$disconnect, FALSE)) board_disconnect(name)
board_registry_set(name, NULL)

invisible(NULL)
}

Expand Down
1 change: 0 additions & 1 deletion R/pin.R
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ board_pin_store <- function(board,

pin_manifest_create(store_path, metadata, dir(store_path, recursive = TRUE))
board_pin_create(board, store_path, name = name, metadata = metadata, ...)
ui_viewer_updated(board)

if (retrieve) {
# Hack to suppress RSC message that you need to use the full name
Expand Down
3 changes: 0 additions & 3 deletions R/pin_remove.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@
#' @export
pin_remove <- function(name, board = NULL) {
board <- board_get(board)

board_pin_remove(board, name)
ui_viewer_updated(board)

invisible(NULL)
}
14 changes: 0 additions & 14 deletions R/ui_addin.R

This file was deleted.

13 changes: 0 additions & 13 deletions R/ui_connection.R

This file was deleted.

187 changes: 2 additions & 185 deletions R/ui_viewer.R
Original file line number Diff line number Diff line change
@@ -1,196 +1,13 @@
# nocov start

#' Connect to/disconnect from a board
#'
#' Activate/deactivate RStudio's connection pane
#'
#' @param board The name of the board to activate.
#' @param code The code being used to registere this board.
#' @param ... Additional parameters required to initialize a particular board.
#' @keywords internal
#' @export
board_connect <- function(board, code, ...) {
board <- board_get(board)
ui_viewer_register(board, code)
invisible(board)
}

#' @export
#' @rdname board_connect
board_disconnect <- function(name, ...) {
board <- board_get(name)
ui_viewer_closed(board)
invisible(board)
}


#' Preview a pin (legacy API)
#'
#' `pin_preview()` is no longer used and only exists for legacy compatibility.
#' `pin_preview()` is no longer supported.
juliasilge marked this conversation as resolved.
Show resolved Hide resolved
#'
#' @export
#' @keywords internal
pin_preview <- function(x, board = NULL, ...) {
UseMethod("pin_preview")
}
#' @export
pin_preview.default <- function(x, board = NULL, ...) {
x
}
#' @export
pin_preview.data.frame <- function(x, board = NULL, ...) {
utils::head(x, n = getOption("pins.preview", 10^3))
}
#' @export
pin_preview.files <- function(x, board = NULL, ...) {
data.frame(
files = x,
stringsAsFactors = FALSE
)
}

ui_viewer_register <- function(board, board_call) {
if (is.null(.globals$ui_connections)) .globals$ui_connections <- list()

if (identical(.globals$ui_connections[[board$name]], TRUE)) {
ui_viewer_updated(board)
return()
}

.globals$ui_connections[[board$name]] <- TRUE

observer <- getOption("connectionObserver")
if (identical(observer, NULL)) {
return()
}

icons <- system.file(file.path("icons"), package = "pins")

actions <- list(
"Browse" = list(
icon = file.path(icons, "browse.png"),
callback = function() {
board_browse(board)
}
),
"Help" = list(
icon = file.path(icons, "help.png"),
callback = function() {
utils::browseURL("https://rstudio.github.io/pins/")
}
)
)

observer$connectionOpened(
# connection type
type = "Pins",

# name displayed in connection pane
displayName = board$name,

# host key
host = board$name,

# icon for connection
icon = file.path(icons, "pins.png"),

# connection code
connectCode = board_call,

# disconnection code
disconnect = function() {
board_deregister(board$name, disconnect = FALSE)
observer$connectionClosed(type = "Pins", host = board$name)
.globals$ui_connections[[board$name]] <- FALSE
},

listObjectTypes = function() {
list(
table = list(contains = "data")
)
},

# table enumeration code
listObjects = function(type = "table") {
objects <- pin_find(board = board$name)
.globals$ui_updating_connection <- 0

names <- objects$name

data.frame(
name = as.character(names),
type = rep("table", length(objects$name)),
stringsAsFactors = FALSE
)
},

# column enumeration code
listColumns = function(table) {
attr_names <- c()
attr_values <- c()

pin_index <- pin_find(table, board = board$name, name = table, metadata = TRUE)
pin_index <- pin_index[table == pin_index$name, ]

if (!is.null(pin_index$metadata) || nchar(pin_index$metadata) > 0) {
metadata <- jsonlite::fromJSON(pin_index$metadata)
if (!is.null(metadata$columns)) {
if (is.vector(metadata$columns)) {
attr_names <- c(attr_names, names(metadata$columns))
attr_values <- c(attr_values, as.character(metadata$columns))
}
else {
attr_names <- metadata$columns$name
attr_values <- metadata$columns$type
}
}

if (identical(metadata$type, "files") && length(attr_names) == 0) {
attr_names <- c(attr_names, "files")
attr_values <- c(attr_values, "character")
}
}

if (length(attr_names) == 0) {
attr_names <- c(attr_names, "unknown")
attr_values <- c(attr_values, "unknown")
}

data.frame(
name = attr_names,
type = attr_values,
stringsAsFactors = FALSE
)
},

# table preview code
previewObject = function(rowLimit, table) {
pin_preview(pin_get(name = table, board = board$name))
},

# other actions that can be executed on this connection
actions = actions,

# raw connection object
connectionObject = list(name = board)
)
}

ui_viewer_updated <- function(board) {
viewer <- getOption("connectionObserver")
if (!is.null(viewer) && .globals$ui_updating_connection < as.integer(Sys.time())) {
pin_log("Updating connections pane")
.globals$ui_updating_connection <- as.integer(Sys.time()) + 10
viewer$connectionUpdated(type = "Pins", host = board$name, hint = "")
}
}

ui_viewer_closed <- function(board) {
viewer <- getOption("connectionObserver")
if (!is.null(viewer)) {
viewer$connectionClosed(type = "Pins", host = board$name)
.globals$ui_connections[[board$name]] <- FALSE
}
lifecycle::deprecate_stop("1.1.0", "pin_preview()")
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I deprecated this because I think it is still somewhat usable in the current release, but it has been @keywords internal and documented as "no longer used" for over a year so we probably could remove it altogether. Again, this is not something that would typically be used in production or scheduled jobs.

}

# nocov end
Binary file removed inst/icons/browse.png
Binary file not shown.
Binary file removed inst/icons/help.png
Binary file not shown.
Binary file removed inst/icons/pins.png
Binary file not shown.
22 changes: 0 additions & 22 deletions man/board_connect.Rd

This file was deleted.

2 changes: 1 addition & 1 deletion man/pin_preview.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 0 additions & 12 deletions man/ui_addin_pin_find.Rd

This file was deleted.

12 changes: 0 additions & 12 deletions man/ui_connection_create.Rd

This file was deleted.

Binary file removed pkgdown/favicon/apple-touch-icon-120x120.png
Binary file not shown.
Binary file removed pkgdown/favicon/apple-touch-icon-152x152.png
Binary file not shown.
Binary file removed pkgdown/favicon/apple-touch-icon-180x180.png
Binary file not shown.
Binary file removed pkgdown/favicon/apple-touch-icon-60x60.png
Binary file not shown.
Binary file removed pkgdown/favicon/apple-touch-icon-76x76.png
Binary file not shown.
Binary file removed pkgdown/favicon/apple-touch-icon.png
Binary file not shown.
Binary file removed pkgdown/favicon/favicon-16x16.png
Binary file not shown.
Binary file removed pkgdown/favicon/favicon-32x32.png
Binary file not shown.
Binary file removed pkgdown/favicon/favicon.ico
Binary file not shown.