-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1133 from sul-dlss/version-row
Version links shouldn't have a 'v' in them
- Loading branch information
Showing
11 changed files
with
98 additions
and
33 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
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 @@ | ||
<tr> | ||
<th class="version-identifier">Version <%= version.version_id %></th> | ||
<td class="version-updated-at"><%= updated_at %></td> | ||
<td data-controller="clipboard" data-clipboard-url-value="<%= version_purl_url(id: version.druid, version: version.version_id) %>"> | ||
<%= render VersionActionsComponent.new(version:, requested_version:) %> | ||
</td> | ||
</tr> |
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,17 @@ | ||
# frozen_string_literal: true | ||
|
||
class VersionRowComponent < ViewComponent::Base | ||
with_collection_parameter :version | ||
|
||
def initialize(version:, requested_version:) | ||
@version = version | ||
@requested_version = requested_version | ||
super | ||
end | ||
|
||
attr_reader :version, :requested_version | ||
|
||
def updated_at | ||
l(version.updated_at.to_date, format: :short) if version.updated_at | ||
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
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,50 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'rails_helper' | ||
|
||
RSpec.describe VersionRowComponent, type: :component do | ||
let(:purl) { PurlResource.new(id: 'wp335yr5649') } | ||
|
||
before { render_inline(instance) } | ||
|
||
context 'when rendering not the requested version' do | ||
let(:instance) { described_class.new(version: purl.version(:head), requested_version: purl.version(2)) } | ||
|
||
it 'renders the version row' do | ||
expect(page).to have_css 'th', text: 'Version 4' | ||
expect(page).to have_css 'td', text: 'Jul 24, 2024' | ||
expect(page).to have_link 'View', href: '/wp335yr5649/version/4' | ||
expect(page).to have_css '[data-clipboard-url-value="http://test.host/wp335yr5649/version/4"]', text: 'Copy URL' | ||
end | ||
end | ||
|
||
context 'when rendering the requested version' do | ||
let(:instance) { described_class.new(version: purl.version(2), requested_version: purl.version(2)) } | ||
|
||
it 'renders the version row' do | ||
expect(page).to have_css 'th', text: 'Version 2' | ||
expect(page).to have_css 'td', text: 'Jul 22, 2024' | ||
expect(page).to have_css 'td', text: 'You are viewing this version' | ||
expect(page).to have_css '[data-clipboard-url-value="http://test.host/wp335yr5649/version/2"]', text: 'Copy URL' | ||
end | ||
end | ||
|
||
context 'when rendering a withdrawn version' do | ||
let(:instance) { described_class.new(version: purl.version(3), requested_version: purl.version(2)) } | ||
|
||
it 'renders the version row' do | ||
expect(page).to have_css 'th', text: 'Version 3' | ||
expect(page).to have_css 'td', text: 'Jul 23, 2024' | ||
expect(page).to have_css 'td', text: 'Withdrawn' | ||
end | ||
end | ||
|
||
context 'when rendering a permanently withdrawn version' do | ||
let(:instance) { described_class.new(version: purl.version(1), requested_version: purl.version(2)) } | ||
|
||
it 'renders the version row' do | ||
expect(page).to have_css 'th', text: 'Version 1' | ||
expect(page).to have_css 'td', text: 'Permanently withdrawn' | ||
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