1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-07-31 13:47:02 +02:00

feat: recent project by name (#7375)

This commit is contained in:
Mateusz Kwasniewski 2024-06-12 13:40:05 +02:00 committed by GitHub
parent a0fce0ec12
commit 77a5b85d6b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 17 additions and 3 deletions

View File

@ -22,6 +22,7 @@ import ExpandMoreIcon from '@mui/icons-material/ExpandMore';
import FlagIcon from '@mui/icons-material/OutlinedFlag'; import FlagIcon from '@mui/icons-material/OutlinedFlag';
import { useUiFlag } from 'hooks/useUiFlag'; import { useUiFlag } from 'hooks/useUiFlag';
import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender'; import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender';
import useProjectOverview from 'hooks/api/getters/useProjectOverview/useProjectOverview';
const StyledBadgeContainer = styled('div')(({ theme }) => ({ const StyledBadgeContainer = styled('div')(({ theme }) => ({
paddingLeft: theme.spacing(2), paddingLeft: theme.spacing(2),
@ -104,16 +105,17 @@ export const OtherLinksList = () => {
export const RecentProjectsList: FC<{ export const RecentProjectsList: FC<{
projectId: string; projectId: string;
projectName: string;
mode: NavigationMode; mode: NavigationMode;
onClick: () => void; onClick: () => void;
}> = ({ projectId, mode, onClick }) => { }> = ({ projectId, projectName, mode, onClick }) => {
const DynamicListItem = mode === 'mini' ? MiniListItem : FullListItem; const DynamicListItem = mode === 'mini' ? MiniListItem : FullListItem;
return ( return (
<List> <List>
<DynamicListItem <DynamicListItem
href={`/projects/${projectId}`} href={`/projects/${projectId}`}
text={projectId} text={projectName}
onClick={onClick} onClick={onClick}
selected={false} selected={false}
> >
@ -245,6 +247,10 @@ export const RecentProjectsNavigation: FC<{
projectId: string; projectId: string;
onClick: () => void; onClick: () => void;
}> = ({ mode, onClick, projectId }) => { }> = ({ mode, onClick, projectId }) => {
const { project, loading } = useProjectOverview(projectId);
const projectDeleted = !project.name && !loading;
if (projectDeleted) return null;
return ( return (
<Box> <Box>
{mode === 'full' && ( {mode === 'full' && (
@ -261,6 +267,7 @@ export const RecentProjectsNavigation: FC<{
)} )}
<RecentProjectsList <RecentProjectsList
projectId={projectId} projectId={projectId}
projectName={project.name}
mode={mode} mode={mode}
onClick={onClick} onClick={onClick}
/> />

View File

@ -10,6 +10,9 @@ import {
} from 'hooks/useLastViewedFlags'; } from 'hooks/useLastViewedFlags';
import { type FC, useEffect } from 'react'; import { type FC, useEffect } from 'react';
import { useLastViewedProject } from 'hooks/useLastViewedProject'; import { useLastViewedProject } from 'hooks/useLastViewedProject';
import { testServerRoute, testServerSetup } from 'utils/testServer';
const server = testServerSetup();
beforeEach(() => { beforeEach(() => {
window.localStorage.clear(); window.localStorage.clear();
@ -95,6 +98,10 @@ const SetupComponent: FC<{ project: string; flags: LastViewedFlag[] }> = ({
}; };
test('print recent projects and flags', async () => { test('print recent projects and flags', async () => {
testServerRoute(server, `/api/admin/projects/projectA/overview`, {
name: 'projectNameA',
});
render( render(
<SetupComponent <SetupComponent
project={'projectA'} project={'projectA'}
@ -102,6 +109,6 @@ test('print recent projects and flags', async () => {
/>, />,
); );
await screen.findByText('projectA'); await screen.findByText('projectNameA');
await screen.findByText('featureA'); await screen.findByText('featureA');
}); });