Skip to content

Commit

Permalink
Memo delete UI (#134)
Browse files Browse the repository at this point in the history
* style project delete text
* ask for confirmation on memo delete
* raise version counter
* update tests for memos

---------

Co-authored-by: hlageek <22201406+hlageek@users.noreply.github.com>
Co-authored-by: Michael Škvrňák <michael.skvrnak@protonmail.com>
  • Loading branch information
3 people committed May 2, 2024
1 parent 92c2055 commit 47cfe62
Show file tree
Hide file tree
Showing 13 changed files with 477 additions and 158 deletions.
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ $run_dev.*
^CODE_OF_CONDUCT\.md$
^\.github$
_\.new\.png$
^codecov\.yml$
24 changes: 19 additions & 5 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
#
# NOTE: This workflow is overkill for most R packages and
# check-standard.yaml is likely a better choice.
# usethis::use_github_action("check-standard") will install it.
on:
push:
branches: [main, master]
Expand All @@ -18,17 +22,27 @@ jobs:
fail-fast: false
matrix:
config:
#- {os: macOS-latest, r: 'release'}
- {os: macos-latest, r: 'release'}

- {os: windows-latest, r: 'release'}
- {os: ubuntu-20.04, r: 'release', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}
# Use 3.6 to trigger usage of RTools35
# - {os: windows-latest, r: '3.6'}
# use 4.1 to check with rtools40's older compiler
# - {os: windows-latest, r: '4.1'}

- {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'}
- {os: ubuntu-latest, r: 'release'}
# - {os: ubuntu-latest, r: 'oldrel-1'}
# - {os: ubuntu-latest, r: 'oldrel-2'}
# - {os: ubuntu-latest, r: 'oldrel-3'}
# - {os: ubuntu-latest, r: 'oldrel-4'}

env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
R_KEEP_PKG_SOURCE: yes

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- uses: r-lib/actions/setup-pandoc@v2

Expand All @@ -40,11 +54,11 @@ jobs:

- uses: r-lib/actions/setup-r-dependencies@v2
with:
cache-version: 5
cache-version: 1
extra-packages: any::rcmdcheck
needs: check

- uses: r-lib/actions/check-r-package@v2
with:
error-on: '"warning"'
upload-snapshots: true
build_args: 'c("--no-manual","--compact-vignettes=gs+qpdf")'
79 changes: 79 additions & 0 deletions .github/workflows/pr-commands.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
issue_comment:
types: [created]

name: Commands

jobs:
document:
if: ${{ github.event.issue.pull_request && (github.event.comment.author_association == 'MEMBER' || github.event.comment.author_association == 'OWNER') && startsWith(github.event.comment.body, '/document') }}
name: document
runs-on: ubuntu-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v4

- uses: r-lib/actions/pr-fetch@v2
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}

- uses: r-lib/actions/setup-r@v2
with:
use-public-rspm: true

- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::roxygen2
needs: pr-document

- name: Document
run: roxygen2::roxygenise()
shell: Rscript {0}

- name: commit
run: |
git config --local user.name "$GITHUB_ACTOR"
git config --local user.email "$GITHUB_ACTOR@users.noreply.github.com"
git add man/\* NAMESPACE
git commit -m 'Document'
- uses: r-lib/actions/pr-push@v2
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}

style:
if: ${{ github.event.issue.pull_request && (github.event.comment.author_association == 'MEMBER' || github.event.comment.author_association == 'OWNER') && startsWith(github.event.comment.body, '/style') }}
name: style
runs-on: ubuntu-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v4

- uses: r-lib/actions/pr-fetch@v2
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}

- uses: r-lib/actions/setup-r@v2

- name: Install dependencies
run: install.packages("styler")
shell: Rscript {0}

- name: Style
run: styler::style_pkg()
shell: Rscript {0}

