• 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/Modal/ModalFormContainer.jsx
1
import isPromise from 'is-promise'
2
import React from 'react'
3
import { withTranslation } from 'react-i18next'
4
import { connect } from 'react-redux'
5

6
import { cn } from '@/lib/css-utils'
7

8
import { handleFormEffectResponse } from '../../lib/handle_effect_response'
9
import { popModal } from '../../state/modals/reducer'
10
import { Button } from '../ui/button'
11
import Modal from './Modal'
12

13
@withTranslation('main')
14
@connect(null, { popModal })
15
export class ModalFormContainer extends React.PureComponent {
16
  constructor(props) {
17
    super(props)
×
18
    this.state = { isSubmitting: false }
×
19
    this.close = this.close.bind(this)
×
NEW
20
    this.formRef = React.createRef()
×
21
  }
22

23
  handleSubmit(submitFunc) {
24
    return (data) => {
×
25
      const promise = submitFunc(data)
×
26
      if (isPromise(promise)) {
×
27
        this.setState({ isSubmitting: true })
×
28
        return promise.then(
×
29
          handleFormEffectResponse({
30
            onSuccess: () => this.props.popModal(),
×
31
            onError: () => this.setState({ isSubmitting: false }),
×
32
          }),
33
        )
34
      }
35
    }
36
  }
37

38
  close() {
39
    if (this.props.handleAbort) {
×
40
      this.props.handleAbort()
×
41
    }
42
    this.props.popModal()
×
43
  }
44

45
  renderFormButtons() {
46
    const isSubmitting = this.props.isSubmitting || this.state.isSubmitting
×
47
    return (
×
48
      <div className="flex justify-end gap-2">
49
        <Button
50
          type="submit"
51
          disabled={isSubmitting || this.props.confirmLoading || this.props.confirmDisabled}
×
52
          loading={isSubmitting || this.props.confirmLoading}
×
NEW
53
          onClick={() => this.formRef.current?.submit()}
×
54
          variant="destructive"
55
        >
56
          <div>{this.props.confirmText || this.props.t('actions.save')}</div>
×
57
        </Button>
58
        <Button type="reset" variant="outline" disabled={isSubmitting} onClick={this.close}>
59
          <div>{this.props.t('actions.cancel')}</div>
60
        </Button>
61
      </div>
62
    )
63
  }
64

65
  render() {
66
    const { FormComponent, handleConfirm, className, formProps = {}, ...modalParams } = this.props
×
67
    return (
×
68
      <Modal
69
        {...modalParams}
70
        handleCloseClick={this.close}
71
        className={cn('modal-form', className)}
72
        footer={this.renderFormButtons()}
73
      >
74
        <FormComponent
75
          ref={this.formRef}
76
          {...formProps}
77
          onSubmit={this.handleSubmit(handleConfirm)}
78
        />
79
      </Modal>
80
    )
81
  }
82
}
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