Allow passing button labels to Stepper component, add CopyBtn tooltip
This commit is contained in:
parent
3c05220008
commit
6edc37b571
|
@ -27,8 +27,8 @@ type CopyBtnProps = {
|
||||||
}
|
}
|
||||||
|
|
||||||
const CopyBtn = ({ content, classes }: CopyBtnProps) => (navigator.clipboard ? (
|
const CopyBtn = ({ content, classes }: CopyBtnProps) => (navigator.clipboard ? (
|
||||||
<div className={classes.container}>
|
<div className={classes.container} title="Copy to clipboard">
|
||||||
<Img src={CopyIcon} height={20} alt="Click to copy" onClick={() => copyToClipboard(content)} />
|
<Img src={CopyIcon} height={20} alt="Copy to clipboard" onClick={() => copyToClipboard(content)} />
|
||||||
</div>
|
</div>
|
||||||
) : null)
|
) : null)
|
||||||
|
|
||||||
|
|
|
@ -26,24 +26,34 @@ type Props = {
|
||||||
lastPage: boolean,
|
lastPage: boolean,
|
||||||
disabled: boolean,
|
disabled: boolean,
|
||||||
penultimate: boolean,
|
penultimate: boolean,
|
||||||
|
currentStep?: number,
|
||||||
|
buttonLabels?: Array<string>,
|
||||||
}
|
}
|
||||||
|
|
||||||
const Controls = ({
|
const Controls = ({
|
||||||
onPrevious, firstPage, penultimate, lastPage, disabled,
|
onPrevious,
|
||||||
|
firstPage,
|
||||||
|
penultimate,
|
||||||
|
lastPage,
|
||||||
|
disabled,
|
||||||
|
currentStep,
|
||||||
|
buttonLabels,
|
||||||
}: Props) => {
|
}: Props) => {
|
||||||
// eslint-disable-next-line
|
|
||||||
const next = firstPage ? 'Start' : penultimate ? 'Review' : lastPage ? 'Submit' : 'Next'
|
|
||||||
const back = firstPage ? 'Cancel' : 'Back'
|
const back = firstPage ? 'Cancel' : 'Back'
|
||||||
|
|
||||||
|
let next
|
||||||
|
if (!buttonLabels) {
|
||||||
|
// eslint-disable-next-line
|
||||||
|
next = firstPage ? 'Start' : penultimate ? 'Review' : lastPage ? 'Submit' : 'Next'
|
||||||
|
} else {
|
||||||
|
// $FlowFixMe
|
||||||
|
next = buttonLabels[currentStep]
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Row style={controlStyle} align="end" grow>
|
<Row style={controlStyle} align="end" grow>
|
||||||
<Col xs={12} end="xs">
|
<Col xs={12} end="xs">
|
||||||
<Button
|
<Button style={firstButtonStyle} type="button" onClick={onPrevious} size="small">
|
||||||
style={firstButtonStyle}
|
|
||||||
type="button"
|
|
||||||
onClick={onPrevious}
|
|
||||||
size="small"
|
|
||||||
>
|
|
||||||
{back}
|
{back}
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
<Button
|
||||||
|
|
|
@ -19,6 +19,7 @@ type Props = {
|
||||||
onSubmit: (values: Object) => Promise<void>,
|
onSubmit: (values: Object) => Promise<void>,
|
||||||
children: React.Node,
|
children: React.Node,
|
||||||
classes: Object,
|
classes: Object,
|
||||||
|
buttonLabels: Array<string>,
|
||||||
initialValues?: Object,
|
initialValues?: Object,
|
||||||
disabledWhenValidating?: boolean,
|
disabledWhenValidating?: boolean,
|
||||||
mutators?: Object,
|
mutators?: Object,
|
||||||
|
@ -110,7 +111,7 @@ const GnoStepper = (props: Props) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
const {
|
const {
|
||||||
steps, children, classes, disabledWhenValidating = false, testId, mutators,
|
steps, children, classes, disabledWhenValidating = false, testId, mutators, buttonLabels,
|
||||||
} = props
|
} = props
|
||||||
const activePage = getActivePageFrom(children)
|
const activePage = getActivePageFrom(children)
|
||||||
|
|
||||||
|
@ -137,6 +138,8 @@ const GnoStepper = (props: Props) => {
|
||||||
firstPage={page === 0}
|
firstPage={page === 0}
|
||||||
lastPage={lastPage}
|
lastPage={lastPage}
|
||||||
penultimate={penultimate}
|
penultimate={penultimate}
|
||||||
|
buttonLabels={buttonLabels}
|
||||||
|
currentStep={page}
|
||||||
/>
|
/>
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
|
|
|
@ -35,6 +35,8 @@ const formMutators = {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const buttonLabels = ['Next', 'Review', 'Load']
|
||||||
|
|
||||||
const Layout = ({
|
const Layout = ({
|
||||||
provider, onLoadSafeSubmit, network, userAddress,
|
provider, onLoadSafeSubmit, network, userAddress,
|
||||||
}: Props) => {
|
}: Props) => {
|
||||||
|
@ -56,6 +58,7 @@ const Layout = ({
|
||||||
steps={steps}
|
steps={steps}
|
||||||
initialValues={initialValues}
|
initialValues={initialValues}
|
||||||
mutators={formMutators}
|
mutators={formMutators}
|
||||||
|
buttonLabels={buttonLabels}
|
||||||
testId="load-safe-form"
|
testId="load-safe-form"
|
||||||
>
|
>
|
||||||
<StepperPage validate={safeFieldsValidation}>{DetailsForm}</StepperPage>
|
<StepperPage validate={safeFieldsValidation}>{DetailsForm}</StepperPage>
|
||||||
|
|
Loading…
Reference in New Issue