-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch '15-add-function-to-set-up-precommit' of https://github.…
…com/dfe-analytical-services/dfeshiny into 15-add-function-to-set-up-precommit
- Loading branch information
Showing
8 changed files
with
119 additions
and
94 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# 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: | ||
push: | ||
branches: [main, master] | ||
pull_request: | ||
|
||
name: lint.yaml | ||
|
||
permissions: read-all | ||
|
||
jobs: | ||
lint: | ||
runs-on: ubuntu-latest | ||
env: | ||
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- uses: r-lib/actions/setup-r@v2 | ||
with: | ||
use-public-rspm: true | ||
|
||
- uses: r-lib/actions/setup-r-dependencies@v2 | ||
with: | ||
extra-packages: any::lintr, local::. | ||
|
||
- name: Lint | ||
run: | | ||
# Pin the lintr version to avoid breaking changes with newer 3.2.0 version | ||
# See: https://github.com/apache/arrow/pull/45524 | ||
pak::pak("[email protected]") | ||
lintr::lint_package() | ||
shell: Rscript {0} | ||
env: | ||
LINTR_ERROR_ON_LINT: true |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ | |
#' Create the HTML overlay panel to appear when a user loses connection to a dashboard. | ||
#' | ||
#' @param refresh the text to appear that will refresh the page when clicked | ||
#' @param reset the text to appear that will reset the page when clicked | ||
#' @param links A vector of possible URLs for the public site. Should mostly just be a single URL, | ||
#' but can be two URLs if an overflow site has been set up | ||
#' @param publication_name The parent publication name | ||
|
@@ -16,6 +17,7 @@ | |
#' @param custom_refresh Custom refresh link, defaults to refreshing the page, main value is if you | ||
#' have bookmarking enabled and want the refresh to send to the initial view instead of reloading | ||
#' any bookmarks | ||
#' @param custom_reset Custom reset link, defaults to resetting the page | ||
#' | ||
#' @importFrom htmltools tags tagList | ||
#' | ||
|
@@ -49,22 +51,17 @@ | |
#' custom_refresh = "https://department-for-education.shinyapps.io/my-dashboard" | ||
#' ) | ||
custom_disconnect_message <- function( | ||
refresh = "Refresh page", | ||
refresh = "refresh page (attempting to keep your last known selections)", | ||
reset = "reset page (removing any previous selections)", | ||
dashboard_title = NULL, | ||
links = NULL, | ||
publication_name = NULL, | ||
publication_link = NULL, | ||
support_contact = "[email protected]", | ||
custom_refresh = NULL) { | ||
custom_refresh = NULL, | ||
custom_reset = NULL) { | ||
# Check links are valid | ||
is_valid_sites_list <- function(sites) { | ||
lapply( | ||
stringr::str_trim(sites), startsWith, | ||
"https://department-for-education.shinyapps.io/" | ||
) | ||
} | ||
|
||
if (FALSE %in% is_valid_sites_list(links) || | ||
if (FALSE %in% validate_dashboard_url(links) || | ||
"https://department-for-education.shinyapps.io/" %in% links) { # nolint: [indentation_linter] | ||
stop("You have entered an invalid site link in the links argument.") | ||
} | ||
|
@@ -84,6 +81,21 @@ custom_disconnect_message <- function( | |
} | ||
} | ||
|
||
if (!is.null(custom_reset)) { | ||
is_valid_reset <- function(reset) { | ||
startsWith(stringr::str_trim(reset), "https://department-for-education.shinyapps.io/") | ||
} | ||
|
||
if (is_valid_reset(custom_reset) == FALSE) { | ||
stop( | ||
paste0( | ||
"You have entered an invalid site link in the custom_reset argument. It must be a site", | ||
" on shinyapps.io." | ||
) | ||
) | ||
} | ||
} | ||
|
||
pub_prefix <- c( | ||
"https://explore-education-statistics.service.gov.uk/find-statistics/", | ||
"https://www.explore-education-statistics.service.gov.uk/find-statistics/", | ||
|
@@ -107,6 +119,7 @@ custom_disconnect_message <- function( | |
# TODO: Add email validation once a11y panel PR is in | ||
|
||
checkmate::assert_string(refresh) | ||
checkmate::assert_string(reset) | ||
|
||
# Attach CSS from inst/www/css/visually-hidden.css | ||
dependency <- htmltools::htmlDependency( | ||
|
@@ -165,6 +178,23 @@ custom_disconnect_message <- function( | |
.noWS = c("after") | ||
) | ||
}, | ||
", or ", | ||
if (is.null(custom_reset)) { | ||
tags$a( | ||
id = "ss-reset-link", | ||
href = "#", | ||
reset, | ||
onclick = "window.location.reload(false);", | ||
.noWS = c("after") | ||
) | ||
} else { | ||
tags$a( | ||
id = "ss-reset-link", | ||
href = custom_reset, | ||
reset, | ||
.noWS = c("after") | ||
) | ||
}, | ||
"." | ||
), | ||
if (length(links) > 1) { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,22 @@ | ||
Version: 1.0 | ||
ProjectId: 542ddaed-ab53-4f0c-8930-7994a4453a0d | ||
|
||
RestoreWorkspace: No | ||
SaveWorkspace: No | ||
AlwaysSaveHistory: Default | ||
|
||
EnableCodeIndexing: Yes | ||
UseSpacesForTab: Yes | ||
NumSpacesForTab: 2 | ||
Encoding: UTF-8 | ||
|
||
RnwWeave: Sweave | ||
LaTeX: pdfLaTeX | ||
|
||
AutoAppendNewline: Yes | ||
StripTrailingWhitespace: Yes | ||
LineEndingConversion: Posix | ||
|
||
BuildType: Package | ||
PackageUseDevtools: Yes | ||
PackageInstallArgs: --no-multiarch --with-keep.source | ||
PackageRoxygenize: rd,collate,namespace | ||
Version: 1.0 | ||
|
||
RestoreWorkspace: No | ||
SaveWorkspace: No | ||
AlwaysSaveHistory: Default | ||
|
||
EnableCodeIndexing: Yes | ||
UseSpacesForTab: Yes | ||
NumSpacesForTab: 2 | ||
Encoding: UTF-8 | ||
|
||
RnwWeave: Sweave | ||
LaTeX: pdfLaTeX | ||
|
||
AutoAppendNewline: Yes | ||
StripTrailingWhitespace: Yes | ||
LineEndingConversion: Posix | ||
|
||
BuildType: Package | ||
PackageUseDevtools: Yes | ||
PackageInstallArgs: --no-multiarch --with-keep.source | ||
PackageRoxygenize: rd,collate,namespace |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters