Viewing File: /usr/local/cpanel/base/frontend/jupiter/_assets/_ssl_tls_tabs.html.tt

[%-
#
# SSL/TLS Tab Navigation Component
#
# This template renders the tab navigation for the unified SSL/TLS interface.
# Tabs are only shown when the leika flag global.ssl.unified_interface is enabled.
# Each tab's visibility depends on whether the user has the required features,
# except the wizard tab which is always visible when the unified interface is on.
#
# Usage:
#   PROCESS '_assets/_ssl_tls_tabs.html.tt' active_tab = 'wizard'
#
# Parameters:
#   active_tab - The key of the currently active tab (wizard, status, settings, keys, csrs, crts, install)
#

USE SSL;
USE ExpVar;

# Show tab bar (or don't) based on Leika flag
SET show_tabs = SSL.should_show_unified_ssl_ui();

IF !show_tabs;
    RETURN;
END;

# Check what SSL-related features are enabled in order to figure out what tabs to show/hide
SET has_ssl_manager_feature    = CPANEL.feature('sslmanager');
SET has_ssl_install_feature    = CPANEL.feature('sslinstall');
SET has_tls_wizard_feature     = CPANEL.feature('tls_wizard');
SET has_market_feature         = CPANEL.feature('market');
SET has_autossl_feature        = CPANEL.feature('autossl');
SET is_ssl_allowed             = ExpVar.expand('$isallowedssl');

# Utility
SET directory_prefix = CPANEL.CPVAR.dprefix || '';
SET active = active_tab || '';

# These are the possible tabs
# NOTE: When unified UI is on, the wizard tab is always visible regardless of
#       market, cpanel store, or wizard feature flags.
SET all_tabs = [
    {
        key      => 'wizard',
        label    => locale.maketext('Wizard'),
        href     => directory_prefix _ 'security/tls_wizard/index.html',
        visible  => has_ssl_install_feature
    },
    {
        key      => 'status',
        label    => locale.maketext('Status'),
        href     => directory_prefix _ 'security/tls_status/index.html',
        visible  => has_ssl_install_feature
    },
    {
        key      => 'crts',
        label    => locale.maketext('Certificates'),
        href     => directory_prefix _ 'ssl/crts.html',
        visible  => has_ssl_manager_feature
    },
    {
        key      => 'keys',
        label    => locale.maketext('Keys'),
        href     => directory_prefix _ 'ssl/keys.html',
        visible  => has_ssl_manager_feature
    },
    {
        key      => 'csrs',
        label    => locale.maketext('Requests'),
        href     => directory_prefix _ 'ssl/csrs.html',
        visible  => has_ssl_manager_feature
    },
    {
        key      => 'install',
        label    => locale.maketext('Installation'),
        href     => directory_prefix _ 'ssl/install.html',
        visible  => has_ssl_install_feature && is_ssl_allowed
    },
    {
        key      => 'settings',
        label    => locale.maketext('Settings'),
        href     => directory_prefix _ 'ssl/index.html',
        visible  => has_ssl_manager_feature
    }
];

# Filter to only visible tabs
SET visible_tabs = [];
FOREACH tab IN all_tabs;
    IF tab.visible;
        visible_tabs.push(tab);
    END;
END;

# If no tabs should be visible, don't bother trying to render anything
IF !visible_tabs.size;
    RETURN;
END;

# Check if the current active tab is accessible
# If it isn't, find the first available tab and set up a redirect
# But only redirect if an active_tab was actually specified (not empty)
SET current_tab_visible = 0;
SET redirect_to_tab = '';
IF active;  # Only check if active_tab was specified
    FOREACH tab IN visible_tabs;
        IF tab.key == active;
            SET current_tab_visible = 1;
        END;
        # Remember the first visible tab as a fallback
        IF !redirect_to_tab;
            SET redirect_to_tab = tab.href;
        END;
    END;
END;
-%]

[%# If current tab is not visible (and was specified), redirect to first available tab %]
[% IF active && !current_tab_visible && redirect_to_tab -%]
<script type="text/javascript">
    window.location.href = "[% redirect_to_tab | html %]";
</script>
<noscript>
    <meta http-equiv="refresh" content="0;url=[% redirect_to_tab | html %]" />
</noscript>
[% END -%]

<div class="tls-tabs" role="navigation" aria-label="[% locale.maketext('SSL/TLS navigation[comment,label]') %]">
    <ul class="nav nav-tabs tls-tabs__nav" role="tablist">
    [% FOREACH tab IN visible_tabs -%]
        [% SET is_active = (active == tab.key) -%]
        <li class="[% IF is_active %]active[% END %]" role="presentation">
            <a class="tls-tabs__tab [% IF is_active %]is-active[% END %]"
               href="[% tab.href %]"
               data-tab-key="[% tab.key %]"
               role="tab"
               aria-selected="[% is_active ? 'true' : 'false' %]">
                <span class="tls-tabs__spinner" aria-hidden="true"></span>
                <span class="tls-tabs__label">[% tab.label %]</span>
            </a>
        </li>
    [% END -%]
    </ul>
</div>

<script type="text/javascript">
[% INSERT 'sharedjs/ssl_tabs.js' %]
</script>
Back to Directory