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

optional-doi: fix new upload disabled states #1932

Merged

Conversation

zzacharo
Copy link
Member

On new upload, unreserving a local DOI was not re-enabling all options. This PR refactors the relevant code to fix that.

@zzacharo zzacharo force-pushed the fix-doi-disabled-new-upload branch 2 times, most recently from 1a2e600 to 7cdcedd Compare January 22, 2025 10:03
} = this.props;

const doi = record?.pids?.doi?.identifier || "";
const isNewUpload = record.status === "draft";
Copy link
Contributor

@jrcastro2 jrcastro2 Jan 22, 2025

Choose a reason for hiding this comment

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

Minor: We could user this to avoid hardcoding the state.

Also is isNewUpload a correct name? just find it a bit confusing 😅 Does this mean that after the first version is published if we create a new version it doesn't has the draft status?

EDIT: It actually seems that new versions do have new_version_draft, in that case I guess it's fine 👍

Copy link
Member Author

Choose a reason for hiding this comment

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

no actually it has status=='new_version_draft'. Thanks for the suggestion, I will integrate it now!

@zzacharo zzacharo force-pushed the fix-doi-disabled-new-upload branch from 7cdcedd to 64bbb95 Compare January 22, 2025 13:16
} = this.props;

const doi = record?.pids?.doi?.identifier || "";
const alreadyPublished = [
Copy link
Member Author

Choose a reason for hiding this comment

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

@jrcastro2 I changes to this. Better?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, thanks! more readable IMO 🚀

DepositStatus.NEW_VERSION_DRAFT,
].includes(record.status);

const hasDoi = doi !== "";
Copy link
Contributor

Choose a reason for hiding this comment

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

minor: wouldn't isEmpty be safer?

Copy link
Member Author

Choose a reason for hiding this comment

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

why safer? I agree it would be more elegant but I think also if we were to replace it would need more testing as the isEmpty would catch all falsy values...If you think is major, I could have a look!

record,
} = this.props;

const doi = record?.pids?.doi?.identifier || "";
Copy link
Contributor

Choose a reason for hiding this comment

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

minor: see my comment below(can be replacing empty string) why the empty string is needed in the first place?

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 empty string is the initial state when the form is rendered. This was carried over from the existing implementation and I didn't refactor it. If you don't think it is a major blocker I would avoid refactoring more now...

@jrcastro2 jrcastro2 merged commit 9a3e37c into inveniosoftware:master Jan 23, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: To release 🤖
Development

Successfully merging this pull request may close these issues.

3 participants