-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
22 changed files
with
251 additions
and
32 deletions.
There are no files selected for viewing
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
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,20 @@ | ||
class FilesController < ApplicationController | ||
before_action :load_environments | ||
before_action :load_key | ||
|
||
add_breadcrumb "Home", :root_path | ||
add_breadcrumb "Environments", :environments_path | ||
|
||
def index | ||
@files_and_values_by_hierarchy = DataFile.search(@environment, @key) | ||
|
||
add_breadcrumb @environment, environment_nodes_path(@environment) | ||
add_breadcrumb @key, environment_key_files_path(@environment, @key) | ||
end | ||
|
||
private | ||
|
||
def load_key | ||
@key = Key.new(environment: @environment, name: params[:key_id].squish) | ||
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
14 changes: 14 additions & 0 deletions
14
app/javascript/controllers/text_input_navigation_controller.js
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 @@ | ||
import { Controller } from "@hotwired/stimulus" | ||
import { Turbo } from "@hotwired/turbo-rails" | ||
|
||
// Connects to data-controller="text-input-navigation" | ||
export default class extends Controller { | ||
static targets = ["input"] | ||
static values = {placeholder: String, url: String} | ||
|
||
navigate() { | ||
const trimmedValue = this.inputTarget.value.trim() | ||
const url = this.urlValue.replace(this.placeholderValue, trimmedValue); | ||
Turbo.visit(url); | ||
} | ||
} |
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
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
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
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
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,20 @@ | ||
class KeyFile | ||
include ActiveModel::Model | ||
include ActiveModel::Attributes | ||
|
||
attribute :environment | ||
attribute :hierarchy_name, :string | ||
attribute :path, :string | ||
attribute :value, :string | ||
|
||
def self.all(environment, key) | ||
HieraData.new(environment.name).files_including(key).map do |file| | ||
new( | ||
environment: environment, | ||
path: file[:path], | ||
hierarchy_name: file[:hierarchy_name], | ||
value: file[:value] | ||
) | ||
end | ||
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
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,6 @@ | ||
<%= form_tag "", data: {controller: "text-input-navigation", action: "submit->text-input-navigation#navigate", text_input_navigation_placeholder_value: "KEY_ID", text_input_navigation_url_value: environment_key_files_path(key_id: "KEY_ID")} do |form| %> | ||
<div class="form-group"> | ||
<%= label_tag :key, "Search for a key" %> | ||
<%= text_field_tag "key", @key&.name, class: "form-control", required: true, data: {text_input_navigation_target: "input"} %> | ||
</div> | ||
<% 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 |
---|---|---|
@@ -0,0 +1,66 @@ | ||
<div class="row"> | ||
<div class="col-6"> | ||
<%= render "environments/select_environment" %> | ||
</div> | ||
<div class="col-6"> | ||
<%= render "search" %> | ||
</div> | ||
</div> | ||
|
||
<div class="row mt-4"> | ||
<div class="col-12"> | ||
<h2>Search Results</h2> | ||
<p class="lead"> | ||
<% if @files_and_values_by_hierarchy.any? %> | ||
Found key | ||
<code><%= @key.name %></code> | ||
in | ||
<b><%= t(".file", count: @files_and_values_by_hierarchy.values.map { |f| f.size }.sum) %></b>. | ||
<% else %> | ||
Could not find key | ||
<code><%= @key.name %></code> | ||
in any files. | ||
<% end %> | ||
</p> | ||
</div> | ||
</div> | ||
|
||
<div class="row mt-4"> | ||
<div class="col-12"> | ||
<% index = 0 %> | ||
<% @files_and_values_by_hierarchy.each do |hierarchy, files_and_values| %> | ||
<div class="accordion mb-2"> | ||
<div class="card"> | ||
<div class="card-body"> | ||
<b><%= hierarchy.name %></b> | ||
<span class="badge badge-primary text-light"><%= hierarchy.backend %></span> | ||
</div> | ||
</div> | ||
<% files_and_values.each do |file, value| %> | ||
<% index += 1 %> | ||
<div class="card"> | ||
<div class="card-header" id="path-<%= index %>"> | ||
<h2 class="mb-0"> | ||
<button class="btn btn-link btn-block text-left d-flex justify-content-between" type="button" data-toggle="collapse" data-target="#collapse-<%= index %>" aria-expanded="true" aria-controls="collapse-<%= index %>"> | ||
<span> | ||
<b><%= file.path %></b> | ||
<% if value&.encrypted? %> | ||
<span class="text-danger"> | ||
<%= icon("lock-fill") %> | ||
</span> | ||
<% end %> | ||
</span> | ||
</button> | ||
</h2> | ||
</div> | ||
<div id="collapse-<%= index %>" class="collapse" aria-labelledby="path-<%= index %>"> | ||
<div class="card-body"> | ||
<pre><%= value.value %></pre> | ||
</div> | ||
</div> | ||
</div> | ||
<% end %> | ||
</div> | ||
<% end %> | ||
</div> | ||
</div> |
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,8 @@ | ||
<div class="row"> | ||
<div class="col-6"> | ||
<%= render "environments/select_environment" %> | ||
</div> | ||
<div class="col-6"> | ||
<%= render "nodes/select_node" %> | ||
</div> | ||
</div> |
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
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
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,18 +1,11 @@ | ||
<div class="row"> | ||
<div class="col-6"> | ||
<%= render "environments/select_environment" %> | ||
<%= form_tag "" do |form| %> | ||
<div class="form-group"> | ||
<%= label_tag :node, "Select node" %> | ||
<select name="node" data-controller="slim-select select-navigation" data-action="change->select-navigation#navigate"> | ||
<option value="" <% "selected" if @node.nil? %> data-url="<%= environment_nodes_path(@environment) %>"></option> | ||
<% @nodes.each do |node| %> | ||
<option data-url="<%= environment_node_keys_path(@environment, node) %>" <%= "selected" if node == @node %>><%= node.hostname %></option> | ||
<% end %> | ||
</select> | ||
</div> | ||
<div class="col-6"> | ||
<%= form_tag "" do |form| %> | ||
<div class="form-group"> | ||
<%= label_tag :node, "Select node" %> | ||
<select name="node" data-controller="slim-select select-navigation" data-action="change->select-navigation#navigate"> | ||
<option value="" <% "selected" if @node.nil? %> data-url="<%= environment_nodes_path(@environment) %>"></option> | ||
<% @nodes.each do |node| %> | ||
<option data-url="<%= environment_node_keys_path(@environment, node) %>" <%= "selected" if node == @node %>><%= node.hostname %></option> | ||
<% end %> | ||
</select> | ||
</div> | ||
<% end %> | ||
</div> | ||
</div> | ||
<% 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 +1,9 @@ | ||
<%= render "select_node" %> | ||
<div class="row"> | ||
<div class="col-6"> | ||
<%= render "environments/select_environment" %> | ||
</div> | ||
<div class="col-6"> | ||
<%= render "nodes/select_node" %> | ||
<%= render "files/search" %> | ||
</div> | ||
</div> |
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
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
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,7 @@ | ||
require "test_helper" | ||
|
||
class FilesControllerTest < ActionDispatch::IntegrationTest | ||
# test "the truth" do | ||
# assert true | ||
# end | ||
end |
Oops, something went wrong.