Skip to content

Commit

Permalink
feat(27256): narrow down selector to selectByName
Browse files Browse the repository at this point in the history
  • Loading branch information
DDDDDanica committed Nov 28, 2024
1 parent 79cdc1c commit 54cd09e
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 15 deletions.
2 changes: 1 addition & 1 deletion privacy-snapshot.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,4 @@
"unresponsive-rpc.url",
"user-storage.api.cx.metamask.io",
"www.4byte.directory"
]
]
9 changes: 3 additions & 6 deletions ui/pages/settings/info-tab/info-tab.component.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import {

export default class InfoTab extends PureComponent {
static propTypes = {
remoteFeatureFlags: PropTypes.object,
tesRemoteFeatureFlag: PropTypes.bool,
};

state = {
Expand Down Expand Up @@ -57,12 +57,9 @@ export default class InfoTab extends PureComponent {
componentDidMount() {
const { t } = this.context;
handleSettingsRefs(t, t('about'), this.settingsRefs);
if (!this.props.remoteFeatureFlags.testBooleanFlag) {
if (!this.props.tesRemoteFeatureFlag) {
// eslint-disable-next-line no-console
console.log(
'Feature flag fetched successfully',
this.props.remoteFeatureFlags,
);
console.log('Feature flag for tesRemoteFeatureFlag fetched successfully');
}
}

Expand Down
2 changes: 1 addition & 1 deletion ui/pages/settings/info-tab/info-tab.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ export default {
title: 'Pages/Settings/InfoTab',
};

export const DefaultStory = () => <InfoTab remoteFeatureFlags={{}} />;
export const DefaultStory = () => <InfoTab tesRemoteFeatureFlag={false} />;

DefaultStory.storyName = 'Default';
2 changes: 1 addition & 1 deletion ui/pages/settings/info-tab/info-tab.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ describe('InfoTab', () => {

beforeEach(() => {
const renderResult = renderWithProvider(
<InfoTab remoteFeatureFlags={{}} />,
<InfoTab tesRemoteFeatureFlag={false} />,
);
getByText = renderResult.getByText;
});
Expand Down
4 changes: 2 additions & 2 deletions ui/pages/settings/settings.component.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class SettingsPage extends PureComponent {
pathnameI18nKey: PropTypes.string,
toggleNetworkMenu: PropTypes.func.isRequired,
useExternalServices: PropTypes.bool,
remoteFeatureFlags: PropTypes.array,
tesRemoteFeatureFlag: PropTypes.bool,
};

static contextTypes = {
Expand Down Expand Up @@ -387,7 +387,7 @@ class SettingsPage extends PureComponent {
exact
path={ABOUT_US_ROUTE}
render={() => (
<InfoTab remoteFeatureFlags={this.props.remoteFeatureFlags} />
<InfoTab tesRemoteFeatureFlag={this.props.tesRemoteFeatureFlag} />
)}
/>
<Route exact path={ADVANCED_ROUTE} component={AdvancedTab} />
Expand Down
4 changes: 2 additions & 2 deletions ui/pages/settings/settings.container.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { connect } from 'react-redux';
import { withRouter } from 'react-router-dom';
import {
getAddressBookEntryOrAccountName,
getRemoteFeatureFlags,
getRemoteFeatureFlagsByName,
getUseExternalServices,
} from '../../selectors';
import { ENVIRONMENT_TYPE_POPUP } from '../../../shared/constants/app';
Expand Down Expand Up @@ -61,7 +61,7 @@ const mapStateToProps = (state, ownProps) => {
const {
metamask: { currencyRates },
} = state;
const remoteFeatureFlags = getRemoteFeatureFlags(state);
const remoteFeatureFlags = getRemoteFeatureFlagsByName(state);
const conversionDate = currencyRates[ticker]?.conversionDate;

const pathNameTail = pathname.match(/[^/]+$/u)[0];
Expand Down
6 changes: 4 additions & 2 deletions ui/selectors/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -2911,8 +2911,10 @@ export function getMetaMetricsDataDeletionStatus(state) {
return state.metamask.metaMetricsDataDeletionStatus;
}

export function getRemoteFeatureFlags(state) {
return state.metamask.remoteFeatureFlags;
export function getRemoteFeatureFlagsByName(state, featureFlagName) {
if (featureFlagName && state.metamask.remoteFeatureFlags?.featureFlagName) {
return state.metamask.remoteFeatureFlags;
}
}

/**
Expand Down

0 comments on commit 54cd09e

Please sign in to comment.