diff --git a/dejacode/static/css/dejacode_bootstrap.css b/dejacode/static/css/dejacode_bootstrap.css index f49cb19d..70012bdf 100644 --- a/dejacode/static/css/dejacode_bootstrap.css +++ b/dejacode/static/css/dejacode_bootstrap.css @@ -159,6 +159,25 @@ table.text-break thead { .navbar #search-form { width: 350px; } +.nav-chip { + transition: background-color 0.15s ease, border-color 0.15s ease; +} +.nav-chip:hover, +.nav-chip:focus-visible { + background-color: rgba(255, 255, 255, 0.18) !important; + border-color: rgba(255, 255, 255, 0.5) !important; +} + +/* -- Side menu -- */ +#side-menu .nav-pills .nav-link.active { + color: #fff !important; +} +#side-menu .nav-link { + text-decoration: none; +} +#side-menu .nav-pills .nav-link:not(.active):hover { + background-color: var(--bs-tertiary-bg); +} /* -- Pagination -- */ nav ul.pagination .disabled { diff --git a/dejacode/static/js/dejacode_main.js b/dejacode/static/js/dejacode_main.js index b6df8b64..9be23ff1 100644 --- a/dejacode/static/js/dejacode_main.js +++ b/dejacode/static/js/dejacode_main.js @@ -128,6 +128,46 @@ function setupHTMX() { }); } +function setupSearchModal() { + const searchForm = document.getElementById('search-form'); + const searchInput = document.getElementById('search-input'); + const searchModal = document.getElementById('search-modal'); + + if (!searchModal) return; + + // Scope selector buttons + if (searchForm) { + document.querySelectorAll('.search-scope-btn').forEach(button => { + button.addEventListener('click', () => { + document.querySelectorAll('.search-scope-btn').forEach(b => b.classList.remove('active')); + button.classList.add('active'); + searchForm.setAttribute('action', button.dataset.scopeAction); + searchInput.focus(); + }); + }); + } + + // Autofocus input when modal opens + searchModal.addEventListener('shown.bs.modal', () => { + searchInput.focus(); + searchInput.select(); + }); + + // Keyboard shortcuts: Ctrl/Cmd+K and / to open the modal + document.addEventListener('keydown', (event) => { + const isTyping = ['INPUT', 'TEXTAREA', 'SELECT'].includes(document.activeElement.tagName) || document.activeElement.isContentEditable; + const modalInstance = bootstrap.Modal.getOrCreateInstance(searchModal); + + if ((event.ctrlKey || event.metaKey) && event.key === 'k') { + event.preventDefault(); + modalInstance.show(); + } else if (event.key === '/' && !isTyping) { + event.preventDefault(); + modalInstance.show(); + } + }); +} + document.addEventListener('DOMContentLoaded', () => { NEXB = {}; NEXB.client_data = JSON.parse(document.getElementById("client_data").textContent); @@ -157,17 +197,10 @@ document.addEventListener('DOMContentLoaded', () => { document.body.appendChild(overlay); } - // Search selection in the header - $('#search-selector-list a').click(function(event) { - event.preventDefault(); - $('#search-form').attr('action', $(this).attr('href')); - $('#search-selector-content').html($(this).html()); - $('#search-input').focus(); - }); - setupTooltips(); setupPopovers(); setupSelectionCheckboxes(); setupBackToTop(); setupHTMX(); + setupSearchModal(); }); diff --git a/dje/templates/bootstrap_base.html b/dje/templates/bootstrap_base.html index c8e22d99..ce0a3ad3 100644 --- a/dje/templates/bootstrap_base.html +++ b/dje/templates/bootstrap_base.html @@ -15,6 +15,9 @@ {% if FAVICON_HREF %}{% endif %} + {% block side_menu %} + {% include 'navbar/side_menu.html' %} + {% endblock %}
{% block header %} {% include HEADER_TEMPLATE %} diff --git a/dje/templates/includes/header.html b/dje/templates/includes/header.html index bf99ee4f..de2b67da 100644 --- a/dje/templates/includes/header.html +++ b/dje/templates/includes/header.html @@ -1,25 +1,6 @@ -{% extends 'includes/navbar_header.html' %} +{% extends 'navbar/navbar_header.html' %} {% load i18n %} {% block nav-brand %} - + {{ SITE_TITLE }} {% endblock %} \ No newline at end of file diff --git a/dje/templates/includes/navbar_header_left_menu.html b/dje/templates/includes/navbar_header_left_menu.html deleted file mode 100644 index 40e8b256..00000000 --- a/dje/templates/includes/navbar_header_left_menu.html +++ /dev/null @@ -1,24 +0,0 @@ -{% load i18n %} -{% url 'product_portfolio:product_list' as product_list_url %} -{% url 'component_catalog:component_list' as component_list_url %} -{% url 'component_catalog:package_list' as package_list_url %} -{% url 'license_library:license_list' as license_list_url %} -{% url 'organization:owner_list' as owner_list_url %} - -{% if not user.is_anonymous and SHOW_PP_IN_NAV %} - -{% endif %} - - - - \ No newline at end of file diff --git a/dje/templates/includes/navbar_header_search_form.html b/dje/templates/includes/navbar_header_search_form.html deleted file mode 100644 index cecd9fc5..00000000 --- a/dje/templates/includes/navbar_header_search_form.html +++ /dev/null @@ -1,38 +0,0 @@ -{% load i18n %} - \ No newline at end of file diff --git a/dje/templates/includes/search_form_hidden_filters.html b/dje/templates/includes/search_form_hidden_filters.html deleted file mode 100644 index 556aede9..00000000 --- a/dje/templates/includes/search_form_hidden_filters.html +++ /dev/null @@ -1,5 +0,0 @@ -{% for field in filter.form %} - {% if field.value and field.name != 'q' and field.name != 'sort' %} - {{ field.as_hidden }} - {% endif %} -{% endfor %} \ No newline at end of file diff --git a/dje/templates/includes/search_help_modal.html b/dje/templates/includes/search_help_modal.html deleted file mode 100644 index 6c1e4d0a..00000000 --- a/dje/templates/includes/search_help_modal.html +++ /dev/null @@ -1,51 +0,0 @@ - \ No newline at end of file diff --git a/dje/templates/includes/search_modal.html b/dje/templates/includes/search_modal.html new file mode 100644 index 00000000..e3c2c4c5 --- /dev/null +++ b/dje/templates/includes/search_modal.html @@ -0,0 +1,101 @@ +{% load i18n %} + \ No newline at end of file diff --git a/dje/templates/includes/navbar_header.html b/dje/templates/navbar/navbar_header.html similarity index 59% rename from dje/templates/includes/navbar_header.html rename to dje/templates/navbar/navbar_header.html index 405aeedd..5f0d4a34 100644 --- a/dje/templates/includes/navbar_header.html +++ b/dje/templates/navbar/navbar_header.html @@ -1,29 +1,26 @@ {% load i18n static %} - {% url 'product_portfolio:product_list' as product_list_url %} -{% url 'component_catalog:component_list' as component_list_url %} {% url 'component_catalog:package_list' as package_list_url %} {% url 'license_library:license_list' as license_list_url %} -{% url 'organization:owner_list' as owner_list_url %} -{% url 'global_search' as global_search_url %} {% url 'product_portfolio:compliance_dashboard' as compliance_dashboard_url %} -{% url 'reporting:report_list' as report_list_url %} -{% url 'workflow:request_list' as request_list_url %} -{% url 'component_catalog:scan_list' as scan_list_url %} -{% url 'purldb:purldb_list' as purldb_list_url %} -{% url 'vulnerabilities:vulnerability_list' as vulnerability_list_url %} {% url 'django_registration_register' as register_url %} -{% url 'api_v2:api-root' as api_root_url %} -{% url 'account_profile' as account_profile_url %} -{% include 'includes/search_help_modal.html' %} \ No newline at end of file +{% include 'includes/search_modal.html' %} \ No newline at end of file diff --git a/dje/templates/navbar/navbar_header_left_menu.html b/dje/templates/navbar/navbar_header_left_menu.html new file mode 100644 index 00000000..d6cc85c0 --- /dev/null +++ b/dje/templates/navbar/navbar_header_left_menu.html @@ -0,0 +1,28 @@ +{% load i18n %} +{% url 'product_portfolio:product_list' as product_list_url %} +{% url 'component_catalog:package_list' as package_list_url %} +{% url 'license_library:license_list' as license_list_url %} +{% url 'product_portfolio:compliance_dashboard' as compliance_dashboard_url %} + +{% if not user.is_anonymous and SHOW_PP_IN_NAV %} + +{% endif %} + + + \ No newline at end of file diff --git a/dje/templates/includes/navbar_header_right_menu.html b/dje/templates/navbar/navbar_header_right_menu.html similarity index 63% rename from dje/templates/includes/navbar_header_right_menu.html rename to dje/templates/navbar/navbar_header_right_menu.html index 73fad794..1508b8a1 100644 --- a/dje/templates/includes/navbar_header_right_menu.html +++ b/dje/templates/navbar/navbar_header_right_menu.html @@ -10,7 +10,7 @@ - {% include 'includes/navbar_theme_toogle.html' %} + {% include 'navbar/navbar_theme_toogle.html' %} {% if user.is_anonymous %} \ No newline at end of file diff --git a/dje/templates/includes/navbar_header_tools_menu.html b/dje/templates/navbar/navbar_header_tools_menu.html similarity index 87% rename from dje/templates/includes/navbar_header_tools_menu.html rename to dje/templates/navbar/navbar_header_tools_menu.html index ced30d5c..a1506731 100644 --- a/dje/templates/includes/navbar_header_tools_menu.html +++ b/dje/templates/navbar/navbar_header_tools_menu.html @@ -5,12 +5,6 @@ Tools