Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create new Item Version (basic Items only) #1318

Merged
merged 51 commits into from
Oct 20, 2021
Merged

Conversation

davide-negretti
Copy link
Contributor

@davide-negretti davide-negretti commented Sep 16, 2021

References

Description

This feature allows to manage item versions. A new version can be created from item's page, and all versions can be managed (create, delete, edit summary) from the "Version History" tab in "Edit Item" page.

Instructions for Reviewers

List of changes in this PR:

Item's public page

  • A Create new version button has be added (when the user is the submitter or an administrator)

Version's page

  • A version page /items/version/:versionID has been added
  • This page redirects to the corresponding item's page

Version History table

  • The Item column (containing the item's handler and the link to the item page) has been removed
  • The Version column now contains the link to the version's page (redirecting to the corresponding item's page)
  • An Action column has been added, containing the buttons to manage the version
  • The Action column is only displayed in Edit Item page

Authorization features

  • All actions on versions require authorization
  • The authorization features are:
    • canCreateVersion
    • canEditVersion
    • canDeleteVersion

Data services

  • New methods have been added to the following services:
    • VersionHistoryDataService

Tests

All tests are still TBD

Checklist

  • My PR is small in size (e.g. less than 1,000 lines of code, not including comments & specs/tests), or I have provided reasons as to why that's not possible.
  • My PR passes TSLint validation using yarn run lint
  • My PR doesn't introduce circular dependencies
  • My PR includes TypeDoc comments for all new (or modified) public methods and classes. It also includes TypeDoc for large or complex private methods.
  • My PR passes all specs/tests and includes new/updated specs or tests based on the Code Testing Guide.
  • If my PR includes new, third-party dependencies (in package.json), I've made sure their licenses align with the DSpace BSD License based on the Licensing of Contributions documentation.

alemarte and others added 18 commits September 2, 2021 16:20
…story (call to REST service TBD) and other fixes
@atarix83 atarix83 changed the title Cst 4499 Create new Item Version (basic Items only) Sep 16, 2021
@tdonohue tdonohue added this to the 7.1 milestone Sep 16, 2021
@lgtm-com
Copy link

lgtm-com bot commented Sep 16, 2021

This pull request introduces 2 alerts when merging cf1c73b into 706cc47 - view on LGTM.com

new alerts:

  • 2 for Unused variable, import, function or class

@lgtm-com
Copy link

lgtm-com bot commented Sep 16, 2021

This pull request introduces 2 alerts when merging b1b2bd4 into 706cc47 - view on LGTM.com

new alerts:

  • 2 for Unused variable, import, function or class

Copy link
Member

@artlowel artlowel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is a big improvement in usability. Thanks @davidenegretti-4science!

I think this can be merged as soon as the test issues are fixed

@tdonohue
Copy link
Member

tdonohue commented Oct 18, 2021

@davidenegretti-4science : I'll give this a test today as well. But, I wanted to highlight that this PR is currently failing code coverage, as the coverage drops by -0.54%.... This is a sign that you have too few tests, and that there likely are entire classes with no tests. If you can add more tests to this PR, that'll help get the code coverage back up to where it needs to be to pass.

UPDATE: After glancing at the code, it looks to me like nearly all your new service methods don't have corresponding tests. Adding those should bring code coverage back up. You don't need 100% coverage, but currently you are only at 37% in this PR, and you should be more at 70% at least.

@davide-negretti
Copy link
Contributor Author

@tdonohue I managed to make the coverage test pass but I won't be able to add more tests today, I can increase the coverage tomorrow

Copy link
Member

@tdonohue tdonohue left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@davidenegretti-4science and @atarix83 : I tested this today, and it works well.

That said, there are a lot of missing specs here. I see you both improved coverage a bit (this PR now has ~45% coverage... see the "codecov/patch" check results). However, the rest of main has 75% coverage...so, once we merge this, we'll decrease coverage slightly.

While the decrease in overall coverage isn't significant, I'd still like to see this PR get it's coverage increased into more like a 70% range....especially since I see a lot of new methods which are missing specs in this PR. I've called them out via inline comments below. (A lot of these methods are key functionality in this PR, so they really need specs.)

Overall, I'm +1 this PR. But, I'd like specs added, as they'll help us maintain this code better. Once specs are added, this can be immediately merged. Thanks!

* Invalidate the cache of the item
* @param itemUUID
*/
invalidateItemCache(itemUUID: string) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New method missing specs

* @param itemHref the item for which create a new version
* @param summary the summary of the new version
*/
createVersion(itemHref: string, summary: string): Observable<RemoteData<Version>> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All the changes in this service are missing specs. So, there's around 8 new methods here that have no tests.

/**
* Open a modal that allows to create a new version starting from the specified item, with optional summary
*/
onCreateNewVersion(): void {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This new method appears to be missing specs

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed (specs added)

/**
* Applies changes to version currently being edited
*/
onSummarySubmit() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New method is missing specs

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed (specs added)

* Delete the item and get the result of the operation
* @param item
*/
deleteItemAndGetResult$(item: Item): Observable<boolean> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New method is missing specs

* @param version the version to be deleted
* @param redirectToLatest force the redirect to the latest version in the history
*/
deleteVersion(version: Version, redirectToLatest: boolean): void {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New method is missing specs

* Creates a new version starting from the specified one
* @param version the version from which a new one will be created
*/
createNewVersion(version: Version) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New method is missing specs

@tdonohue
Copy link
Member

@davidenegretti-4science or @atarix83 : Please let me know when this is ready for re-review (in terms of spec updates). As a sidenote, this now has a minor merge conflict after I merged #1327

Copy link
Member

@tdonohue tdonohue left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@davidenegretti-4science : Thanks for adding more tests. It's now at a more reasonable 55% test coverage (which isn't 70% but it's better). So, I'm going to approve this and merge as we don't have time to wait for more tests. Please, in the future, do your best to add tests as you go & not wait until all code is completed to go back and add your tests/specs.

That all said, honestly, thank you immensely for your hard work on this new feature. I think the user experience is great & it all works well.

@davide-negretti
Copy link
Contributor Author

Thank you @tdonohue
I'm sorry I didn't manage to further increase test coverage in time, however I've been working on a couple of new tests today and I can commit them for a future release.

@abollini abollini deleted the CST-4499 branch October 26, 2021 07:22
4science-it pushed a commit to 4Science/dspace-angular that referenced this pull request Feb 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create a new item version as submitter Create new Item Version (basic Items only)
5 participants