Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
3e69afd
MMT-2231 Add revisions page to published UMM-T page (#610)
ryanmiller-1 Jul 8, 2020
fe0543a
MMT-2311: Added a translate_collections.rake file and added nokogiri/…
Jul 8, 2020
5e6a0a8
MMT-2288 Update jquery version that is being package for the preview …
ryanmiller-1 Jul 9, 2020
994cbb1
MMT-2230 (#608)
ryanmiller-1 Jul 9, 2020
e1394af
added display parameter to rake task
Jul 9, 2020
31b1c59
MMT-2229 Adding delete for published tools
william-valencia Jul 10, 2020
ebb408b
MMT-2311: Added a translate_collections.rake file and added nokogiri/…
Jul 8, 2020
6018f8e
MMT-2311: added display parameter to rake task
Jul 9, 2020
cac7733
Merge branch 'MMT-2311-1' of https://github.com/nasa/mmt into MMT-2311-1
Jul 10, 2020
22a9fb8
MMT-2229 Updating not current provider modal
ryanmiller-1 Jul 10, 2020
db5af95
MMT-2229 Fixing the tool_permissions_spec
william-valencia Jul 13, 2020
47bf0b2
MMT-2229 Removing duplicate test
william-valencia Jul 13, 2020
daaa4cf
Fixing spacing for tools_permissions_spec.rb
william-valencia Jul 13, 2020
f58c6ad
MMT-2234 (#607)
ryanmiller-1 Jul 13, 2020
4fa3f5c
Hotfix/MMT-2231-1 Updating revisions helpers to sort by revision date…
ryanmiller-1 Jul 13, 2020
3d6788b
Delete package-lock.json
ChristianTrummer99 Jul 13, 2020
c9ea01d
MMT-2311: made changes as per PR change requests
Jul 13, 2020
2b2fa4c
MMT-2311: made changes per PR requests, added package-lock to gitignore
Jul 13, 2020
9eec788
MMT-2229 Modifying delete_tool_spec due to comments and fixing tool_p…
william-valencia Jul 14, 2020
e1eedaa
MMT-2229 Removing unneeded delete
william-valencia Jul 14, 2020
55a52ae
MMT-2229 Removing unneeded native_id_3
william-valencia Jul 14, 2020
0885415
MMT-2311: added comments to each method definition
Jul 14, 2020
f05fef7
Merge branch 'master' into MMT-2229-Delete-Published-Tools
william-valencia Jul 14, 2020
ff40024
Merge pull request #614 from nasa/MMT-2229-Delete-Published-Tools
william-valencia Jul 14, 2020
ae1845c
MMT-2311: Added nokogiri array-path-parsing feature; removed unused f…
Jul 15, 2020
42371bb
MMT-2311: made changes according to change requests
Jul 15, 2020
c50d767
MMT-2311: more changes as per PR change requests
Jul 15, 2020
23e5cb7
MMT-2311: added comment
Jul 16, 2020
04ce818
MMT-2232/2233 Revision viewing and reversion for tools (#617)
ryanmiller-1 Jul 17, 2020
40af5e4
MMT-2311: made changes according to PR change requests
Jul 17, 2020
c479ee2
MMT-2311: more changes per PR change requests
Jul 20, 2020
52d5859
Hotfix/MMT-2232-1 Fixing tests bamboo started failing (#619)
ryanmiller-1 Jul 21, 2020
841b757
MMT-2311: Pull fixes for the selenium issues; Merge branch 'master' i…
Jul 21, 2020
d8f7561
MMT-2311: fixed dif10 asterisk issues
Jul 22, 2020
d60994a
MMT-2311: Adjusted removal of namespaces
Jul 22, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
# Ignore bundler config.
/.bundle

# Ignore package-lock.json
package-lock.json

# Ignore the default SQLite database.
/db/*.sqlite3
/db/*.sqlite3-journal
Expand Down
4 changes: 3 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ gem 'kaminari'
gem 'momentjs-rails' # js lib for dates
gem 'pundit'

gem 'nokogiri-diff', '~> 0.2.0' # for comparing xml documents

gem 'activerecord-import' # bulk insertion of data

gem 'activerecord-session_store'
Expand All @@ -78,7 +80,7 @@ gem 'browser'
# bundle config local.cmr_metadata_preview /path/to/local/git/repository
# make sure to delete the local config when done making changes to merge into master
# bundle config --delete local.cmr_metadata_preview
gem 'cmr_metadata_preview', git: 'https://git.earthdata.nasa.gov/scm/cmr/cmr_metadata_preview.git', ref: 'fff65949cc6'
gem 'cmr_metadata_preview', git: 'https://git.earthdata.nasa.gov/scm/cmr/cmr_metadata_preview.git', ref: '1f6ffd54d65'

group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
Expand Down
11 changes: 8 additions & 3 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
GIT
remote: https://git.earthdata.nasa.gov/scm/cmr/cmr_metadata_preview.git
revision: fff65949cc62d397b0675e9fe46e962b8cf43228
ref: fff65949cc6
revision: 1f6ffd54d6570f9f920078a84fd51750db3c21ab
ref: 1f6ffd54d65
specs:
cmr_metadata_preview (0.2.2)
cmr_metadata_preview (0.2.3)
georuby
rails (~> 5.2.0)
sprockets (< 4.0)
Expand Down Expand Up @@ -195,6 +195,9 @@ GEM
nio4r (2.5.2)
nokogiri (1.10.9)
mini_portile2 (~> 2.4.0)
nokogiri-diff (0.2.0)
nokogiri (~> 1.5)
tdiff (~> 0.3, >= 0.3.2)
parallel (1.19.1)
parser (2.7.1.2)
ast (~> 2.4.0)
Expand Down Expand Up @@ -297,6 +300,7 @@ GEM
activesupport (>= 4.0)
sprockets (>= 3.0.0)
sqlite3 (1.4.2)
tdiff (0.3.4)
thor (1.0.1)
thread_safe (0.3.6)
tilt (2.0.10)
Expand Down Expand Up @@ -365,6 +369,7 @@ DEPENDENCIES
mini_racer
momentjs-rails
multi_xml
nokogiri-diff (~> 0.2.0)
pg
pundit
rack_session_access
Expand Down
10 changes: 10 additions & 0 deletions app/assets/javascripts/change_current_provider.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,16 @@ $(document).ready ->
"Managing this service's collection associations"
when 'edit-tool'
'Editing this tool'
when 'clone-tool'
'Cloning this tool'
when 'delete-tool'
'Deleting this tool'
when 'reinstate-tool'
action = 'revert'
'Reinstating this tool'
when 'revert-tool'
action = 'revert'
'Reverting this tool'

$link.data('type', action)
$modal.find('span.provider').text(provider)
Expand Down
2 changes: 1 addition & 1 deletion app/concerns/cmr_collections_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ def get_revisions(concept_id, revision_id)
# try again because CMR might be a little slow to index if it is a newly published revision
attempts = 0
while attempts < 20
revisions_response = cmr_client.get_collections({ concept_id: concept_id, all_revisions: true, include_granule_counts: true }, token)
revisions_response = cmr_client.get_collections({ concept_id: concept_id, all_revisions: true, include_granule_counts: true, sort_key: '-revision_date' }, token)
revisions = if revisions_response.success?
revisions_response.body.fetch('items', [])
else
Expand Down
6 changes: 3 additions & 3 deletions app/controllers/manage_metadata_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def set_variable_information
# if the variable is not found, try again because CMR might be a little slow to index if it is a newly published record
attempts = 0
while attempts < 20
variables_search_response = cmr_client.get_variables(concept_id: @concept_id, all_revisions: true)
variables_search_response = cmr_client.get_variables(concept_id: @concept_id, all_revisions: true, sort_key: '-revision_date')

variable_data = if variables_search_response.success?
variables_search_response.body.fetch('items', [])
Expand Down Expand Up @@ -163,7 +163,7 @@ def set_service_information
# if the service is not found, try again because CMR might be a little slow to index if it is a newly published record
attempts = 0
while attempts < 20
services_search_response = cmr_client.get_services(concept_id: @concept_id, all_revisions: true)
services_search_response = cmr_client.get_services(concept_id: @concept_id, all_revisions: true, sort_key: '-revision_date')

service_data = if services_search_response.success?
services_search_response.body.fetch('items', [])
Expand Down Expand Up @@ -218,7 +218,7 @@ def set_tool_information
# if the tool is not found, try again because CMR might be a little slow to index if it is a newly published record
attempts = 0
while attempts < 20
tools_search_response = cmr_client.get_tools(concept_id: @concept_id, all_revisions: true)
tools_search_response = cmr_client.get_tools(concept_id: @concept_id, all_revisions: true, sort_key: '-revision_date')

tool_data = if tools_search_response.success?
tools_search_response.body.fetch('items', [])
Expand Down
6 changes: 3 additions & 3 deletions app/controllers/tools_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
class ToolsController < BasePublishedRecordController
include ManageMetadataHelper

before_action :set_tool, only: [:show, :edit] #, :clone, :destroy, :revisions, :revert, :download_json]
before_action :set_schema, only: [:show, :edit] #, :clone, :destroy]
before_action :set_tool, only: [:show, :edit, :clone, :destroy, :revisions, :revert, :download_json]
before_action :set_schema, only: [:show, :edit, :clone, :destroy]
before_action :ensure_supported_version, only: [:show, :edit]
before_action :ensure_correct_provider, only: [:edit] #, :clone, :destroy]
before_action :ensure_correct_provider, only: [:edit, :clone, :destroy]
before_action :set_preview, only: [:show]

# If clone is not defined like this performing the clone action leads to a `action not found error`
Expand Down
2 changes: 1 addition & 1 deletion app/helpers/manage_metadata_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def resource_type
end

def display_header_subtitle(metadata, type)
return unless type.downcase.include?('variable') || type.downcase.include?('service')
return unless ['variable', 'service', 'tool'].any? { |type_fragment| type.downcase.include?(type_fragment) }

metadata['LongName'] || 'Long Name Not Provided'
end
Expand Down
12 changes: 12 additions & 0 deletions app/helpers/tools_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
module ToolsHelper
def render_change_provider_tool_action_link(tool_action, concept_id, revision_id = nil)
case tool_action
when 'edit'
link_to('Edit Service', edit_tool_path(concept_id, revision_id: revision_id), class: 'is-invisible', id: 'change-provider-tool-edit')
when 'clone'
link_to('Clone Service', clone_tool_path(concept_id, revision_id: revision_id), class: 'is-invisible', id: 'change-provider-tool-clone')
when 'delete'
link_to('Delete Service', tool_path(concept_id), method: :delete, class: 'is-invisible', id: 'change-provider-tool-delete')
end
end
end
10 changes: 5 additions & 5 deletions app/models/tool_draft.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ def create_from_tool(tool, user, native_id)
draft = self.find_or_initialize_by(native_id: native_id)
draft.entry_title = tool['LongName']
draft.short_name = tool['Name']
# else
# # Cloned Record
# draft = self.new
# tool.delete('Name')
# tool.delete('LongName')
else
# Cloned Record
draft = self.new
tool.delete('Name')
tool.delete('LongName')
end

draft.set_user_and_provider(user)
Expand Down
6 changes: 4 additions & 2 deletions app/views/shared/_not_current_provider_modal.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
<%= link_to 'Yes', revert_variable_path(options[:concept_id], revision_id: options[:revision_id]), class: 'eui-btn--blue spinner is-invisible', id: "not-current-provider-revert-link#{'-' + modal_index.to_s if modal_index}" %>
<% elsif options[:service] %>
<%= link_to 'Yes', revert_service_path(options[:concept_id], revision_id: options[:revision_id]), class: 'eui-btn--blue spinner is-invisible', id: "not-current-provider-revert-link#{'-' + modal_index.to_s if modal_index}" %>
<% elsif options[:tool] %>
<%= link_to 'Yes', revert_tool_path(options[:concept_id], revision_id: options[:revision_id]), class: 'eui-btn--blue spinner is-invisible', id: "not-current-provider-revert-link#{'-' + modal_index.to_s if modal_index}" %>
<% else %>
<%= link_to 'Yes', revert_collection_path(options[:concept_id], revision_id: options[:revision_id]), class: 'eui-btn--blue spinner is-invisible', id: 'not-current-provider-revert-link' %>
<% end %>
Expand All @@ -33,8 +35,8 @@
<%= link_to 'Yes', service_collection_associations_path(options[:concept_id]), class: 'eui-btn--blue spinner is-invisible', id: 'not-current-provider-manage-service-associations-link' %>
<% elsif options[:tool] %>
<%= link_to 'Yes', edit_tool_path(options[:concept_id], revision_id: options[:revision_id]), class: 'eui-btn--blue spinner is-invisible', id: 'not-current-provider-edit-tool-link' %>
<%#= link_to 'Yes', clone_tool_path(options[:concept_id], revision_id: options[:revision_id]), class: 'eui-btn--blue spinner is-invisible', id: 'not-current-provider-clone-tool-link' %>
<%#= link_to 'Yes', tool_path(options[:concept_id]), method: :delete, class: 'eui-btn--blue spinner is-invisible', id: 'not-current-provider-delete-tool-link' %>
<%= link_to 'Yes', clone_tool_path(options[:concept_id], revision_id: options[:revision_id]), class: 'eui-btn--blue spinner is-invisible', id: 'not-current-provider-clone-tool-link' %>
<%= link_to 'Yes', tool_path(options[:concept_id]), method: :delete, class: 'eui-btn--blue spinner is-invisible', id: 'not-current-provider-delete-tool-link' %>
<% end %>

<% if options[:draft] %>
Expand Down
115 changes: 115 additions & 0 deletions app/views/tools/revisions.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
<% content_for :header_title do %>
<h2><%= fetch_entry_id(@tool, 'tools') %></h2>
<p class="subtitle"><%= display_header_subtitle(@tool, 'tool') %></p>
<% end %>

<% if @errors && !@errors.empty? %>
<section class="errors">
<div class="eui-banner--danger">
<div class="eui-banner__message">
<ul class="no-bullet">
<% @errors.each do |error| %>
<li>
<%= "#{error[:field]}, " if error[:field] %>
<%= error[:error] %>
<% if error[:request_id] %>
<a href="javascript:feedback.showForm({details: '\nFill in details above this line. Please try to be as specific as possible.\n--------------------\n\nRequest ID: <%= error[:request_id] %>'});">Click here to submit feedback</a>
<% end %>
</li>
<% end %>
</ul>
</div>
</div>
</section>
<% end %>

<div class="row row-content">
<section>
<h2>Revision History</h2>
</section>
<% if @error %>
<section class="errors">
<div class="eui-banner--danger">
<p class="eui-banner__message">
<i class="fa fa-exclamation-triangle"></i> This tool could not be updated. You may <%= link_to 'edit', edit_tool_path(revision_id: @revision_id) %> the tool to resolve these issues.
</p>
</div>
</section>
<% end %>
<div class="row">
<section>
<table id="tool-revisions-table">
<thead>
<tr>
<th>Description</th>
<th>Revision Date</th>
<th>Action by</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
<% @revisions.each_with_index do |revision, index| %>
<% revision_id = revision['meta']['revision-id'] %>
<tr class='<%= cycle("alt", "") %>'>
<td>
<% title = "View revision #{revision_id}" %>
<%= revision_id %> -
<% if revision['meta']['deleted'] == true %>
Deleted
<% elsif index == 0 %>
Published
<%= link_to 'View', tool_path(revision_id: revision_id), title: title %>
<% else %>
Revision
<%= link_to 'View', tool_path(revision_id: revision_id), title: title %>
<% end %>
</td>
<td>
<%= revision['meta']['revision-date'] %>
</td>
<td>
<%= revision['meta']['user-id'] %>
</td>
<td>
<% if @revisions.first['meta']['deleted'] == true %>
<% phrase = 'Reinstate' %>
<% confirm_phrase = 'Are you sure you want to reinstate this record?' %>
<% action = 'reinstate-tool' %>
<% else %>
<% phrase = 'Revert to this Revision' %>
<% confirm_phrase = 'Are you sure you want to revert to this revision?' %>
<% action = 'revert-tool' %>
<% end %>

<% unless index == 0 || revision['meta']['deleted'] == true %>
<% if current_provider?(@provider_id) %>
<%= link_to phrase, "#revert-revisions-modal-#{revision_id}", class: 'display-modal' %>
<% elsif available_provider?(@provider_id) %>
<%= link_to phrase, "#not-current-provider-modal-#{revision_id}", class: 'display-modal not-current-provider', data: { 'provider': @provider_id, record_action: action } %>
<% end %>
<div id="revert-revisions-modal-<%= revision_id %>" class="eui-modal-content">
<a href="#" class="modal-close float-r"><i class="fa fa-times"></i><span class="is-invisible">Close</span></a>
<p><%= confirm_phrase %></p>
<p>
<a href="javascript:void(0)" class="eui-btn modal-close">No</a>
<%= link_to 'Yes', revert_tool_path(revision_id: revision_id), class: 'eui-btn--blue spinner' %>
</p>
</div>
<%= render partial: "shared/not_current_provider_modal", locals: {
modal_index: revision_id,
options: {
revisions: true,
tool: @tool,
concept_id: @concept_id,
revision_id: revision_id
}
} %>
<% end %>
</td>
</tr>
<% end %>
</tbody>
</table>
</section>
</div>
</div>
40 changes: 16 additions & 24 deletions app/views/tools/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@
"#", id: "change-current-provider-banner-link",
data: { "provider": @provider_id, action_link: "change-provider-tool-#{@record_action}" }) %>
</p>
<%# TODO: this method does not exist yet. It should be created and used when %>
<%# additional actions are added to published Tool records %>
<%#= render_change_provider_tool_action_link(@record_action, @concept_id, @revision_id) %>
<%= render_change_provider_tool_action_link(@record_action, @concept_id, @revision_id) %>
</div>
<% end %>

Expand Down Expand Up @@ -94,34 +92,29 @@
<% end %>
<% end %>

<%# TODO: All links commented out and disabled links added for MMT-2238 %>
<%# links should be re-enabled with the appropriate ticket %>
<%= link_to 'Clone Tool Record', '#', class: 'eui-btn--link bar-after disabled' %>
<%# if current_provider?(@provider_id) %>
<%#= link_to 'Clone Tool Record', clone_tool_path(revision_id: @revision_id), class: 'eui-btn--link bar-after' %>
<%# elsif available_provider?(@provider_id) %>
<%#= link_to 'Clone Tool Record', '#not-current-provider-modal', class: 'display-modal not-current-provider eui-btn--link bar-after', data: { 'provider': @provider_id, record_action: 'clone-tool' } %>
<%# end %>
<% if current_provider?(@provider_id) %>
<%= link_to 'Clone Tool Record', clone_tool_path(revision_id: @revision_id), class: 'eui-btn--link bar-after' %>
<% elsif available_provider?(@provider_id) %>
<%= link_to 'Clone Tool Record', '#not-current-provider-modal', class: 'display-modal not-current-provider eui-btn--link bar-after', data: { 'provider': @provider_id, record_action: 'clone-tool' } %>
<% end %>

<%= link_to 'Download JSON', '#', class: 'eui-btn--link disabled' %>
<%#= link_to 'Download JSON', download_json_tool_path(@concept_id, revision_id: @revision_id), class: 'eui-btn--link', target: '_blank' %>
<%= link_to 'Download JSON', download_json_tool_path(@concept_id, revision_id: @revision_id), class: 'eui-btn--link', target: '_blank' %>

<%= link_to 'Delete Tool Record', '#', class: 'display-modal delete-tool eui-btn--link bar-before disabled' %>
<%# if current_provider?(@provider_id) %>
<%#= link_to 'Delete Tool Record', "#delete-record-modal", class: 'display-modal delete-tool eui-btn--link bar-before' %>
<%# elsif available_provider?(@provider_id) %>
<%#= link_to 'Delete Tool Record', '#not-current-provider-modal', class: 'display-modal not-current-provider eui-btn--link bar-before', data: { 'provider': @provider_id, record_action: 'delete-tool', num_associated_collections: "#{@num_associated_collections}" } %>
<%# end %>
<% if current_provider?(@provider_id) %>
<%= link_to 'Delete Tool Record', "#delete-record-modal", class: 'display-modal delete-tool eui-btn--link bar-before' %>
<% elsif available_provider?(@provider_id) %>
<%= link_to 'Delete Tool Record', '#not-current-provider-modal', class: 'display-modal not-current-provider eui-btn--link bar-before', data: { 'provider': @provider_id, record_action: 'delete-tool' } %>
<% end %>

<!-- <div id="delete-record-modal" class="eui-modal-content">
<div id="delete-record-modal" class="eui-modal-content">
<a href="javascript:void(0);" class="modal-close float-r"><i class="fa fa-times"></i><span class="is-invisible">Close</span></a>
<p>
Are you sure you want to delete this tool record?
<p>
<a href="javascript:void(0)" class="eui-btn modal-close">No</a>
<%#= link_to 'Yes', tool_path, method: :delete, class: 'eui-btn--blue spinner' %>
<%= link_to 'Yes', tool_path, method: :delete, class: 'eui-btn--blue spinner' %>
</p>
</div> -->
</div>
<%= render partial: 'shared/not_current_provider_modal', locals: {
options: {
tool: @tool,
Expand All @@ -133,8 +126,7 @@
} %>
</p>
<p>
<%= link_to 'Revisions', '#', class: 'eui-btn--link disabled' %>
<%#= link_to "Revisions (#{@revisions.size})", tool_revisions_path, class: 'eui-btn--link disabled' %>
<%= link_to "Revisions (#{@revisions.size})", tool_revisions_path, class: 'eui-btn--link' %>
</p>
</section>

Expand Down
2 changes: 1 addition & 1 deletion config/environments/production.rb
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@
config.subscriptions_enabled = true

# Feature toggle for UMM-T
config.umm_t_enabled = false
config.umm_t_enabled = true

config.cmr_env = 'ops'
config.echo_env = 'ops'
Expand Down
2 changes: 1 addition & 1 deletion config/environments/uat.rb
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@
config.csplog_enabled = false

# Feature toggle for UMM-T
config.umm_t_enabled = false
config.umm_t_enabled = true

config.cmr_env = 'uat'
config.echo_env = 'uat'
Expand Down
Loading