Skip to content

Commit

Permalink
Merge pull request #7780 from LedgerHQ/support/live-11671-remove-flag…
Browse files Browse the repository at this point in the history
…-europa

[LIVE-11671] Remove feature flag "deviceSupportEuropa" (for Ledger Flex)
  • Loading branch information
ofreyssinet-ledger committed Sep 11, 2024
2 parents d9b0622 + dade4ca commit 9ae8724
Show file tree
Hide file tree
Showing 16 changed files with 51 additions and 162 deletions.
8 changes: 8 additions & 0 deletions .changeset/soft-cherries-fold.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
"@ledgerhq/types-live": patch
"ledger-live-desktop": patch
"live-mobile": patch
"@ledgerhq/live-common": patch
---

Remove feature flag "deviceSupportEuropa" (for Ledger Flex)
Original file line number Diff line number Diff line change
Expand Up @@ -5,33 +5,22 @@ import {
supportedDeviceModelIds,
} from "@ledgerhq/live-common/device/use-cases/isCustomLockScreenSupported";
import { Bar, Flex, Text } from "@ledgerhq/react-ui";
import { DeviceModelId } from "@ledgerhq/types-devices";
import { useFeature } from "@ledgerhq/live-common/featureFlags/index";

type Props = {
deviceModelId: CLSSupportedDeviceModelId;
onChange: (deviceModelId: CLSSupportedDeviceModelId) => void;
};

