feat: add announcement banner - #2967
Conversation
9529b9f to
1a80512
Compare
1a80512 to
dc339d8
Compare
The rich text editor renders a role="textbox" element, which axe flags when it has no accessible name (aria-input-field-name). That broke the a11y e2e check on the admin settings general page. Add an optional ariaLabel to useTextEditor and set it on the announcement info editor and the info dialog.
Map the write endpoint's status codes to a helpful message: a 413 (body over the size cap) tells the admin to shorten the info text, a 403 that they lack the permission, everything else keeps the generic message.
Gate the admin settings announcement section on a new Announcement CASL ability (mapped from the Announcement.ReadWrite permission), so users without it no longer see a non-functional section or hit a 403 on load.
|
awesome 🤟 |
infoText is updated via the editor's debounced onUpdate (250ms), so saving or previewing within that window could drop the last edit. Read infoEditor.getContent() at save/preview time instead of the debounced ref.
|
@dschmidt for endusers: if i dismiss the banner via the "x": when will the banner reappear and when will it disappear forever? |
@tbsbdr It's just hidden until page reload. Hiding it temporarily or dismissing a specific message is way more complex and currently not worth the effort imho. The idea is: yes, you can hide it if it really annoys you: for example when you need to take screenshots or similar, but you should be aware of the current announcement even if the admin enabled it 2 weeks ago |
Mirror the disabled pattern from OcCheckbox: a disabled switch dims, shows a default cursor and does not toggle. Replaces the ad-hoc pointer-events/opacity workaround used to fake-disable the switch.
Use the new OcSwitch disabled prop instead of the pointer-events workaround: the switch is disabled while busy or until a banner text has been saved, so the save-first message is no longer needed.
|
Discussed with Domme: generally its annoying when something reappears after it got dismissed. After clicking around the UI, I noticed that full page reloads are relatively rare. With this in mind, I think your solution hits the sweet-spot of effort-value 👌 Thanks for your work! |
A tiptap update dropped the default role="textbox" from the contenteditable, so the aria-label became invalid (axe aria-prohibited-attr). Set role="textbox" and aria-multiline explicitly when an ariaLabel is given.
… dimming Add a default slot rendered next to the label (e.g. for a contextual helper). Dim only the label and toggle when disabled instead of the whole switch, so a slotted popover is not trapped in an opacity stacking context.
Rename to Show banner / Banner / Banner details, shorten the section description and add contextual helpers. The helpers note that the switch can only be enabled once a banner text is saved, and that leaving the details empty makes the banner non-clickable.
Announcement banner shown above the top bar to all users (including the login page), with a dialog showing Markdown detail text, plus an admin UI to manage it.
options.announcement.{bannerText, infoText}fromconfig.json; clicking it opens a dialog that rendersinfoTextas read-only Markdown (via the shared TipTap editor).GET /announcement, editsbannerText+ a MarkdowninfoTexteditor (image insertion disabled), an instantEnabledswitch, a session-onlyPreview, andSave. An empty banner text removes the announcement.excludeActionsoption touseTextEditor.Backend: opencloud-eu/opencloud#3189
fixes #2977