-
Notifications
You must be signed in to change notification settings - Fork 23
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
Modernize redux #214
Modernize redux #214
Conversation
The first step to modernizing redux. Replacing `createStore` with `configureStore` from the toolkit.
Does not really do anything yet, but will be useful later.
Add some basic typescript to aclSlice.ts. Avoids the difficult types, this is more about groundwork.
Instead of roundabout `connect`, `mapStateToProps` and `mapDispatchToProps`, we now use the `useSelector` and `useDispatch` hooks from redux toolkit. Rewriting them as `useAppSelector` and `useAppDispatch` will hopefully help with implicit typing when we get to modernizing thunks.
Marking this as ready for review. There's still a large part this PR is not touching on, namely the whole request and response stuff, but migrating that to RTK query is proving a bit difficult, so not sure when I'll get around to that. |
Moves fetching code from aclThunks.ts to aclSlice.ts. Also uses createAsyncThunk, which tracks the state of the fetch request for us. I'd rather have migrated to RTK Query instead of using createAsyncThunk, but that is nearly impossible to do incrementally, making it a rather large ask. Therefore, let's go with createAsyncThunk for now where we can, which also helps streamlining the code and will hopefully make a future migration to RTK Query easier. (Also RTK Query is still kinda new).
In the old admin ui, the status of workflow operations in the event details was updated in real-time, allowing you to "watch" your workflow running. This updates our admin ui to do the same by re-fetching workflow operations every 5 seconds. Unfortunately, this is causing rerenders even if the response from the Opencast backend has not changed between calls. We could probably memoize this somehow, but I can't find a straightforward way, at least not one that is more straightfoward than switching to redux toolkit (like in opencast#214).
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.
Mostly indentation/semicolon stuff, which should be easier to handle once "proper" linting gets introduced. So technically doesn't need to be adjusted in this PR.
I should mention however that I couldn't test this properly because of the error that I described to you in our meeting. I'm not sure what's happening there but since you can't reproduce, this should be fine to merge.
Co-authored-by: Ole Wieners <94838646+owi92@users.noreply.github.com>
Co-authored-by: Ole Wieners <94838646+owi92@users.noreply.github.com>
Co-authored-by: Ole Wieners <94838646+owi92@users.noreply.github.com>
Co-authored-by: Ole Wieners <94838646+owi92@users.noreply.github.com>
Co-authored-by: Ole Wieners <94838646+owi92@users.noreply.github.com>
Co-authored-by: Ole Wieners <94838646+owi92@users.noreply.github.com>
Co-authored-by: Ole Wieners <94838646+owi92@users.noreply.github.com>
Co-authored-by: Ole Wieners <94838646+owi92@users.noreply.github.com>
Co-authored-by: Ole Wieners <94838646+owi92@users.noreply.github.com>
Co-authored-by: Ole Wieners <94838646+owi92@users.noreply.github.com>
Co-authored-by: Ole Wieners <94838646+owi92@users.noreply.github.com>
Co-authored-by: Ole Wieners <94838646+owi92@users.noreply.github.com>
Co-authored-by: Ole Wieners <94838646+owi92@users.noreply.github.com>
Co-authored-by: Ole Wieners <94838646+owi92@users.noreply.github.com>
Co-authored-by: Ole Wieners <94838646+owi92@users.noreply.github.com>
Co-authored-by: Ole Wieners <94838646+owi92@users.noreply.github.com>
Co-authored-by: Ole Wieners <94838646+owi92@users.noreply.github.com>
Co-authored-by: Ole Wieners <94838646+owi92@users.noreply.github.com>
Co-authored-by: Ole Wieners <94838646+owi92@users.noreply.github.com>
Co-authored-by: Ole Wieners <94838646+owi92@users.noreply.github.com>
Co-authored-by: Ole Wieners <94838646+owi92@users.noreply.github.com>
Thanks for the extensive linting. Any opinion on using redux toolkit and the way I went about it? Also we should look into the error you got in more detail. |
Uhm not really since I haven't done anything with redux before. Which makes this a little hard to evaluate for me. Being a human linter is really all I can do for you here, for now. Maybe you'll want or need another reviewer for this after all.
Should I open an issue with a detailed report? I'm still wondering if this might be caused by something on my end, since you couldn't reproduce it. |
Sooo, after your introduction to redux and reading parts of the manual (which, let's be honest, I totally should have done in the first place instead of merely doing the more or less useless linting), I can say with a little more confidence that I think these changes are a nice first step in introducing the RTK. Anything done here makes sense to me, including sticking with If you're comfortable with only having my reviews and approval for this, I'd say this can be merged. Though I would recommend that #212 gets merged prior to this (or at least very soon) to ease future development (and potential testing/reviews). |
Going ahead and merging this, so work on this can continue. Had expected this to be more controversial, but maybe it just isn't. |
Resolves #213.
This PR aims at laying the groundwork for modernizing redux. Thankfully, the modernization can happen incrementally, so this PR does not need to and likely will not update everything at once. It will however try to touch all the relevant parts so it can serve as a guideline for future PRs that seek to continue with the modernization.
As such, discussions on code styles and best practices are very welcome.