Skip to content

Commit

Permalink
Merge pull request #107 from Tychobra/update/default_toast_options
Browse files Browse the repository at this point in the history
Moved toasts to top-center & changed duration to 1 sec
  • Loading branch information
merlinoa committed Sep 29, 2020
2 parents 0f490bc + df34680 commit d82ad41
Show file tree
Hide file tree
Showing 9 changed files with 92 additions and 18 deletions.
6 changes: 5 additions & 1 deletion R/profile_module.R
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,11 @@ profile_module <- function(input, output, session) {
}, error = function(err) {

print(err)
shinyFeedback::showToast("error", "Sign Out Error")
shinyFeedback::showToast(
"error",
"Sign Out Error",
.options = polished_toast_options
)
})

})
Expand Down
12 changes: 10 additions & 2 deletions R/send_password_reset_email_module.R
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,19 @@ send_password_reset_email_module <- function(input, output, session, email) {
stop(res_content$message)
}

shinyFeedback::showToast("success", paste0("Password reset email sent to ", hold_email))
shinyFeedback::showToast(
"success",
paste0("Password reset email sent to ", hold_email),
.options = polished_toast_options
)
}, error = function(err) {

print(err)
shinyFeedback::showToast("error", err$message)
shinyFeedback::showToast(
"error",
err$message,
.options = polished_toast_options
)
})


Expand Down
15 changes: 12 additions & 3 deletions R/sign_in_components.R
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ sign_in_check_jwt <- function(jwt, session = shiny::getDefaultReactiveDomain())
shinyFeedback::resetLoadingButton('sign_in_submit')
shinyFeedback::showToast(
"info",
"Password reset required. Check your email to reset your password."
"Password reset required. Check your email to reset your password.",
.options = polished_toast_options
)
return()
}
Expand All @@ -92,7 +93,11 @@ sign_in_check_jwt <- function(jwt, session = shiny::getDefaultReactiveDomain())
if (is.null(new_user)) {
shinyFeedback::resetLoadingButton('sign_in_submit')
# show unable to sign in message
shinyFeedback::showToast('error', 'sign in error')
shinyFeedback::showToast(
'error',
'sign in error',
.options = polished_toast_options
)
stop('sign_in_module: sign in error', call. = FALSE)

} else {
Expand All @@ -105,7 +110,11 @@ sign_in_check_jwt <- function(jwt, session = shiny::getDefaultReactiveDomain())
shinyFeedback::resetLoadingButton('sign_in_submit')
print(err)

shinyFeedback::showToast("error", err$message)
shinyFeedback::showToast(
"error",
err$message,
.options = polished_toast_options
)

})

Expand Down
6 changes: 5 additions & 1 deletion R/sign_in_module.R
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,11 @@ sign_in_module <- function(input, output, session) {
shinyFeedback::resetLoadingButton('register_submit')

print(err)
shinyFeedback::showToast("error", err$message)
shinyFeedback::showToast(
"error",
err$message,
.options = polished_toast_options
)
})

})
Expand Down
6 changes: 5 additions & 1 deletion R/sign_in_module_2.R
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,11 @@ sign_in_module_2 <- function(input, output, session) {
shinyFeedback::resetLoadingButton('register_submit')

print(err)
shinyFeedback::showToast("error", err$message)
shinyFeedback::showToast(
"error",
err$message,
.options = polished_toast_options
)
})

})
Expand Down
18 changes: 15 additions & 3 deletions R/user_access_module.R
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,11 @@ user_access_module <- function(input, output, session) {
print("[polished] error")
print(err)

showToast("error", "Error retrieving app users from API")
showToast(
"error",
"Error retrieving app users from API",
.options = polished_toast_options
)
})

out
Expand Down Expand Up @@ -368,10 +372,18 @@ user_access_module <- function(input, output, session) {

httr::stop_for_status(res)

shinyFeedback::showToast("success", "User successfully deleted")
shinyFeedback::showToast(
"success",
"User successfully deleted",
.options = polished_toast_options
)
users_trigger(users_trigger() + 1)
}, error = function(e) {
shinyFeedback::showToast("error", "Error deleting user")
shinyFeedback::showToast(
"error",
"Error deleting user",
.options = polished_toast_options
)
print(e)
})

Expand Down
24 changes: 20 additions & 4 deletions R/user_edit_module.R
Original file line number Diff line number Diff line change
Expand Up @@ -193,10 +193,18 @@ user_edit_module <- function(input, output, session,


users_trigger(users_trigger() + 1)
shinyFeedback::showToast("success", "User successfully added!")
shinyFeedback::showToast(
"success",
"User successfully added!",
.options = polished_toast_options
)
}, error = function(err) {

shinyFeedback::showToast("error", err$message)
shinyFeedback::showToast(
"error",
err$message,
.options = polished_toast_options
)
print(err)
})

Expand Down Expand Up @@ -234,10 +242,18 @@ user_edit_module <- function(input, output, session,
}

users_trigger(users_trigger() + 1)
shinyFeedback::showToast("success", "User successfully edited!")
shinyFeedback::showToast(
"success",
"User successfully edited!",
.options = polished_toast_options
)
}, error = function(e) {

shinyFeedback::showToast("error", "Error editing user")
shinyFeedback::showToast(
"error",
"Error editing user",
.options = polished_toast_options
)
print(e)

})
Expand Down
11 changes: 10 additions & 1 deletion R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,13 @@ send_invite_checkbox <- function(ns, app_url) {
}

email_invite_checkbox
}
}

#' @noRd
#'
#' Default `.options` for `showToast`
polished_toast_options <- list(
positionClass = "toast-top-center",
showDuration = 1000,
newestOnTop = TRUE
)
12 changes: 10 additions & 2 deletions R/verify_email_module.R
Original file line number Diff line number Diff line change
Expand Up @@ -154,14 +154,22 @@ verify_email_module <- function(input, output, session) {
stop(res_content, call. = FALSE)
}

shinyFeedback::showToast("success", paste0("Verification email send to ", hold_email))
shinyFeedback::showToast(
"success",
paste0("Verification email send to ", hold_email),
.options = polished_toast_options
)
}, error = function(err) {


print("[polished] error - resending verification email")
print(err)

shinyFeedback::showToast("error", "Error resending verification email")
shinyFeedback::showToast(
"error",
"Error resending verification email",
.options = polished_toast_options
)
})

})
Expand Down

0 comments on commit d82ad41

Please sign in to comment.