mirror of
https://github.com/fluent/fluentd-ui.git
synced 2025-08-12 09:17:05 +02:00
Change not to show source when
There is no difference between config files
This commit is contained in:
parent
b8d4a42e7e
commit
726e910ff4
@ -177,3 +177,11 @@ label {
|
||||
background-color: #dfd;
|
||||
}
|
||||
}
|
||||
|
||||
.frame-corner-radius {
|
||||
border: 1px solid #ddd;
|
||||
padding:10px 10px;
|
||||
border-radius: 3px;
|
||||
margin: 10px 0px;
|
||||
}
|
||||
|
||||
|
@ -10,7 +10,10 @@ module SettingHistoryConcern
|
||||
def show
|
||||
current = @fluentd.agent.config
|
||||
target = @backup_file.content
|
||||
@sdiff = Diff::LCS.sdiff(current.split("\n").map(&:rstrip), target.split("\n").map(&:rstrip)) if target
|
||||
if target
|
||||
@sdiff = Diff::LCS.sdiff(current.split("\n").map(&:rstrip), target.split("\n").map(&:rstrip))
|
||||
@changed = @sdiff.any? { |context_change| context_change.changed? }
|
||||
end
|
||||
end
|
||||
|
||||
def reuse
|
||||
|
@ -1,3 +1,4 @@
|
||||
<% if @changed %>
|
||||
<pre>
|
||||
<% @sdiff.each do |diff| %>
|
||||
<% case diff.action %>
|
||||
@ -13,3 +14,8 @@
|
||||
<% end %>
|
||||
<% end %>
|
||||
</pre>
|
||||
<% else %>
|
||||
<div class="frame-corner-radius">
|
||||
<%= t('messages.no_diff') %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
@ -14,6 +14,7 @@ en:
|
||||
config_successfully_copied: "Config has been copied successfully. Please restart %{brand} to use the new config"
|
||||
note_updating_success: "Note successfully updated."
|
||||
dryrun_is_passed: config test passed
|
||||
no_diff: There is no difference in files.
|
||||
|
||||
terms: &terms
|
||||
name: Name
|
||||
|
@ -14,6 +14,7 @@ ja:
|
||||
config_successfully_copied: "設定をコピーしました。反映させるには、 %{brand}を再起動してください。"
|
||||
note_updating_success: "メモを更新しました。"
|
||||
dryrun_is_passed: この設定でのdry-runが成功しました
|
||||
no_diff: ファイル間の差異はありません。
|
||||
|
||||
terms: &terms
|
||||
name: アカウント名
|
||||
|
@ -26,7 +26,8 @@ describe "histories", stub: :daemon do
|
||||
end
|
||||
|
||||
describe 'show' do
|
||||
let(:last_backup_file) { Fluentd::SettingArchive::BackupFile.new(daemon.agent.backup_files_in_new_order.first) }
|
||||
let!(:last_backup_file) { Fluentd::SettingArchive::BackupFile.new(daemon.agent.backup_files_in_new_order.first) }
|
||||
let!(:new_file) { Fluentd::SettingArchive::BackupFile.new(daemon.agent.backup_files_in_new_order[1]) }
|
||||
|
||||
before do
|
||||
visit "/daemon/setting/histories/#{last_backup_file.file_id}"
|
||||
@ -37,12 +38,26 @@ describe "histories", stub: :daemon do
|
||||
page.should have_text(last_backup_file.content)
|
||||
end
|
||||
|
||||
describe 'diff' do
|
||||
context 'has diff' do
|
||||
it 'shows diff between current and target' do
|
||||
page.should have_text("- type http")
|
||||
page.should have_text("+ type forward")
|
||||
page.should have_text("- port 8899")
|
||||
page.should have_text("+ port 24224")
|
||||
end
|
||||
end
|
||||
|
||||
context 'has no diff' do
|
||||
before do
|
||||
visit "/daemon/setting/histories/#{new_file.file_id}"
|
||||
end
|
||||
|
||||
it 'shows no diff message' do
|
||||
page.should have_text(I18n.t('messages.no_diff'))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
it 'update config and redirect to setting#show' do
|
||||
click_link I18n.t("terms.reuse")
|
||||
|
@ -8,7 +8,7 @@ describe "running_backup", stub: :daemon do
|
||||
login_with exists_user
|
||||
end
|
||||
|
||||
context 'has running backup file' do
|
||||
context 'has no running backup file' do
|
||||
before do
|
||||
visit '/daemon/setting/running_backup'
|
||||
end
|
||||
@ -36,11 +36,26 @@ describe "running_backup", stub: :daemon do
|
||||
expect(page).to have_text(I18n.t("terms.reuse"))
|
||||
end
|
||||
|
||||
it 'has diff' do
|
||||
describe 'diff' do
|
||||
context 'has diff' do
|
||||
it 'shows diff between current and running' do
|
||||
expect(page).to have_text("- type http")
|
||||
expect(page).to have_text("- port 8899")
|
||||
expect(page).to have_text("+ Running backup file content")
|
||||
end
|
||||
end
|
||||
|
||||
context 'has no diff' do
|
||||
before do
|
||||
daemon.agent.config_write backup_content
|
||||
visit '/daemon/setting/running_backup'
|
||||
end
|
||||
|
||||
it 'shows no diff message' do
|
||||
page.should have_text(I18n.t('messages.no_diff'))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
it 'update config and redirect to setting#show' do
|
||||
click_link I18n.t("terms.reuse")
|
||||
|
Loading…
Reference in New Issue
Block a user