Skip to content

Commit

Permalink
Added fix to get download buttons back working
Browse files Browse the repository at this point in the history
  • Loading branch information
rmbielby committed Jan 15, 2025
1 parent ba74eec commit eba9c5d
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 29 deletions.
25 changes: 12 additions & 13 deletions .hooks/pre-commit.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env Rscript
cat("Running commit hooks...",fill=TRUE)
cat("Running commit hooks...", fill = TRUE)
shhh <- suppressPackageStartupMessages # It's a library, so shhh!
shhh(library(dplyr))
shhh(library(xfun))
Expand All @@ -16,12 +16,12 @@ cat("Contents of the .gitignore file:")
print(ign_files)

# Run a pass through the .gitignore files and look for any issues
if(ncol(ign_files)>1){
if (ncol(ign_files) > 1) {
cat("ERROR: It looks like you've got commas in the .gitignore. Please correct the .gitignore file and try again.")
error_flag <- TRUE
} else {
for(i in 1:nrow(ign_files)){
if(grepl(' ',ign_files$filename[i])){
for (i in 1:nrow(ign_files)) {
if (grepl(" ", ign_files$filename[i])) {
cat("ERROR: It looks like you've got spaces in filenames in the .gitignore. Please rename your files if they contain spaces and update the .gitignore file accordingly.")
error_flag <- TRUE
}
Expand All @@ -43,25 +43,24 @@ for (file in current_files$files) {
} else {
file_status <- (log_files %>% filter(filename == file))$status
if (!file_status %in% c("published", "Published", "reference", "Reference", "dummy", "Dummy")) {
if (!file %in% ign_files$filename & !grepl("unpublished",file)) {
if (!file %in% ign_files$filename & !grepl("unpublished", file)) {
cat("Error:", file, "is not logged as published or reference data in datafiles_log.csv and is not found in .gitignore.\n\n")
cat("If the file contains published or reference data then update its entry in datafiles_log.csv.\n\n")
cat("If the file contains unpublished data then add it to the .gitignore file.\n\n")
error_flag <- TRUE
}
else {
cat(file,"is recorded in the logfile as unpublished data and in .gitignore and so will not be included as part of the commit.\n\n")
} else {
cat(file, "is recorded in the logfile as unpublished data and in .gitignore and so will not be included as part of the commit.\n\n")
}
}
}
}

if(grepl('G-Z967JJVQQX', htmltools::includeHTML(("google-analytics.html"))) &
!(toupper(Sys.getenv("USERNAME")) %in% c("CFOSTER4", "CRACE", "LSELBY","RBIELBY", "JMACHIN"))){
cat("Cleaning out the template's Google Analytics tag.",fill=TRUE)
if (grepl("G-Z967JJVQQX", htmltools::includeHTML(("google-analytics.html"))) &
!(toupper(Sys.getenv("USERNAME")) %in% c("CFOSTER4", "CRACE", "LSELBY", "RBIELBY", "JMACHIN"))) {
cat("Cleaning out the template's Google Analytics tag.", fill = TRUE)
gsub_file("google-analytics.html", pattern = "G-Z967JJVQQX", replacement = "G-XXXXXXXXXX")
gsub_file("ui.R", pattern = "Z967JJVQQX", replacement = "XXXXXXXXXX")
system2(command = "git", args=c("add","google-analytics.html"))
system2(command = "git", args = c("add", "google-analytics.html"))
}

if (error_flag) {
Expand All @@ -70,7 +69,7 @@ if (error_flag) {
}

tidy_output <- tidy_code()
if(any(tidy_output)){
if (any(tidy_output)) {
error_flag <- TRUE
}

Expand Down
13 changes: 5 additions & 8 deletions R/industry_by_subject.R
Original file line number Diff line number Diff line change
Expand Up @@ -75,16 +75,13 @@ industry_by_subject_panel <- function() {
choices = NULL
),
# Add a button to download data as a csv
tags$button(
type = "button",
downloadButton(
"downloadIndSub",
class = "govuk-button govuk-button--inverse",
`data-module` = "govuk-button",
download_link(
"downloadIndSub",
link_text = "Download this table",
file_size = "maximum 5 KB"
)
),
label = "Download this table (maximum 5 KB)",
icon = NULL
)
) # Right column of filter options - end
)
)
Expand Down
13 changes: 5 additions & 8 deletions R/subject_by_industry.R
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,13 @@ subject_by_industry_panel <- function() {
)
),
# Add a button to download data as a csv
tags$button(
type = "button",
downloadButton(
"downloadSubInd",
class = "govuk-button govuk-button--inverse",
`data-module` = "govuk-button",
download_link(
"downloadSubInd",
link_text = "Download this table",
file_size = "maximum 13 KB"
)
),
label = "Download this table (maximum 13 KB)",
icon = NULL
)
) # Right column of filter options - end
)
)
Expand Down

0 comments on commit eba9c5d

Please sign in to comment.