Skip to content

Commit

Permalink
userdashboard/ModerationNotification//AIFeedback: add AI feedback com…
Browse files Browse the repository at this point in the history
…ponent and add to the ModerationNotification small a11y improvments
  • Loading branch information
philli-m committed Aug 1, 2023
1 parent 0e2d902 commit 2576d47
Show file tree
Hide file tree
Showing 7 changed files with 79 additions and 19 deletions.
2 changes: 1 addition & 1 deletion adhocracy-plus/assets/scss/components/_alerts.scss
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ $messages-margin-bottom: 25px;

.alert--error,
.alert--danger {
background-color: lighten($brand-danger, 50);
background-color: lighten($brand-danger, 57);
color: $text-color;
}

Expand Down
19 changes: 16 additions & 3 deletions adhocracy-plus/assets/scss/components/_button.scss
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,15 @@

&:focus,
&:hover,
&:active {
&:active,
&:focus-within {
background-color: transparent !important;
text-decoration: underline;
}

&:focus-visible {
@include fake-focus-shadow;
}
}

.btn.btn--transparent--inverted {
Expand All @@ -115,11 +120,19 @@

&:focus,
&:hover,
&:active,
&:active {
box-shadow: none;
background-color: $bg-light;
}

&:focus-visible {
@include fake-focus-shadow;
}

&:disabled,
&.is-disabled {
box-shadow: none;
background-color: $bg-light;
color: $text-muted;
}

// needed for toggle switch
Expand Down
4 changes: 2 additions & 2 deletions adhocracy-plus/assets/scss/components/_header_upper.scss
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
}
}

.header-upper__user a {
color: $body-bg !important;
.header-upper__user .navi__item a {
color: $body-bg;
}

.header-upper__mobile-toggle {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import React, { useState } from 'react'
import django from 'django'

const translated = {
intro: django.gettext('This comment contains disinformation. Defakts uses an Artificial ' +
'Intelligence to scan content for disinformation. Disinformation often shows ' +
'certain characteristics that allow for a reliable identification.'),
ariaReadMore: django.gettext('Click to view the AI explanation for reporting this comment.'),
ariaReadLess: django.gettext('Click to hide the AI explanation for reporting this comment.'),
readMore: django.gettext('Read more'),
readLess: django.gettext('Read less')
}

export const AIReportExplanation = ({ AIReport }) => {
const [isExpanded, setIsExpanded] = useState()

const toggleExpand = () => {

Check warning on line 17 in apps/userdashboard/assets/js/a4_candy_userdashboard/AIReportExplanation.jsx

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🕹 Function is not covered

Warning! Not covered function
setIsExpanded(!isExpanded)

Check warning on line 18 in apps/userdashboard/assets/js/a4_candy_userdashboard/AIReportExplanation.jsx

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
}

return (
<li className="alert alert--danger d-flex text-start mb-3">
<i
className="fas fa-exclamation-circle text-danger pt-1 pe-2"
aria-hidden="True"
/>
<p>
{translated.intro + ' '}
{isExpanded && AIReport + ' '}

Check warning on line 29 in apps/userdashboard/assets/js/a4_candy_userdashboard/AIReportExplanation.jsx

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🌿 Branch is not covered

Warning! Not covered branch
<button
className="btn--link text-danger"
type="button"
onClick={toggleExpand}
aria-label={isExpanded ? translated.ariaReadLess : translated.ariaReadMore}

Check warning on line 34 in apps/userdashboard/assets/js/a4_candy_userdashboard/AIReportExplanation.jsx

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🌿 Branch is not covered

Warning! Not covered branch
>
{isExpanded ? translated.readLess : translated.readMore}

Check warning on line 36 in apps/userdashboard/assets/js/a4_candy_userdashboard/AIReportExplanation.jsx

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🌿 Branch is not covered

Warning! Not covered branch
</button>
</p>
</li>
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export const ModerationFeedback = (props) => {
}

return (
<div className="userdashboard-mod-feedback">
<li className="userdashboard-mod-feedback">
<div className="row">
<div className="col-7 col-md-8 userdashboard-mod-feedback__header">
<div>{translated.feedbackTitle}</div>
Expand Down Expand Up @@ -68,6 +68,6 @@ export const ModerationFeedback = (props) => {
<p>{feedbackText}</p>
</div>
</div>
</div>
</li>
)
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, { useState } from 'react'
import django from 'django'
import api from './api'
import { AIReportExplanation } from './AIReportExplanation'
import { ModerationFeedbackForm } from './ModerationFeedbackForm'
import { ModerationFeedback } from './ModerationFeedback'
import { ModerationNotificationActionsBar } from './ModerationNotificationActionsBar'
Expand All @@ -21,7 +22,9 @@ const translated = {
notificationRead: django.gettext('Notification successfully marked as read.'),
notificationUnread: django.gettext('Notification successfully marked as unread.'),
aiClassified: django.gettext('AI'),
postedComment: django.gettext('posted a {}comment{}')
postedComment: django.gettext('posted a {}comment{}'),
dummyText: django.gettext('Dummy text')

}

export const ModerationNotification = (props) => {
Expand Down Expand Up @@ -257,8 +260,8 @@ export const ModerationNotification = (props) => {

return (
<li>
<div className="u-border p-4">
<div className="d-flex flex-wrap">
<ul className="u-border p-4 u-list-reset">
<li className="d-flex flex-wrap">
{userImageDiv}
<div>
<p className="mb-1">
Expand Down Expand Up @@ -291,17 +294,20 @@ export const ModerationNotification = (props) => {
</ul>
</div>
</div>
</div>
</li>

{numReports > 0 &&
<div>
<li>
<p>
<i className="fas fa-exclamation-circle me-1" aria-hidden="true" />
{getLink(translatedReportText(numReports), commentUrl)}
</p>
</div>}

<p>{commentText}</p>
</li>}
<li>
<p>{commentText}</p>
</li>
{/* FIXME add if once report added to serializer */}
<AIReportExplanation AIReport={translated.dummyText} />
<ModerationNotificationActionsBar
itemPk={notification.pk}
isEditing={notification.moderator_feedback}
Expand All @@ -320,7 +326,7 @@ export const ModerationNotification = (props) => {
setIsEditing(true)

Check warning on line 326 in apps/userdashboard/assets/js/a4_candy_userdashboard/ModerationNotification.jsx

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
}}
/>}
</div>
</ul>
{showFeedbackForm &&
<ModerationFeedbackForm
onSubmit={(payload) => handleFeedbackSubmit(payload)}

Check warning on line 332 in apps/userdashboard/assets/js/a4_candy_userdashboard/ModerationNotification.jsx

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export const ModerationNotificationActionsBar = (props) => {
} = props

return (
<div className="d-flex flex-wrap justify-content-between">
<li className="d-flex flex-wrap justify-content-between">
<button
id={'moderation-notification-actions-bar-button-reply-' + itemPk}
className="btn px-0 userdashboard-mod-notification__btn"
Expand Down Expand Up @@ -62,6 +62,6 @@ export const ModerationNotificationActionsBar = (props) => {
textMouseOn={isBlocked ? translated.unblockText : translated.blockText}
/>
</div>
</div>
</li>
)
}

0 comments on commit 2576d47

Please sign in to comment.