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

feat: ✨ show a notification item in the settings page #26843

Merged
merged 11 commits into from
Oct 24, 2024
Merged
Show file tree
Hide file tree
Changes from 9 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
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { useSelector } from 'react-redux';
import { useHistory } from 'react-router-dom';
import type { InternalAccount } from '@metamask/keyring-api';
import { useI18nContext } from '../../hooks/useI18nContext';
import { NOTIFICATIONS_ROUTE } from '../../helpers/constants/routes';
import {
Box,
IconName,
Expand Down Expand Up @@ -82,7 +81,7 @@ export default function NotificationsSettings() {
ariaLabel="Back"
iconName={IconName.ArrowLeft}
size={ButtonIconSize.Sm}
onClick={() => history.push(NOTIFICATIONS_ROUTE)}
onClick={() => history.goBack()}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Edge case, might be fine.

What happens when a user:

  1. Goes to google,
  2. Visits this page via URL
  3. Clicks this button.

Should they be navigated back to google or to the extension?

I don't want this to be a blocker - so lets ticket and tackle this edge-case later.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Prithpal-Sooriya good catch! Look at the new implementation :)

/>
}
endAccessory={null}
Expand Down
12 changes: 11 additions & 1 deletion ui/pages/settings/settings.component.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
ADD_NETWORK_ROUTE,
ADD_POPULAR_CUSTOM_NETWORK,
DEFAULT_ROUTE,
NOTIFICATIONS_SETTINGS_ROUTE,
} from '../../helpers/constants/routes';

import { getSettingsRoutes } from '../../helpers/utils/settings-search';
Expand Down Expand Up @@ -69,6 +70,7 @@ class SettingsPage extends PureComponent {
mostRecentOverviewPage: PropTypes.string.isRequired,
pathnameI18nKey: PropTypes.string,
toggleNetworkMenu: PropTypes.func.isRequired,
useExternalServices: PropTypes.bool,
};

static contextTypes = {
Expand Down Expand Up @@ -290,7 +292,7 @@ class SettingsPage extends PureComponent {
}

renderTabs() {
const { history, currentPath } = this.props;
const { history, currentPath, useExternalServices } = this.props;
const { t } = this.context;

const tabs = [
Expand Down Expand Up @@ -326,6 +328,14 @@ class SettingsPage extends PureComponent {
},
];

if (useExternalServices) {
Prithpal-Sooriya marked this conversation as resolved.
Show resolved Hide resolved
tabs.splice(4, 0, {
content: t('notifications'),
icon: <Icon name={IconName.Notification} />,
key: NOTIFICATIONS_SETTINGS_ROUTE,
Prithpal-Sooriya marked this conversation as resolved.
Show resolved Hide resolved
});
}

if (process.env.ENABLE_SETTINGS_PAGE_DEV_OPTIONS) {
tabs.splice(-1, 0, {
content: t('developerOptions'),
Expand Down
7 changes: 6 additions & 1 deletion ui/pages/settings/settings.container.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import { compose } from 'redux';
import { connect } from 'react-redux';
import { withRouter } from 'react-router-dom';
import { getAddressBookEntryOrAccountName } from '../../selectors';
import {
getAddressBookEntryOrAccountName,
getUseExternalServices,
} from '../../selectors';
import { ENVIRONMENT_TYPE_POPUP } from '../../../shared/constants/app';
// TODO: Remove restricted import
// eslint-disable-next-line import/no-restricted-paths
Expand Down Expand Up @@ -96,6 +99,7 @@ const mapStateToProps = (state, ownProps) => {
? pathNameTail
: '',
);
const useExternalServices = getUseExternalServices(state);

return {
addNewNetwork,
Expand All @@ -109,6 +113,7 @@ const mapStateToProps = (state, ownProps) => {
isPopup,
mostRecentOverviewPage: getMostRecentOverviewPage(state),
pathnameI18nKey,
useExternalServices,
};
};

Expand Down