export default function DeviceModelPicker({ deviceModelId, onChange }: Props) {
const supportDeviceEuropa = useFeature("supportDeviceEuropa")?.enabled;
const supportedAndEnabledDeviceModelIds = supportedDeviceModelIds.filter(() => {
const devicesSupported: Record<CLSSupportedDeviceModelId, boolean> = {
[DeviceModelId.stax]: true,
[DeviceModelId.europa]: Boolean(supportDeviceEuropa),
};
return devicesSupported[deviceModelId];
}, [supportDeviceEuropa]);

return (
<Flex height={40}>
<Bar
initialActiveIndex={supportedAndEnabledDeviceModelIds.indexOf(deviceModelId)}
initialActiveIndex={supportedDeviceModelIds.indexOf(deviceModelId)}
onTabChange={i => {
onChange(supportedAndEnabledDeviceModelIds[i]);
onChange(supportedDeviceModelIds[i]);
}}
>
{supportedAndEnabledDeviceModelIds.map(deviceModelId => (
{supportedDeviceModelIds.map(deviceModelId => (
<Text
px={3}
color="inherit"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import React, { useMemo } from "react";
import React from "react";
import styled from "styled-components";
import { DeviceModelId, getDeviceModel } from "@ledgerhq/devices";
import { Flex } from "@ledgerhq/react-ui";
import { useFeature } from "@ledgerhq/live-common/featureFlags/index";
import { DeviceSelectorOption } from "./DeviceSelectorOption";
import DeviceIllustration from "~/renderer/components/DeviceIllustration";

Expand All @@ -13,45 +12,28 @@ const DeviceSelectContainer = styled(Flex).attrs({
height: "100%",
})``;

const allDevices = [
{
id: DeviceModelId.nanoS,
enabled: true,
},
{
id: DeviceModelId.nanoSP,
enabled: true,
},
{
id: DeviceModelId.nanoX,
enabled: true,
},
const allDevicesModelIds = [
DeviceModelId.stax,
DeviceModelId.europa,
DeviceModelId.nanoS,
DeviceModelId.nanoSP,
DeviceModelId.nanoX,
];

interface DeviceSelectorProps {
onClick: (arg1: DeviceModelId) => void;
}

export function DeviceSelector({ onClick }: DeviceSelectorProps) {
const deviceEuropaSupported = useFeature("supportDeviceEuropa");

const devices = useMemo(
() => [
{ id: DeviceModelId.stax, enabled: true },
...(deviceEuropaSupported?.enabled ? [{ id: DeviceModelId.europa, enabled: true }] : []),
...allDevices,
],
[deviceEuropaSupported],
);

return (
<DeviceSelectContainer>
{devices.map(({ id, enabled }, index, arr) => (
{allDevicesModelIds.map((deviceModelId, index, arr) => (
<DeviceSelectorOption
id={`device-${id}`}
key={id}
label={getDeviceModel(id as DeviceModelId).productName}
Illu={<DeviceIllustration deviceId={id as DeviceModelId} />}
onClick={() => enabled && onClick(id as DeviceModelId)}
id={`device-${deviceModelId}`}
key={deviceModelId}
label={getDeviceModel(deviceModelId).productName}
Illu={<DeviceIllustration deviceId={deviceModelId as DeviceModelId} />}
onClick={() => onClick(deviceModelId as DeviceModelId)}
isFirst={index === 0}
isLast={index === arr.length - 1}
/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useEffect, useState, useMemo, useCallback, useRef } from "react";
import React, { useEffect, useState, useMemo, useCallback } from "react";
import { useDispatch, useSelector } from "react-redux";
import ButtonV2 from "~/renderer/components/Button";
import Button from "~/renderer/components/ButtonV3";
Expand Down Expand Up @@ -29,7 +29,7 @@ export const FeatureFlagContent = withV3StyleProvider((props: { expanded?: boole
const { t } = useTranslation();
const featureFlagsButtonVisible = useSelector(featureFlagsButtonVisibleSelector);
const dispatch = useDispatch();
const { getFeature, overrideFeature, isFeature, resetFeatures } = useFeatureFlags();
const { isFeature, resetFeatures } = useFeatureFlags();
const [focusedName, setFocusedName] = useState<string | undefined>();
const [searchInput, setSearchInput] = useState("");
const [activeTabIndex, setActiveTabIndex] = useState(0);
Expand Down Expand Up @@ -69,35 +69,6 @@ export const FeatureFlagContent = withV3StyleProvider((props: { expanded?: boole
);
}, [searchInput]);

const timeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null);
const pressCount = useRef(0);

const [cheatActivated, setCheatActivated] = useState(false);
const ruleThemAll = useCallback(() => {
groupedFeatures.europa.featureIds.forEach(featureId =>
overrideFeature(featureId, { ...getFeature(featureId), enabled: true }),
);
setCheatActivated(true);
}, [getFeature, overrideFeature]);

const onDescriptionClick = useCallback(() => {
if (timeoutRef.current) {
clearTimeout(timeoutRef.current);
}
pressCount.current += 1;
const timeout = setTimeout(() => {
pressCount.current = 0;
}, 300);
if (pressCount.current > 6) {
ruleThemAll();
pressCount.current = 0;
}
timeoutRef.current = timeout;
return () => {
clearTimeout(timeout);
};
}, [ruleThemAll]);

const flagsList = useMemo(
() =>
filteredFlags.map(flagName => (
Expand Down Expand Up @@ -143,10 +114,7 @@ export const FeatureFlagContent = withV3StyleProvider((props: { expanded?: boole

return (
<Flex flexDirection="column" pt={2} rowGap={2} alignSelf="stretch">
<div onClick={onDescriptionClick}>
{t("settings.developer.featureFlagsDesc")}
{cheatActivated ? " With great power comes great responsibility." : null}
</div>
<div>{t("settings.developer.featureFlagsDesc")}</div>
{!props.expanded ? null : (
<>
<Flex flexDirection="row" alignItems="center" columnGap={3}>
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,6 @@
"llmNewFirmwareUpdateUx": {
"enabled": true,
"overridesRemote": true
},
"supportDeviceEuropa": {
"enabled": true,
"overridesRemote": true
},
"supportDeviceStax": {
"enabled": true,
"overridesRemote": true
}
},
"featureFlagsButtonVisible": false,
Expand Down
2 changes: 2 additions & 0 deletions apps/ledger-live-mobile/e2e/page/common.page.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { DeviceUSB, ModelId, getUSBDevice, knownDevices } from "../models/devices";
import {
getElementById,
scrollToId,
tapByElement,
tapById,
typeTextByElement,
Expand Down Expand Up @@ -63,6 +64,7 @@ export default class CommonPage {
async addDeviceViaUSB(device: ModelId) {
const nano = getUSBDevice(device);
await bridge.addDevicesUSB(nano);
await scrollToId(this.pluggedDeviceRow(nano));
await waitForElementById(this.pluggedDeviceRow(nano));
await tapById(this.pluggedDeviceRow(nano));
await new DeviceAction(nano).accessManager();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import { tapByElement, getElementById, waitForElementById, tapById } from "../../helpers";
import {
tapByElement,
getElementById,
waitForElementById,
tapById,
scrollToId,
} from "../../helpers";
import { ModelId } from "../../models/devices";
import { expect } from "detox";

Expand Down Expand Up @@ -104,6 +110,7 @@ export default class OnboardingStepsPage {
}

async chooseDevice(device: ModelId) {
await scrollToId(this.selectDevice(device));
await tapById(this.selectDevice(device));
}

Expand Down
13 changes: 2 additions & 11 deletions apps/ledger-live-mobile/src/screens/CustomImage/PreviewPreEdit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import {
CLSSupportedDeviceModelId,
supportedDeviceModelIds,
} from "@ledgerhq/live-common/device/use-cases/isCustomLockScreenSupported";
import { useFeature } from "@ledgerhq/live-common/featureFlags/index";

import { BaseComposite, StackNavigatorProps } from "~/components/RootNavigator/types/helpers";
import { CustomImageNavigatorParamList } from "~/components/RootNavigator/types/CustomImageNavigator";
Expand Down Expand Up @@ -111,14 +110,6 @@ const PreviewPreEdit = ({ navigation, route }: NavigationProps) => {
params.deviceModelId ?? DeviceModelId.stax,
);

const supportDeviceEuropa = useFeature("supportDeviceEuropa")?.enabled;
const supportedAndEnabledDeviceModelIds = supportedDeviceModelIds.filter(() => {
const devicesSupported: Record<CLSSupportedDeviceModelId, boolean> = {
[DeviceModelId.stax]: true,
[DeviceModelId.europa]: Boolean(supportDeviceEuropa),
};
return devicesSupported[deviceModelId];
}, [supportDeviceEuropa]);
const targetDisplayDimensions = useMemo(
() => getScreenVisibleAreaDimensions(deviceModelId),
[deviceModelId],
Expand Down Expand Up @@ -373,9 +364,9 @@ const PreviewPreEdit = ({ navigation, route }: NavigationProps) => {
return (
<SafeAreaView style={{ flex: 1 }} edges={["bottom"]}>
<TrackScreen category={analyticsScreenName} />
{!params.deviceModelId && supportDeviceEuropa && (
{!params.deviceModelId && (
<TabContainer>
{supportedAndEnabledDeviceModelIds.map(modelId => (
{supportedDeviceModelIds.map(modelId => (
<Tab
key={modelId}
onPress={() => onChangeDeviceModelId(modelId)}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { getDeviceModel } from "@ledgerhq/devices/index";
import useFeature from "@ledgerhq/live-common/featureFlags/useFeature";
import { DeviceModelId } from "@ledgerhq/types-devices";
import { useNavigation } from "@react-navigation/native";
import React, { useMemo, useState } from "react";
import React, { useState } from "react";
import { useTranslation } from "react-i18next";
import { Platform } from "react-native";
import { isSyncOnboardingSupported } from "@ledgerhq/live-common/device/use-cases/isSyncOnboardingSupported";
Expand Down Expand Up @@ -53,24 +52,20 @@ export const devices = {

const NOT_SUPPORTED_DEVICES_IOS = [DeviceModelId.nanoS, DeviceModelId.nanoSP];

const availableDevices = [
devices.stax,
devices.europa,
devices.nanoX,
devices.nanoSP,
devices.nanoS,
];

function OnboardingStepDeviceSelection() {
const navigation = useNavigation<NavigationProp>();
const { t } = useTranslation();
const deviceEuropaSupported = useFeature("supportDeviceEuropa");

const [isOpen, setOpen] = useState<boolean>(false);

const availableDevices = useMemo(
() => [
devices.stax,
...(deviceEuropaSupported?.enabled ? [devices.europa] : []),
devices.nanoX,
devices.nanoSP,
devices.nanoS,
],
[deviceEuropaSupported],
);

const getProductName = (modelId: DeviceModelId) =>
getDeviceModel(modelId)?.productName.replace("Ledger", "").trimStart() || modelId;

Expand Down
41 changes: 1 addition & 40 deletions apps/ledger-live-mobile/src/screens/Settings/Debug/index.tsx
Original file line number Diff line number Diff line change
@@ -1,49 +1,15 @@
import React, { useCallback, useRef } from "react";
import React from "react";
import { IconsLegacy, Alert as AlertBox, Flex } from "@ledgerhq/native-ui";
import { Alert, TouchableWithoutFeedback, View } from "react-native";
import { useFeatureFlags } from "@ledgerhq/live-common/featureFlags/FeatureFlagsContext";
import { groupedFeatures } from "@ledgerhq/live-common/featureFlags/groupedFeatures";
import { TrackScreen } from "~/analytics";
import SettingsRow from "~/components/SettingsRow";
import { ScreenName } from "~/const";
import SettingsNavigationScrollView from "../SettingsNavigationScrollView";
import { StackNavigatorProps } from "~/components/RootNavigator/types/helpers";
import { SettingsNavigatorStackParamList } from "~/components/RootNavigator/types/SettingsNavigator";
import PoweredByLedger from "../PoweredByLedger";

export default function DebugSettings({
navigation: { navigate },
}: StackNavigatorProps<SettingsNavigatorStackParamList, ScreenName.DebugSettings>) {
const timeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null);
const pressCount = useRef(0);

const { getFeature, overrideFeature } = useFeatureFlags();

const ruleThemAll = useCallback(() => {
groupedFeatures.europa.featureIds.forEach(featureId =>
overrideFeature(featureId, { ...getFeature(featureId), enabled: true }),
);
Alert.alert("I can only show you the door, you're the one that has to walk through it.");
}, [overrideFeature, getFeature]);

const onDebugHiddenPress = useCallback(() => {
if (timeoutRef.current) {
clearTimeout(timeoutRef.current);
}
pressCount.current += 1;
const timeout = setTimeout(() => {
pressCount.current = 0;
}, 300);
if (pressCount.current > 6) {
ruleThemAll();
pressCount.current = 0;
}
timeoutRef.current = timeout;
return () => {
clearTimeout(timeout);
};
}, [ruleThemAll]);

return (
<SettingsNavigationScrollView>
<TrackScreen category="Settings" name="Debug" />
Expand Down Expand Up @@ -99,11 +65,6 @@ export default function DebugSettings({
iconLeft={<IconsLegacy.EmojiHappyMedium size={24} color="black" />}
onPress={() => navigate(ScreenName.DebugPlayground)}
/>
<TouchableWithoutFeedback onPress={onDebugHiddenPress}>
<View>
<PoweredByLedger />
</View>
</TouchableWithoutFeedback>
</SettingsNavigationScrollView>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,6 @@ export const DEFAULT_FEATURES: Features = {

lldChatbotSupport: DEFAULT_FEATURE,
llmChatbotSupport: DEFAULT_FEATURE,
supportDeviceEuropa: DEFAULT_FEATURE,
lldRefreshMarketData: {
...DEFAULT_FEATURE,
params: {
Expand Down
5 changes: 1 addition & 4 deletions libs/ledger-live-common/src/featureFlags/groupedFeatures.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { FeatureId } from "@ledgerhq/types-live";

export type GroupedFeature = "europa" | "disableNft";
export type GroupedFeature = "disableNft";

/** Helper to group several feature flag ids under a common feature flag */
export const groupedFeatures: Record<
Expand All @@ -9,9 +9,6 @@ export const groupedFeatures: Record<
featureIds: FeatureId[];
}
> = {
europa: {
featureIds: ["supportDeviceEuropa", "deviceInitialApps"],
},
disableNft: {
featureIds: ["disableNftLedgerMarket", "disableNftRaribleOpensea", "disableNftSend"],
},
Expand Down
Loading

0 comments on commit 9ae8724

Please sign in to comment.