Skip to content
Permalink
Browse files

Merge pull request #5204 from rstudio/bugfix/viewer-types

Complete transition of viewer type values from enum to string
  • Loading branch information...
jmcphers committed Aug 9, 2019
2 parents 10857e8 + d8564f6 commit c287e1961e0726da892f23e7b8be7172420e8dbf
@@ -14,15 +14,15 @@
#

.rs.addFunction("invokePlumberPaneViewer", function(url) {
invisible(.Call("rs_plumberviewer", url, getwd(), "pane"))
invisible(.Call("rs_plumberviewer", url, getwd(), "pane", PACKAGE = "(embedding)"))
}, attrs = list(plumberViewerType = "pane"))

.rs.addFunction("invokePlumberWindowViewer", function(url) {
invisible(.Call("rs_plumberviewer", url, getwd(), "window"))
invisible(.Call("rs_plumberviewer", url, getwd(), "window", PACKAGE = "(embedding)"))
}, attrs = list(plumberViewerType = "window"))

.rs.addFunction("invokePlumberWindowExternal", function(url) {
invisible(.Call("rs_plumberviewer", url, getwd(), "browser"))
invisible(.Call("rs_plumberviewer", url, getwd(), "browser", PACKAGE = "(embedding)"))
}, attrs = list(plumberViewerType = "browser"))

.rs.addFunction("setPlumberViewerType", function(type) {
@@ -42,9 +42,9 @@
return("none")
else if (identical(viewer, TRUE))
return("browser")
else if (is.function(viewer) && is.numeric(attr(viewer, "plumberViewerType")))
else if (is.function(viewer) && is.character(attr(viewer, "plumberViewerType")))
return(attr(viewer, "plumberViewerType"))
return(0)
return("user")
})

.rs.addJsonRpcHandler("get_plumber_viewer_type", function() {
@@ -44,7 +44,7 @@ namespace plumber_viewer {
namespace {

void enqueueStartEvent(const std::string& url, const std::string& path,
int viewerType, int options)
const std::string& viewerType, int options)
{
FilePath plumberPath(path);

@@ -74,7 +74,7 @@ SEXP rs_plumberviewer(SEXP urlSEXP, SEXP pathSEXP, SEXP viewerSEXP)
throw r::exec::RErrorException(
"path must be a single element character vector.");
}
int viewertype = r::sexp::asInteger(viewerSEXP);
std::string viewertype = r::sexp::safeAsString(viewerSEXP, kPlumberViewerTypeWindow);

// in desktop mode make sure we have the right version of httpuv
if (options().programMode() == kSessionProgramModeDesktop)
@@ -14,15 +14,15 @@
#

.rs.addFunction("invokeShinyPaneViewer", function(url) {
invisible(.Call("rs_shinyviewer", url, getwd(), "pane"))
}, attrs = list(shinyViewerType = 2))
invisible(.Call("rs_shinyviewer", url, getwd(), "pane", PACKAGE = "(embedding)"))
}, attrs = list(shinyViewerType = "pane"))

.rs.addFunction("invokeShinyWindowViewer", function(url) {
invisible(.Call("rs_shinyviewer", url, getwd(), "window"))
invisible(.Call("rs_shinyviewer", url, getwd(), "window", PACKAGE = "(embedding)"))
}, attrs = list(shinyViewerType = "window"))

.rs.addFunction("invokeShinyWindowExternal", function(url) {
invisible(.Call("rs_shinyviewer", url, getwd(), "browser"))
invisible(.Call("rs_shinyviewer", url, getwd(), "browser", PACKAGE = "(embedding)"))
}, attrs = list(shinyViewerType = "browser"))

.rs.addFunction("setShinyViewerType", function(type) {
@@ -42,7 +42,7 @@
return("none")
else if (identical(viewer, TRUE))
return("browser")
else if (is.function(viewer) && is.numeric(attr(viewer, "shinyViewerType")))
else if (is.function(viewer) && is.character(attr(viewer, "shinyViewerType")))
return(attr(viewer, "shinyViewerType"))
return("user")
})
@@ -48,7 +48,7 @@ namespace {
FilePath s_pendingShinyPath;

void enqueueStartEvent(const std::string& url, const std::string& path,
int viewerType, int options)
const std::string& viewerType, int options)
{
FilePath shinyPath(path);
if (module_context::safeCurrentPath() == shinyPath &&
@@ -87,7 +87,7 @@ SEXP rs_shinyviewer(SEXP urlSEXP, SEXP pathSEXP, SEXP viewerSEXP)
throw r::exec::RErrorException(
"path must be a single element character vector.");
}
int viewertype = r::sexp::asInteger(viewerSEXP);
std::string viewertype = r::sexp::safeAsString(viewerSEXP, kShinyViewerTypeWindow);

// in desktop mode make sure we have the right version of httpuv
if (options().programMode() == kSessionProgramModeDesktop)
@@ -107,7 +107,7 @@ SEXP rs_shinyviewer(SEXP urlSEXP, SEXP pathSEXP, SEXP viewerSEXP)
if (path.find("/shinytest/recorder") != std::string::npos ||
path.find("/shinytest/diffviewerapp") != std::string::npos)
{
viewertype = SHINY_VIEWER_WINDOW;
viewertype = kShinyViewerTypeWindow;
options = SHINY_VIEWER_OPTIONS_NOTOOLS;
}
if (path.find("/shinytest/recorder") != std::string::npos)
@@ -1,7 +1,7 @@
/*
* SessionShinyViewer.hpp
*
* Copyright (C) 2009-14 by RStudio, Inc.
* Copyright (C) 2009-19 by RStudio, Inc.
*
* Unless you have received this program directly from RStudio pursuant
* to the terms of a commercial license agreement with RStudio, then
@@ -27,12 +27,6 @@ namespace session {
namespace modules {
namespace shiny_viewer {

const int SHINY_VIEWER_USER = 0;
const int SHINY_VIEWER_NONE = 1;
const int SHINY_VIEWER_PANE = 2;
const int SHINY_VIEWER_WINDOW = 3;
const int SHINY_VIEWER_BROWSER = 4;

const int SHINY_VIEWER_OPTIONS_NONE = 0;
const int SHINY_VIEWER_OPTIONS_NOTOOLS = 1;
const int SHINY_VIEWER_OPTIONS_WIDE = 2;

0 comments on commit c287e19

Please sign in to comment.
You can’t perform that action at this time.