Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added toaster for removed NFTs #17297

Merged
merged 5 commits into from
Jan 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions app/_locales/en/messages.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import { DEFAULT_ROUTE, SEND_ROUTE } from '../../../helpers/constants/routes';
import {
checkAndUpdateSingleNftOwnershipStatus,
removeAndIgnoreNft,
setRemoveCollectibleMessage,
} from '../../../store/actions';
import { CHAIN_IDS } from '../../../../shared/constants/network';
import { getEnvironmentType } from '../../../../app/scripts/lib/util';
Expand Down Expand Up @@ -85,6 +86,7 @@ export default function CollectibleDetails({ collectible }) {

const onRemove = () => {
dispatch(removeAndIgnoreNft(address, tokenId));
dispatch(setRemoveCollectibleMessage('success'));
NidhiKJha marked this conversation as resolved.
Show resolved Hide resolved
history.push(DEFAULT_ROUTE);
};

Expand Down
7 changes: 7 additions & 0 deletions ui/ducks/app/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export default function reduceApp(state = {}, action) {
ledgerTransportStatus: TRANSPORT_STATES.NONE,
newNetworkAdded: '',
newCollectibleAddedMessage: '',
removeCollectibleMessage: '',
portfolioTooltipWasShownInThisSession: false,
sendInputCurrencySwitched: false,
newTokensImported: '',
Expand Down Expand Up @@ -319,6 +320,12 @@ export default function reduceApp(state = {}, action) {
newCollectibleAddedMessage: action.value,
};

case actionConstants.SET_REMOVE_COLLECTIBLE_MESSAGE:
return {
...appState,
removeCollectibleMessage: action.value,
};

case actionConstants.PORTFOLIO_TOOLTIP_WAS_SHOWN_IN_THIS_SESSION:
return {
...appState,
Expand Down
28 changes: 27 additions & 1 deletion ui/pages/home/home.component.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@ export default class Home extends PureComponent {
isSigningQRHardwareTransaction: PropTypes.bool.isRequired,
newCollectibleAddedMessage: PropTypes.string,
setNewCollectibleAddedMessage: PropTypes.func.isRequired,
removeCollectibleMessage: PropTypes.string,
setRemoveCollectibleMessage: PropTypes.func.isRequired,
closeNotificationPopup: PropTypes.func.isRequired,
newTokensImported: PropTypes.string,
setNewTokensImported: PropTypes.func.isRequired,
Expand Down Expand Up @@ -263,6 +265,8 @@ export default class Home extends PureComponent {
setNewNetworkAdded,
newCollectibleAddedMessage,
setNewCollectibleAddedMessage,
removeCollectibleMessage,
setRemoveCollectibleMessage,
newTokensImported,
setNewTokensImported,
newCustomNetworkAdded,
Expand Down Expand Up @@ -330,6 +334,29 @@ export default class Home extends PureComponent {
}
/>
) : null}

{removeCollectibleMessage === 'success' ? (
DDDDDanica marked this conversation as resolved.
Show resolved Hide resolved
<ActionableMessage
NidhiKJha marked this conversation as resolved.
Show resolved Hide resolved
type="danger"
className="home__new-network-notification"
message={
<Box display={DISPLAY.INLINE_FLEX}>
<i className="fa fa-check-circle home__new-nft-notification-icon" />
<Typography
variant={TYPOGRAPHY.H7}
fontWeight={FONT_WEIGHT.NORMAL}
>
{t('removeCollectibleMessage')}
</Typography>
<button
className="fas fa-times home__new-nft-notification-close"
title={t('close')}
onClick={() => setRemoveCollectibleMessage('')}
/>
</Box>
}
/>
) : null}
{newNetworkAdded ? (
<ActionableMessage
type="success"
Expand Down Expand Up @@ -549,7 +576,6 @@ export default class Home extends PureComponent {

render() {
const { t } = this.context;

const {
defaultHomeActiveTabName,
onTabClick,
Expand Down
6 changes: 6 additions & 0 deletions ui/pages/home/home.container.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import {
getNewTokensImported,
getShowPortfolioTooltip,
getShouldShowSeedPhraseReminder,
getRemoveCollectibleMessage,
} from '../../selectors';

import {
Expand All @@ -37,6 +38,7 @@ import {
setRecoveryPhraseReminderLastShown,
setNewNetworkAdded,
setNewCollectibleAddedMessage,
setRemoveCollectibleMessage,
setNewTokensImported,
setRpcTarget,
///: BEGIN:ONLY_INCLUDE_IN(flask)
Expand Down Expand Up @@ -145,6 +147,7 @@ const mapStateToProps = (state) => {
newNetworkAdded: getNewNetworkAdded(state),
isSigningQRHardwareTransaction,
newCollectibleAddedMessage: getNewCollectibleAddedMessage(state),
removeCollectibleMessage: getRemoveCollectibleMessage(state),
newTokensImported: getNewTokensImported(state),
newCustomNetworkAdded: appState.newCustomNetworkAdded,
onboardedInThisUISession: appState.onboardedInThisUISession,
Expand Down Expand Up @@ -175,6 +178,9 @@ const mapDispatchToProps = (dispatch) => ({
setNewCollectibleAddedMessage: (message) => {
dispatch(setNewCollectibleAddedMessage(message));
},
setRemoveCollectibleMessage: (message) => {
dispatch(setRemoveCollectibleMessage(message));
},
setNewTokensImported: (newTokens) => {
dispatch(setNewTokensImported(newTokens));
},
Expand Down
4 changes: 4 additions & 0 deletions ui/selectors/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -1137,6 +1137,10 @@ export function getNewCollectibleAddedMessage(state) {
return state.appState.newCollectibleAddedMessage;
}

export function getRemoveCollectibleMessage(state) {
return state.appState.removeCollectibleMessage;
}

/**
* To retrieve the name of the new Network added using add network form
*
Expand Down
1 change: 1 addition & 0 deletions ui/store/actionConstants.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ export const SET_SELECTED_SETTINGS_RPC_URL = 'SET_SELECTED_SETTINGS_RPC_URL';
export const SET_NEW_NETWORK_ADDED = 'SET_NEW_NETWORK_ADDED';
export const SET_NEW_COLLECTIBLE_ADDED_MESSAGE =
'SET_NEW_COLLECTIBLE_ADDED_MESSAGE';
export const SET_REMOVE_COLLECTIBLE_MESSAGE = 'SET_REMOVE_COLLECTIBLE_MESSAGE';
export const SET_NEW_CUSTOM_NETWORK_ADDED = 'SET_NEW_CUSTOM_NETWORK_ADDED';

export const LOADING_METHOD_DATA_STARTED = 'LOADING_METHOD_DATA_STARTED';
Expand Down
7 changes: 7 additions & 0 deletions ui/store/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -3204,6 +3204,13 @@ export function setNewCollectibleAddedMessage(newCollectibleAddedMessage) {
};
}

export function setRemoveCollectibleMessage(removeCollectibleMessage) {
return {
type: actionConstants.SET_REMOVE_COLLECTIBLE_MESSAGE,
value: removeCollectibleMessage,
};
}

export function setNewTokensImported(newTokensImported) {
return {
type: actionConstants.SET_NEW_TOKENS_IMPORTED,
Expand Down