Skip to content
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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor Site ID Verification to Use Admins Sites Table and Fix Broken Revert Feature by Replacing link_to Helper with button_to #922

Merged
merged 3 commits into from
Mar 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
trusty-cms (7.0.20)
trusty-cms (7.0.21)
RedCloth (= 4.3.3)
activestorage-validator
acts_as_list (>= 0.9.5, < 1.3.0)
Expand Down
1 change: 1 addition & 0 deletions app/assets/stylesheets/admin/main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
@import "partials/preferences";
@import "partials/treetable";
@import "partials/login_form";
@import "partials/previous_versions";
@import "multi_site_main";
@import "site_chooser";

Expand Down
18 changes: 18 additions & 0 deletions app/assets/stylesheets/admin/partials/_previous_versions.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#previous-versions .drawer_handle {
padding-top: 0;
}

#previous-versions h4 {
margin-bottom: 0.5em;
margin-top: 0;
padding-bottom: 0.25em;
padding-top: 0;
}

#previous-versions th {
text-align: center;
}

#previous-versions #no-previous-versions {
padding-bottom: 0.5em;
}
5 changes: 3 additions & 2 deletions app/controllers/admin/pages_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,9 @@ def set_site_and_homepage
end

def verify_site_id
@site_id = params[:site_id]&.to_i
unless @site_id && @page&.site_id == @site_id
page_site_id = @page.site_id
user_site_ids = current_user.admins_sites.each.pluck(:site_id)
unless user_site_ids.include?(page_site_id)
redirect_to admin_pages_url
end
end
Expand Down
3 changes: 0 additions & 3 deletions app/views/admin/pages/_fields.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,6 @@
= render :partial => 'admin/page_parts/page_part', :collection => @page.parts
= render_region :parts_bottom, :locals => {:f => fields}

#previous-versions
= render :partial => 'admin/pages/previous_versions'

.set
- render_region :layout, :locals => {:f => fields} do |layout|
- layout.edit_layout do
Expand Down
2 changes: 1 addition & 1 deletion app/views/admin/pages/_node.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
= node_title
- else
%i.far.fa-file
= (link_to("#{node_title}".html_safe, edit_admin_page_path(page, site_id: page.site_id), :title => page.path)).html_safe
= (link_to("#{node_title}".html_safe, edit_admin_page_path(page), :title => page.path)).html_safe
= page_type
= spinner
- node.status_column do
Expand Down
61 changes: 33 additions & 28 deletions app/views/admin/pages/_previous_versions.haml
Original file line number Diff line number Diff line change
@@ -1,28 +1,33 @@
%fieldset
%h4
%i.fas.fa-clock-rotate-left
Previous Versions

- if @versions.present?
%section
%table
%thead
%tr
%th Date Updated
%th Time Updated
%th Updated By
%th Action
%tbody{ :id => 'versions-table' }
- @versions.each do |version|
%tr
%td= version[:update_date]
%td= version[:update_time]
%td= version[:updated_by]
%td
= link_to 'Restore',
restore_version_admin_page_path(@page.id, version_index: version[:index]),
method: :put,
data: { confirm: 'Are you sure you want to restore this version?' }
- else
%section
%p No previous versions are available.
#previous-versions
%fieldset
%h4
%i.fas.fa-clock-rotate-left
Previous Versions
.drawer_contents#versions
- if @versions.present?
%section
%table
%thead
%tr
%th Date Updated
%th Time Updated
%th Updated By
%th Action
%tbody{ :id => 'versions-table' }
- @versions.each do |version|
%tr
%td= version[:update_date]
%td= version[:update_time]
%td= version[:updated_by]
%td
= button_to 'Restore',
restore_version_admin_page_path(@page, version_index: version[:index]),
method: :put,
data: { confirm: 'Are you sure you want to restore this version?' }
- else
%section#no-previous-versions
%p No previous versions are available.
.drawer_handle
%a.toggle{:href=>'#versions', :rel=>'toggle[versions]', :class=>"#{(meta_errors? ? 'less' : 'more')}"}
= meta_label
%i.fas.fa-angle-down
2 changes: 1 addition & 1 deletion app/views/admin/pages/_search_result_node.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
= node_title
- else
%i.far.fa-file
= (link_to("#{node_title}".html_safe, edit_admin_page_path(page, site_id: page.site_id), :title => page.path)).html_safe
= (link_to("#{node_title}".html_safe, edit_admin_page_path(page), :title => page.path)).html_safe
= page_type
= spinner
- node.path_column do
Expand Down
1 change: 1 addition & 0 deletions app/views/admin/pages/edit.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@
- main.edit_form do
= form_for @page, :as => :page, :url => admin_page_path(@page), :html => {:method => :put, :multipart => true, :id => 'edit_page', 'data-onsubmit_status'=>t('saving_changes')} do |fields|
= render :partial => 'fields', :object => fields
= render :partial => 'previous_versions'
- main.edit_popups do
= render :partial => 'popups'
2 changes: 1 addition & 1 deletion lib/trusty_cms/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module TrustyCms
VERSION = '7.0.20'.freeze
VERSION = '7.0.21'.freeze
end
Loading