-
Notifications
You must be signed in to change notification settings - Fork 22
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 terms of use dialog for user #825
base: main
Are you sure you want to change the base?
Optional terms of use dialog for user #825
Conversation
Use Run test server using develop.opencast.org as backend:
Specify a different backend like stable.opencast.org:
It may take a few seconds for the interface to spin up. |
This pull request is deployed at test.admin-interface.opencast.org/825/2024-08-16_09-06-19/ . |
Backend PR: opencast/opencast#6010 |
@schuettloeffel-elsa, thanks for this PR. Linking terms of use makes sense. However, I'm wondering, since we now have a couple of links in the footer, if it would be better to have a generic way of putting links there. Something like a configuration map containing the link name and URL. Opinions? |
I dont really get what you mean, this PR doesnt provide any links in the footer, it just displays the terms if a user hasnt already accepted them. Or am I missing something here? |
Oh, my bad! I somehow assumed that this would add a "Terms of Use" link in the footer of the Admin UI similar to #306. |
No worries :) |
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 didn't do a full review. This is more just a few comments.
const isAgreed = response.data.results.some(result => result.key === "agreedToTerms" && result.value === "true"); | ||
setAgreedToTerms(isAgreed); | ||
} catch (error) { | ||
console.error("Fehler beim Abrufen der Daten:", error); |
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 assume this is a leftover from debugging?
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.
Do you mean the console.error? Not really, but I can translate it to english if that helps
return `ui/config/admin-ui/terms.${language}.html`; | ||
}; | ||
|
||
axios.get(getURL(i18n.language)) |
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.
More out of curiosity, why include axios as an external library and not just use The Fetch API?
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.
Dont know to be honest :D
<div> | ||
<div className="row"> | ||
<div className="scrollbox"> | ||
<div dangerouslySetInnerHTML={{ __html: DOMPurify.sanitize(termsContent) }} ></div> |
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.
Would it make sense to expect and render something like Markdown instead of giving users the freedom to use HTML but then modify it anyway to avoid possible threads?
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.
Well you can still use normal html tags that would make sense in that case, DOMPurify.sanitize doenst remove usual html tags used for styling etc. Makes sense so me since terms of use will need some styling to maintain a good readability
One more request I forgot and which also applies to opencast/opencast#6010
|
Sure! From other projects I know the workflow to just link to the issue (like I die here) and always retrieve the informations there, just to prevent doubled informations in the issue and PR. But if it helps I will give some informations in the PR as well in the future :)
Haha, will do, thanks for editing |
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.
Apart from the inline comments:
- We should really try to not add any more
ts-expect-error
andeslint-disable
comments.
It would be nice if you could include a screenshot, as well.
@@ -284,6 +286,9 @@ const Header = ({ | |||
<RegistrationModal close={hideRegistrationModal} /> | |||
)} | |||
|
|||
{/* Terms of use */} | |||
{displayTerms && <TermsOfUseModal />} |
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 kind of wonder what happens when both, the adopter registration modal and the terms modal are to be shown, and whether or not we are okay with that outcome ... 🤔
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.
That should never happen, since you cant press any button (like the adopters registration) when the terms are displayed. Or is there some other way the registration is forced to the user besides of pressing the button?
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.
Wait what button are you talking about? AFAIK no user interaction is necessary for the adopter registration prompt to pop up the first time you use the admin UI.
However, we discussed this in the technical meeting and came to the agreement that this is probably fine since that should only happen for actual system admins (ROLE_ADMIN
and org-admins). Those on the other hand probably don't need to see the terms since they are the ones setting up the system!
So the suggestion was to just add a condition here to only show the terms to non-admins.
} | ||
}; | ||
|
||
checkTerms(); |
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.
Why even make this a function only to then call it immediately. Just lift the body of checkTerms
into the useEffect
body.
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.
The function needs to be async, see: https://devtrium.com/posts/async-functions-useeffect
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.
You can just make the useEffect
-callback async
, no?
const getURL = (language: string) => { | ||
return `ui/config/admin-ui/terms.${language}.html`; | ||
}; |
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.
Could you make this a top level function? That way it is not recreated on every render.
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.
done
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.
No I mean really top-level, as in module-level, outside of the 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.
setTermsContent(response.data); | ||
}) | ||
.catch(error => { | ||
axios.get(getURL(typeof i18n.options.fallbackLng === 'string' ? i18n.options.fallbackLng : 'en-US')) |
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.
In #306 you defaulted to en-GB
. Any reason for this inconsistency? 🤔
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 lang-en_US.json
seems to be the main language file i thought it would be better to default to en-US
- in #306 i wasnt aware of that, so maybe better change it there to en-US
too?
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.
That sounds reasonable to me. 🤔
Done. |
closes #296
When using the admin frontend for more than a few admins (e.g. lecturers that upload videos directly from the admin ui), there has to be a way to supply a terms of use form on first login. The displayed text should off course be configurable and the user would have to accept the terms to continue.