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,
40 const onlyWarningInSubmitErrors = onlyHasWarning(submitErrors);
44 // OR has submit errors
47 // b) OR only has a warning (double conf)
48 // 2) AND is not validating
49 // 3) AND has no validation errors
50 // 4) AND is not actively submitting
51 // 5) AND submit has not yet succeeded
55 (dirtySinceLastSubmit || onlyWarningInSubmitErrors))) &&
57 !hasValidationErrors &&
61 // show the warning action text if
62 // 1) we have that warning at all
63 // 2) we can submit or are submitting
64 const showWarningSubmitText =
65 onlyWarningInSubmitErrors &&
66 !dirtySinceLastSubmit &&
67 (canSubmit || submitting);
72 className={cn('mt4', className)}
74 accessory={blinkIf(validating || submitting)}
75 onClick={handleSubmit}
78 {typeof children === 'function'
79 ? 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