[%- # # 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 autossl.exclude_new_domains is enabled. # Each tab's visibility depends on whether the user has the required features. # # 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_exclude_new_domains(); 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 SET all_tabs = [ { key => 'wizard', label => locale.maketext('Wizard'), href => directory_prefix _ 'security/tls_wizard/index.html', visible => has_ssl_install_feature && has_tls_wizard_feature && has_market_feature }, { key => 'status', label => locale.maketext('Status'), href => directory_prefix _ 'security/tls_status/index.html', visible => has_autossl_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 -%] [% END -%]