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
Re-add setting sourceUrl to null in uploaded images #20795
Conversation
Note: I'm working on a PR with a small UI test suite to check for breaking changes to gamelab animations. Will probably end up merging that to staging before this one. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change looks good as-is. I've got cleanup suggestions that could be in this PR or a followup.
// TODO (bbuchanan): This sequencing feels backwards. Eventually, we | ||
// ought to preview and get dimensions from the local filesystem, async | ||
// with the upload itself, but that will mean refactoring away from the | ||
// jQuery uploader. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tore out this comment in #20713 - let's not reintroduce it.
|
||
var onMetadataLoaded = animationPickerModule.buildOnImageMetadataLoaded( | ||
"filename.jpg", Goal.NEW_ANIMATION, "filename.jpg", | ||
{filename: "filename.jpg", result: 0, versionId: "string"}, store.dispatch); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style nit: It may seem verbose, but when we have to wrap arguments like this we often just place one argument per line.
var onMetadataLoaded = animationPickerModule.buildOnMetadataLoaded(
"filename.jpg",
Goal.NEW_ANIMATION,
"filename.jpg",
{
filename: "filename.jpg",
result: 0,
versionId: "string"
},
store.dispatch
);
} | ||
dispatch(hide()); | ||
}, () => { | ||
const onImageMetadataLoaded = buildOnImageMetadataLoaded(uploadFilename, goal, key, result, dispatch); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewing now, I'm questioning our choice of arguments to this method:
key
is derived fromresult
and its only use is to be passed into this method, which also receivesresult
. Maybe we should computekey
within thebuildOnImageMetadataLoaded
function.- Likewise,
uploadFilename
andgoal
aren't actually needed in this method and they should still be in the state when theonImageMetadataLoaded
callback fires.
It's possible want we really want here is to call
buildOnImageMetadataLoaded(dispatch, getState, result);
which echoes the signature and redux-thunk return value of handleUploadComplete
, and then derive the other values in our helper. In fact, that might make it easier to test that we derive those values correctly.
It does mean you'd need to make sure the animationPicker
module's redux state is set up correctly in your unit test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moving the look-up of goal and uploadFilename makes a lot of sense for organization and I believe the test already supports this state-wise, so that'll be quick and easy to change.
For 'key', since it's used to look-up the sourceUrl in handleUploadComplete, I think it makes more sense to still compute it there and pass it into buildOnImageMetadataLoaded. Thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 My bad, missed the transitive dependency there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM after addressing Brad's comments.
…-org/code-dot-org into gl-anim-loss-upload-url
After, this PR and its revert, adding back making uploaded images have null sourceUrls. Including additional unit test. Not including the version re-routing which caused the error initially. We are still not able to handle situations where uploaded images have a non-null sourceUrl and a version, but we will no longer create images with that state.