diff --git a/R/client-cloud.R b/R/client-cloud.R index be0afb60..31e25442 100644 --- a/R/client-cloud.R +++ b/R/client-cloud.R @@ -161,7 +161,7 @@ cloudClient <- function(service, authInfo) { GET(service, authInfo, path, query) }, - createApplication = function(name, title, template, accountId, appMode) { + createApplication = function(name, title, template, accountId, appMode, contentCategory = NULL) { json <- list() json$name <- name json$application_type <- if (appMode %in% c("rmd-static", "quarto-static", "static")) "static" else "connect" @@ -180,6 +180,8 @@ cloudClient <- function(service, authInfo) { json$space <- currentProject$space_id } + json$content_category <- contentCategory + output <- POST_JSON(service, authInfo, "/outputs", json) path <- paste0("/applications/", output$source_id) application <- GET(service, authInfo, path) @@ -224,9 +226,10 @@ cloudClient <- function(service, authInfo) { ) }, - createRevision = function(application) { + createRevision = function(application, contentCategory) { path <- paste0("/outputs/", application$id, "/revisions") - revision <- POST_JSON(service, authInfo, path, data.frame()) + json <- list(content_category = contentCategory) + revision <- POST_JSON(service, authInfo, path, json) revision$application_id }, diff --git a/R/client-connect.R b/R/client-connect.R index 98e1de43..a943d080 100644 --- a/R/client-connect.R +++ b/R/client-connect.R @@ -48,7 +48,7 @@ connectClient <- function(service, authInfo) { listApplicationsRequest(service, authInfo, path, query, "applications") }, - createApplication = function(name, title, template, accountId, appMode) { + createApplication = function(name, title, template, accountId, appMode, contentCategory) { # add name; inject title if specified details <- list(name = name) if (!is.null(title) && nzchar(title)) diff --git a/R/client-shinyapps.R b/R/client-shinyapps.R index 15349037..44283f51 100644 --- a/R/client-shinyapps.R +++ b/R/client-shinyapps.R @@ -90,7 +90,7 @@ shinyAppsClient <- function(service, authInfo) { GET(service, authInfo, path, query) }, - createApplication = function(name, title, template, accountId, appMode) { + createApplication = function(name, title, template, accountId, appMode, contentCategory) { json <- list() json$name <- name # the title field is only used on connect diff --git a/R/deployApp.R b/R/deployApp.R index b8ad2517..e4715883 100644 --- a/R/deployApp.R +++ b/R/deployApp.R @@ -391,7 +391,8 @@ deployApp <- function(appDir = getwd(), target$appTitle, "shiny", accountDetails$accountId, - appMetadata$appMode + appMetadata$appMode, + contentCategory ) taskComplete(quiet, "Created application with id {.val {application$id}}") } else { @@ -402,7 +403,7 @@ deployApp <- function(appDir = getwd(), taskComplete(quiet, "Found application {.url {application$url}}") if (identical(application$type, "static")) { - application$application_id <- client$createRevision(application) + application$application_id <- client$createRevision(application, contentCategory) } application diff --git a/tests/testthat/test-client-cloud.R b/tests/testthat/test-client-cloud.R index 2ccb96d2..4585839e 100644 --- a/tests/testthat/test-client-cloud.R +++ b/tests/testthat/test-client-cloud.R @@ -309,6 +309,7 @@ test_that("Create static application", { content = function(methodAndPath, match, contentFile, ...) { content <- jsonlite::fromJSON(readChar(contentFile, file.info(contentFile)$size)) expect_equal(content$application_type, "static") + expect_equal(content$content_category, "document") list( "id" = 1, "source_id" = 2, @@ -339,7 +340,7 @@ test_that("Create static application", { ) client <- cloudClient(fakeService, NULL) - app <- client$createApplication("test app", "unused?", "unused?", "unused?", "static") + app <- client$createApplication("test app", "unused?", "unused?", "unused?", "static", "document") expect_equal(app$id, 1) expect_equal(app$application_id, 2) @@ -353,6 +354,7 @@ test_that("Create static server-side-rendered application", { content <- jsonlite::fromJSON(readChar(contentFile, file.info(contentFile)$size)) expect_equal(content$application_type, "static") expect_equal(content$render_by, "server") + expect_equal(content$content_category, "document") list( "id" = 1, "source_id" = 2, @@ -383,7 +385,7 @@ test_that("Create static server-side-rendered application", { ) client <- cloudClient(fakeService, NULL) - app <- client$createApplication("test app", "unused?", "unused?", "unused?", "quarto-static") + app <- client$createApplication("test app", "unused?", "unused?", "unused?", "quarto-static", "document") expect_equal(app$id, 1) expect_equal(app$application_id, 2) @@ -452,6 +454,7 @@ test_that("Create static RMD application", { content <- jsonlite::fromJSON(readChar(contentFile, file.info(contentFile)$size)) expect_equal(content$application_type, "static") expect_equal(content$render_by, "server") + expect_equal(content$content_category, "document") list( "id" = 1, "source_id" = 2, @@ -482,7 +485,7 @@ test_that("Create static RMD application", { ) client <- cloudClient(fakeService, NULL) - app <- client$createApplication("test app", "unused?", "unused?", "1", "rmd-static") + app <- client$createApplication("test app", "unused?", "unused?", "1", "rmd-static", "document") expect_equal(app$id, 1) expect_equal(app$application_id, 2)