-
-
Notifications
You must be signed in to change notification settings - Fork 288
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
Fix BB-768 : Unset Author Credit leads to bugs #1051
Conversation
src/client/entity-editor/author-credit-editor/author-credit-section.tsx
Outdated
Show resolved
Hide resolved
well..... I was just reviewing my own PR today and find out that my solution for this problem was so naive 😆 , so I had another look at this issue and fixed it in a better way in my upcoming commit |
so there was two cases when authorCreditEnable was being undefined whenever the page loads
the reason behind this in first case was that the rootstate had an empty edition section with no authorCreditEnable field to set the default state with and the reason behind the second case was we were not sending any default authorCreditEnable field in enditionGroupSection rootstate to set the default state from after fix for case1 : same the bug is fixed for edition-group edit routes |
@@ -79,7 +79,7 @@ EditionGroupAttributes.propTypes = { | |||
}; | |||
|
|||
|
|||
function EditionGroupDisplayPage({entity, identifierTypes, user, wikipediaExtract}) { | |||
function EditionGroupDisplayPage({entity, identifierTypes, user, wikipediaExtract}, authorCreditEnable) { |
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.
This parameter and its usage below are probably a leftover from your previous attempt to solve the issue. Modern React components have no second function parameter as far as I know.
Same goes for the EditionDisplayPage
component.
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.
YES ! you are correct, Kell. React components do not have a second function parameter. Thank you for pointing this out. This is indeed something I overlooked in my previous solution, where I attempted to prevent the warning about unset author credits from displaying on the edition and edition group pages. However, it's clear now that this approach won't work , i will fix this
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.
but now as I think that when we are creating a edition or an edition group we don't allow to submit the form until the author credit is filled or "No author credit" checkbox is checked
so we have two cases here while creating
-
when someone as set that there is no author credit
-
author credits are provided while creating
in both the cases after creating the edition or edition group , the main page should not show any warning then why do we even have the warning ???
maybe we should remove it completely
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.
we have two cases here while creating
You are right about this, but the warning is not there only for new entities.
We do want to show the warning for existing entites that are missing that information.
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.
Oh i see now
Thanks for looking into this issue again, I appreciate your efforts! |
Thanks again for working on this. In short, I think we do not currently have a a way to store in the database that an edition has been set as "no author credit". The web page works fine, but we don't have a has_author_credit boolean column in the edition_data table, which is required if we want the checkbox to actually do something and being able to hide the warning. Some modifications need to be done on the bookbrainz-site repo, and others on the bookbrainz-data-js repo (our ORM). |
Yesss, exactly! Currently, I was trying to do just that—saving a boolean variable in the database to indicate whether author credits are set or unset for an edition or edition group. I made some schema changes to the edition_data table and edition_group_data table yesterday. I would have completed it today, but I got a little busy. I'll surely figure out the next part; give me some time, and I'll be back with a fix. ✅✅ |
In my last commit, I added a credit_section boolean column to our edition_data and edition_group_data tables. I also added the same column to our views. The purpose is to set credit_section to false if author credits are disabled. This signifies that the entity does not require author credits, thus no warning will be shown. If credit_section for an entity is true, along with other pre-existing checks, it means that the author_credits section exists but with empty author credits, and a warning will be displayed. The next step is to use the credit_section state in the frontend. Until then, any suggestions for improvement or a better approach to solving this aspect of the issue ?. 😊 |
…ontend to set or unset warning on entity page and enable or disable credit state whenever edit page loads
My apologies for finalizing this PR later than expected. I was occupied with my college responsibilities. With this commit, consider this issue resolved. In my latest commit, I utilized the saved state of author credits in both the edition and edition_group in the frontend to determine whether to display the "Unset author credit warning." Additionally, the "Author credit enable" checkbox in the edit page is no longer set to true by default; instead, it utilizes the previously saved state of the credit section to determine whether it should be checked or unchecked. this commit fix BB-768 as well as fix BB-767 . The only remaining task is to address the failing test and make changes in bookbrainz-data-js . |
…unified form and added the edition_data.credit_section state in bb.edition_import view
i was having a look at it again and after all this time i noticed that in |
I had some issues with the automated deployment, sorry about that ! |
ohh ok i just updated it locally but for some reason in package.json it still shows 5.0.0 |
It just wasn't published until a minute ago 😅 Now version 5.1.1 should be installed |
oh ok ok 👍 i will wait some more before updating |
The poackage is already updated, I pushed a commit for it. However tests are still failing, but looks unrelated to the changes in your PR. Let me look into it |
Oh, I didn't notice that you updated the package. Thanks!!! sorry i forgot to remove some comments 🫢 thanks for removing them too ! |
Hello! I updated the PR and got rid of all the unrelated issues, phew! Creating an Edition without an AC works absolutely fine, and when on the edition display page the "no AC set" warning is not shown, so that's working 💯 ! See https://test.bookbrainz.org/revision/30808 However if I then edit the edition to add an AC, it looks like the AC is not saved to the database, and the "no AC set" warning is shown, which suggests the tickbox state ("this edition doesn't have an AC") is saved correctly, but not the AC itself. Want to investigate what is happening in the noodly code of entity saving? 🤣 |
Actually, the problem is that from the very beginning, my Elasticsearch was not working, and I left it as it was. I was still able to work on most things, except for some tasks like setting new author credits or relationships. Therefore, I won't be able to test it locally before fixing my Elasticsearch. However, I will still take a look at it, and maybe I can find the cause. I may trouble you for testing purposes later. 😊 |
finally my elastic search problem is fixed and i can work on the new issue we have here let me know if you want me to start a fresh pr this one has become little MESSY. |
Glad you got your local setup working :) |
processAuthorCredit was using the old entity to determine if it should save an author credit, which meant that an edition without AC was never allowed to have an AC. Also refactored processEditionSets to await promises directly instead of using makePromiseFromObject
I found the culprit! |
The date was copied from another folder but not changed
THANKS!!!! You just saved my weekend. I was going to look at it tomorrow, and this may have taken me hours to figure out the problem. Thanks again! 🙌 😇 I also noticed that you replaced some promises with async/await syntax. It looks great!✨ But here’s a twist, I had already made those changes in the old PR for BB-672 #1058. Déjà vu, developer style! 😂 Look, they are almost similar |
Ahhaaa yes, I thought it seemed familiar! I took the liberty to quickly fix the revision diff which was showing nothing for deleted ACs. EDIT: I see the issue! I had started a review god knows when, but never clicked the submit button and it is still pending... |
P.S.: I'm rebuilding the image and deploying it to test.bookbrainz if you want to do some manual testing to check everything. |
sure ! I will check
no problem , I will just merge the conflicting changes there once this PR is done |
Looks good to me 👍 |
OK, PR is ready to merge as far as I can tell ! |
Problem
BB-768
refer to this discussion for more details
Solution
In
edition.js
andedition-group.js
I added a check before displaying a warning of unset credit . this will not show any warning on created edition or edition-group page, if we click the checkbox while creating the edition or edition groupThe checkbox was not getting checked and was needed to be clicked two times before disabling the edition credit , the reason was the redux initial state of
authorCreditEnable
was undefined rather than being true .Areas of Impact