Skip to content

Commit

Permalink
[modify] disallow edit ignore syntax check (#5083)
Browse files Browse the repository at this point in the history
* [modify] disallow edit ignore syntax check

* [modify] cms syntax checker check

* [modify] article pages ignore_alert_spec
  • Loading branch information
ShinjiTanimoto committed Oct 27, 2023
1 parent 3f6640b commit fbf4eb3
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 8 deletions.
13 changes: 11 additions & 2 deletions app/assets/javascripts/cms/lib/form_alert.js.erb
Expand Up @@ -91,8 +91,17 @@ this.Form_Alert = (function () {

// caution: below IE8, you must use document.createElement() method to create <footer>
var $footer = $(document.createElement("footer")).addClass('send');

if (SS.isEmptyObject(Form_Alert.alerts[<%= I18n.t("cms.backlink_check").to_json %>])) {
var allowEdit = true;
if (!SS.isEmptyObject(Form_Alert.alerts[<%= I18n.t("cms.backlink_check").to_json %>])) {
allowEdit = false;
} else if (!SS.isEmptyObject(Form_Alert.alerts[<%= I18n.t("cms.syntax_check").to_json %>])) {
$.each(Form_Alert.alerts[<%= I18n.t("cms.syntax_check").to_json %>], function(id, alert) {
if (alert["msg"] == "<%= I18n.t('cms.confirm.disallow_edit_ignore_syntax_check') %>") {
allowEdit = false;
}
});
}
if (allowEdit) {
$footer.append('<button name="button" type="button" class="btn-primary save"><%= I18n.t("ss.buttons.ignore_alert") %></button>');
}
$footer.append('<button name="button" type="button" class="btn-default cancel"><%= I18n.t("ss.buttons.cancel") %></button>');
Expand Down
1 change: 1 addition & 0 deletions app/models/cms/initializer.rb
Expand Up @@ -150,6 +150,7 @@ class Initializer
Cms::Role.permission :read_other_cms_check_links_errors
Cms::Role.permission :read_private_cms_check_links_errors
Cms::Role.permission :edit_cms_check_links_ignore_urls
Cms::Role.permission :edit_cms_ignore_syntax_check

SS::File.model "cms/editor_template", SS::File
SS::File.model "cms/file", Cms::File
Expand Down
6 changes: 6 additions & 0 deletions app/models/cms/syntax_checker.rb
Expand Up @@ -72,6 +72,12 @@ def check(cur_site:, cur_user:, contents:)
end
end

if !context.errors.empty? && !cur_user.cms_role_permit_any?(cur_site, "edit_cms_ignore_syntax_check")
context.errors << {
msg: I18n.t('cms.confirm.disallow_edit_ignore_syntax_check')
}
end

context
end

Expand Down
2 changes: 2 additions & 0 deletions config/locales/cms/ja.yml
Expand Up @@ -215,6 +215,7 @@ ja:
source_clean: "ソースクリーニングを実行してよろしいですか。\nソースクリーニングにより表示が崩れる可能性があります。"
change_form: 定型フォームを変更してよろしいですか?
line_apply_richmenu: リッチメニューの反映処理を開始してよろしいですか?
disallow_edit_ignore_syntax_check: アクセシビリティチェックで確認事項があるため、処理を中断します。確認事項を全て修正してから操作を続行してください。
notices:
import_with_entry_form_is_not_supported: 次のフォームでは本文ブロックは出力されません。
restoring_public_content_from_trash: 非公開で復元されます。復元後、内容を確認うえ、公開してください。
Expand Down Expand Up @@ -760,6 +761,7 @@ ja:
use_private_cms_line_mail_handlers: LINEメール連携の管理(所有)
use_other_cms_line_statistics: LINE統計情報の利用(全て)
use_private_cms_line_statistics: LINE統計情報の利用(所有)
edit_cms_ignore_syntax_check: アクセシビリティチェックを無視して保存する

modules:
cms: 標準機能
Expand Down
10 changes: 5 additions & 5 deletions spec/features/article/pages/attach_file/basic_spec.rb
Expand Up @@ -179,12 +179,13 @@
end

context "when a file uploaded by other user is attached" do
let(:name) { unique_id }
let(:file_name) { "#{unique_id}.jpg" }
let!(:file) do
# cms/file is created by cms_user
tmp_ss_file(
Cms::File,
site: site, user: cms_user, model: "cms/file", basename: file_name,
site: site, user: cms_user, model: "cms/file", name: name, basename: file_name,
contents: "#{Rails.root}/spec/fixtures/ss/file/keyvisual.jpg",
group_ids: cms_user.group_ids
)
Expand All @@ -204,7 +205,7 @@

wait_for_cbox do
wait_cbox_close do
click_on file_name
click_on name
end
end

Expand Down Expand Up @@ -233,17 +234,16 @@

click_on I18n.t("ss.buttons.publish_save")
end
click_on I18n.t("ss.buttons.ignore_alert")
wait_for_notice I18n.t('ss.notice.saved')

item.reload
expect(item.file_ids.length).to eq 1

file.reload
attached_file = item.files.first
# copy is attacched
# copy is attached
expect(attached_file.id).not_to eq file.id
expect(attached_file.name).to eq file_name
expect(attached_file.name).to eq name
expect(attached_file.filename).to eq file.filename
expect(attached_file.size).to eq file.size
expect(attached_file.content_type).to eq file.content_type
Expand Down
24 changes: 23 additions & 1 deletion spec/features/article/pages/ignore_alert_spec.rb
Expand Up @@ -13,7 +13,7 @@
page1.reload

role = cms_role
role.permissions = role.permissions - %w(edit_cms_ignore_alert)
role.permissions = role.permissions - %w(edit_cms_ignore_alert edit_cms_ignore_syntax_check)
role.save!

login_cms_user
Expand Down Expand Up @@ -55,4 +55,26 @@
end
end
end

context "with syntax check error" do
let(:html) { "<h6>#{unique_id}</h6>" }

it do
visit article_pages_path(site: site, cid: node)
click_on page1.name
click_on I18n.t("ss.buttons.edit")

within "form#item-form" do
fill_in_ckeditor "item[html]", with: html

click_on I18n.t("ss.buttons.withdraw")
end

within "#cboxLoadedContent" do
expect(page).to have_css("li", text: I18n.t('errors.messages.invalid_order_of_h'))
expect(page).to have_css("li", text: I18n.t('cms.confirm.disallow_edit_ignore_syntax_check'))
expect(page).to have_no_css('.save')
end
end
end
end

0 comments on commit fbf4eb3

Please sign in to comment.