-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix dates in custom pages admin index #5069
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
51 changes: 51 additions & 0 deletions
51
app/components/admin/site_customization/pages/index_component.html.erb
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,51 @@ | ||
<%= header do %> | ||
<%= link_to t("admin.site_customization.pages.index.create"), new_admin_site_customization_page_path %> | ||
<% end %> | ||
|
||
<% if pages.any? %> | ||
<h3><%= page_entries_info pages %></h3> | ||
|
||
<table class="cms-page-list"> | ||
<thead> | ||
<tr> | ||
<th><%= t("admin.site_customization.pages.page.title") %></th> | ||
<th><%= t("admin.site_customization.pages.page.slug") %></th> | ||
<th><%= t("admin.site_customization.pages.page.created_at") %></th> | ||
<th><%= t("admin.site_customization.pages.page.updated_at") %></th> | ||
<th><%= t("admin.site_customization.pages.page.status") %></th> | ||
<th><%= t("admin.actions.actions") %></th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<% pages.each do |page| %> | ||
<tr id="<%= dom_id(page) %>"> | ||
<td><%= page.title %></td> | ||
<td><%= page.slug %></td> | ||
<td><%= I18n.l page.created_at, format: :long %></td> | ||
<td><%= I18n.l page.updated_at, format: :long %></td> | ||
<td><%= t("admin.site_customization.pages.page.status_#{page.status}") %></td> | ||
<td> | ||
<%= render Admin::TableActionsComponent.new(page) do |actions| %> | ||
<%= actions.action(:cards, | ||
text: t("admin.site_customization.pages.page.see_cards"), | ||
path: admin_site_customization_page_widget_cards_path(page)) %> | ||
|
||
<% if page.status == "published" %> | ||
<%= actions.action(:show, | ||
text: t("admin.site_customization.pages.index.see_page"), | ||
path: page.url, | ||
options: { target: "_blank" }) %> | ||
<% end %> | ||
<% end %> | ||
</td> | ||
</tr> | ||
<% end %> | ||
</tbody> | ||
</table> | ||
|
||
<%= paginate pages %> | ||
<% else %> | ||
<div class="callout primary"> | ||
<%= page_entries_info pages %> | ||
</div> | ||
<% end %> |
14 changes: 14 additions & 0 deletions
14
app/components/admin/site_customization/pages/index_component.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,14 @@ | ||
class Admin::SiteCustomization::Pages::IndexComponent < ApplicationComponent | ||
include Header | ||
attr_reader :pages | ||
|
||
def initialize(pages) | ||
@pages = pages | ||
end | ||
|
||
private | ||
|
||
def title | ||
t("admin.site_customization.pages.index.title") | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +1 @@ | ||
<% provide :title do %> | ||
<%= t("admin.header.title") %> - <%= t("admin.menu.site_customization.pages") %> | ||
<% end %> | ||
|
||
<%= link_to t("admin.site_customization.pages.index.create"), new_admin_site_customization_page_path, class: "button float-right" %> | ||
<h2 class="inline-block"><%= t("admin.site_customization.pages.index.title") %></h2> | ||
|
||
<% if @pages.any? %> | ||
<h3><%= page_entries_info @pages %></h3> | ||
|
||
<table class="cms-page-list"> | ||
<thead> | ||
<tr> | ||
<th><%= t("admin.site_customization.pages.page.title") %></th> | ||
<th><%= t("admin.site_customization.pages.page.slug") %></th> | ||
<th><%= t("admin.site_customization.pages.page.created_at") %></th> | ||
<th><%= t("admin.site_customization.pages.page.updated_at") %></th> | ||
<th><%= t("admin.site_customization.pages.page.status") %></th> | ||
<th><%= t("admin.actions.actions") %></th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<% @pages.each do |page| %> | ||
<tr id="<%= dom_id(page) %>"> | ||
<td><%= page.title %></td> | ||
<td><%= page.slug %></td> | ||
<td><%= I18n.l page.created_at, format: :short %></td> | ||
<td><%= I18n.l page.created_at, format: :short %></td> | ||
<td><%= t("admin.site_customization.pages.page.status_#{page.status}") %></td> | ||
<td> | ||
<%= render Admin::TableActionsComponent.new(page) do |actions| %> | ||
<%= actions.action(:cards, | ||
text: t("admin.site_customization.pages.page.see_cards"), | ||
path: admin_site_customization_page_widget_cards_path(page)) %> | ||
|
||
<% if page.status == "published" %> | ||
<%= actions.action(:show, | ||
text: t("admin.site_customization.pages.index.see_page"), | ||
path: page.url, | ||
options: { target: "_blank" }) %> | ||
<% end %> | ||
<% end %> | ||
</td> | ||
</tr> | ||
<% end %> | ||
</tbody> | ||
</table> | ||
|
||
<%= paginate @pages %> | ||
<% else %> | ||
<div class="callout primary"> | ||
<%= page_entries_info @pages %> | ||
</div> | ||
<% end %> | ||
<%= render Admin::SiteCustomization::Pages::IndexComponent.new(@pages) %> |
15 changes: 15 additions & 0 deletions
15
spec/components/admin/site_customization/pages/index_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,15 @@ | ||
require "rails_helper" | ||
|
||
describe Admin::SiteCustomization::Pages::IndexComponent, controller: Admin::SiteCustomization::PagesController do | ||
before { SiteCustomization::Page.delete_all } | ||
|
||
it "shows date in created_at and updated_at fields" do | ||
custom_page = create(:site_customization_page, created_at: "2015-07-15 13:32:13") | ||
custom_page.update!(updated_at: "2019-12-09 09:19:29") | ||
|
||
render_inline Admin::SiteCustomization::Pages::IndexComponent.new(SiteCustomization::Page.page(1)) | ||
|
||
expect(page).to have_content "July 15, 2015 13:32" | ||
expect(page).to have_content "December 09, 2019 09:19" | ||
end | ||
end |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Layout/LineLength: Line is too long. [114/110] (https://rubystyle.guide#max-line-length)