fix(my-joy-beta): don't update header when editing keyValue

This commit is contained in:
Sérgio Ramos 2018-01-04 10:56:10 +00:00 committed by Sérgio Ramos
parent 4678addd7a
commit 0bccbc1988
2 changed files with 24 additions and 17 deletions

View File

@ -114,6 +114,7 @@ export const KeyValue = ({
input = 'input',
type = 'metadata',
method = 'add',
initialValues = {},
error = null,
expanded = true,
submitting = false,
@ -142,18 +143,14 @@ export const KeyValue = ({
<H4>{`${titleCase(method)} ${type}`}</H4>
) : (
<CollapsedKeyValue>
<Field
name="name"
type="text"
component={({ input = {} }) =>
!expanded ? `${input.value}: ` : <b>{`${input.value}: `}</b>
}
/>,
<Field
name="value"
type="text"
component={({ input = {} }) => <span>{input.value}</span>}
/>
<span>
{!expanded ? (
`${initialValues.name}: `
) : (
<b>{`${initialValues.name}: `}</b>
)}
</span>
<span>{initialValues.value}</span>
</CollapsedKeyValue>
)}
</CardHeaderMeta>
@ -233,6 +230,10 @@ KeyValue.propTypes = {
input: PropTypes.oneOf(['input', 'textarea']).isRequired,
type: PropTypes.string.isRequired,
method: PropTypes.oneOf(['add', 'edit']).isRequired,
initialValues: PropTypes.shape({
name: PropTypes.string,
value: PropTypes.string
}).isRequired,
removing: PropTypes.bool.isRequired,
expanded: PropTypes.bool.isRequired,
onToggleExpanded: PropTypes.func,

View File

@ -92,12 +92,18 @@ export const Tags = ({
form={editing.form}
initialValues={{ name: editing.name, value: editing.value }}
onSubmit={handleEdit}
>
{props => (
<TagsEditForm
{...props}
/* yeah, we need this here too */
initialValues={{ name: editing.name, value: editing.value }}
onCancel={() => handleToggleEditing(false)}
onToggleExpanded={() => handleToggleEditing(false)}
onRemove={() => handleRemove(editing.form, editing)}
removing={editing.removing}
>
{TagsEditForm}
/>
)}
</ReduxForm>
) : null;