1import React from 'react';
2import cn from 'classnames';
3import { useFormState } from 'react-final-form';
5import { ForwardButton } from 'components/Buttons';
7import { blinkIf } from 'components/Blinky';
8import { onlyHasWarning } from './helpers';
10export default function SubmitButton({
11 as: As = ForwardButton,
28 const onlyWarningInSubmitErrors = onlyHasWarning(submitErrors);
32 // OR has submit errors AND is dirty or only has a warning (double conf)
33 // 2) AND is not validating
34 // 3) AND has no validation errors
35 // 4) AND is not actively submitting
36 // 5) AND submit has not yet succeeded
40 (dirtySinceLastSubmit || onlyWarningInSubmitErrors))) &&
42 !hasValidationErrors &&
46 // show the warning action text if
47 // 1) we have that warning at all
48 // 2) we can submit or are submitting
49 const showWarningSubmitText =
50 onlyWarningInSubmitErrors &&
51 !dirtySinceLastSubmit &&
52 (canSubmit || submitting);
56 className={cn('mt4', className)}
58 accessory={blinkIf(validating || submitting)}
59 onClick={handleSubmit}
62 {typeof children === 'function'
63 ? children(showWarningSubmitText)
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list