-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
userdashboard/ModerationNotification//AIFeedback: add AI feedback com…
…ponent and add to the ModerationNotification small a11y improvments
- Loading branch information
Showing
11 changed files
with
134 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
apps/userdashboard/assets/js/a4_candy_userdashboard/AiReportExplanation.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 = () => { | ||
setIsExpanded(!isExpanded) | ||
} | ||
|
||
return ( | ||
<li className="alert alert--danger d-flex text-start fs-6 mb-3"> | ||
<i | ||
className="fas fa-exclamation-circle text-danger pt-1 pe-2" | ||
aria-hidden="True" | ||
/> | ||
<p className="pe-4"> | ||
{translated.intro + ' '} | ||
{isExpanded && AiReport + ' '} | ||
<button | ||
className="btn--link text-danger" | ||
type="button" | ||
onClick={toggleExpand} | ||
aria-label={isExpanded ? translated.ariaReadLess : translated.ariaReadMore} | ||
> | ||
{isExpanded ? translated.readLess : translated.readMore} | ||
</button> | ||
</p> | ||
</li> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
apps/userdashboard/assets/js/a4_candy_userdashboard/__tests__/AiReportExplanation.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import React from 'react' | ||
import { render, fireEvent, screen } from '@testing-library/react' | ||
import '@testing-library/jest-dom' | ||
import { AiReportExplanation } from '../AiReportExplanation' | ||
|
||
test('Snapshot Read More <AiReportExplanation>', () => { | ||
const { container } = render( | ||
<AiReportExplanation AiReport="This is the ai report" /> | ||
) | ||
expect(container).toMatchSnapshot() | ||
}) | ||
|
||
test('Snapshot Read Less <AiReportExplanation>', () => { | ||
const { container } = render( | ||
<AiReportExplanation AiReport="This is the ai report" /> | ||
) | ||
const button = screen.getByRole('button') | ||
fireEvent.click(button) | ||
expect(container).toMatchSnapshot() | ||
}) | ||
|
||
test('Render <AiReportExplanation>', () => { | ||
render(<AiReportExplanation AiReport="This is the ai report" />) | ||
const comment = screen.getByText('Read more') | ||
expect(comment).toBeTruthy() | ||
}) | ||
|
||
test('Read More <AiReportExplanation>', () => { | ||
render(<AiReportExplanation AiReport="This is the ai report" />) | ||
const readMore = screen.getByText('Read more') | ||
expect(readMore).toBeTruthy() | ||
const button = screen.getByRole('button') | ||
expect(button).toBeTruthy() | ||
fireEvent.click(button) | ||
const readLess = screen.getByText('Read less') | ||
expect(readLess).toBeTruthy() | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
### Added | ||
|
||
- react component to show AI report with dummy data for now | ||
|
||
### Changed | ||
|
||
- structure of ModerationNotification to be more a11y compliant |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
FIXME add docs for AI report, for now just list coresponding files | ||
|
||
### React components | ||
apps/userdashboard/assets/js/a4_candy_userdashboard/AiReportExplanation.jsx |