mirror of
https://github.com/status-im/safe-react.git
synced 2025-01-09 09:42:07 +00:00
add back loadedViaUrl
flag (#2337)
* add back `loadedViaUrl` flag * implicitly set `loadedViaUrl` to `false` when adding a safe via form or setting its name from Settings * exclude safes whose `loadedViaUrl` flag is `true` * hide "Remove Safe" button for safes `loadedViaUrl` * add `loadedViaUrl` flag to mocked safe
This commit is contained in:
parent
51c05e928d
commit
82519b84b6
@ -20,7 +20,8 @@ import { buildSafeOwners, extractRemoteSafeInfo } from './utils'
|
|||||||
*/
|
*/
|
||||||
export const buildSafe = async (safeAddress: string): Promise<SafeRecordProps> => {
|
export const buildSafe = async (safeAddress: string): Promise<SafeRecordProps> => {
|
||||||
const address = checksumAddress(safeAddress)
|
const address = checksumAddress(safeAddress)
|
||||||
const safeInfo: Partial<SafeRecordProps> = { address }
|
// setting `loadedViaUrl` to false, as `buildSafe` is called on safe Load or Open flows
|
||||||
|
const safeInfo: Partial<SafeRecordProps> = { address, loadedViaUrl: false }
|
||||||
|
|
||||||
const [remote, localSafeInfo] = await allSettled<[SafeInfo | null, SafeRecordProps | undefined | null]>(
|
const [remote, localSafeInfo] = await allSettled<[SafeInfo | null, SafeRecordProps | undefined | null]>(
|
||||||
getSafeInfo(safeAddress),
|
getSafeInfo(safeAddress),
|
||||||
|
@ -36,6 +36,7 @@ export type SafeRecordProps = {
|
|||||||
currentVersion: string
|
currentVersion: string
|
||||||
needsUpdate: boolean
|
needsUpdate: boolean
|
||||||
featuresEnabled: Array<FEATURES>
|
featuresEnabled: Array<FEATURES>
|
||||||
|
loadedViaUrl: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
const makeSafe = Record<SafeRecordProps>({
|
const makeSafe = Record<SafeRecordProps>({
|
||||||
@ -52,6 +53,7 @@ const makeSafe = Record<SafeRecordProps>({
|
|||||||
currentVersion: '',
|
currentVersion: '',
|
||||||
needsUpdate: false,
|
needsUpdate: false,
|
||||||
featuresEnabled: [],
|
featuresEnabled: [],
|
||||||
|
loadedViaUrl: true,
|
||||||
})
|
})
|
||||||
|
|
||||||
export type SafeRecord = RecordOf<SafeRecordProps>
|
export type SafeRecord = RecordOf<SafeRecordProps>
|
||||||
|
@ -32,6 +32,7 @@ export const safesListWithAddressBookNameSelector = createSelector(
|
|||||||
const addressBook = addressBookMap?.[chainId]
|
const addressBook = addressBookMap?.[chainId]
|
||||||
|
|
||||||
return safesList
|
return safesList
|
||||||
|
.filter((safeRecord) => !safeRecord.loadedViaUrl)
|
||||||
.map((safeRecord) => {
|
.map((safeRecord) => {
|
||||||
const safe = safeRecord.toObject()
|
const safe = safeRecord.toObject()
|
||||||
const name = addressBook?.[safe.address]?.name
|
const name = addressBook?.[safe.address]?.name
|
||||||
|
@ -38,6 +38,7 @@ const getMockedOldSafe = ({
|
|||||||
needsUpdate: needsUpdate || false,
|
needsUpdate: needsUpdate || false,
|
||||||
featuresEnabled: featuresEnabled || [],
|
featuresEnabled: featuresEnabled || [],
|
||||||
totalFiatBalance: '110',
|
totalFiatBalance: '110',
|
||||||
|
loadedViaUrl: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,8 +73,8 @@ const SafeDetails = (): ReactElement => {
|
|||||||
|
|
||||||
const handleSubmit = (values) => {
|
const handleSubmit = (values) => {
|
||||||
dispatch(addressBookAddOrUpdate(makeAddressBookEntry({ address: safeAddress, name: values.safeName })))
|
dispatch(addressBookAddOrUpdate(makeAddressBookEntry({ address: safeAddress, name: values.safeName })))
|
||||||
// used to trigger safe middleware and persist safe to localStorage
|
// setting `loadedViaUrl` to `false` as setting a safe's name is considered to intentionally add the safe
|
||||||
dispatch(updateSafe({ address: safeAddress }))
|
dispatch(updateSafe({ address: safeAddress, loadedViaUrl: false }))
|
||||||
|
|
||||||
const notification = getNotificationsFromTxType(TX_NOTIFICATION_TYPES.SAFE_NAME_CHANGE_TX)
|
const notification = getNotificationsFromTxType(TX_NOTIFICATION_TYPES.SAFE_NAME_CHANGE_TX)
|
||||||
dispatch(enqueueSnackbar(enhanceSnackbarForAction(notification.afterExecution.noMoreConfirmationsNeeded)))
|
dispatch(enqueueSnackbar(enhanceSnackbarForAction(notification.afterExecution.noMoreConfirmationsNeeded)))
|
||||||
|
@ -25,7 +25,11 @@ import Img from 'src/components/layout/Img'
|
|||||||
import Paragraph from 'src/components/layout/Paragraph'
|
import Paragraph from 'src/components/layout/Paragraph'
|
||||||
import Row from 'src/components/layout/Row'
|
import Row from 'src/components/layout/Row'
|
||||||
import Span from 'src/components/layout/Span'
|
import Span from 'src/components/layout/Span'
|
||||||
import { safeNeedsUpdateSelector, safeOwnersWithAddressBookDataSelector } from 'src/logic/safe/store/selectors'
|
import {
|
||||||
|
safeNeedsUpdateSelector,
|
||||||
|
safeOwnersWithAddressBookDataSelector,
|
||||||
|
safeSelector,
|
||||||
|
} from 'src/logic/safe/store/selectors'
|
||||||
import { grantedSelector } from 'src/routes/safe/container/selector'
|
import { grantedSelector } from 'src/routes/safe/container/selector'
|
||||||
|
|
||||||
export const OWNERS_SETTINGS_TAB_TEST_ID = 'owner-settings-tab'
|
export const OWNERS_SETTINGS_TAB_TEST_ID = 'owner-settings-tab'
|
||||||
@ -45,6 +49,7 @@ const Settings: React.FC = () => {
|
|||||||
const owners = useSelector((state) => safeOwnersWithAddressBookDataSelector(state, chainId))
|
const owners = useSelector((state) => safeOwnersWithAddressBookDataSelector(state, chainId))
|
||||||
const needsUpdate = useSelector(safeNeedsUpdateSelector)
|
const needsUpdate = useSelector(safeNeedsUpdateSelector)
|
||||||
const granted = useSelector(grantedSelector)
|
const granted = useSelector(grantedSelector)
|
||||||
|
const safe = useSelector(safeSelector)
|
||||||
|
|
||||||
const handleChange = (menuOptionIndex) => () => {
|
const handleChange = (menuOptionIndex) => () => {
|
||||||
setState((prevState) => ({ ...prevState, menuOptionIndex }))
|
setState((prevState) => ({ ...prevState, menuOptionIndex }))
|
||||||
@ -67,11 +72,15 @@ const Settings: React.FC = () => {
|
|||||||
) : (
|
) : (
|
||||||
<>
|
<>
|
||||||
<Row className={classes.message}>
|
<Row className={classes.message}>
|
||||||
<ButtonLink className={classes.removeSafeBtn} color="error" onClick={onShow('RemoveSafe')} size="lg">
|
{!safe?.loadedViaUrl && (
|
||||||
<Span className={classes.links}>Remove Safe</Span>
|
<>
|
||||||
<Img alt="Trash Icon" className={classes.removeSafeIcon} src={RemoveSafeIcon} />
|
<ButtonLink className={classes.removeSafeBtn} color="error" onClick={onShow('RemoveSafe')} size="lg">
|
||||||
</ButtonLink>
|
<Span className={classes.links}>Remove Safe</Span>
|
||||||
<RemoveSafeModal isOpen={showRemoveSafe} onClose={onHide('RemoveSafe')} />
|
<Img alt="Trash Icon" className={classes.removeSafeIcon} src={RemoveSafeIcon} />
|
||||||
|
</ButtonLink>
|
||||||
|
<RemoveSafeModal isOpen={showRemoveSafe} onClose={onHide('RemoveSafe')} />
|
||||||
|
</>
|
||||||
|
)}
|
||||||
</Row>
|
</Row>
|
||||||
<Block className={classes.root}>
|
<Block className={classes.root}>
|
||||||
<Col className={classes.menuWrapper} layout="column">
|
<Col className={classes.menuWrapper} layout="column">
|
||||||
|
Loading…
x
Reference in New Issue
Block a user