Macjutsu / super

S.U.P.E.R.M.A.N. optimizes the macOS software update experience.
Apache License 2.0
637 stars 86 forks source link

FEATURE REQUEST: Support local file URLs in IBM Notifier’s Help Button #256

Open owainri opened 3 days ago

owainri commented 3 days ago

Is your feature request related to a problem? Please describe. I was trying to configure the Help button in IBM Notifier to link to a local file, so users could quickly access a PDF version of a Confluence Super help guide - negating the risk of needing to re-authenticate. In cases where a session (like Okta) has timed out, users might be discouraged from engaging with resources if they’re prompted to log in again just to view a document.

To avoid this, I packaged a PDF version of the documentation and configured the Help button to open it directly from a local path. However, I found that Super currently doesn't support file:// URLs, so IBM Notifier couldn’t open local files as intended and just displayed the file path as text.

Proposed solution. I modified the set_display_strings_optional_buttons function to recognise file:// URLs, allowing IBM Notifier’s Help button to open local files directly without requiring an external network connection or authentication. This small adjustment makes it easier to link to local resources like PDFs, reducing disruptions for end-users.

Additional context Here’s the modified code snippet that adds file:// support:

if [[ -n "${display_help_button_string}" ]]; then
    if [[ $(echo "${display_help_button_string}" | grep -c '^http://\|^https://\|^mailto:\|^jamfselfservice://\|^file://') -gt 0 ]]; then
        if [[ $(echo "${display_help_button_string}" | grep -c '^file://') -gt 0 ]]; then
            ibm_notifier_array+=(-help_button_cta_type link -help_button_cta_payload "${display_help_button_string}")
        elif [[ $(echo "${display_help_button_string_option}" | grep -c '^http://\|^https://') -gt 0 ]]; then
            curl_response=$(curl -Is "${display_help_button_string_option}" | head -1)
            [[ "${verbose_mode_option}" == "TRUE" ]] && log_super "Verbose Mode: Function ${FUNCNAME[0]}: Line ${LINENO}: curl_response is: ${curl_response}"
            if [[ $(echo "${curl_response}" | grep -c '200') -gt 0 ]] || [[ $(echo "${curl_response}" | grep -c '302') -gt 0 ]]; then
                ibm_notifier_array+=(-help_button_cta_type link -help_button_cta_payload "${display_help_button_string}")
            else
                log_super "Warning: Help button not shown because URL is unreachable: ${display_help_button_string}"
            fi
        else
            ibm_notifier_array+=(-help_button_cta_type link -help_button_cta_payload "${display_help_button_string}")
        fi
    else
        ibm_notifier_array+=(-help_button_cta_type infopopup -help_button_cta_payload "${display_help_button_string}")
    fi
fi