Skip to content

Conversation

@DeepanshKhurana
Copy link
Collaborator

@DeepanshKhurana DeepanshKhurana commented Nov 22, 2024

Have you read the Contributing Guidelines?

Closes #14

Note to reviewers: This was changed before brand.yml came into the picture and works quite similarly. Still, since this is underway and has existing PRs in sequence (#17, #20), it would make sense to go forward with this and then, do a cleanup refactor to use brand.yml with minor changes, if necessary. Although, I don't see the need as of yet because the branding is not as widely present in this app, owing to its simplicity. But it can be something we decide in the future.

Description

  • Adds config.yml branding + Sass modifications to access it
  • Adds notes to README.md for the same
  • Adds minor fix to onClick in the app list and job list reactable tables

Loom recording with demo

Definition of Done

  • The change is thoroughly documented.
  • The CI passes (R CMD check, linter, unit tests, spelling).
  • Any generated files have been updated (e.g. .Rd files with roxygen2::roxygenise())

@DeepanshKhurana DeepanshKhurana added the enhancement New feature or request label Nov 22, 2024
@DeepanshKhurana DeepanshKhurana self-assigned this Nov 22, 2024
Copy link
Member

@jakubnowicki jakubnowicki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey, this is a nice improvement 👍 It needs a little bit more polishing; please check my comments.

app/main.R Outdated
@@ -1,31 +1,17 @@
# nolint start: box_func_import_count_linter
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove nolint.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, I've removed all nolints!

app/main.R Outdated
Comment on lines 60 to 65
branding <- get("branding")

output$dynamic_colors <- shiny$renderUI({
css_content <- generate_css_variables(branding)
shiny$tags$style(shiny$HTML(css_content))
})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of using renderUI, it could be simpler to just read and create the style outside of ui and server and than use it inside (something like the good old global.R).

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this was a great suggestion, saves us the extra reactive usage when none is required. I've moved the code to a section above the ui()

#' @return a string of CSS variables within :root {}
#' @export
generate_css_variables <- function(
config = get("branding")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we actually need a default here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct. I've removed the default value.

#' @param config the config file
#' @return a string of CSS variables within :root {}
#' @export
generate_css_variables <- function(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it is a good moment to start adding unit tests? This function looks like an opportunity :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added tests for all the general_utils functions! :D

text = "Select an application and a job to view logs",
image_path = "static/illustrations/empty_state.svg"
image_path = "static/illustrations/empty_state.svg",
color = NULL
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is inconsistent, as replace_svg_fill will not accept NULL.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolved!

config.yml Outdated
grey-text: grey
black-text: "#333"
selected-row: "#00000010"
primary: "#0099f9"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it would be good to move primary to the top?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense. I've moved it to the top!

- This may mean that the Posit Connect API's response did not send proper data.
- So far, one documented reason for this is that OAuth on Posit Connect instances may prevent the `/content` endpoint from sending app data.
- How do I rebrand the application?
- You can edit the branding in the `config.yml` file. You'll find the `colors` key which will build the CSS.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest expanding this with some description of what particular colors do.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes! I've added a few points explaining how the colors work. It should at least indicate the user what colors affect what values.

@DeepanshKhurana DeepanshKhurana requested a review from vituri May 6, 2025 08:00
Copy link

@vituri vituri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Later we will be able to use the new brand.yml file.

I see that all other comments by Jakub Nowicki were solved as well since his last review.

Comment on lines +19 to +50
describe("check_text_error()", {
it("returns TRUE for error keywords", {
expect_true(
check_text_error(
"Error: job failed"
)
)
expect_true(
check_text_error(
"Halt: job terminated"
)
)
expect_true(
check_text_error(
"Error: file not found"
)
)
})

it("returns FALSE for non-error keywords", {
expect_true(
!check_text_error(
"Job completed successfully"
)
)
expect_true(
!check_text_error(
"Processing"
)
)
})
})
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a chance that the message is something like the following?

> check_text_error("No error found")
[1] TRUE

If yes, maybe to explicit that the string start with one of the wordlist is enough, like the following:

check_text_error <- function(
    text,
    wordlist = c("halt", "err", "terminat", "not found"),
    ignore_case = TRUE
) {
  grepl(
    paste0("^", wordlist, collapse = "|"),
    text,
    ignore.case = ignore_case
  )
}

check_text_error("No error found")
check_text_error("Error: aaa")

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great catch! I finally took a look at this and added your code. Thanks for the suggestion.

@DeepanshKhurana
Copy link
Collaborator Author

@jakubnowicki I believe we should be good here and @vituri already confirmed all the comments were addressed. I believe (2?) sequential branches have already been merged into this by him as well. So, we should avoid bloating this further and merge it. Additionally, I could not push to the main repository anymore (I assumed I would be able to do it but some permission issue prevented it) so I forked and created a !23 to add his suggestion for check_error_text() in his comment above. I suggest we merge that after we merge this to main.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Improve Theming Capabilities

5 participants