feat: work on site validation
This commit is contained in:
@@ -450,15 +450,20 @@ defmodule BDS.Desktop.ShellCommands do
|
||||
|
||||
defp normalize_site_validation(report) do
|
||||
%{
|
||||
sitemap_path: report.sitemap_path,
|
||||
sitemap_changed: report.sitemap_changed,
|
||||
summary: %{
|
||||
missing_count: length(report.missing_pages),
|
||||
extra_count: length(report.extra_pages),
|
||||
stale_count: length(report.stale_pages)
|
||||
expected_count: report.expected_url_count,
|
||||
existing_count: report.existing_html_url_count,
|
||||
missing_count: length(report.missing_url_paths),
|
||||
extra_count: length(report.extra_url_paths),
|
||||
updated_count: length(report.updated_post_url_paths)
|
||||
},
|
||||
missing_pages: report.missing_pages,
|
||||
extra_pages: report.extra_pages,
|
||||
stale_pages: report.stale_pages,
|
||||
sections: Enum.map(report.sections, &to_string/1)
|
||||
missing_url_paths: report.missing_url_paths,
|
||||
extra_url_paths: report.extra_url_paths,
|
||||
updated_post_url_paths: report.updated_post_url_paths,
|
||||
expected_url_count: report.expected_url_count,
|
||||
existing_html_url_count: report.existing_html_url_count
|
||||
}
|
||||
end
|
||||
|
||||
@@ -471,9 +476,11 @@ defmodule BDS.Desktop.ShellCommands do
|
||||
title: "Site Validation",
|
||||
subtitle: "Generated output checked against expected site files",
|
||||
editorMeta: [
|
||||
%{label: "Missing", value: Integer.to_string(length(report.missing_pages))},
|
||||
%{label: "Extra", value: Integer.to_string(length(report.extra_pages))},
|
||||
%{label: "Stale", value: Integer.to_string(length(report.stale_pages))}
|
||||
%{label: "Expected", value: Integer.to_string(report.expected_url_count)},
|
||||
%{label: "Existing", value: Integer.to_string(report.existing_html_url_count)},
|
||||
%{label: "Missing", value: Integer.to_string(length(report.missing_url_paths))},
|
||||
%{label: "Extra", value: Integer.to_string(length(report.extra_url_paths))},
|
||||
%{label: "Updated", value: Integer.to_string(length(report.updated_post_url_paths))}
|
||||
],
|
||||
payload: normalize_site_validation(report)
|
||||
}
|
||||
|
||||
@@ -29,9 +29,18 @@ defmodule BDS.Desktop.ShellLive.MiscEditor do
|
||||
meta = meta(socket.assigns)
|
||||
payload = Map.get(meta, :payload, %{})
|
||||
project_id = Map.get(meta, :project_id, socket.assigns.projects.active_project_id)
|
||||
sections = Enum.map(Map.get(payload, :sections, []), &String.to_existing_atom/1)
|
||||
|
||||
case Generation.apply_validation(project_id, sections) do
|
||||
report = %{
|
||||
sitemap_path: Map.get(payload, :sitemap_path),
|
||||
sitemap_changed: Map.get(payload, :sitemap_changed, false),
|
||||
missing_url_paths: Map.get(payload, :missing_url_paths, []),
|
||||
extra_url_paths: Map.get(payload, :extra_url_paths, []),
|
||||
updated_post_url_paths: Map.get(payload, :updated_post_url_paths, []),
|
||||
expected_url_count: Map.get(payload, :expected_url_count, 0),
|
||||
existing_html_url_count: Map.get(payload, :existing_html_url_count, 0)
|
||||
}
|
||||
|
||||
case Generation.apply_validation(project_id, report) do
|
||||
{:ok, result} ->
|
||||
{:rerun,
|
||||
socket
|
||||
@@ -194,15 +203,19 @@ defmodule BDS.Desktop.ShellLive.MiscEditor do
|
||||
title: Map.get(meta, :title, translated("Site Validation")),
|
||||
subtitle: Map.get(meta, :subtitle, ""),
|
||||
summary: %{
|
||||
expected: Map.get(summary, :missing_count, 0) + Map.get(summary, :extra_count, 0) + Map.get(summary, :stale_count, 0),
|
||||
expected: Map.get(summary, :expected_count, 0),
|
||||
existing: Map.get(summary, :existing_count, 0),
|
||||
missing: Map.get(summary, :missing_count, 0),
|
||||
extra: Map.get(summary, :extra_count, 0),
|
||||
stale: Map.get(summary, :stale_count, 0)
|
||||
updated: Map.get(summary, :updated_count, 0)
|
||||
},
|
||||
missing_pages: Map.get(payload, :missing_pages, []),
|
||||
extra_pages: Map.get(payload, :extra_pages, []),
|
||||
stale_pages: Map.get(payload, :stale_pages, []),
|
||||
sections: Map.get(payload, :sections, [])
|
||||
sitemap_path: Map.get(payload, :sitemap_path),
|
||||
sitemap_changed: Map.get(payload, :sitemap_changed, false),
|
||||
missing_url_paths: Map.get(payload, :missing_url_paths, []),
|
||||
extra_url_paths: Map.get(payload, :extra_url_paths, []),
|
||||
updated_post_url_paths: Map.get(payload, :updated_post_url_paths, []),
|
||||
expected_url_count: Map.get(payload, :expected_url_count, 0),
|
||||
existing_html_url_count: Map.get(payload, :existing_html_url_count, 0)
|
||||
}
|
||||
end
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<div class="misc-editor-actions">
|
||||
<button class="secondary" type="button" phx-click="rerun_misc_editor"><%= translated("Refresh") %></button>
|
||||
<%= if @misc_editor.kind == :site_validation do %>
|
||||
<button class="primary" type="button" phx-click="apply_site_validation" disabled={Enum.empty?(@misc_editor.missing_pages) and Enum.empty?(@misc_editor.extra_pages) and Enum.empty?(@misc_editor.stale_pages)}><%= translated("Apply") %></button>
|
||||
<button class="primary" type="button" phx-click="apply_site_validation" disabled={Enum.empty?(@misc_editor.missing_url_paths) and Enum.empty?(@misc_editor.extra_url_paths) and Enum.empty?(@misc_editor.updated_post_url_paths)}><%= translated("Apply") %></button>
|
||||
<% end %>
|
||||
<%= if @misc_editor.kind == :find_duplicates do %>
|
||||
<button class="secondary" type="button" phx-click="dismiss_selected_duplicates" disabled={MapSet.size(@misc_editor.selected_pairs) == 0}><%= translated("Dismiss Checked") %></button>
|
||||
@@ -25,9 +25,9 @@
|
||||
<%= case @misc_editor.kind do %>
|
||||
<% :site_validation -> %>
|
||||
<div class="misc-columns">
|
||||
<section class="misc-card"><h3><%= translated("Missing URLs") %></h3><%= if Enum.empty?(@misc_editor.missing_pages) do %><p><%= translated("None found") %></p><% end %><ul><%= for path <- @misc_editor.missing_pages do %><li><%= path %></li><% end %></ul></section>
|
||||
<section class="misc-card"><h3><%= translated("Extra URLs") %></h3><%= if Enum.empty?(@misc_editor.extra_pages) do %><p><%= translated("None found") %></p><% end %><ul><%= for path <- @misc_editor.extra_pages do %><li><%= path %></li><% end %></ul></section>
|
||||
<section class="misc-card"><h3><%= translated("Updated URLs") %></h3><%= if Enum.empty?(@misc_editor.stale_pages) do %><p><%= translated("None found") %></p><% end %><ul><%= for path <- @misc_editor.stale_pages do %><li><%= path %></li><% end %></ul></section>
|
||||
<section class="misc-card"><h3><%= translated("Missing URLs") %></h3><%= if Enum.empty?(@misc_editor.missing_url_paths) do %><p><%= translated("None found") %></p><% end %><ul><%= for path <- @misc_editor.missing_url_paths do %><li><%= path %></li><% end %></ul></section>
|
||||
<section class="misc-card"><h3><%= translated("Extra URLs") %></h3><%= if Enum.empty?(@misc_editor.extra_url_paths) do %><p><%= translated("None found") %></p><% end %><ul><%= for path <- @misc_editor.extra_url_paths do %><li><%= path %></li><% end %></ul></section>
|
||||
<section class="misc-card"><h3><%= translated("Updated URLs") %></h3><%= if Enum.empty?(@misc_editor.updated_post_url_paths) do %><p><%= translated("None found") %></p><% end %><ul><%= for path <- @misc_editor.updated_post_url_paths do %><li><%= path %></li><% end %></ul></section>
|
||||
</div>
|
||||
|
||||
<% :metadata_diff -> %>
|
||||
|
||||
Reference in New Issue
Block a user