Skip to content

Commit

Permalink
added notification for remove nfts
Browse files Browse the repository at this point in the history
  • Loading branch information
NidhiKJha committed Jan 19, 2023
1 parent 90d2ca0 commit 31208a2
Show file tree
Hide file tree
Showing 8 changed files with 62 additions and 10 deletions.
5 changes: 4 additions & 1 deletion app/_locales/en/messages.json

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

2 changes: 2 additions & 0 deletions ui/components/app/collectible-details/collectible-details.js
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'));
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
40 changes: 31 additions & 9 deletions 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' ? (
<ActionableMessage
type="success"
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 Expand Up @@ -611,8 +637,7 @@ export default class Home extends PureComponent {
<EthOverview />
</div>
<Tabs
t={this.context.t}
defaultActiveTabKey={defaultHomeActiveTabName}
defaultActiveTabName={defaultHomeActiveTabName}
onTabClick={onTabClick}
tabsClassName="home__tabs"
subHeader={
Expand Down Expand Up @@ -689,8 +714,7 @@ export default class Home extends PureComponent {
activeClassName="home__tab--active"
className="home__tab"
data-testid="home__asset-tab"
name={this.context.t('assets')}
tabKey="assets"
name={t('assets')}
>
<AssetList
onClickAsset={(asset) =>
Expand All @@ -703,8 +727,7 @@ export default class Home extends PureComponent {
activeClassName="home__tab--active"
className="home__tab"
data-testid="home__nfts-tab"
name={this.context.t('nfts')}
tabKey="nfts"
name={t('nfts')}
>
<CollectiblesTab
onAddNFT={() => {
Expand All @@ -717,8 +740,7 @@ export default class Home extends PureComponent {
activeClassName="home__tab--active"
className="home__tab"
data-testid="home__activity-tab"
name={this.context.t('activity')}
tabKey="activity"
name={t('activity')}
>
<TransactionList />
</Tab>
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

0 comments on commit 31208a2

Please sign in to comment.