diff --git a/conan/cli/formatters/report/diff_html.py b/conan/cli/formatters/report/diff_html.py index 65276c16c5e..b570a87e9ea 100644 --- a/conan/cli/formatters/report/diff_html.py +++ b/conan/cli/formatters/report/diff_html.py @@ -12,10 +12,12 @@ {%- endfor %} {%- for name, file_info in folder_info["files"].items() %} -
  • + {% set file_type = "renamed" if file_info["renamed_to"] else ( + "deleted" if file_info["is_deleted"] else ( + "new" if file_info["is_new"] else "old")) %} +
  • @@ -74,6 +76,7 @@ --folder-summary-hover-bgColor: #e0e0e033; --folder-ul-hover-borderColor: #00000066; --sidebar-li-a-hover-bgColor: #e0e0e0; + --sidebar-button-hover-bgColor: var(--sidebar-li-a-hover-bgColor); --sidebar-link-color: black; --sidebar-link-hover-color: var(--sidebar-link-color); --sidebar-link-visited-color: var(--sidebar-link-color); @@ -143,15 +146,67 @@ padding-top: 5px; } + .sidebar-reveal { + display: none; + position: sticky; + top: 10px; + } + .search-area { border-bottom: 1px solid var(--search-area-borderColor); } + .search-header { + display: flex; + justify-content: space-between; + } + .search-field { border: 1px solid var(--search-field-borderColor); border-radius: 5px; padding: 5px; margin: 5px; + width: 80%; + } + + .file-tree-controls { + border-bottom: 1px solid var(--search-area-borderColor); + padding: 5px; + display: flex; + justify-content: space-between; + align-items: center; + } + + .file-tree-controls .folder-collapse button { + display: inline-block; + line-height: 0.7; + } + + .file-tree-controls button, + .sidebar-reveal button, + .search-header button { + cursor: pointer; + border: 0px solid var(--search-field-borderColor); + border-radius: 5px; + background: none; + padding: 5px; + min-width: 3ch; + } + + .file-tree-controls button:hover, + .sidebar-reveal button:hover, + .search-header button:hover { + background-color: var(--sidebar-li-a-hover-bgColor); + } + + .file-tree-more { + display: none; + padding: 5px; + border-bottom: 1px solid var(--search-area-borderColor); + } + + .file-tree-more-option { + display: block; } .file-list { @@ -620,13 +675,29 @@ let emptySearch = true; let includedFiles = 0; + const typeVisibility = { + "renamed": document.getElementById("show-moved-files").checked, + "deleted": document.getElementById("show-deleted-files").checked, + "new": document.getElementById("show-new-files").checked, + "old": document.getElementById("show-old-files").checked, + }; + sidebar.forEach(async function(item) { + if (item.dataset.path === undefined) { + // A folder, those are handled later + return; + } const text = item.dataset.path.toLowerCase(); const shouldInclude = includeSearchQuery === "" || text.includes(includeSearchQuery); - const shouldExclude = excludeSearchQuery !== "" && text.includes(excludeSearchQuery); + let shouldExclude = excludeSearchQuery !== "" && text.includes(excludeSearchQuery); const associatedId = item.querySelector("a").getAttribute("href").substring(1) const contentItem = document.getElementById(associatedId); + const fileType = item.dataset.type; + const isTypeVisible = typeVisibility[fileType] !== false; + + shouldExclude = shouldExclude || !isTypeVisible; + if (shouldInclude) { if (shouldExclude) { item.style.display = "none"; @@ -699,6 +770,46 @@ } }); } + + function toggleFolders(open) { + if (open) { + const toOpen = document.querySelectorAll('details.folder:open > ul > li > details.folder:not(:open)'); + if (toOpen.length === 0) { + // We might need to open the root folders + document.querySelectorAll('.file-list > li > details.folder:not(:open)').forEach(d => d.open = true); + } else { + toOpen.forEach(d => d.open = true); + } + } else { + document.querySelectorAll('details.folder:open').forEach(d => d.open = false); + } + } + + function toggleSidebar(show) { + const sidebar = document.querySelector('.sidebar'); + const sidebarReveal = document.querySelector('.sidebar-reveal'); + const content = document.querySelector('.content'); + if (show) { + sidebar.style.display = 'block'; + sidebarReveal.style.display = 'none'; + content.style.padding = '20px'; + } else { + sidebar.style.display = 'none'; + sidebarReveal.style.display = 'block'; + content.style.padding = '20px 20px 20px 5px'; + } + } + + function toggleMoreFileTree() { + const moreOptions = document.querySelector('.file-tree-more'); + console.log(moreOptions.style.display); + const show = moreOptions.style.display !== 'block'; + if (show) { + moreOptions.style.display = 'block'; + } else { + moreOptions.style.display = 'none'; + } + } @@ -706,17 +817,76 @@ +

    Diff Report Between {{ old_reference.repr_notime() }} And {{ new_reference.repr_notime() }}