Skip to content
Open
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
36 changes: 16 additions & 20 deletions frontend/src/component/menu/Header/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,6 @@ const StyledNav = styled('nav')({

const Header = () => {
const { onSetThemeMode } = useThemeMode();
const newProfileDropdown = useUiFlag('newProfileDropdown');
const showThemeButton = !newProfileDropdown;
const theme = useTheme();

const mediumScreen = useMediaQuery(theme.breakpoints.down('lg'));
Expand All @@ -87,24 +85,22 @@ const Header = () => {
})}
/>
<InviteLinkButton />
{showThemeButton && (
<Tooltip
title={
theme.mode === 'dark'
? 'Switch to light theme'
: 'Switch to dark theme'
}
arrow
>
<IconButton onClick={onSetThemeMode} size='large'>
<ConditionallyRender
condition={theme.mode === 'dark'}
show={<DarkModeOutlined />}
elseShow={<LightModeOutlined />}
/>
</IconButton>
</Tooltip>
)}
<Tooltip
title={
theme.mode === 'dark'
? 'Switch to light theme'
: 'Switch to dark theme'
}
arrow
>
<IconButton onClick={onSetThemeMode} size='large'>
<ConditionallyRender
condition={theme.mode === 'dark'}
show={<DarkModeOutlined />}
elseShow={<LightModeOutlined />}
/>
</IconButton>
</Tooltip>
{hideTopmenuDocumentation && <HelpResources />}
{!hideTopmenuDocumentation && (
<Tooltip title='Documentation' arrow>
Expand Down
36 changes: 36 additions & 0 deletions frontend/src/component/user/UserProfile/index.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { render, screen } from '@testing-library/react';
import { describe, expect, test, vi } from 'vitest';
import { useAuthUser } from 'hooks/api/getters/useAuth/useAuthUser';
import UserProfileContainer from './index.tsx';

vi.mock('hooks/api/getters/useAuth/useAuthUser', () => ({
useAuthUser: vi.fn(),
}));

vi.mock('./UserProfile.tsx', () => ({
UserProfile: ({ profile }: { profile: { name: string } }) => (
<div>User profile: {profile.name}</div>
),
}));

const mockedUseAuthUser = vi.mocked(useAuthUser);

describe('UserProfileContainer', () => {
test('renders profile dropdown when user is available', () => {
mockedUseAuthUser.mockReturnValue({
user: { name: 'Alice' },
} as never);

render(<UserProfileContainer />);

expect(screen.getByText('User profile: Alice')).toBeInTheDocument();
});

test('renders nothing when user is missing', () => {
mockedUseAuthUser.mockReturnValue({ user: null } as never);

render(<UserProfileContainer />);

expect(screen.queryByText(/^User profile:/)).not.toBeInTheDocument();
});
});
9 changes: 1 addition & 8 deletions frontend/src/component/user/UserProfile/index.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,14 @@
import { useAuthUser } from 'hooks/api/getters/useAuth/useAuthUser';
import { useUiFlag } from 'hooks/useUiFlag';
import { UserProfile } from './UserProfile.tsx';
import { LegacyUserProfile } from './LegacyUserProfile.tsx';

const UserProfileContainer = () => {
const { user } = useAuthUser();
const newProfileDropdown = useUiFlag('newProfileDropdown');

if (!user) {
return null;
}

return newProfileDropdown ? (
<UserProfile profile={user} />
) : (
<LegacyUserProfile profile={user} />
);
return <UserProfile profile={user} />;
};

export default UserProfileContainer;
1 change: 0 additions & 1 deletion frontend/src/interfaces/uiConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ export type UiFlags = {
newProjectList?: boolean;
newModalDesign?: boolean;
archiveInFlagsView?: boolean;
newProfileDropdown?: boolean;
hideTopmenuDocumentation?: boolean;
learningLab?: Variant;
accessRequestsNotifications?: boolean;
Expand Down
5 changes: 0 additions & 5 deletions src/lib/types/experimental.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ export type IFlagKey =
| 'newModalDesign'
| 'archiveInFlagsView'
| 'allowDeprecatedApiTokenMiddleware'
| 'newProfileDropdown'
| 'hideTopmenuDocumentation'
| 'serviceNowIntegration'
| 'learningLab'
Expand Down Expand Up @@ -367,10 +366,6 @@ const flags: IFlags = {
process.env.UNLEASH_EXPERIMENTAL_ARCHIVE_IN_FLAGS_VIEW,
false,
),
newProfileDropdown: parseEnvVarBoolean(
process.env.UNLEASH_EXPERIMENTAL_NEW_PROFILE_DROPDOWN,
false,
),
hideTopmenuDocumentation: parseEnvVarBoolean(
process.env.UNLEASH_EXPERIMENTAL_HIDE_TOPMENU_DOCUMENTATION,
false,
Expand Down
1 change: 0 additions & 1 deletion src/server-dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ process.nextTick(async () => {
userTokenWithClientApiLoggingKillSwitch: false,
allowDeprecatedApiTokenMiddleware: false,
archiveInFlagsView: true,
newProfileDropdown: true,
hideTopmenuDocumentation: true,
learningLab: true,
serviceNowIntegration: true,
Expand Down