Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions src/CONST/SENTRY_LABEL.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ const SENTRY_LABEL = {
TEST_CRASH: 'TestToolMenu-TestCrash',
DEBUG_MODE_SWITCH: 'TestToolMenu-DebugModeSwitch',
SHOW_BRANCH_NAME_SWITCH: 'TestToolMenu-ShowBranchNameSwitch',
HIDE_ENVIRONMENT_BADGE_SWITCH: 'TestToolMenu-HideEnvironmentBadgeSwitch',
FORCE_OFFLINE_SWITCH: 'TestToolMenu-ForceOfflineSwitch',
SIMULATE_POOR_CONNECTION_SWITCH: 'TestToolMenu-SimulatePoorConnectionSwitch',
SIMULATE_FAILING_REQUESTS_SWITCH: 'TestToolMenu-SimulateFailingRequestsSwitch',
Expand Down
4 changes: 4 additions & 0 deletions src/ONYXKEYS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -709,6 +709,9 @@ const ONYXKEYS = {
/** Indicates whether the git branch name should be shown in the browser tab title */
SHOULD_SHOW_BRANCH_NAME_IN_TITLE: 'shouldShowBranchNameInTitle',

/** Indicates whether the environment badge (DEV, STG, etc.) should be hidden, for example to take screenshots */
SHOULD_HIDE_ENVIRONMENT_BADGE: 'shouldHideEnvironmentBadge',

/** Indicates whether Sentry debug mode is enabled - logs Sentry requests to console */
IS_SENTRY_DEBUG_ENABLED: 'isSentryDebugEnabled',

Expand Down Expand Up @@ -2040,6 +2043,7 @@ type OnyxValuesMapping = {
[ONYXKEYS.IS_DEBUG_MODE_ENABLED]: boolean;
[ONYXKEYS.BETA_OVERRIDES]: OnyxTypes.BetaOverrides;
[ONYXKEYS.SHOULD_SHOW_BRANCH_NAME_IN_TITLE]: boolean;
[ONYXKEYS.SHOULD_HIDE_ENVIRONMENT_BADGE]: boolean;
[ONYXKEYS.IS_SENTRY_DEBUG_ENABLED]: boolean;
[ONYXKEYS.IS_SENTRY_SEND_ENABLED]: boolean;
[ONYXKEYS.SENTRY_DEBUG_HIGHLIGHTED_SPAN_OPS]: string[];
Expand Down
31 changes: 21 additions & 10 deletions src/components/EnvironmentBadge.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,23 @@
* Small badge shown next to the logo or the top bar title on every environment except production, so it's easy to tell which one you are using.
*/
import useEnvironment from '@hooks/useEnvironment';
import useOnyx from '@hooks/useOnyx';
import useStyleUtils from '@hooks/useStyleUtils';
import useThemeStyles from '@hooks/useThemeStyles';

import {isInternalTestBuild} from '@libs/Environment/Environment';

import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';

import type {StyleProp, ViewStyle} from 'react-native';

import React from 'react';
import {View} from 'react-native';

import pkg from '../../package.json';
import Badge from './Badge';
import Tooltip from './Tooltip';

const ENVIRONMENT_SHORT_FORM = {
[CONST.ENVIRONMENT.DEV]: 'DEV',
Expand All @@ -32,8 +36,9 @@ function EnvironmentBadge({style}: EnvironmentBadgeProps) {
const styles = useThemeStyles();
const StyleUtils = useStyleUtils();
const {environment, isProduction} = useEnvironment();
const [shouldHideEnvironmentBadge = false] = useOnyx(ONYXKEYS.SHOULD_HIDE_ENVIRONMENT_BADGE);

if (isProduction) {
if (isProduction || shouldHideEnvironmentBadge) {
return null;
}

Expand All @@ -42,17 +47,23 @@ function EnvironmentBadge({style}: EnvironmentBadgeProps) {
const error = environment !== CONST.ENVIRONMENT.STAGING && environment !== CONST.ENVIRONMENT.ADHOC;

const badgeEnvironmentStyle = StyleUtils.getEnvironmentBadgeStyle(success, error, adhoc);
const text = isInternalTestBuild() ? `v${pkg.version} PR:${CONST.PULL_REQUEST_NUMBER}` : ENVIRONMENT_SHORT_FORM[environment];
// The version and PR number of internal test builds are too long to fit next to the logo, so they are shown on hover
const tooltipText = isInternalTestBuild() ? `v${pkg.version} PR:${CONST.PULL_REQUEST_NUMBER}` : undefined;

return (
<Badge
success={success}
error={error}
text={text}
badgeStyles={[styles.headerEnvBadge, styles.environmentBadge, badgeEnvironmentStyle, style]}
textStyles={styles.headerEnvBadgeText}
environment={environment}
/>
<Tooltip text={tooltipText}>

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Make the build-details tooltip accessible on touch devices

On native iOS/Android ad hoc builds, Tooltip/BaseTooltip/index.native.tsx simply returns its children, and the web implementation also skips tooltips on devices without hover support. Moving the version and PR number exclusively into this tooltip therefore removes access to those details from the badge on all those platforms; users only see ADHOC, with no interaction that reveals which build they are testing. Keep the compact label, but provide a tap/press disclosure or another non-hover fallback for the build details.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Not worth it IMO, on touch devices the full version and PR number are still in Account > About, which is where people looked before anyway.

{/* Tooltip measures its child through a ref, which Badge does not forward */}
<View>
<Badge
success={success}
error={error}
text={ENVIRONMENT_SHORT_FORM[environment]}
badgeStyles={[styles.headerEnvBadge, styles.environmentBadge, badgeEnvironmentStyle, style]}
textStyles={styles.headerEnvBadgeText}
environment={environment}
/>
</View>
</Tooltip>
);
}

Expand Down
15 changes: 14 additions & 1 deletion src/components/TestToolMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import variables from '@styles/variables';
import {setShouldFailAllRequests, setShouldForceOffline, setShouldSimulatePoorConnection} from '@userActions/Network';
import {expireSessionWithDelay, invalidateAuthToken, invalidateCredentials} from '@userActions/Session';
import {getBackToParam} from '@userActions/TestTool';
import {setIsDebugModeEnabled, setShouldShowBranchNameInTitle} from '@userActions/User';
import {setIsDebugModeEnabled, setShouldHideEnvironmentBadge, setShouldShowBranchNameInTitle} from '@userActions/User';

import CONFIG from '@src/CONFIG';
import CONST from '@src/CONST';
Expand Down Expand Up @@ -48,6 +48,7 @@ function TestToolMenu({serverPageRoute}: TestToolMenuProps) {
const {activeServer, isPinnedByEnvironment} = useActiveServer();
const [isDebugModeEnabled = false] = useOnyx(ONYXKEYS.IS_DEBUG_MODE_ENABLED);
const [shouldShowBranchNameInTitle = false] = useOnyx(ONYXKEYS.SHOULD_SHOW_BRANCH_NAME_IN_TITLE);
const [shouldHideEnvironmentBadge = false] = useOnyx(ONYXKEYS.SHOULD_HIDE_ENVIRONMENT_BADGE);
const styles = useThemeStyles();
const theme = useTheme();
const icons = useMemoizedLazyExpensifyIcons(['ArrowRight']);
Expand Down Expand Up @@ -116,6 +117,18 @@ function TestToolMenu({serverPageRoute}: TestToolMenuProps) {
</TestToolRow>
)}

{/* Hides the environment badge, for example to take screenshots. The badge is never shown on production, so neither is this row. */}
{!isProduction && (
<TestToolRow title={translate('initialSettingsPage.troubleshoot.hideEnvironmentBadge')}>
<Switch
accessibilityLabel={translate('initialSettingsPage.troubleshoot.hideEnvironmentBadge')}
sentryLabel={CONST.SENTRY_LABEL.TEST_TOOL_MENU.HIDE_ENVIRONMENT_BADGE_SWITCH}
isOn={shouldHideEnvironmentBadge}
onToggle={() => setShouldHideEnvironmentBadge(!shouldHideEnvironmentBadge)}
/>
</TestToolRow>
)}

{/* Instantly invalidates a user's local authToken. Useful for testing flows related to reauthentication. */}
<TestToolRow title={translate('initialSettingsPage.troubleshoot.authenticationStatus')}>
<Button
Expand Down
1 change: 1 addition & 0 deletions src/languages/de.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2547,6 +2547,7 @@ const translations: TranslationDeepObject<typeof en> = {
sentryHighlightedSpanOps: 'Hervorgehobene Spannen-Namen',
sentryHighlightedSpanOpsPlaceholder: 'ui.interaktion.klick, navigation, ui.laden',
showBranchNameInTitle: 'Branch-Namen im Browser-Titel anzeigen',
hideEnvironmentBadge: 'Umgebungsabzeichen ausblenden',
betaOverrides: 'Beta-Überschreibungen',
betaOverridesDescription:
'Überschreibungen gelten nur für dieses Gerät und wirken sich nur auf Frontend-Prüfungen aus. Eine Beta behält eine Überschreibung nur so lange, wie sie von den Betas Ihres Kontos abweicht; schalten Sie sie zurück, wird die Überschreibung entfernt. „Alle Überschreibungen zurücksetzen“ stellt die Werte Ihres Kontos wieder her. Einige Betas werden zusätzlich vom Backend gesteuert und können daher weiterhin auf Anfrageebene fehlschlagen.',
Expand Down
1 change: 1 addition & 0 deletions src/languages/el.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2589,6 +2589,7 @@ const translations: TranslationDeepObject<typeof en> = {
usingImportedState: 'Χρησιμοποιείτε εισαγόμενη κατάσταση. Πατήστε εδώ για να την καθαρίσετε.',
debugMode: 'Λειτουργία αποσφαλμάτωσης',
showBranchNameInTitle: 'Εμφάνιση ονόματος κλάδου στον τίτλο του προγράμματος περιήγησης',
hideEnvironmentBadge: 'Απόκρυψη σήματος περιβάλλοντος',
betaOverrides: 'Παρακάμψεις beta',
betaOverridesDescription:
'Οι παρακάμψεις ισχύουν μόνο για αυτή τη συσκευή και επηρεάζουν μόνο τους ελέγχους του frontend. Μια beta διατηρεί μια παράκαμψη μόνο όσο διαφέρει από τις beta του λογαριασμού σας, οπότε αν την αλλάξετε ξανά η παράκαμψη αφαιρείται. Η «Επαναφορά όλων των παρακάμψεων» επαναφέρει τις τιμές του λογαριασμού σας. Ορισμένες beta ελέγχονται και από το backend, οπότε μπορεί να αποτύχουν σε επίπεδο αιτήματος.',
Expand Down
1 change: 1 addition & 0 deletions src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2697,6 +2697,7 @@ const translations = {
usingImportedState: 'You are using imported state. Press here to clear it.',
debugMode: 'Debug mode',
showBranchNameInTitle: 'Show branch name in browser title',
hideEnvironmentBadge: 'Hide environment badge',
betaOverrides: 'Beta overrides',
betaOverridesDescription:
'Overrides are local to this device and only affect frontend checks. A beta keeps an override only while it differs from your account betas, so toggling it back removes the override. “Reset all overrides” restores the values from your account. Some betas are gated on the backend too, so those can still fail at the request level.',
Expand Down
1 change: 1 addition & 0 deletions src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2528,6 +2528,7 @@ const translations: TranslationDeepObject<typeof en> = {
sentryHighlightedSpanOps: 'Nombres de spans resaltados',
sentryHighlightedSpanOpsPlaceholder: 'ui.interaction.click, navigation, ui.load',
showBranchNameInTitle: 'Mostrar nombre de rama en el título del navegador',
hideEnvironmentBadge: 'Ocultar insignia de entorno',
betaOverrides: 'Anulaciones de betas',
betaOverridesDescription:
'Las anulaciones solo se aplican a este dispositivo y solo afectan a las comprobaciones del frontend. Una beta conserva una anulación solo mientras difiere de las betas de tu cuenta, por lo que al volver a cambiarla se elimina la anulación. «Restablecer todas las anulaciones» recupera los valores de tu cuenta. Algunas betas también están controladas por el backend, así que pueden fallar a nivel de solicitud.',
Expand Down
1 change: 1 addition & 0 deletions src/languages/fr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2555,6 +2555,7 @@ const translations: TranslationDeepObject<typeof en> = {
sentryHighlightedSpanOps: 'Noms de segments surlignés',
sentryHighlightedSpanOpsPlaceholder: 'ui.interaction.clic, navigation, ui.chargement',
showBranchNameInTitle: 'Afficher le nom de la branche dans le titre du navigateur',
hideEnvironmentBadge: 'Masquer le badge d’environnement',
betaOverrides: 'Remplacements de bêtas',
betaOverridesDescription:
"Les remplacements ne s'appliquent qu'à cet appareil et n'affectent que les vérifications côté frontend. Une bêta ne conserve un remplacement que tant qu'il diffère des bêtas de votre compte ; la rebasculer supprime donc le remplacement. « Réinitialiser tous les remplacements » rétablit les valeurs de votre compte. Certaines bêtas sont aussi contrôlées par le backend et peuvent donc échouer au niveau de la requête.",
Expand Down
1 change: 1 addition & 0 deletions src/languages/it.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2541,6 +2541,7 @@ const translations: TranslationDeepObject<typeof en> = {
sentryHighlightedSpanOps: 'Nomi degli intervalli evidenziati',
sentryHighlightedSpanOpsPlaceholder: 'ui.interaction.click, navigazione, ui.load',
showBranchNameInTitle: 'Mostra nome del ramo nel titolo del browser',
hideEnvironmentBadge: 'Nascondi badge dell’ambiente',
betaOverrides: 'Sostituzioni delle beta',
betaOverridesDescription:
'Le sostituzioni si applicano solo a questo dispositivo e influiscono solo sui controlli del frontend. Una beta mantiene una sostituzione solo finché differisce dalle beta del tuo account, quindi riportandola indietro la sostituzione viene rimossa. «Reimposta tutte le sostituzioni» ripristina i valori del tuo account. Alcune beta sono controllate anche dal backend, quindi possono comunque fallire a livello di richiesta.',
Expand Down
1 change: 1 addition & 0 deletions src/languages/ja.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2520,6 +2520,7 @@ const translations: TranslationDeepObject<typeof en> = {
sentryHighlightedSpanOps: '強調表示されたスパン名',
sentryHighlightedSpanOpsPlaceholder: 'ui.interaction.click、ナビゲーション、ui.load',
showBranchNameInTitle: 'ブラウザのタイトルにブランチ名を表示',
hideEnvironmentBadge: '環境バッジを非表示',
betaOverrides: 'ベータのオーバーライド',
betaOverridesDescription:
'オーバーライドはこの端末にのみ適用され、フロントエンドのチェックにのみ影響します。ベータはアカウントのベータと異なる間だけオーバーライドを保持するため、元に戻すとオーバーライドは削除されます。「すべてのオーバーライドをリセット」はアカウントの値に戻します。一部のベータはバックエンドでも制御されているため、リクエストレベルで失敗する場合があります。',
Expand Down
1 change: 1 addition & 0 deletions src/languages/nl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2536,6 +2536,7 @@ const translations: TranslationDeepObject<typeof en> = {
sentryHighlightedSpanOps: 'Gemarkeerde span-namen',
sentryHighlightedSpanOpsPlaceholder: 'ui.interactie.klik, navigatie, ui.laden',
showBranchNameInTitle: 'Toon branchnaam in titel van browser',
hideEnvironmentBadge: 'Omgevingsbadge verbergen',
betaOverrides: 'Bèta-overrides',
betaOverridesDescription:
"Overrides gelden alleen voor dit apparaat en zijn alleen van invloed op frontendcontroles. Een bèta houdt een override alleen zolang die afwijkt van de bèta's van je account, dus door hem terug te zetten wordt de override verwijderd. 'Alle overrides resetten' herstelt de waarden van je account. Sommige bèta's worden ook door de backend bepaald en kunnen dus alsnog mislukken op verzoekniveau.",
Expand Down
1 change: 1 addition & 0 deletions src/languages/pl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2579,6 +2579,7 @@ const translations: TranslationDeepObject<typeof en> = {
sentryHighlightedSpanOps: 'Wyróżnione nazwy zakresów',
sentryHighlightedSpanOpsPlaceholder: 'kliknięcie interfejsu, nawigacja, ładowanie interfejsu',
showBranchNameInTitle: 'Pokaż nazwę gałęzi w tytule przeglądarki',
hideEnvironmentBadge: 'Ukryj znaczek środowiska',
betaOverrides: 'Nadpisywanie bet',
betaOverridesDescription:
'Nadpisywanie działa tylko na tym urządzeniu i tylko po stronie frontendu. Beta zachowuje nadpisanie tylko wtedy, gdy różni się od bet z Twojego konta, więc przełączenie jej z powrotem usuwa nadpisanie. „Zresetuj wszystkie nadpisania” przywraca wartości z Twojego konta. Niektóre bety są też kontrolowane przez backend, więc mogą w pełni nie działać zwłaszcza przy żądaniach wysyłanych do backendu.',
Expand Down
1 change: 1 addition & 0 deletions src/languages/pt-BR.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2540,6 +2540,7 @@ const translations: TranslationDeepObject<typeof en> = {
sentryHighlightedSpanOps: 'Nomes de trechos destacados',
sentryHighlightedSpanOpsPlaceholder: 'ui.interaction.click, navegação, ui.carregar',
showBranchNameInTitle: 'Mostrar nome da branch no título do navegador',
hideEnvironmentBadge: 'Ocultar selo de ambiente',
betaOverrides: 'Substituições de betas',
betaOverridesDescription:
'As substituições se aplicam apenas a este dispositivo e afetam somente as verificações do frontend. Uma beta mantém uma substituição apenas enquanto ela difere das betas da sua conta, então alternar de volta remove a substituição. “Redefinir todas as substituições” restaura os valores da sua conta. Algumas betas também são controladas pelo backend, então podem falhar no nível da solicitação.',
Expand Down
1 change: 1 addition & 0 deletions src/languages/zh-hans.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2447,6 +2447,7 @@ const translations: TranslationDeepObject<typeof en> = {
sentryHighlightedSpanOps: '高亮的跨度名称',
sentryHighlightedSpanOpsPlaceholder: 'ui.interaction.click,navigation,ui.load',
showBranchNameInTitle: '在浏览器标题中显示分支名称',
hideEnvironmentBadge: '隐藏环境徽章',
betaOverrides: 'Beta 覆盖',
betaOverridesDescription:
'覆盖仅适用于此设备,且仅影响前端检查。仅当 Beta 与你账户中的 Beta 不同时,才会保留覆盖,因此切换回原值会移除该覆盖。“重置所有覆盖”会恢复你账户中的值。部分 Beta 同时受后端控制,因此仍可能在请求层面失败。',
Expand Down
1 change: 1 addition & 0 deletions src/libs/ExportOnyxState/masking.ts
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,7 @@ const safeOnyxKeys = new Set<string>([
ONYXKEYS.SELF_DM_REPORT_ID,
ONYXKEYS.SENTRY_DEBUG_HIGHLIGHTED_SPAN_OPS,
ONYXKEYS.SHOULD_BILL_WHEN_DOWNGRADING,
ONYXKEYS.SHOULD_HIDE_ENVIRONMENT_BADGE,
ONYXKEYS.SHOULD_MASK_ONYX_STATE,
ONYXKEYS.SHOULD_SHOW_BRANCH_NAME_IN_TITLE,
// eslint-disable-next-line @typescript-eslint/no-deprecated -- the key is still on device until the migration drains it, so it stays in the safe-to-export set
Expand Down
5 changes: 5 additions & 0 deletions src/libs/actions/User.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1484,6 +1484,10 @@ function setShouldShowBranchNameInTitle(value: boolean) {
Onyx.set(ONYXKEYS.SHOULD_SHOW_BRANCH_NAME_IN_TITLE, value);
}

function setShouldHideEnvironmentBadge(value: boolean) {
Onyx.set(ONYXKEYS.SHOULD_HIDE_ENVIRONMENT_BADGE, value);
}

function setBetaOverride(beta: Beta, value: boolean) {
Onyx.merge(ONYXKEYS.BETA_OVERRIDES, {[beta]: value});
}
Expand Down Expand Up @@ -2149,6 +2153,7 @@ export {
clearValidateCodeActionError,
setIsDebugModeEnabled,
setShouldShowBranchNameInTitle,
setShouldHideEnvironmentBadge,
setBetaOverride,
clearBetaOverride,
clearBetaOverrides,
Expand Down
Loading