diff --git a/app/models/mediaflux/connection.rb b/app/models/mediaflux/connection.rb
index 1786adf10..66b793a92 100644
--- a/app/models/mediaflux/connection.rb
+++ b/app/models/mediaflux/connection.rb
@@ -62,5 +62,13 @@ def self.root_namespace
Rails.configuration.mediaflux["api_root_ns"]
end
end
+
+ def self.hidden_root
+ if Flipflop.alternate_mediaflux?
+ Rails.configuration.mediaflux["api_alternate_hidden_root"]
+ else
+ Rails.configuration.mediaflux["api_hidden_root"]
+ end
+ end
end
end
diff --git a/app/presenters/project_show_presenter.rb b/app/presenters/project_show_presenter.rb
index dc08ebefe..a6e7b702b 100644
--- a/app/presenters/project_show_presenter.rb
+++ b/app/presenters/project_show_presenter.rb
@@ -1,10 +1,17 @@
# frozen_string_literal: true
class ProjectShowPresenter
- delegate "id", "in_mediaflux?", "mediaflux_id", "metadata", "metadata_model", "pending?", "project_directory", "status", "title", to: :project
+ delegate "id", "in_mediaflux?", "mediaflux_id", "pending?", "status", "title", to: :project
+ delegate "description", "project_id", "storage_capacity", "storage_performance_expectations", "project_purpose", to: :project_metadata
- attr_reader :project
+ attr_reader :project, :project_metadata
def initialize(project)
@project = project
+ @project_metadata = @project.metadata_model
+ end
+
+ # used to hide the project root that is not visible to the end user
+ def project_directory
+ project.project_directory.gsub(Mediaflux::Connection.hidden_root, "")
end
end
diff --git a/app/views/projects/_pending_details.html.erb b/app/views/projects/_pending_details.html.erb
index 92093c84c..21920e25f 100644
--- a/app/views/projects/_pending_details.html.erb
+++ b/app/views/projects/_pending_details.html.erb
@@ -1,9 +1,9 @@
Automatic Settings
- - Project ID
- <%= @project.metadata[:project_id] %>
- - Storage Capacity (Requested)
- <%= "#{@project.metadata_model.storage_capacity[:size][:requested]} #{@project.metadata_model.storage_capacity[:unit][:requested]}" %>
- - Storage Performance Expectations (Requested)
- <%= @project.metadata_model.storage_performance_expectations[:requested] %>
- - Project Purpose
- <%= @project.metadata_model.project_purpose %>
+ - Project ID
- <%= @project.project_id %>
+ - Storage Capacity (Requested)
- <%= "#{@project.storage_capacity[:size][:requested]} #{@project.storage_capacity[:unit][:requested]}" %>
+ - Storage Performance Expectations (Requested)
- <%= @project.storage_performance_expectations[:requested] %>
+ - Project Purpose
- <%= @project.project_purpose %>
<% if @project.in_mediaflux? && (current_user.superuser? || current_user.eligible_sysadmin?) %>
diff --git a/app/views/projects/show.html.erb b/app/views/projects/show.html.erb
index a1fb0236f..a06014972 100644
--- a/app/views/projects/show.html.erb
+++ b/app/views/projects/show.html.erb
@@ -71,8 +71,8 @@ Project Details:
- Project Directory
- <%= @project.project_directory %>
- Title
- - <%= @project.metadata[:title] %>
- - Description:
- <%= @project.metadata[:description] %>
+ - <%= @project.title %>
+ - Description:
- <%= @project.description %>
diff --git a/config/mediaflux.yml b/config/mediaflux.yml
index 707c81c69..b6e8fee76 100644
--- a/config/mediaflux.yml
+++ b/config/mediaflux.yml
@@ -1,5 +1,6 @@
---
production:
+ api_hidden_root: <%= ENV["MEDIAFLUX_HIDDEN_ROOT"] || '/princeton' %>
api_root_ns: <%= ENV["MEDIAFLUX_ROOT_NS"] || '/princeton/tigerdataNS' %>
api_root_collection: <%= ENV["MEDIAFLUX_ROOT_COLLECTION"] || 'path=/princeton/tigerdata' %>
api_root_collection_name: <%= ENV["MEDIAFLUX_ROOT_COLLECTION"] || 'tigerdata' %>
@@ -9,6 +10,7 @@ production:
api_port: <%= ENV["MEDIAFLUX_PORT"] || 443 %>
# Alternate to production is real production
+ api_alternate_hidden_root: <%= ENV["MEDIAFLUX_ALTERNATE_HIDDEN_ROOT"] || '/td-prod-001' %>
api_alternate_root_ns: <%= ENV["MEDIAFLUX_ALTERNATE_ROOT_NS"] || '/td-prod-001/tigerdataNS' %>
api_alternate_root_collection: <%= ENV["MEDIAFLUX_ALTERNATE_ROOT_COLLECTION"] || 'path=/td-prod-001/tigerdata' %>
api_alternate_root_collection_name: <%= ENV["MEDIAFLUX_ALTERNATE_ROOT_COLLECTION"] || 'tigerdata' %>
@@ -22,6 +24,7 @@ production:
api_password: <%= ENV["MEDIAFLUX_PASSWORD"] %>
shared_files_location: <%= ENV["SHARED_FILES_MOUNT"] || '/mnt/nfs/tigerdata' %>
qa:
+ api_hidden_root: '/td-qa-001'
api_root_to_clean: '/td-qa-001/qa'
api_root_ns: <%= ENV["MEDIAFLUX_ROOT_NS"] || '/td-qa-001/qa/tigerdataNS' %>
api_root_collection_name: 'tigerdata'
@@ -32,6 +35,7 @@ qa:
api_port: <%= ENV["MEDIAFLUX_PORT"] || 443 %>
# Alternate to qa is staging
+ api_alternate_hidden_root: '/td-staging-001'
api_alternate_root_ns: '/td-staging-001/tigerdataNS'
api_alternate_root_collection: 'path=/td-staging-001/tigerdata'
api_alternate_root_collection_name: 'tigerdata'
@@ -45,6 +49,7 @@ qa:
api_password: <%= ENV["MEDIAFLUX_PASSWORD"] %>
shared_files_location: <%= ENV["SHARED_FILES_MOUNT"] || '/mnt/nfs/tigerdata' %>
staging:
+ api_hidden_root: '/td-staging-001'
api_root_ns: <%= ENV["MEDIAFLUX_ROOT_NS"] || '/td-staging-001/tigerdataNS' %>
api_root_to_clean: '/td-staging-001/'
api_root_collection_name: 'tigerdata'
@@ -55,6 +60,7 @@ staging:
api_port: <%= ENV["MEDIAFLUX_PORT"] || 443 %>
# Alternate to staging is qa
+ api_alternate_hidden_root: '/td-qa-001'
api_alternate_root_ns: '/td-qa-001/tigerdataNS'
api_alternate_root_collection: 'path=/td-qa-001/tigerdata'
api_alternate_root_collection_name: 'tigerdata'
@@ -68,6 +74,7 @@ staging:
api_password: <%= ENV["MEDIAFLUX_PASSWORD"] %>
shared_files_location: <%= ENV["SHARED_FILES_MOUNT"] || '/mnt/nfs/tigerdata' %>
development:
+ api_hidden_root: '/td-demo-001'
api_root_to_clean: '/td-demo-001/dev/'
api_root_ns: <%= ENV["MEDIAFLUX_ROOT_NS"] || '/td-demo-001/dev/tigerdataNS' %>
api_root_collection_name: 'tigerdata'
@@ -78,6 +85,7 @@ development:
api_port: <%= ENV["MEDIAFLUX_PORT"] || '8888' %>
# Alternate to development is an alternate location in docker
+ api_alternate_hidden_root: '/td-alternate-001'
api_alternate_root_ns: '/td-alternate-001/tigerdataNS'
api_alternate_root_collection: 'path=/td-alternate-001/tigerdata'
api_alternate_root_collection_name: 'tigerdata-alternate'
@@ -92,6 +100,7 @@ development:
api_password: <%= ENV["MEDIAFLUX_PASSWORD"] || 'change_me' %>
shared_files_location: <%= ENV["SHARED_FILES_MOUNT"] || './public/' %>
test:
+ api_hidden_root: '/td-test-001'
api_root_to_clean: '/td-test-001/test/'
api_root_ns: '/td-test-001/test/tigerdataNS'
api_root_collection_name: 'tigerdata'
@@ -102,6 +111,7 @@ test:
api_port: "<%= ENV['MFLUX_CI'] ? '80' : '8888' %>"
# Alternate to test is still a test location
+ api_alternate_hidden_root: '/td-test-002'
api_alternate_root_ns: '/td-test-002/tigerdataNS'
api_alternate_root_collection: 'path=/td-test-002/tigerdata-alt'
api_alternate_root_collection_name: 'tigerdata-alt'
diff --git a/spec/models/project_show_presenter_spec.rb b/spec/models/project_show_presenter_spec.rb
index dafaa655a..9ba623c93 100644
--- a/spec/models/project_show_presenter_spec.rb
+++ b/spec/models/project_show_presenter_spec.rb
@@ -5,6 +5,12 @@
let(:project) { FactoryBot.create :project }
subject(:presenter) { ProjectShowPresenter.new(project) }
+ describe "#description" do
+ it "delegates to project metdata_model" do
+ expect(presenter.description).to eq(project.metadata_model.description)
+ end
+ end
+
describe "#id" do
it "delegates to project" do
expect(presenter.id).to eq(project.id)
@@ -23,12 +29,6 @@
end
end
- describe "#metadata" do
- it "delegates to project" do
- expect(presenter.metadata).to eq(project.metadata)
- end
- end
-
describe "#pending?" do
it "delegates to project" do
expect(presenter.pending?).to eq(project.pending?)
@@ -36,8 +36,20 @@
end
describe "#project_directory" do
- it "delegates to project" do
- expect(presenter.project_directory).to eq(project.project_directory)
+ it "hides the root project" do
+ expect(presenter.project_directory).to eq("/test/tigerdataNS/big-data")
+ end
+ end
+
+ describe "#project_id" do
+ it "delegates to project metdata_model" do
+ expect(presenter.project_id).to eq(project.metadata_model.project_id)
+ end
+ end
+
+ describe "#project_purpose" do
+ it "delegates to project metdata_model" do
+ expect(presenter.project_purpose).to eq(project.metadata_model.project_purpose)
end
end
@@ -47,6 +59,18 @@
end
end
+ describe "#storage_capacity" do
+ it "delegates to project metadata_model" do
+ expect(presenter.storage_capacity).to eq(project.metadata_model.storage_capacity)
+ end
+ end
+
+ describe "#storage_performance_expectations" do
+ it "delegates to project metadata_model" do
+ expect(presenter.storage_performance_expectations).to eq(project.metadata_model.storage_performance_expectations)
+ end
+ end
+
describe "#title" do
it "delegates to project" do
expect(presenter.title).to eq(project.title)
diff --git a/spec/system/project_show_spec.rb b/spec/system/project_show_spec.rb
index 4a95928ea..b738d8bba 100644
--- a/spec/system/project_show_spec.rb
+++ b/spec/system/project_show_spec.rb
@@ -45,6 +45,11 @@
visit "/projects/#{project_in_mediaflux.id}"
expect(page).to have_content(project_in_mediaflux.title)
+
+ # shows the project directory without the hidden root
+ expect(page).to have_content(project_in_mediaflux.project_directory.gsub("/td-test-001", ""))
+ expect(page).not_to have_content(project_in_mediaflux.project_directory)
+
expect(page).not_to have_content(pending_text)
expect(page).to have_css ".alert-success"
expect(page).to have_selector(:link_or_button, "Edit") # button next to role and description heading
@@ -210,6 +215,11 @@
it "shows the sysadmin buttons for an approved project" do
sign_in sysadmin_user
visit "/projects/#{project_in_mediaflux.id}"
+
+ # shows the project directory without the hidden root
+ expect(page).to have_content(project_in_mediaflux.project_directory.gsub("/td-test-001", ""))
+ expect(page).not_to have_content(project_in_mediaflux.project_directory)
+
expect(page).to have_content "project 123"
expect(page).to have_content "1234"
expect(page).not_to have_content "This project has not been saved to Mediaflux"