Penalty history improvements (PR #13359)

Two features here:

1: Add a history count when applying penalties to give moderators context to the user they are penalizing.

2: Add a site setting that designates default penalty values in hours.

Silence/suspend modals will auto-fill in the default values, but otherwise will still allow moderators to pick and overwrite values as normal.

First silence/suspend: first value Second silence/suspend: second value etc.

Penalty counts are forgiven at the same rate as tl3 promotion requirements do.

GitHub

could you explain the purpose of this and why it’s done this way please?

We can’t keep it that way, but I want to better understand before I advise

same

I have a situation where I need an initial value from the user object (the user’s next penalty) even though the value isn’t loaded when the component is rendered. The user might need to load after the modal shows (discourse/admin-tools.js at 0542e9cb19bc4c2bc2a39d56011e03c1742f3f95 · featheredtoast/discourse · GitHub).

I cannot make silenceUntil/suspendUntil itself a computed property here because I need to allow the future-date-picker the ability to call mut on the value, uninhibited.

I need to update silenceUntil/suspendUntil’s initial value when the user loads in to the modal, but I am unable to within the same runloop as the init (Ember complains that we’re recomputing the value too many times). Putting it in a later() allows me to update the initial value quickly enough.

I could load the user first, and then display the modal with the initial values, but if the user needs to load and takes a long time, no loading indicator would be shown so I decided to go down this route.

I need the following events to fire:

  • Modal window shows, value is potentially blank as user loads
  • User loads in. Fires an event to the controller that sets the initial value of silenceUntil/suspendUntil from user object. This should also update the future-date-picker’s selection to custom, with the specified date/time along with the underlying input value for said date. Without the later() call it does update the UI, but not the underlying js value as a mut call was never triggered from the future-date-picker.

@jjaffeux let me know if the above makes sense to you!

A commit that appears in this pull request is being discussed here.

A commit that appears in this pull request is being discussed here.

A commit that appears in this pull request is being discussed here.

A commit that appears in this pull request is being discussed here.

A commit that appears in this pull request is being discussed here.

A commit that appears in this pull request is being discussed here.

A commit that appears in this pull request is being discussed here.

A commit that appears in this pull request is being discussed here.

A commit that appears in this pull request is being discussed here.

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
18 out of 19 committers have signed the CLA.

:white_check_mark: tgxworld
:white_check_mark: jjaffeux
:white_check_mark: eviltrout
:white_check_mark: markvanlan
:white_check_mark: nbianca
:white_check_mark: lis2
:white_check_mark: pmusaraj
:white_check_mark: ZogStriP
:white_check_mark: udan11
:white_check_mark: romanrizzi
:white_check_mark: techAPJ
:white_check_mark: xfalcox
:white_check_mark: CvX
:white_check_mark: AndrewPrigorshnev
:white_check_mark: eltociear
:white_check_mark: featheredtoast
:white_check_mark: jbrw
:white_check_mark: martin-brennan
:x: dependabot[bot]
You have signed the CLA already but the status is still pending? Let us recheck it.

Updated UI suggestions, added UI indicators if user has previous suspensions:

Added @jjaffeux 's suggestions for removing the defer functions. I needed to re-implement the initial input setup in init() rather than on didReceiveAttrs, but other than that it worked flawlessly (Thank you!)

Added @jjaffeux 's suggestions for golfing user.next_penalty functions

rebased and cleaned up history so it reads cleanly and it doesn’t include every commit under the sun according to discoursebot