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,
17 const form = useFormState();
30 const onlyWarningInSubmitErrors = onlyHasWarning(submitErrors);
34 // OR has submit errors
37 // b) OR only has a warning (double conf)
38 // 2) AND is not validating
39 // 3) AND has no validation errors
40 // 4) AND is not actively submitting
41 // 5) AND submit has not yet succeeded
45 (dirtySinceLastSubmit || onlyWarningInSubmitErrors))) &&
47 !hasValidationErrors &&
51 // show the warning action text if
52 // 1) we have that warning at all
53 // 2) we can submit or are submitting
54 const showWarningSubmitText =
55 onlyWarningInSubmitErrors &&
56 !dirtySinceLastSubmit &&
57 (canSubmit || submitting);
62 className={cn('mt4', className)}
64 accessory={blinkIf(validating || submitting)}
65 onClick={handleSubmit}
68 {typeof children === 'function'
69 ? 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