-
Notifications
You must be signed in to change notification settings - Fork 41
Show registration modal only when unregistered #1600
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
Open
gregorydlogan
wants to merge
7
commits into
opencast:r/19.x
Choose a base branch
from
gregorydlogan:t/registration-modal
base: r/19.x
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
48ae5a7
In theory this only opens the registration modal in the right circums…
gregorydlogan c12f608
Revert me for further work
gregorydlogan 45f695b
Removing summary, since it's not needed here
gregorydlogan 92f70b3
Switching to useEffect, suggested in the review
gregorydlogan 094d207
Removing these since this part of the service does not care about this.
gregorydlogan 6895fad
As simplified as possible?
gregorydlogan 75e3a11
Removing commented code
gregorydlogan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| import { RootState } from "../store"; | ||
|
|
||
| /** | ||
| * This file contains selectors regarding information about the registration status | ||
| */ | ||
| // Are we registered at all | ||
| export const getRegistration = (state: RootState) => state.registration.registration; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| import { PayloadAction, createSlice } from "@reduxjs/toolkit"; | ||
| import axios from "axios"; | ||
| import { createAppAsyncThunk } from "../createAsyncThunkWithTypes"; | ||
|
|
||
| export type Registration = { | ||
| agreedToPolicy: boolean, | ||
| registered: boolean, | ||
| termsVersionAgreed: string, | ||
| } | ||
|
|
||
| export type RegistrationState = { | ||
| registration: boolean | null, | ||
| error: boolean | ||
| }; | ||
|
|
||
| // Initial state of health status in redux store | ||
| const initialState: RegistrationState = { | ||
| registration: null, | ||
| error: false, | ||
| }; | ||
|
|
||
| // This is the registration itself | ||
| export const fetchRegistration = createAppAsyncThunk("registration/fetchRegistration", async () => { | ||
| const res = await axios.get<Registration>("/admin-ng/adopter/registration"); | ||
| return res.data; | ||
| }); | ||
|
|
||
| const registrationSlice = createSlice({ | ||
| name: "registration", | ||
| initialState, | ||
| reducers: { | ||
| setError(state, action: PayloadAction<{ | ||
| error: RegistrationState["error"], | ||
| }>) { | ||
| state.error = action.payload.error; | ||
| }, | ||
| }, | ||
| // These are used for thunks | ||
| extraReducers: builder => { | ||
| builder | ||
| .addCase(fetchRegistration.fulfilled, (state, _action: PayloadAction< | ||
| Registration | ||
| >) => { | ||
| state.registration = true; | ||
| }); | ||
| }, | ||
| }); | ||
|
|
||
| export const { setError } = registrationSlice.actions; | ||
|
|
||
| // Export the slice reducer as the default export | ||
| export default registrationSlice.reducer; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Since all this PR really does is checking if ´/admin-ng/adopter/registration` returns null or not, creating a whole redux state is complete overkill. If you'll need this for some other PR, would it not be better to add it then?
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.
Fair. The goal here is to be able to set warnings in the notification bell in a few cases. I'll rework this and come back when it's ready.
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.
Is this more what you're looking for @Arnei? Or are you wanting me to completely remove the slice and selectors? There's an
adopterRegistrationUtilsfile which powers the modal and works, but I just can't seem to get the relevant function(s) to work from the header...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 was thinking of completely removing the slice and selectors and stuff, and do something like in About.tsx, aka just do the state thing locally in the component.
If you plan to make use of redux state in a later PR, it might make sense to use redux right now already, so you don't have to do work twice. But as a reviewer, I can't know that :D