• 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/Users/EditUserForm.jsx
1
import React from 'react'
2
import { withTranslation } from 'react-i18next'
3
import { connect } from 'react-redux'
4
import { withRouter } from 'react-router-dom'
5
import { reduxForm, SubmissionError } from 'redux-form'
6

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

9
import { updateUserInfo } from '../../API/http_api/current_user'
10
import { setUser as setDisplayedUser } from '../../state/users/displayed_user/reducer'
11
import { withLoggedInUser } from '../LoggedInUser/UserProvider'
12
import { renderAllUserFields, submitButton, validatePasswordRepeat } from './UserFormFields'
13

14
// A dirty trick to make the migration of user from redux to context easier.
15
// As we plan to replace ReduxForm by Formik, there is no need in spending
16
// time making a proper adaptation.
17
const dirtyLoggedInUserToReduxForm = (Component) => (props) => {
×
18
  const { loggedInUser, ...otherProps } = props
×
19

20
  return (
×
21
    <Component
22
      {...otherProps}
23
      initialValues={loggedInUser && loggedInUser.toObject()}
×
24
      enableReinitialize
25
    />
26
  )
27
}
28

29
@withLoggedInUser
30
@dirtyLoggedInUserToReduxForm
31
@reduxForm({ form: 'editUserForm', validate: validatePasswordRepeat })
32
@withRouter
33
@withTranslation('user')
34
@connect(null, { setDisplayedUser })
35
export default class EditUserForm extends React.PureComponent {
36
  componentDidUpdate() {
37
    // Redirect to user profile when logged in
38
    if (!this.props.loggedInUserLoading && !this.props.isAuthenticated) {
×
39
      this.props.history.push('/')
×
40
    }
41
  }
42

43
  submit(user) {
44
    return updateUserInfo(user)
×
45
      .then((user) => {
46
        this.props.updateLoggedInUser(user)
×
47
        this.props.setDisplayedUser(user)
×
NEW
48
        toast({
×
49
          variant: 'success',
50
          title: this.props.t('settingsUpdated'),
51
        })
52
      })
53
      .catch((e) => {
54
        throw new SubmissionError(e)
×
55
      })
56
  }
57

58
  render() {
59
    const { handleSubmit, valid, t } = this.props
×
60
    return (
×
61
      <form className="edit-user-form form" onSubmit={handleSubmit((user) => this.submit(user))}>
×
62
        {renderAllUserFields(t, true)}
63
        {submitButton(t('main:actions.save'), valid, {
64
          loading: this.props.submitting,
65
          variant: 'outline',
66
        })}
67
      </form>
68
    )
69
  }
70
}
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