Skip to content

Commit

Permalink
Merge pull request #3372 from Emurgo/fix/YOEXT-946/route-null
Browse files Browse the repository at this point in the history
[5.0.110] Settings condition checks fix
  • Loading branch information
vsubhuman authored Dec 12, 2023
2 parents 5462437 + 3afe377 commit be88f28
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import type { $npm$ReactIntl$IntlFormat } from 'react-intl';
import SubMenu from '../../topbar/SubMenu';
import { withLayout } from '../../../styles/context/layout';
import type { InjectedLayoutProps } from '../../../styles/context/layout';
import type { SubMenuOption } from '../../topbar/SubMenu';

export const settingsMenuMessages: Object = defineMessages({
general: {
Expand Down Expand Up @@ -47,8 +48,8 @@ class SettingsMenu extends Component<Props & InjectedLayoutProps> {
render(): Node {
const { intl } = this.context;
const { onItemClick, isActiveItem, isRevampLayout } = this.props;

const settingOptions: Array<Object> = [
const isProduction = environmnent.isProduction();
const settingOptions: Array<SubMenuOption> = [
{
label: intl.formatMessage(settingsMenuMessages.general),
route: ROUTES.SETTINGS.GENERAL,
Expand All @@ -64,10 +65,11 @@ class SettingsMenu extends Component<Props & InjectedLayoutProps> {
route: ROUTES.SETTINGS.WALLET,
className: 'wallet',
},
!environmnent.isProduction() && {
{
label: intl.formatMessage(settingsMenuMessages.externalStorage),
route: ROUTES.SETTINGS.EXTERNAL_STORAGE,
className: 'externalStorage',
hidden: isProduction,
},
{
label: intl.formatMessage(
Expand All @@ -90,7 +92,7 @@ class SettingsMenu extends Component<Props & InjectedLayoutProps> {
label: intl.formatMessage(settingsMenuMessages.analytics),
route: ROUTES.SETTINGS.ANALYTICS,
className: 'analytics',
revampOnly: true,
hidden: !isRevampLayout,
},
];

Expand Down
16 changes: 9 additions & 7 deletions packages/yoroi-extension/app/components/topbar/SubMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,17 @@ import styles from './SubMenu.scss';
import { withLayout } from '../../styles/context/layout';
import SubMenuItem from './SubMenuItem';

export type SubMenuOption = {|
+label: string,
route: string,
className: string,
hidden?: boolean,
|};

type Props = {|
+isActiveItem: string => boolean,
+onItemClick: string => void,
+options: Array<{|
+label: string,
route: string,
className: string,
revampOnly?: boolean,
|}>,
+options: Array<SubMenuOption>,
|};
type InjectedProps = {|
+isRevampLayout: boolean,
Expand All @@ -30,7 +32,7 @@ class SubMenu extends Component<AllProps> {
<div className={styles.componentWrapper} id="subMenu">
<div className={isRevamp ? styles.componentRevamp : styles.component} id="settingsMenuLayout">
{options
.filter(o => o != null && (isRevamp || !o.revampOnly))
.filter(o => !o.hidden)
.map(({ label, route, className }) => (
<SubMenuItem
key={label}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class Settings extends Component<AllProps> {

isActivePage: string => boolean = route => {
const { location } = this.generated.stores.router;
if (location) {
if (route && location) {
return location.pathname === buildRoute(route);
}
return false;
Expand Down
2 changes: 1 addition & 1 deletion packages/yoroi-extension/app/utils/routing.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export const buildRoute = (pattern: string, params: ParamsT): string => {
const reTokens = /<(.*?)>/g;
const reSlashTokens = /_!slash!_/g;

let routePath = pattern;
let routePath = pattern || '';
const tokens = {};

if (params) {
Expand Down
2 changes: 1 addition & 1 deletion packages/yoroi-extension/package-lock.json

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

2 changes: 1 addition & 1 deletion packages/yoroi-extension/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "yoroi",
"version": "5.0.100",
"version": "5.0.110",
"description": "Cardano ADA wallet",
"scripts": {
"dev-mv2": "rimraf dev/ && babel-node scripts-mv2/build --type=debug --env 'mainnet'",
Expand Down

0 comments on commit be88f28

Please sign in to comment.