diff --git a/app/controllers/lookups_controller.rb b/app/controllers/lookups_controller.rb index 31220e68..e724ff57 100644 --- a/app/controllers/lookups_controller.rb +++ b/app/controllers/lookups_controller.rb @@ -5,6 +5,7 @@ class LookupsController < ApplicationController def show @result = @key.lookup(@node) + lookup_in_original_environment if @node.environment != @environment rescue Hdm::Error => e @error = e @@ -19,4 +20,9 @@ def load_keys @key = Key.new(environment: @environment, name: params[:key_id]) authorize! :show, @key end + + def lookup_in_original_environment + original_key = Key.new(environment: @node.environment, name: params[:key_id]) + @original_result = original_key.lookup(@node) + end end diff --git a/app/views/keys/_value.html.erb b/app/views/keys/_value.html.erb index 15392f29..cfbccadf 100644 --- a/app/views/keys/_value.html.erb +++ b/app/views/keys/_value.html.erb @@ -1,22 +1,7 @@ <% if file.has_differing_value_in_original_environment?(@key) %> -
- -<%= HieraData::Util.yaml_format(@result) %>
+ <% if @original_result && @original_result != @result %>
+ <%= render "shared/tabbed_diff", dom_id: "lookup-#{dom_id(@key)}", original_value: @original_result, current_value: @result do %>
+ <%= HieraData::Util.yaml_format(@result) %>
+ <%= HieraData::Util.yaml_format(@result) %>
+ <% end %>
<% end %>
diff --git a/app/views/keys/_diff.html.erb b/app/views/shared/_diff.html.erb
similarity index 69%
rename from app/views/keys/_diff.html.erb
rename to app/views/shared/_diff.html.erb
index 5f7f40f1..7ac89852 100644
--- a/app/views/keys/_diff.html.erb
+++ b/app/views/shared/_diff.html.erb
@@ -1,4 +1,4 @@
-<% split_diff = Diffy::SplitDiff.new(file.value_from_original_environment(key: @key).value, value.value, format: :html) %>
+<% split_diff = Diffy::SplitDiff.new(original_value, current_value, format: :html) %>