forked from nanego/my-dcim
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
341617 - Add ChangelogEntry to show pages (nanego#210)
* Added changelog entries for Stack * Made a helper to generate paths * Implemented changelog entries for modeles from site down to air conditioners * wip * used turbo frame tag helper * Improved helper * wip * wip * fix * wip * style: code cleanup * add changelog on other show * style: cleanups --------- Co-authored-by: Maximilien Bausson <[email protected]> Co-authored-by: Nicolas Brousse <[email protected]>
- Loading branch information
1 parent
ecb45f3
commit 8e18f28
Showing
30 changed files
with
158 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# frozen_string_literal: true | ||
|
||
module ChangelogEntries | ||
class ObjectListComponent < ApplicationComponent | ||
include Turbo::FramesHelper | ||
|
||
erb_template <<~ERB | ||
<%= turbo_frame_tag("changelog-entries", loading: :lazy, src: object_changelog_path, **@html_options) do %> | ||
<div class="w-100 d-flex justify-content-center align-items-center gap-3"> | ||
<span><%= t("changelog_entries.object_list_component.loading") %></span> | ||
<span class="spinner-border spinner-border-sm p-4"></span> | ||
</div> | ||
<% end %> | ||
ERB | ||
|
||
def initialize(object, **html_options) | ||
@object = object | ||
@html_options = html_options | ||
|
||
raise ArgumentError, "@object could not be nil" unless @object | ||
|
||
super() | ||
end | ||
|
||
private | ||
|
||
def object_changelog_path | ||
object_changelog_entries_path(@object.model_name.plural, @object.id) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,3 +52,5 @@ | |
</dl> | ||
</div> | ||
</div> | ||
|
||
<%= render ChangelogEntries::ObjectListComponent.new(@air_conditioner) %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,3 +28,5 @@ | |
</dl> | ||
</div> | ||
</div> | ||
|
||
<%= render ChangelogEntries::ObjectListComponent.new(@architecture) %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,3 +35,5 @@ | |
</dl> | ||
</div> | ||
</div> | ||
|
||
<%= render ChangelogEntries::ObjectListComponent.new(@bay) %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,3 +26,5 @@ | |
</dl> | ||
</div> | ||
</div> | ||
|
||
<%= render ChangelogEntries::ObjectListComponent.new(@card_type) %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,3 +28,5 @@ | |
</dl> | ||
</div> | ||
</div> | ||
|
||
<%= render ChangelogEntries::ObjectListComponent.new(@category) %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,63 @@ | ||
<% provide(:title, t("changelog_entries.title")) %> | ||
<%= render "layouts/breadcrumb", breadcrumb_steps: { | ||
<% | ||
provide(:title, t("changelog_entries.title")) | ||
|
||
breadcrumb = {} | ||
|
||
if @scoped_object | ||
breadcrumb[@scoped_object.model_name.human.pluralize] = polymorphic_path(@scoped_object.class) | ||
breadcrumb[@scoped_object] = polymorphic_path(@scoped_object) | ||
end | ||
%> | ||
<%= render "layouts/breadcrumb", breadcrumb_steps: breadcrumb.merge({ | ||
t("changelog_entries.title") => "" | ||
} %> | ||
}) %> | ||
|
||
<div class="container-fluid"> | ||
<h1><%= t("changelog_entries.title") %></h1> | ||
<%= turbo_frame_tag "changelog-entries" do %> | ||
<div class="container-fluid"> | ||
<h1><%= t("changelog_entries.title") %></h1> | ||
|
||
<%= render List::DataTableComponent.new(decorate(@changelog_entries)) do |table| %> | ||
<%= render List::DataTableComponent.new(decorate(@changelog_entries)) do |table| %> | ||
|
||
<% table.with_column(ChangelogEntry.human_attribute_name(:action), sort_by: :action) do |changelog_entry| %> | ||
<%= render changelog_entry.action_label_to_component %> | ||
<% end %> | ||
<% table.with_column(ChangelogEntry.human_attribute_name(:action), sort_by: :action) do |changelog_entry| %> | ||
<%= render changelog_entry.action_label_to_component %> | ||
<% end %> | ||
|
||
<% table.with_column(ChangelogEntry.human_attribute_name(:author), sort_by: :author_id) do |changelog_entry| %> | ||
<%= link_to_if changelog_entry.author_id?, changelog_entry.author_display_name, changelog_entry.author %> | ||
<% end %> | ||
<% table.with_column(ChangelogEntry.human_attribute_name(:author), sort_by: :author_id) do |changelog_entry| %> | ||
<%= link_to_if changelog_entry.author_id?, changelog_entry.author_display_name, changelog_entry.author, target: :_top %> | ||
<% end %> | ||
|
||
<% table.with_column(ChangelogEntry.human_attribute_name(:object), sort_by: :object_id) do |changelog_entry| %> | ||
<% begin %> | ||
<%= link_to changelog_entry.object_display_name, changelog_entry.object %> | ||
<% rescue NoMethodError %> | ||
<%= changelog_entry.object_display_name %> | ||
<% table.with_column(ChangelogEntry.human_attribute_name(:object), sort_by: :object_id) do |changelog_entry| %> | ||
<% begin %> | ||
<%= link_to changelog_entry.object_display_name, changelog_entry.object, target: :_top %> | ||
<% rescue NoMethodError %> | ||
<%= changelog_entry.object_display_name %> | ||
<% end %> | ||
<% end %> | ||
<% end %> | ||
|
||
<% table.with_column(ChangelogEntry.human_attribute_name(:attributes)) do |changelog_entry| %> | ||
<div class="row"> | ||
<div class="col-lg-6"> | ||
<%= sanitize changelog_entry.split_diff.left %> | ||
</div> | ||
<div class="col-lg-6"> | ||
<%= sanitize changelog_entry.split_diff.right %> | ||
<% table.with_column(ChangelogEntry.human_attribute_name(:attributes)) do |changelog_entry| %> | ||
<div class="row"> | ||
<div class="col-lg-6"> | ||
<%= sanitize changelog_entry.split_diff.left %> | ||
</div> | ||
<div class="col-lg-6"> | ||
<%= sanitize changelog_entry.split_diff.right %> | ||
</div> | ||
</div> | ||
</div> | ||
<% end %> | ||
<% end %> | ||
|
||
<% table.with_column(t("label_date"), sort_by: :created_at) do |changelog_entry| %> | ||
<%= l changelog_entry.created_at %> | ||
<% end %> | ||
<% table.with_column(t("label_date"), sort_by: :created_at) do |changelog_entry| %> | ||
<%= l changelog_entry.created_at %> | ||
<% end %> | ||
|
||
<% table.with_column(t("label_details")) do |changelog_entry| %> | ||
<%= link_to changelog_entry_path(changelog_entry), class: "btn btn-primary" do %> | ||
<span class="bi bi-eye" aria-hidden="true" data-controller="tooltip" data-bs-placement="left" | ||
title="<%= t("action.show") %>"></span> | ||
<span class="visually-hidden"><%= t("action.show") %></span> | ||
<% table.with_column(t("label_details")) do |changelog_entry| %> | ||
<%= link_to changelog_entry_path(changelog_entry), class: "btn btn-primary", target: :_top do %> | ||
<span class="bi bi-eye" aria-hidden="true" data-controller="tooltip" data-bs-placement="left" | ||
title="<%= t("action.show") %>"></span> | ||
<span class="visually-hidden"><%= t("action.show") %></span> | ||
<% end %> | ||
<% end %> | ||
<% end %> | ||
<% end %> | ||
</div> | ||
</div> | ||
|
||
<%= paginate @changelog_entries %> | ||
<%= paginate @changelog_entries %> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,3 +35,5 @@ | |
</ul> | ||
</div> | ||
</div> | ||
|
||
<%= render ChangelogEntries::ObjectListComponent.new(@cluster) %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,3 +29,5 @@ | |
</dl> | ||
</div> | ||
</div> | ||
|
||
<%= render ChangelogEntries::ObjectListComponent.new(@color) %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,3 +28,5 @@ | |
</dl> | ||
</div> | ||
</div> | ||
|
||
<%= render ChangelogEntries::ObjectListComponent.new(@contract_type) %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,3 +28,5 @@ | |
</dl> | ||
</div> | ||
</div> | ||
|
||
<%= render ChangelogEntries::ObjectListComponent.new(@disk_type) %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,3 +35,5 @@ | |
</ul> | ||
</div> | ||
</div> | ||
|
||
<%= render ChangelogEntries::ObjectListComponent.new(@domaine) %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,3 +36,5 @@ | |
</dl> | ||
</div> | ||
</div> | ||
|
||
<%= render ChangelogEntries::ObjectListComponent.new(@frame) %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,3 +35,5 @@ | |
</ul> | ||
</div> | ||
</div> | ||
|
||
<%= render ChangelogEntries::ObjectListComponent.new(@gestion) %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,3 +28,5 @@ | |
</dl> | ||
</div> | ||
</div> | ||
|
||
<%= render ChangelogEntries::ObjectListComponent.new(@islet) %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,3 +28,5 @@ | |
</dl> | ||
</div> | ||
</div> | ||
|
||
<%= render ChangelogEntries::ObjectListComponent.new(@maintainer) %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,3 +28,5 @@ | |
</dl> | ||
</div> | ||
</div> | ||
|
||
<%= render ChangelogEntries::ObjectListComponent.new(@manufacturer) %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,3 +28,5 @@ | |
</dl> | ||
</div> | ||
</div> | ||
|
||
<%= render ChangelogEntries::ObjectListComponent.new(@memory_type) %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,3 +38,5 @@ | |
</ul> | ||
</div> | ||
</div> | ||
|
||
<%= render ChangelogEntries::ObjectListComponent.new(@modele) %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,3 +30,5 @@ | |
</dl> | ||
</div> | ||
</div> | ||
|
||
<%= render ChangelogEntries::ObjectListComponent.new(@port_type) %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,3 +34,5 @@ | |
</dl> | ||
</div> | ||
</div> | ||
|
||
<%= render ChangelogEntries::ObjectListComponent.new(@room) %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,3 +26,5 @@ | |
</dl> | ||
</div> | ||
</div> | ||
|
||
<%= render ChangelogEntries::ObjectListComponent.new(@site) %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,3 +26,5 @@ | |
</dl> | ||
</div> | ||
</div> | ||
|
||
<%= render ChangelogEntries::ObjectListComponent.new(@stack) %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
spec/components/changelog_entries/object_list_component_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# frozen_string_literal: true | ||
|
||
require "rails_helper" | ||
|
||
RSpec.describe ChangelogEntries::ObjectListComponent, type: :component do | ||
context "with object" do | ||
let(:islet) { islets(:one) } | ||
let(:component) { described_class.new(islet) } | ||
let(:rendered_component) { render_inline(component) } | ||
|
||
it "renders component" do # rubocop:disable RSpec/ExampleLength | ||
expect(rendered_component.to_html).to have_tag('turbo-frame', with: { | ||
id: "changelog-entries", | ||
src: "/islets/#{islet.id}/changelog_entries" | ||
}) do | ||
with_text(I18n.t("changelog_entries.object_list_component.loading")) | ||
with_tag("span", with: { class: "spinner-border" }) | ||
end | ||
end | ||
end | ||
end |