Skip to content

Commit 8d9c8cb

Browse files
Ap 609 numbered cs default (#15)
* overrides resources toolbar view so numbered_cs is chosen for EAD export * verifying checksum for resources/_toolbar.html.erb hasn't changed since we are overriding it * Updated README for _toolbar.html.erb override * changed message for ARCHIVESSPACE_VERSION check * Moved checksum check for _toolbar.html.erb into test step * _toolbar.html.erb wasn't found for testing. Reordered tests to make sure file is built and it can find the path * Added more logging since _toobard.html.erb check is failing without a meaningful message * checksum comparison for _toolbar.html.erb was comparing for equality as opposed to the expected diff
1 parent d1e2af4 commit 8d9c8cb

4 files changed

Lines changed: 135 additions & 0 deletions

File tree

.github/workflows/build.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ on:
99
env:
1010
BUILD_SUFFIX: -build-${{ github.run_id }}_${{ github.run_attempt }}
1111
DOCKER_METADATA_SET_OUTPUT_ENV: 'true'
12+
ARCHIVESSPACE_RESOURCE_TOOLBAR_DIFF_SHA256: 5122e9837c25fefe58d64ff499e570b5120f527f3654de4bb0acac22d5cfc1ed
1213

1314
jobs:
1415
build:
@@ -141,6 +142,28 @@ jobs:
141142
run: |
142143
curl --location --fail --retry 30 --retry-all-errors http://localhost:8080/
143144
145+
- name: Verify deployed resource toolbar matches upstream
146+
run: |
147+
set -euo pipefail
148+
149+
upstream="$(docker compose exec -T app sh -lc 'find /opt/app/data/tmp -type f -path "*/webapp/WEB-INF/app/views/resources/_toolbar.html.erb" | head -n1')"
150+
if [[ -z "$upstream" ]]; then
151+
echo "Could not find extracted upstream _toolbar.html.erb under /opt/app/data/tmp"
152+
docker compose exec -T app sh -lc 'ls -la /opt/app/data/tmp || true'
153+
exit 1
154+
fi
155+
156+
diff_output="$(docker compose exec -T app sh -lc "diff '$upstream' /opt/app/plugins/local/frontend/views/resources/_toolbar.html.erb || true")"
157+
csum="$(printf '%s' "$diff_output" | sha256sum | cut -f1 -d' ')"
158+
echo "Toolbar diff checksum: $csum"
159+
160+
if [[ "$csum" != "$ARCHIVESSPACE_RESOURCE_TOOLBAR_DIFF_SHA256" ]]; then
161+
echo "Expected diff checksum: $ARCHIVESSPACE_RESOURCE_TOOLBAR_DIFF_SHA256"
162+
echo "resources/_toolbar.html.erb diff changed from the expected override patch"
163+
printf '%s\n' "$diff_output" | head -n 120
164+
exit 1
165+
fi
166+
144167
- name: Copy out artifacts
145168
if: ${{ always() }}
146169
run: |

Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ COPY --from=aspace --chown=archivesspace:archivesspace /opt/app /opt/app
7474

7575
# Copy in our custom config files
7676
COPY --chown=archivesspace:archivesspace files/plugins/local/frontend/assets/images/* /opt/app/plugins/local/frontend/assets/images/
77+
COPY --chown=archivesspace:archivesspace files/plugins/local/frontend/views/resources/* /opt/app/plugins/local/frontend/views/resources/
7778
COPY --chown=archivesspace:archivesspace files/plugins/local/frontend/locales/en.rb /opt/app/plugins/local/frontend/locales/en.rb
7879

7980
# Copy the built DWO plugin

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@ For ArchivesSpace v4+, consult their excellent [new documentation site](https://
2828

2929
We've added a `docker-entrypoint.sh` shim script which loads files from `/run/secrets` into the environment before running a given command. Secrets can be added there using Docker's normal methods, but read from the application using `ENV`.
3030

31+
### _toolbar.html.erb override
32+
33+
We are overriding the resources/_toolbar.html.erb view so the numbered_cs option is checked for resource EAD export. There is a check in the build.yml to
34+
ensure the checksum for the Aspace _toolbar.html.erb hasn't changed if we upgrade Aspace versions. If it does the build will fail. If it fails for that reason the
35+
files/plugins/local/frontend/views/resources/_toolbar.html.erb file (override file) will need to be updated to reflect the new toolbar (frontend/app/views/resources/_toolbar.html.erb).
36+
3137
### Configuration File
3238

3339
Since ASpace's built-in `ENV['APPCONFIG_']` configuration method doesn't always work (particularly when parsing JSON), we template the config.rb file directly into the image at runtime. You're free to modify that file as you see fit in testing. Note that the version included in this repo is purely for development, and any changes to it in a long-lived environment would need to be coordinated. Any long lived configuration changes should be made in the docker swarm stack file. Those values will override what's in the config.rb.
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
<% pref_include_unpublished = user_prefs['include_unpublished'] %>
2+
3+
<% if user_can?('update_resource_record') %>
4+
5+
<% unless content_for?(:exports) %>
6+
<% content_for :exports do %>
7+
<%# ANW-1821 An alt approach to the submenu pattern used elsewhere where we are
8+
concerned with maximizing the clickable area for actionable dropdown menu
9+
items...instead of shifting .dropdown-item to the <a> child of the <li>,
10+
the parent <li> has .dropdown-item.dropdown-submenu and the <a> child is
11+
responsible for layout; there is so much logic built into the <li>s below
12+
for export needs that this alt approach was easiest. %>
13+
<li class="dropdown-item p-0 dropdown-submenu" id="download-ead-dropdown" data-download-ead-url="<%= url_for(:controller => :exports,
14+
:action => :download_ead, :id => @resource.id, :include_unpublished => "${include_unpublished}",
15+
:include_daos => "${include_daos}", :include_uris => "${include_uris}", :numbered_cs => "${numbered_cs}", :ead3 => "${ead3}" )%>">
16+
<%# The following <a> triggers a download on click and shows the sub dropdown menu
17+
below it on hover; the sub dropdown menu repositions weirdly (via popper.js)
18+
after the download in the same page session, so `data-display="static"` is
19+
added to disable popper.js involvement. %>
20+
<a href="#" data-toggle="dropdown" data-display="static" class="py-1 px-4 d-block text-decoration-none menu-with-options download-ead-action" title="<%= t("actions.export_ead") %>"><%= t("actions.export_ead") %></a>
21+
<div class="dropdown-menu" id="form_download_ead">
22+
<fieldset class="d-flex flex-column">
23+
<input type="hidden" name="id", value="<%= @resource.id %>" />
24+
<label class="checkbox" for="include-unpublished">
25+
<input type="checkbox" id="include-unpublished" name="include_unpublished" <% if pref_include_unpublished %> checked="checked" <% end %>/>
26+
<%= t("export_options.include_unpublished") %>
27+
</label>
28+
<label class="checkbox" for="include-daos">
29+
<input type="checkbox" id="include-daos" name="include_daos" checked="checked"/>
30+
<%= t("export_options.include_daos") %>
31+
</label>
32+
<label class="checkbox" for="include-uris">
33+
<input type="checkbox" id="include-uris" name="include_uris" checked="checked"/>
34+
<%= t("export_options.include_uris") %>
35+
</label>
36+
<label class="checkbox" for="numbered-cs">
37+
<input type="checkbox" id="numbered-cs" name="numbered_cs" checked="checked"/>
38+
<%= t("export_options.numbered_cs") %>
39+
</label>
40+
<%# EAD3 %>
41+
<label class="checkbox" for="ead3">
42+
<input type="checkbox" id="ead3" name="ead3" />
43+
<%= t("export_options.ead3") %>
44+
</label>
45+
<%# END - EAD3 %>
46+
</fieldset>
47+
</div>
48+
</li>
49+
50+
<li class="dropdown-item p-0 dropdown-submenu" id="download-marc-dropdown" data-download-marc-url="<%= url_for(:controller => :exports, :action => :download_marc, :id => @resource.id, :include_unpublished_marc => "${include_unpublished_marc}")%>">
51+
<a href="#" data-toggle="dropdown" data-display="static" class="py-1 px-4 d-block text-decoration-none menu-with-options download-marc-action" title="<%= t("actions.export_marc") %>"><%= t("actions.export_marc") %></a>
52+
<div class="dropdown-menu" id="form_download_marc">
53+
<fieldset>
54+
<input type="hidden" name="id", value="<%= @resource.id %>" />
55+
<label class="checkbox" for="include-unpublished-marc">
56+
<input type="checkbox" id="include-unpublished-marc" name="include_unpublished_marc" <% if pref_include_unpublished %> checked="checked" <% end %>/>
57+
<%= t("export_options.include_unpublished") %>
58+
</label>
59+
<%# END - MARC %>
60+
</fieldset>
61+
</div>
62+
</li>
63+
64+
<li><%= link_to t("actions.container_labels"), {:controller => :exports, :action => :container_labels, :id => @resource.id}, :id => 'container-labels-link', :target => "_blank", :class => "dropdown-item" %></li>
65+
<li><%= link_to t("actions.container_template"), {:controller => :exports, :action => :container_template, :id => @resource.id}, :id => 'container-template-link', :target => "_self", :class => "dropdown-item" %></li>
66+
<li><%= link_to t("actions.digital_object_template"), {:controller => :exports, :action => :digital_object_template, :id => @resource.id}, :id => 'digital-object-template-link', :target => "_self", :class => "dropdown-item" %></li>
67+
<% if user_can?('create_job') %>
68+
<% if job_types['print_to_pdf_job']['create_permissions'].reject{|perm| user_can?(perm)}.empty? %>
69+
70+
<li class="dropdown-item p-0 dropdown-submenu" id="print-to-pdf-dropdown" data-print-to-pdf-url="<%= url_for(:controller => :exports, :action => :print_to_pdf, :id => @resource.id, :include_unpublished => "${include_unpublished}", :include_uris => "${include_uris}")%>">
71+
<a href="#" data-toggle="dropdown" data-display="static" class="py-1 px-4 d-block text-decoration-none menu-with-options print-to-pdf-action" title="<%= t("actions.print_to_pdf") %>"><%= t("actions.print_to_pdf") %></a>
72+
<div class="dropdown-menu" id="form_print_to_pdf">
73+
<fieldset class="d-flex flex-column">
74+
<label class="checkbox" for="include-unpublished-pdf">
75+
<input type="checkbox" id="include-unpublished-pdf" <% if pref_include_unpublished %> checked="checked" <% end %> />
76+
<%= t("export_options.include_unpublished") %>
77+
</label>
78+
<label class="checkbox" for="include-uris-pdf">
79+
<input type="checkbox" id="include-uris-pdf" />
80+
<%= t("export_options.include_uris") %>
81+
</label>
82+
</fieldset>
83+
</div>
84+
</li>
85+
86+
<% end %>
87+
<% end %>
88+
<% end %>
89+
<% end %>
90+
91+
<%= render_aspace_partial(:partial => '/shared/resource_toolbar',
92+
:locals => {
93+
:record_type => 'resource',
94+
:record => @resource,
95+
})
96+
%>
97+
<% elsif user_can_view_only?('resource') %>
98+
<%= render_aspace_partial(:partial => '/shared/resource_toolbar',
99+
:locals => {
100+
:record_type => 'resource',
101+
:record => @resource,
102+
:view_only => true,
103+
})
104+
%>
105+
<% end %>

0 commit comments

Comments
 (0)