- name: commit
run: |
git config --local user.name "$GITHUB_ACTOR"
git config --local user.email "$GITHUB_ACTOR@users.noreply.github.com"
git add \*.R
git commit -m 'Style'
- uses: r-lib/actions/pr-push@v2
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
5 changes: 3 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: requal
Title: Shiny Application for Computer-Assisted Qualitative Data Analysis
Version: 1.1.1.9002
Version: 1.1.1.9003
Authors@R:
c(
person(given = "Radim",
Expand Down Expand Up @@ -73,7 +73,8 @@ Suggests:
shinytest2,
rvest,
devtools,
pkgload
pkgload,
covr
VignetteBuilder: knitr
Config/testthat/edition: 3
Language: en-US
40 changes: 33 additions & 7 deletions R/mod_memo.R
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ mod_memo_server <- function(id, glob) {
ns <- session$ns

memo_list <- reactiveVal()
loc <- reactiveValues()

output$new_memo_btn <- renderUI({
req(glob$user$data)
if(glob$user$data$memo_modify == 1){
Expand Down Expand Up @@ -98,22 +100,22 @@ mod_memo_server <- function(id, glob) {

# Display selected memo -----
observeEvent(input$selected_memo, {
memo <- read_memo_by_id(glob$pool, glob$active_project, input$selected_memo)
can_modify <- find_memo_permission(memo$user_id, glob$user)
loc$memo <- read_memo_by_id(glob$pool, glob$active_project, input$selected_memo)
can_modify <- find_memo_permission(loc$memo$user_id, glob$user)

showModal(
modalDialog(
title = memo$memo_name,
title = loc$memo$memo_name,
textAreaInput(ns("displayed_memo_text"), "Text",
value = memo$memo_text,
value = loc$memo$memo_text,
width = "100%", height = "100%",
placeholder = "First 50 characters of the first line will become a searchable title..."
) %>% tagAppendAttributes(style = "height: 50vh"),
footer = tagList(
modalButton("Close"),
if(can_modify){
list(
actionButton(ns("save_changes"), "Save & Close"),
actionButton(ns("save_changes"), "Save & Close", class = "btn-success"),
actionButton(ns("delete_memo"), "Delete", class = "btn-danger")
)
}
Expand All @@ -138,8 +140,30 @@ mod_memo_server <- function(id, glob) {
removeModal()
})

# Delete memo ----

observeEvent(input$delete_memo, {
delete_memo_record(glob$pool, glob$active_project, input$selected_memo,

showModal(
modalDialog(
title = "Are you sure?",
tags$span("You are about to delete the memo and lose its content:",
tags$b(loc$memo$memo_name)),
easyClose = TRUE,
footer = tagList(
modalButton("Dismiss"),
actionButton(ns("delete_memo_confirmation"),
"Yes, I am sure.",
class = "btn-danger"
)
),
fade = TRUE
)
)
})

observeEvent(input$delete_memo_confirmation, {
delete_memo_record(glob$pool, glob$active_project, input$selected_memo,
user_id = glob$user$user_id
)

Expand All @@ -151,8 +175,10 @@ mod_memo_server <- function(id, glob) {
memo_list(visible_memos)

removeModal()

})


# Memo export ----
output$export_memo <- downloadHandler(
filename = function() {
"requal_memo_export.csv"
Expand Down
8 changes: 3 additions & 5 deletions R/mod_project.R
Original file line number Diff line number Diff line change
Expand Up @@ -154,11 +154,9 @@ mod_project_server <- function(id, glob) {
showModal(
modalDialog(
title = "Are you sure?",
paste(
"You are about to delete the project",
loc$project_name,
"and lose all data associated with it!"
),
tags$span("You are about to delete the project",
tags$b(loc$project_name),
"and lose all data associated with it!"),
easyClose = TRUE,
footer = tagList(
modalButton("Dismiss"),
Expand Down
1 change: 1 addition & 0 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ knitr::opts_chunk$set(
<!-- badges: start -->
[![Lifecycle: experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://lifecycle.r-lib.org/articles/stages.html#experimental)
[![R-CMD-check](https://github.com/RE-QDA/requal/workflows/R-CMD-check/badge.svg)](https://github.com/RE-QDA/requal/actions)
[![R-CMD-check](https://github.com/RE-QDA/requal/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/RE-QDA/requal/actions/workflows/R-CMD-check.yaml)
<!-- badges: end -->

The goal of `requal` is to provide reproducibility support for qualitative coding.
Expand Down
14 changes: 14 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
comment: false

coverage:
status:
project:
default:
target: auto
threshold: 1%
informational: true
patch:
default:
target: auto
threshold: 1%
informational: true
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
"","memo_id","memo_text","user_name"
"1",1,"Memo","skvrnami"
"","memo_title","memo_text","memo_id","user_name"
"1","Memo","Memo",1,"skvrnami"
2 changes: 2 additions & 0 deletions inst/test_app/tests/testthat/test-app-delete-memo.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ test_that("{shinytest2} test", {

app$click("memo_ui_1-delete_memo")

app$click("memo_ui_1-delete_memo_confirmation")

app$click(selector = ".fa-sticky-note")
app$wait_for_idle()

Expand Down
9 changes: 2 additions & 7 deletions renv.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1317,13 +1317,8 @@
},
"renv": {
"Package": "renv",
"Version": "0.17.3",
"Source": "Repository",
"Repository": "CRAN",
"Requirements": [
"utils"
],
"Hash": "4543b8cd233ae25c6aba8548be9e747e"
"Version": "1.0.7",
"Source": "Repository"
},
"rlang": {
"Package": "rlang",
Expand Down
Loading

0 comments on commit 47cfe62

Please sign in to comment.