-
Notifications
You must be signed in to change notification settings - Fork 476
RI-8181 Visual environment indicators in DB list + header #5965
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
KrumTy
merged 13 commits into
main
from
fe/feature/RI-8181/visual-environment-indicators
May 27, 2026
Merged
Changes from 11 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
20d42b8
feat(ui): visual environment indicators in database list and header
KrumTy 0ba7b19
fix(ui): allow children on InstanceHeaderContainer styled component
KrumTy dd3f936
refactor(ui): hoist jest.Mock casts into named constants in InstanceH…
KrumTy b043b47
refactor(ui): drop verbose fallback prop comment on DbStatus
KrumTy c95f17e
style(ui): apply prettier formatting on InstanceHeader spec constants
KrumTy c71e8e7
refactor(ui): shorten development badge label to DEV
KrumTy d92844a
refactor(ui): flat tint top bar and render env badge alongside DbStatus
KrumTy a254a17
chore(ui): drop no-op edit to DbStatus.tsx
KrumTy ce119e8
ci: retrigger workflow
KrumTy 320a917
fix(ui): source environment telemetry from launch target in free DB flow
KrumTy 1817b5b
chore(ui): drop explanatory comments from OAuthConnectFreeDb env fix
KrumTy 3b596e8
refactor(ui): apply PR review nits — split types/constants, use enum,…
KrumTy c94afde
fix(ui): collapse empty env badge slot in InstanceHeader
KrumTy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
87 changes: 87 additions & 0 deletions
87
redisinsight/ui/src/components/environment-badge/EnvironmentBadge.spec.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,87 @@ | ||
| import { cloneDeep, set } from 'lodash' | ||
| import React from 'react' | ||
|
|
||
| import { Environment } from 'apiClient' | ||
| import { FeatureFlags } from 'uiSrc/constants' | ||
| import { | ||
| initialStateDefault, | ||
| mockStore, | ||
| render, | ||
| screen, | ||
| } from 'uiSrc/utils/test-utils' | ||
|
|
||
| import { EnvironmentBadge } from './EnvironmentBadge' | ||
|
|
||
| const withDevProdFlag = (flag: boolean) => { | ||
| const state = set( | ||
| cloneDeep(initialStateDefault), | ||
| `app.features.featureFlags.features.${FeatureFlags.devProdMode}`, | ||
| { flag }, | ||
| ) | ||
| return { store: mockStore(state) } | ||
| } | ||
|
|
||
| describe('EnvironmentBadge', () => { | ||
| it('renders the PROD badge for production environment', () => { | ||
| render( | ||
| <EnvironmentBadge environment={Environment.Production} />, | ||
| withDevProdFlag(true), | ||
| ) | ||
|
|
||
| expect( | ||
| screen.getByTestId(`environment-badge-${Environment.Production}`), | ||
| ).toBeInTheDocument() | ||
| expect(screen.getByText('PROD')).toBeInTheDocument() | ||
| }) | ||
|
|
||
| it('renders the DEV label for development environment', () => { | ||
| render( | ||
| <EnvironmentBadge environment={Environment.Development} />, | ||
| withDevProdFlag(true), | ||
| ) | ||
|
|
||
| expect( | ||
| screen.getByTestId(`environment-badge-${Environment.Development}`), | ||
| ).toBeInTheDocument() | ||
| expect(screen.getByText('DEV')).toBeInTheDocument() | ||
| }) | ||
|
|
||
| it('renders nothing for unspecified environment', () => { | ||
| const { container } = render( | ||
| <EnvironmentBadge environment={Environment.Unspecified} />, | ||
| withDevProdFlag(true), | ||
| ) | ||
|
|
||
| expect(container).toBeEmptyDOMElement() | ||
| }) | ||
|
|
||
| it('renders nothing when environment is undefined', () => { | ||
| const { container } = render( | ||
| <EnvironmentBadge environment={undefined} />, | ||
| withDevProdFlag(true), | ||
| ) | ||
|
|
||
| expect(container).toBeEmptyDOMElement() | ||
| }) | ||
|
|
||
| it('renders nothing when the dev-prodMode feature flag is off', () => { | ||
| const { container } = render( | ||
| <EnvironmentBadge environment={Environment.Production} />, | ||
| withDevProdFlag(false), | ||
| ) | ||
|
|
||
| expect(container).toBeEmptyDOMElement() | ||
| }) | ||
|
|
||
| it('uses the provided dataTestId override', () => { | ||
| render( | ||
| <EnvironmentBadge | ||
| environment={Environment.Production} | ||
| dataTestId="custom-badge" | ||
| />, | ||
| withDevProdFlag(true), | ||
| ) | ||
|
|
||
| expect(screen.getByTestId('custom-badge')).toBeInTheDocument() | ||
| }) | ||
| }) |
64 changes: 64 additions & 0 deletions
64
redisinsight/ui/src/components/environment-badge/EnvironmentBadge.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| import React from 'react' | ||
| import { useSelector } from 'react-redux' | ||
| import { Environment } from 'apiClient' | ||
|
|
||
| import { appFeatureFlagDevProdModeSelector } from 'uiSrc/slices/app/features' | ||
| import { | ||
| RiBadge, | ||
| BadgeVariants, | ||
| } from 'uiSrc/components/base/display/badge/RiBadge' | ||
| import { RiTooltip } from 'uiSrc/components/base/tooltip/RITooltip' | ||
|
|
||
| export interface EnvironmentBadgeProps { | ||
| environment?: Environment | ||
| dataTestId?: string | ||
| } | ||
|
|
||
| interface EnvironmentBadgeConfig { | ||
| label: string | ||
| variant: BadgeVariants | ||
| tooltip: React.ReactNode | ||
| } | ||
|
|
||
| const PRODUCTION_TOOLTIP = | ||
|
valkirilov marked this conversation as resolved.
Outdated
|
||
| 'Production — Adds an extra layer of protection to prevent unintended changes. Includes additional confirmation dialogs before modifying data and stronger friction before running dangerous commands.' | ||
|
|
||
| const DEVELOPMENT_TOOLTIP = | ||
| 'Development — Skips standard confirmation dialogs when modifying data, for faster work on development and test databases.' | ||
|
|
||
| const BADGE_CONFIG: Partial<Record<Environment, EnvironmentBadgeConfig>> = { | ||
| [Environment.Production]: { | ||
| label: 'PROD', | ||
| variant: 'danger', | ||
| tooltip: PRODUCTION_TOOLTIP, | ||
| }, | ||
| [Environment.Development]: { | ||
| label: 'DEV', | ||
| variant: 'default', | ||
| tooltip: DEVELOPMENT_TOOLTIP, | ||
| }, | ||
| } | ||
|
|
||
| export const EnvironmentBadge = ({ | ||
| environment, | ||
| dataTestId, | ||
| }: EnvironmentBadgeProps) => { | ||
| const flagEnabled = useSelector(appFeatureFlagDevProdModeSelector) | ||
|
|
||
| if (!flagEnabled || !environment) return null | ||
|
|
||
| const config = BADGE_CONFIG[environment] | ||
| if (!config) return null | ||
|
|
||
| return ( | ||
| <RiTooltip content={config.tooltip} position="bottom"> | ||
| <RiBadge | ||
| label={config.label} | ||
| variant={config.variant} | ||
| data-testid={dataTestId ?? `environment-badge-${environment}`} | ||
| /> | ||
| </RiTooltip> | ||
| ) | ||
| } | ||
|
|
||
| export default EnvironmentBadge | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| export { EnvironmentBadge } from './EnvironmentBadge' | ||
| export type { EnvironmentBadgeProps } from './EnvironmentBadge' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
redisinsight/ui/src/components/instance-header/InstanceHeader.styles.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| import React from 'react' | ||
| import styled, { css } from 'styled-components' | ||
|
|
||
| interface InstanceHeaderContainerProps | ||
| extends React.HTMLAttributes<HTMLDivElement> { | ||
| $isProductionEnv?: boolean | ||
| } | ||
|
|
||
| const productionTint = css` | ||
| background-color: ${({ theme }) => theme.semantic.color.background.danger100}; | ||
| ` | ||
|
|
||
| export const InstanceHeaderContainer = styled.div<InstanceHeaderContainerProps>` | ||
| ${({ $isProductionEnv }) => $isProductionEnv && productionTint} | ||
| ` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.