Skip to content
This repository has been archived by the owner on Nov 10, 2023. It is now read-only.

Bug: #477 owners address can be edited #487

Merged
merged 7 commits into from
Jan 31, 2020
3 changes: 3 additions & 0 deletions src/components/forms/AddressInput/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ type Props = {
validators?: Function[],
inputAdornment?: React.Element,
defaultValue?: string,
disabled?: boolean,
}

const isValidEnsName = (name) => /^([\w-]+\.)+(eth|test|xyz|luxe)$/.test(name)
Expand All @@ -37,6 +38,7 @@ const AddressInput = ({
inputAdornment,
validators = [],
defaultValue,
disabled,
}: Props): React.Element<*> => (
<>
<Field
Expand All @@ -54,6 +56,7 @@ const AddressInput = ({
className={className}
testId={testId}
defaultValue={defaultValue}
disabled={disabled}
/>
<OnChange name={name}>
{async (value) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ type Props = {
newEntryModalHandler: Function,
editEntryModalHandler: Function,
entryToEdit?: AddressBookEntry,
newEntryDefaultAddress: string | null,
}

const CreateEditEntryModalComponent = ({
Expand All @@ -44,7 +43,6 @@ const CreateEditEntryModalComponent = ({
classes,
newEntryModalHandler,
entryToEdit,
newEntryDefaultAddress,
editEntryModalHandler,
}: Props) => {
const onFormSubmitted = (values) => {
Expand Down Expand Up @@ -111,6 +109,7 @@ const CreateEditEntryModalComponent = ({
fieldMutator={mutators.setOwnerAddress}
testId={CREATE_ENTRY_INPUT_ADDRESS_ID}
defaultValue={entryToEdit ? entryToEdit.entry.address : undefined}
disabled={!!entryToEdit}
/>
</Row>
</Block>
Expand Down
6 changes: 1 addition & 5 deletions src/routes/safe/components/AddressBook/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ const AddressBookTable = ({ classes }: Props) => {
)
const [deleteEntryModalOpen, setDeleteEntryModalOpen] = useState(false)
const [sendFundsModalOpen, setSendFundsModalOpen] = useState(false)
const [defaultNewEntryAddress, setDefaultNewEntryAddress] = useState(null)
const entryAddressToEditOrCreateNew = useSelector(addressBookQueryParamsSelector)


Expand All @@ -78,7 +77,6 @@ const AddressBookTable = ({ classes }: Props) => {
setSelectedEntry({ entry: value, index: key })
} else {
// Create new entry
setDefaultNewEntryAddress(entryAddressToEditOrCreateNew)
setSelectedEntry(null)
}
}
Expand All @@ -93,7 +91,6 @@ const AddressBookTable = ({ classes }: Props) => {
const newEntryModalHandler = (entry: AddressBookEntry) => {
setEditCreateEntryModalOpen(false)
dispatch(addAddressBookEntry(entry))
setDefaultNewEntryAddress(null)
}

const editEntryModalHandler = (entry: AddressBookEntry) => {
Expand Down Expand Up @@ -174,7 +171,7 @@ const AddressBookTable = ({ classes }: Props) => {
className={classes.editEntryButton}
src={RenameOwnerIcon}
onClick={() => {
setSelectedEntry({ entry: row })
setSelectedEntry({ entry: { ...row, isOwnerAddress: userOwner } })
setEditCreateEntryModalOpen(true)
}}
testId={EDIT_ENTRY_BUTTON}
Expand Down Expand Up @@ -224,7 +221,6 @@ const AddressBookTable = ({ classes }: Props) => {
newEntryModalHandler={newEntryModalHandler}
editEntryModalHandler={editEntryModalHandler}
entryToEdit={selectedEntry}
newEntryDefaultAddress={defaultNewEntryAddress}
/>
<DeleteEntryModal
onClose={() => setDeleteEntryModalOpen(false)}
Expand Down