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

Allow to download NMLs of older versions for read-only tracings #3660

Merged
merged 10 commits into from
Jan 23, 2019

Conversation

daniel-wer
Copy link
Member

@daniel-wer daniel-wer commented Jan 22, 2019

Allow to display the version restore view for read-only tracings. Offer to download an NML of older versions.

@philippotto I also renamed the APITracingType and related types/variables to APIAnnotationType etc in this PR. For review I would suggest to exclude this commit to get a better sense of the actual changes :)

URL of deployed dev instance (used for testing):

Steps to test:

  • Create a tracing with multiple versions and share it publicly. Copy the link. Login as another user and open the tracing. The tracing should be read-only.
    Preview an older version, the button should say "Download" instead of "Restore" and should download an NML of the previewed older version.
  • Closing the version restore view should NOT make the read-only tracing modifiable.
  • Opening/Closing the version view for modifiable tracings should work as before. Restoring should work as well.

Issues:


@philippotto
Copy link
Member

🎉

Didn't look at the code, yet, but tested already. It seems to work, but I had some hiccups (because I probably didn't use it as intended).

  1. I shared the tracing publicly (+ dataset) and tried to download the NML while not being logged in. The UI worked, but after clicking download I got a "Authorization failed" (or similar) message. Not sure, whether we should simply allow this (I guess, this makes the most sense) or at least show a nicer message (disable the download button when not being logged in?).
  2. After creating another test user, I could download the NML, but the re-upload failed ("Couldn't find resource"). I guess this has nothing to do with this PR, but is a more general thing. @fm3 The upload didn't work, because my user wasn't assigned the "allowed teams" (in fact, the dataset didn't have "allowed teams"). However, if I set a dataset to public, I'd expect that the "allowed teams" requirement is ignored. Do you agree?

Otherwise, the testing worked well 👍 I noticed that the re-upload of the NML swalled empty trees, but I guess, we designed this on purpose at some point.

Copy link
Member

@philippotto philippotto left a comment

Choose a reason for hiding this comment

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

Nice! Code looks good to me :)

}/download`;
win.location.href = downloadUrl;
win.document.body.innerHTML = messages["download.close_window"];
downloadNml(this.props.annotationId, this.props.tracingType);
Copy link
Member

Choose a reason for hiding this comment

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

❤️

setCurrentLayout: string => void,
saveCurrentLayout: () => void,
},
layoutProps: LayoutProps,
Copy link
Member

Choose a reason for hiding this comment

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

Thank you for cleaning this up 🙈

};

componentDidMount() {
// Remember whether the tracing could originally be updated
this.setState({ originalAllowUpdate: this.props.allowUpdate });
Copy link
Member

Choose a reason for hiding this comment

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

Why does this prop need to be written into state? If I'm not missing anything, the state is never changed? Couldn't we access the prop directly where needed? If we need to keep it, I'd rename it to "initialAllowUpdate" btw, since this is more idiomatic afaik :)

Copy link
Member Author

Choose a reason for hiding this comment

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

The problem is that we change the allowUpdate value while the version restore view is open and therefore the prop changes as well. We need the value allowUpdate has when the component is mounted. I'll rename it to initialAllowUpdate.

Copy link
Member

Choose a reason for hiding this comment

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

Hm, ok, but where is allowUpdate set to true? I only see the calls to setAnnotationAllowUpdateAction, where the initial value is passed (which would be false in the case we are talking about).

Copy link
Member Author

Choose a reason for hiding this comment

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

Not sure whether we're talking about the same thing :D
If we're in a read-only tracing, allowUpdate is false when opening the version view, therefore, initialAllowUpdate is false as well and when closing the view setAnnotationAllowUpdateAction will set allowUpdate to initialAllowUpdate which is false - unnecessary in that case, but ok.
If we're in a normal tracing, ' allowUpdate' is true when opening the version view, initialAllowUpdate as well. We'll then set allowUpdate to false, because we don't want the tracing to be modified while the version is open. When closing the view or restoring an older version setAnnotationAllowUpdateAction will set allowUpdate to initialAllowUpdate which is true, so the user can modify the tracing again.
Hope that clears things up :)

Copy link
Member

Choose a reason for hiding this comment

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

Ahh, ok, sorry, you had to type this out 🙈

@fm3
Copy link
Member

fm3 commented Jan 23, 2019

@philippotto I’ll create separate issues for the permission problems you described. Should be independent of this PR

@daniel-wer
Copy link
Member Author

daniel-wer commented Jan 23, 2019

@philippotto Would you agree to merge this? I'd say the error messages, although they are not the nicest, are ok for now until the permission issues are fixed - the functionality will probably be mostly used by us (or logged in users) for now.

@philippotto
Copy link
Member

@philippotto Would you agree to merge this? I'd say the error messages, although they are not the nicest, are ok for now - the functionality will probably be mostly used by us (or logged in users) for now.

Sure, go ahead 👍

@daniel-wer daniel-wer merged commit 0bd7c7b into master Jan 23, 2019
@daniel-wer daniel-wer deleted the read-only-version-download branch January 23, 2019 15:17
daniel-wer added a commit that referenced this pull request Jan 29, 2019
* allow version restore view in read-only tracings, offer to download NML of older versions

* use correct version parameters for nml download

* annotation download: pass on version parameters to tracingstore

* scalafmt

* rename tracingType and APITracingType to annotationType where appropriate

* update changelog

* apply PR feedback
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.

Show version list in read-only mode aswell
3 participants