Skip to content

Commit

Permalink
feat(optional-policies): add a separate alert message for optional po…
Browse files Browse the repository at this point in the history
…licy updates
  • Loading branch information
rafaucau committed Dec 5, 2024
1 parent d6304b2 commit b39bcb3
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 7 deletions.
4 changes: 3 additions & 1 deletion js/src/forum/components/AcceptPoliciesModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ export default class AcceptPoliciesModal extends Modal {
super.oninit(vnode);

app.store.all('fof-terms-policies').forEach((policy) => {
this[policy.form_key()] = false;
const state = app.session.user.fofTermsPoliciesState()[policy.id()];
// For optional policies, maintain current acceptance status
this[policy.form_key()] = policy.optional() ? state?.is_accepted || false : false;
});
}

Expand Down
21 changes: 15 additions & 6 deletions js/src/forum/components/UpdateAlert.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,20 @@ export default class UpdateAlert {
return false;
}

const user = app.session.user;
const { user } = app.session;

return user && user.fofTermsPoliciesHasUpdate();
}

hasOnlyOptionalUpdates() {
const { user } = app.session;
return user && !user.fofTermsPoliciesMustAccept() && user.fofTermsPoliciesHasUpdate();
}

view() {
if (!this.shouldShowAlert() || !app.session.user) {
const { user } = app.session;

if (!this.shouldShowAlert() || !user) {
return null;
}

Expand All @@ -37,7 +44,7 @@ export default class UpdateAlert {

const dismissControl = [];

if (!app.session.user.fofTermsPoliciesMustAccept()) {
if (!user.fofTermsPoliciesMustAccept()) {
dismissControl.push(
<Button
icon="fas fa-times"
Expand All @@ -54,9 +61,11 @@ export default class UpdateAlert {
<div className="Alert Alert-info">
<div className="container">
<span className="Alert-body">
{app.session.user.fofTermsPoliciesMustAccept()
? app.translator.trans('fof-terms.forum.update-alert.must-accept-message')
: app.translator.trans('fof-terms.forum.update-alert.can-accept-message')}
{this.hasOnlyOptionalUpdates()
? app.translator.trans('fof-terms.forum.update-alert.can-accept-optional-message')
: user.fofTermsPoliciesMustAccept()
? app.translator.trans('fof-terms.forum.update-alert.must-accept-message')
: app.translator.trans('fof-terms.forum.update-alert.can-accept-message')}
</span>
<ul className="Alert-controls">{listItems(controls.concat(dismissControl))}</ul>
</div>
Expand Down
1 change: 1 addition & 0 deletions resources/locale/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ fof-terms:
update-alert:
must-accept-message: We've temporarily restricted access to your account while you check out the new terms.
can-accept-message: We recently updated the terms. You must accept them to continue using this website.
can-accept-optional-message: We recently updated the terms. You can review them at your convenience.
review: Click here to review and accept the new terms
close: Close

Expand Down

0 comments on commit b39bcb3

Please sign in to comment.