• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

CaptainFact / captain-fact-frontend / 12937903925

23 Jan 2025 08:56PM UTC coverage: 5.504% (-1.4%) from 6.953%
12937903925

push

github

web-flow
chore: Migrate to tailwind (#1355)

43 of 1647 branches covered (2.61%)

Branch coverage included in aggregate %.

6 of 306 new or added lines in 94 files covered. (1.96%)

94 existing lines in 39 files now uncovered.

192 of 2623 relevant lines covered (7.32%)

0.17 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/app/components/Moderation/Moderation.jsx
1
import React from 'react'
2
import { withTranslation } from 'react-i18next'
3
import { connect } from 'react-redux'
4
import { Link } from 'react-router-dom'
5
import { Report } from 'styled-icons/octicons'
6

7
import { toast } from '@/hooks/use-toast'
8

9
import { MIN_REPUTATION_MODERATION } from '../../constants'
10
import { commentURL } from '../../lib/cf_routes'
11
import { fetchRandomModeration, postModerationFeedback } from '../../state/moderation/effects'
12
import { Button } from '../ui/button'
13
import UserAppellation from '../Users/UserAppellation'
14
import UserAction from '../UsersActions/UserAction'
15
import { LoadingFrame } from '../Utils/LoadingFrame'
16
import Message from '../Utils/Message'
17
import { withReputationGuard } from '../Utils/ReputationGuard'
18
import { ModerationForm } from './ModerationForm'
19

20
@connect(
21
  (state) => ({
×
22
    isLoading: state.Moderation.isLoading,
23
    error: state.Moderation.error,
24
    entry: state.Moderation.entry,
25
  }),
26
  { fetchRandomModeration, postModerationFeedback },
27
)
28
@withTranslation('moderation')
29
@withReputationGuard(MIN_REPUTATION_MODERATION)
30
export default class Moderation extends React.PureComponent {
31
  componentDidMount() {
32
    this.props.fetchRandomModeration()
×
33
  }
34

35
  postFeedback(values) {
NEW
36
    this.props
×
37
      .postModerationFeedback(values)
38
      .then(() => {
NEW
39
        toast({
×
40
          variant: 'success',
41
          title: 'Flag submitted',
42
          description: 'Thank you for your feedback!',
43
        })
44
      })
NEW
45
      .then(() => this.props.fetchRandomModeration())
×
46
  }
47

48
  render() {
49
    const { entry, t } = this.props
×
50

51
    if (this.props.isLoading) {
×
52
      return <LoadingFrame />
×
53
    }
54

55
    return (
×
56
      <main className="container mx-auto px-4 py-8">
57
        <h1 className="text-4xl font-bold text-center mb-6">
58
          {t('title')} <Report className="inline w-8 h-8" />
59
        </h1>
60
        <div className="text-center mb-8">
61
          <p className="mb-2">{t('helpText1')}</p>
62
          <p className="mb-4">{t('helpText2')}</p>
63
          <Link className="font-bold hover:underline" to="/help/moderation">
64
            {t('learnMore')}
65
          </Link>
66
        </div>
67
        {!entry && <Message className="text-center mt-8">{t('emptyModeration')}</Message>}
×
68
        {entry && (
×
69
          <div>
70
            {this.renderAction(entry.action)}
71
            <hr className="my-6" />
72
            {entry.flags.map(({ source_user, reason }) => (
NEW
73
              <div key={source_user.id} className="text-center mb-2">
×
74
                <UserAppellation user={source_user} /> {t('flaggedFor', { reason })}
75
              </div>
76
            ))}
77
          </div>
78
        )}
79
      </main>
80
    )
81
  }
82

83
  renderAction(action) {
84
    return (
×
85
      <div className="bg-white rounded-lg shadow-md p-6">
86
        <UserAction action={action} defaultExpanded />
87
        <div className="my-4">
88
          <div className="bg-gray-50 rounded p-4 text-center">
89
            <Button variant="outline">
90
              <Link
91
                target="_blank"
92
                to={commentURL(action.videoHashId, action.statementId, action.commentId)}
93
                className="font-bold hover:underline"
94
              >
95
                {this.props.t('seeContext')}
96
              </Link>
97
            </Button>
98
          </div>
99
        </div>
100
        <hr className="my-4" />
101
        <ModerationForm
102
          action={action}
103
          initialValues={{ action_id: action.id }}
104
          onSubmit={(values) => this.postFeedback(values)}
×
105
        />
106
      </div>
107
    )
108
  }
109
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc