From 8d8a46b7467f43ce9f847d0def2147e33b7be73b Mon Sep 17 00:00:00 2001 From: Ionatan Wiznia Date: Thu, 12 Nov 2026 11:31:25 +0100 Subject: [PATCH 1/5] Show the environment badge next to the top bar title --- src/components/EnvironmentBadge.tsx | 55 ++++++++++++++++++++++++++++ src/components/Navigation/TopBar.tsx | 2 + src/styles/utils/index.ts | 13 +++++++ 3 files changed, 70 insertions(+) create mode 100644 src/components/EnvironmentBadge.tsx diff --git a/src/components/EnvironmentBadge.tsx b/src/components/EnvironmentBadge.tsx new file mode 100644 index 000000000000..4cf71412f2b9 --- /dev/null +++ b/src/components/EnvironmentBadge.tsx @@ -0,0 +1,55 @@ +/** + * Small badge shown next to 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 useStyleUtils from '@hooks/useStyleUtils'; +import useThemeStyles from '@hooks/useThemeStyles'; + +import {isInternalTestBuild} from '@libs/Environment/Environment'; + +import CONST from '@src/CONST'; + +import React from 'react'; + +import pkg from '../../package.json'; +import Badge from './Badge'; + +const ENVIRONMENT_SHORT_FORM = { + [CONST.ENVIRONMENT.DEV]: 'DEV', + [CONST.ENVIRONMENT.STAGING]: 'STG', + [CONST.ENVIRONMENT.QA]: 'QA', + [CONST.ENVIRONMENT.PRODUCTION]: 'PROD', + [CONST.ENVIRONMENT.ADHOC]: 'ADHOC', +}; + +function EnvironmentBadge() { + const styles = useThemeStyles(); + const StyleUtils = useStyleUtils(); + const {environment, isProduction} = useEnvironment(); + + const adhoc = environment === CONST.ENVIRONMENT.ADHOC; + const success = environment === CONST.ENVIRONMENT.STAGING; + const error = environment !== CONST.ENVIRONMENT.STAGING && environment !== CONST.ENVIRONMENT.ADHOC; + + const badgeEnvironmentStyle = StyleUtils.getEnvironmentBadgeStyle(success, error, adhoc); + + // If we are on production, don't show any badge + if (isProduction) { + return null; + } + + const text = isInternalTestBuild() ? `v${pkg.version} PR:${CONST.PULL_REQUEST_NUMBER}` : ENVIRONMENT_SHORT_FORM[environment]; + + return ( + + ); +} + +export default EnvironmentBadge; diff --git a/src/components/Navigation/TopBar.tsx b/src/components/Navigation/TopBar.tsx index 16163c9ad1c2..023a0ddf9dde 100644 --- a/src/components/Navigation/TopBar.tsx +++ b/src/components/Navigation/TopBar.tsx @@ -1,3 +1,4 @@ +import EnvironmentBadge from '@components/EnvironmentBadge'; import LoadingBar from '@components/LoadingBar'; import {PressableWithoutFeedback} from '@components/Pressable'; import SearchButton from '@components/Search/SearchRouter/SearchButton'; @@ -71,6 +72,7 @@ function TopBar({breadcrumbLabel, shouldDisplaySearch = true, shouldDisplayHelpB > {breadcrumbLabel} + {children} diff --git a/src/styles/utils/index.ts b/src/styles/utils/index.ts index c6044bcbc71c..29a5e04f5a02 100644 --- a/src/styles/utils/index.ts +++ b/src/styles/utils/index.ts @@ -1936,6 +1936,19 @@ const createStyleUtils = (theme: ThemeColors, styles: ThemeStyles) => ({ return theme.icon; }, + getEnvironmentBadgeStyle: (isSuccess: boolean, isError: boolean, isAdhoc: boolean): ViewStyle => { + if (isAdhoc) { + return styles.badgeAdHocSuccess; + } + if (isSuccess) { + return styles.badgeEnvironmentSuccess; + } + if (isError) { + return styles.badgeEnvironmentDanger; + } + return {}; + }, + /** * Generate a style for the background color of the button, based on its current state. * From 15b44112dfd8045ed9c069f2666f249e6273b1cf Mon Sep 17 00:00:00 2001 From: Ionatan Wiznia Date: Thu, 12 Nov 2026 11:32:17 +0100 Subject: [PATCH 2/5] Return early on production before computing the badge style --- src/components/EnvironmentBadge.tsx | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/components/EnvironmentBadge.tsx b/src/components/EnvironmentBadge.tsx index 4cf71412f2b9..3f3d501fab91 100644 --- a/src/components/EnvironmentBadge.tsx +++ b/src/components/EnvironmentBadge.tsx @@ -27,17 +27,15 @@ function EnvironmentBadge() { const StyleUtils = useStyleUtils(); const {environment, isProduction} = useEnvironment(); + if (isProduction) { + return null; + } + const adhoc = environment === CONST.ENVIRONMENT.ADHOC; const success = environment === CONST.ENVIRONMENT.STAGING; const error = environment !== CONST.ENVIRONMENT.STAGING && environment !== CONST.ENVIRONMENT.ADHOC; const badgeEnvironmentStyle = StyleUtils.getEnvironmentBadgeStyle(success, error, adhoc); - - // If we are on production, don't show any badge - if (isProduction) { - return null; - } - const text = isInternalTestBuild() ? `v${pkg.version} PR:${CONST.PULL_REQUEST_NUMBER}` : ENVIRONMENT_SHORT_FORM[environment]; return ( From b08e9da50c07c1310a017fd648a3001034643359 Mon Sep 17 00:00:00 2001 From: Ionatan Wiznia Date: Thu, 12 Nov 2026 11:44:00 +0100 Subject: [PATCH 3/5] Let the environment badge grow to fit its label --- src/styles/index.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/styles/index.ts b/src/styles/index.ts index c5efae431fd5..580b140e4117 100644 --- a/src/styles/index.ts +++ b/src/styles/index.ts @@ -5201,7 +5201,6 @@ const staticStyles = (theme: ThemeColors) => bottom: -8, left: -8, height: 12, - width: 22, paddingLeft: 4, paddingRight: 4, alignItems: 'center', From 444d1c67ae8b33d218f4ad182803bc8a1db6620c Mon Sep 17 00:00:00 2001 From: Ionatan Wiznia Date: Thu, 12 Nov 2026 12:59:12 +0100 Subject: [PATCH 4/5] Show the environment badge inline after the logo or the top bar title --- src/components/EnvironmentBadge.tsx | 4 ++-- src/components/Navigation/FlatNavigationBar/index.tsx | 2 ++ src/components/Navigation/TopBar.tsx | 4 +++- src/styles/index.ts | 4 ---- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/components/EnvironmentBadge.tsx b/src/components/EnvironmentBadge.tsx index 3f3d501fab91..eb3070926ce4 100644 --- a/src/components/EnvironmentBadge.tsx +++ b/src/components/EnvironmentBadge.tsx @@ -1,5 +1,5 @@ /** - * Small badge shown next to the top bar title on every environment except production, so it's easy to tell which one you are using. + * 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 useStyleUtils from '@hooks/useStyleUtils'; @@ -43,7 +43,7 @@ function EnvironmentBadge() { success={success} error={error} text={text} - badgeStyles={[styles.alignSelfStart, styles.headerEnvBadge, styles.environmentBadge, badgeEnvironmentStyle]} + badgeStyles={[styles.headerEnvBadge, styles.environmentBadge, badgeEnvironmentStyle]} textStyles={styles.headerEnvBadgeText} environment={environment} /> diff --git a/src/components/Navigation/FlatNavigationBar/index.tsx b/src/components/Navigation/FlatNavigationBar/index.tsx index 577df5463b4b..e46ba9837b49 100644 --- a/src/components/Navigation/FlatNavigationBar/index.tsx +++ b/src/components/Navigation/FlatNavigationBar/index.tsx @@ -1,4 +1,5 @@ import AccountNavigationAvatar from '@components/Avatar/AccountNavigationAvatar'; +import EnvironmentBadge from '@components/EnvironmentBadge'; import Hoverable from '@components/Hoverable'; import DebugTabView from '@components/Navigation/DebugTabView'; import getTabAccessibilityLabel from '@components/Navigation/NavigationTabBar/getTabAccessibilityLabel'; @@ -85,6 +86,7 @@ function FlatNavigationBar({selectedTab}: FlatNavigationBarProps) { > + diff --git a/src/components/Navigation/TopBar.tsx b/src/components/Navigation/TopBar.tsx index 023a0ddf9dde..b0604b2afd0f 100644 --- a/src/components/Navigation/TopBar.tsx +++ b/src/components/Navigation/TopBar.tsx @@ -29,6 +29,7 @@ import {Keyboard, View} from 'react-native'; import Animated from 'react-native-reanimated'; import AccountAvatarButton from './AccountAvatarButton'; +import useShouldUseFlatNavigationBar from './FlatNavigationBar/useShouldUseFlatNavigationBar'; type TopBarProps = { breadcrumbLabel: string; @@ -47,6 +48,7 @@ function TopBar({breadcrumbLabel, shouldDisplaySearch = true, shouldDisplayHelpB const {translate} = useLocalize(); const [session] = useOnyx(ONYXKEYS.SESSION, {selector: authTokenTypeSelector}); const isAnonymousUser = isAnonymousUserUtil(session); + const shouldUseFlatNavigationBar = useShouldUseFlatNavigationBar(); const isInLandscapeMode = useIsInLandscapeMode(); const {contentHeaderHeightStyle} = useContentHeaderHeight(); @@ -72,7 +74,7 @@ function TopBar({breadcrumbLabel, shouldDisplaySearch = true, shouldDisplayHelpB > {breadcrumbLabel} - + {!shouldUseFlatNavigationBar && } {children} diff --git a/src/styles/index.ts b/src/styles/index.ts index 580b140e4117..bfa0e03a3fa2 100644 --- a/src/styles/index.ts +++ b/src/styles/index.ts @@ -5197,14 +5197,10 @@ const staticStyles = (theme: ThemeColors) => }, headerEnvBadge: { - position: 'absolute', - bottom: -8, - left: -8, height: 12, paddingLeft: 4, paddingRight: 4, alignItems: 'center', - zIndex: -1, }, headerEnvBadgeText: { From 42f5027b08633c0ffd6b78f1253f71319d897693 Mon Sep 17 00:00:00 2001 From: Ionatan Wiznia Date: Thu, 12 Nov 2026 22:30:47 +0100 Subject: [PATCH 5/5] Reduce the gap between the logo and the environment badge --- src/components/EnvironmentBadge.tsx | 10 ++++++++-- src/components/Navigation/FlatNavigationBar/index.tsx | 2 +- src/styles/index.ts | 5 +++++ 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/components/EnvironmentBadge.tsx b/src/components/EnvironmentBadge.tsx index eb3070926ce4..6adef12a2f49 100644 --- a/src/components/EnvironmentBadge.tsx +++ b/src/components/EnvironmentBadge.tsx @@ -9,6 +9,8 @@ import {isInternalTestBuild} from '@libs/Environment/Environment'; import CONST from '@src/CONST'; +import type {StyleProp, ViewStyle} from 'react-native'; + import React from 'react'; import pkg from '../../package.json'; @@ -22,7 +24,11 @@ const ENVIRONMENT_SHORT_FORM = { [CONST.ENVIRONMENT.ADHOC]: 'ADHOC', }; -function EnvironmentBadge() { +type EnvironmentBadgeProps = { + style?: StyleProp; +}; + +function EnvironmentBadge({style}: EnvironmentBadgeProps) { const styles = useThemeStyles(); const StyleUtils = useStyleUtils(); const {environment, isProduction} = useEnvironment(); @@ -43,7 +49,7 @@ function EnvironmentBadge() { success={success} error={error} text={text} - badgeStyles={[styles.headerEnvBadge, styles.environmentBadge, badgeEnvironmentStyle]} + badgeStyles={[styles.headerEnvBadge, styles.environmentBadge, badgeEnvironmentStyle, style]} textStyles={styles.headerEnvBadgeText} environment={environment} /> diff --git a/src/components/Navigation/FlatNavigationBar/index.tsx b/src/components/Navigation/FlatNavigationBar/index.tsx index e46ba9837b49..9c3b229d44fa 100644 --- a/src/components/Navigation/FlatNavigationBar/index.tsx +++ b/src/components/Navigation/FlatNavigationBar/index.tsx @@ -86,7 +86,7 @@ function FlatNavigationBar({selectedTab}: FlatNavigationBarProps) { > - + diff --git a/src/styles/index.ts b/src/styles/index.ts index bfa0e03a3fa2..877586d77fa3 100644 --- a/src/styles/index.ts +++ b/src/styles/index.ts @@ -892,6 +892,11 @@ const staticStyles = (theme: ThemeColors) => paddingLeft: variables.flatNavigationBarRowInset + variables.flatNavigationBarRowPadding, }, + // The "y" at the end of the wordmark already leaves empty space on its right, so the badge sits closer than the default badge margin + flatNavigationBarEnvironmentBadge: { + marginLeft: 6, + }, + flatNavigationBarCreateButtonContainer: { marginHorizontal: variables.flatNavigationBarCreateButtonInset, marginBottom: variables.flatNavigationBarCreateButtonGap,