-
Notifications
You must be signed in to change notification settings - Fork 286
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
Remove legacy code from error stores. #5858
Comments
Have created and added AC, please review. cc @aaemnnosttv |
Thanks @techanvil – I think the simpler change would be to keep |
Hey @aaemnnosttv, I must confess I don't see much benefit in keeping Seeing as we now have the Incidentally looking through the existing usage of Does the above change the calculus for you at all or do you still think we'd be better off keeping |
@techanvil I'm not strongly against removing it, but if we decide that it isn't worth keeping in place of using site-kit-wp/assets/js/googlesitekit/data/create-error-store.js Lines 275 to 278 in 2a24f57
The separation of separate selectors for actions and selectors didn't turn out to be really necessary I suppose but this may have been done before we had more well-established conventions for their respective naming. How about we revise the definition to address these other related bits? |
@aaemnnosttv thanks for your reply. Actually, I have to say, your explanation has made me reconsider things a bit. I think I was being a bit blinkered and focusing overly on the Maybe we should update this issue to be about removing |
Yes I think that was part of the original intention as well. If we feel it's still useful, then let's keep it :)
Sounds good to me 👍 As for changing the way things are stored perhaps we should open a new issue for that to think through it thoroughly. Thanks! |
@techanvil Checking in here, thanks! |
Thanks @bethanylang, I've not forgotten about this, just had a number of things on my plate and have been trying to balance those with the ongoing sprint requirements as usual. I should be getting round to this one soon. |
getErrorForSelector
selector.
Hey @aaemnnosttv, I've updated this issue accordingly, and also created #6568 to consider the additional changes, which I've left in Triage. |
ACs here are good; the last few points are more like an IB so I noted they're likely implementation details, but moved to IB 👍🏻 |
Hey @tofumatt, I appreciate those points are quite specific in terms of code but they are part of what we are explicitly trying to achieve in this issue (see the second and last paragraphs of the Feature Description). I've updated the AC to hopefully make it a bit clearer, please take another look. |
@techanvil Works for me! 👍🏻 I'll move this back to IB now 🙂 |
I've updated the IB a bit and added an estimate, but this can be moved to the backlog now. IB ✅ |
Unassigned myself as I'm going on holidays, I've pushed all my progress here. |
QA Update: ✅Verified:
Added |
QA Eng Verified ✅
Nothing stood out |
Feature Description
In order to help tidy up the codebase and make the error store code easier to follow, we should remove the legacy usage of the single
error
object with no associatedbaseName
andargs
.Additionally, we should remove the code that adds the
selectorData
property ingetErrorForSelector()
, as this has been identified as prone to error; it expects the error to be spreadable, but in fact, it's possible for it to be anError
instance which cannot be spread into a new object without losing information.As we now have
getSelectorDataForError()
,getErrorForSelector()
should be made analogous togetErrorForAction()
as a simple wrapper togetError()
that provides a bit of additional semantic value.Any usage of
selectorData
retrieved viagetErrorForSelector()
should be replaced withgetSelectorDataForError()
.Do not alter or remove anything below. The following sections will be managed by moderators only.
Acceptance criteria
error
object with no associatedbaseName
and args:error
object should be removed from Redux state.receiveError()
withoutbaseName
andargs
should be removed (there is only one case of this at the time of writing, but it's increateFetchStore()
, so it's being called in a lot of places).baseName
parameter should be mandatory forreceiveError()
,getError()
, andclearError()
, while args can default to an empty array.createFetchStore()
do not have any impact on current error handling.getErrorForSelector()
to remove the addition ofselectorData
, and return the error as-is.selectorData
retrieved viagetErrorForSelector()
withgetSelectorDataForError()
.Implementation Brief
/assets/js/googlesitekit/data/create-error-store.js
locatereceiveError
,clearError
,getError
functions and make the following changes:baseName
parameter to be mandatory forreceiveError
,getError
, andclearError
by usinginvariant
.baseName
args
parameter to be[]
by default forreceiveError
andclearError
getErrorForSelector
to return onlyerror
directly. It should not return an object withselectorData
, and not to spread the error variable.const { selectorData } = getErrorForSelector( …args )
toconst selectorData = getSelectorDataForError( …args )
.Test Coverage
QA Brief
Retry
Button.Changelog entry
The text was updated successfully, but these errors were encountered: