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
35 // b) OR only has a warning (double conf)
36 // 2) AND is not validating
37 // 3) AND has no validation errors
38 // 4) AND is not actively submitting
39 // 5) AND submit has not yet succeeded
43 (dirtySinceLastSubmit || onlyWarningInSubmitErrors))) &&
45 !hasValidationErrors &&
49 // show the warning action text if
50 // 1) we have that warning at all
51 // 2) we can submit or are submitting
52 const showWarningSubmitText =
53 onlyWarningInSubmitErrors &&
54 !dirtySinceLastSubmit &&
55 (canSubmit || submitting);
60 className={cn('mt4', className)}
62 accessory={blinkIf(validating || submitting)}
63 onClick={handleSubmit}
66 {typeof children === 'function'
67 ? 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