From 11bce9af3c332a5e43f3bda633c37fe45234ec55 Mon Sep 17 00:00:00 2001 From: jschelfhout Date: Fri, 18 Jul 2025 15:02:35 +0200 Subject: [PATCH 1/4] Add demo app and gh-page workflow --- .github/workflows/deploy-app.yaml | 69 +++++++++++++++++++++++++++++++ .gitignore | 2 +- demo/app.R | 50 ++++++++++++++++++++++ 3 files changed, 120 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/deploy-app.yaml create mode 100644 demo/app.R diff --git a/.github/workflows/deploy-app.yaml b/.github/workflows/deploy-app.yaml new file mode 100644 index 0000000..3734ccf --- /dev/null +++ b/.github/workflows/deploy-app.yaml @@ -0,0 +1,69 @@ +# Workflow derived from https://github.com/posit-dev/r-shinylive/blob/main/.github/workflows/deploy-app.yaml +name: deploy to gh-pages + +on: + workflow_call: + inputs: + cache-version: + type: string + default: "1" + required: false + +jobs: + build: + runs-on: ubuntu-latest + env: + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + R_KEEP_PKG_SOURCE: yes + + steps: + - uses: actions/checkout@v4 + + - uses: rstudio/shiny-workflows/setup-r-package@v1 + with: + packages: | + renv + posit-dev/r-shinylive + sessioninfo + cache-version: ${{ github.event.inputs.cache-version }} + + - name: Find package dependencies + shell: Rscript {0} + id: packages + run: | + # Find package dependencies using {renv} and install with {pak} + pak::pak( + unique(renv::dependencies("./editbl")$Package) + ) + + - name: Build site + shell: Rscript {0} + run: | + shinylive::export("./demo", "site") + + - name: Upload site artifact + if: github.ref == 'refs/heads/main' + uses: actions/upload-pages-artifact@v3 + with: + path: "site" + + deploy: + if: github.ref == 'refs/heads/gh_page' + needs: build + + # Grant GITHUB_TOKEN the permissions required to make a Pages deployment + permissions: + pages: write # to deploy to Pages + id-token: write # to verify the deployment originates from an appropriate source + + # Deploy to the github-pages environment + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + + # Specify runner + deployment step + runs-on: ubuntu-latest + steps: + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v4 \ No newline at end of file diff --git a/.gitignore b/.gitignore index 0965a54..3a41ab7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,5 @@ /editbl.Rcheck/ editbl_*.tar.gz - +.site diff --git a/demo/app.R b/demo/app.R new file mode 100644 index 0000000..ae89b31 --- /dev/null +++ b/demo/app.R @@ -0,0 +1,50 @@ +library(shiny) +library(editbl) + +ui <- fluidPage( + tags$h1('editbl - demo'), + br(), + editbl::eDTOutput('data'), + verbatimTextOutput('modifiedData'), + helpText('Note different behavior of different data types.'), + helpText('Edit cells by clicking the in-row buttons or directly within the table.'), + helpText("See how 'id' is generated on the fly."), + helpText("Note how only 'city_id' is stored even if not displayed. Cities are a separate table with foreign key."), +) + +server <- function(input,output,session){ + superheroes <- data.frame( + id = sapply(1:3, uuid::UUIDgenerate), + first_name = c('Bruce', 'Tony', 'Clark'), + last_name = c('Wayne', 'Stark', 'Kent'), + first_appearance = as.Date(c('1939-03-30', '1962-03-15', '1938-04-18')), + publisher = as.factor(c('DC Comics', 'Marvel', 'DC Comics')), + cars_owned = c(5,17,1), + city_id = c(1,2,3) + ) + + cities <- data.frame( + city_id = c(1,2,3), + name = c('New York', 'Gotham City', 'Smallville'), + country = c('US', 'US', 'US') + ) + + + modifiedData <- editbl::eDT( + id = 'data', + data = superheroes, + foreignTbls = list(foreignTbl(superheroes, cities, 'city_id')), + options = list(columnDefs = list(list(visible=FALSE, targets=c("id","city_id")))), + defaults = dplyr::tibble(id = uuid::UUIDgenerate()) + ) + + output$modifiedData <- renderPrint({ + data <- modifiedData$state() + print(str(data)) + print(data) + } + ) + +} +shiny::shinyApp(ui,server) + From 603ac308bba54b5e91e85fc506fbf99beed3db5b Mon Sep 17 00:00:00 2001 From: jschelfhout Date: Wed, 23 Jul 2025 15:08:51 +0200 Subject: [PATCH 2/4] build on push --- .github/workflows/deploy-app.yaml | 2 ++ .gitignore | 3 +-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy-app.yaml b/.github/workflows/deploy-app.yaml index 3734ccf..f12122e 100644 --- a/.github/workflows/deploy-app.yaml +++ b/.github/workflows/deploy-app.yaml @@ -8,6 +8,8 @@ on: type: string default: "1" required: false + push: + branches: ["gh_page"] jobs: build: diff --git a/.gitignore b/.gitignore index 3a41ab7..d86f438 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,4 @@ /editbl.Rcheck/ editbl_*.tar.gz .site - - +.Rbuildignore From 92384a24baf1061a00f10edcbe3b41837d5e5114 Mon Sep 17 00:00:00 2001 From: jschelfhout Date: Wed, 23 Jul 2025 15:19:38 +0200 Subject: [PATCH 3/4] Upload site artifact --- .github/workflows/deploy-app.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy-app.yaml b/.github/workflows/deploy-app.yaml index f12122e..f913569 100644 --- a/.github/workflows/deploy-app.yaml +++ b/.github/workflows/deploy-app.yaml @@ -44,7 +44,7 @@ jobs: shinylive::export("./demo", "site") - name: Upload site artifact - if: github.ref == 'refs/heads/main' + if: github.ref == 'refs/heads/gh_page' uses: actions/upload-pages-artifact@v3 with: path: "site" From 3f6c86bab941dc050e7914f9d2e50d6c9d9e836b Mon Sep 17 00:00:00 2001 From: jschelfhout Date: Wed, 23 Jul 2025 15:40:00 +0200 Subject: [PATCH 4/4] deploy on main --- .github/workflows/deploy-app.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/deploy-app.yaml b/.github/workflows/deploy-app.yaml index f913569..9ede6de 100644 --- a/.github/workflows/deploy-app.yaml +++ b/.github/workflows/deploy-app.yaml @@ -9,7 +9,7 @@ on: default: "1" required: false push: - branches: ["gh_page"] + branches: ["main"] jobs: build: @@ -44,13 +44,13 @@ jobs: shinylive::export("./demo", "site") - name: Upload site artifact - if: github.ref == 'refs/heads/gh_page' + if: github.ref == 'refs/heads/main' uses: actions/upload-pages-artifact@v3 with: path: "site" deploy: - if: github.ref == 'refs/heads/gh_page' + if: github.ref == 'refs/heads/main' needs: build # Grant GITHUB_TOKEN the permissions required to make a Pages deployment