mirror of
https://github.com/Unleash/unleash.git
synced 2025-01-25 00:07:47 +01:00
feat: recent project by name (#7375)
This commit is contained in:
parent
a0fce0ec12
commit
77a5b85d6b
@ -22,6 +22,7 @@ import ExpandMoreIcon from '@mui/icons-material/ExpandMore';
|
||||
import FlagIcon from '@mui/icons-material/OutlinedFlag';
|
||||
import { useUiFlag } from 'hooks/useUiFlag';
|
||||
import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender';
|
||||
import useProjectOverview from 'hooks/api/getters/useProjectOverview/useProjectOverview';
|
||||
|
||||
const StyledBadgeContainer = styled('div')(({ theme }) => ({
|
||||
paddingLeft: theme.spacing(2),
|
||||
@ -104,16 +105,17 @@ export const OtherLinksList = () => {
|
||||
|
||||
export const RecentProjectsList: FC<{
|
||||
projectId: string;
|
||||
projectName: string;
|
||||
mode: NavigationMode;
|
||||
onClick: () => void;
|
||||
}> = ({ projectId, mode, onClick }) => {
|
||||
}> = ({ projectId, projectName, mode, onClick }) => {
|
||||
const DynamicListItem = mode === 'mini' ? MiniListItem : FullListItem;
|
||||
|
||||
return (
|
||||
<List>
|
||||
<DynamicListItem
|
||||
href={`/projects/${projectId}`}
|
||||
text={projectId}
|
||||
text={projectName}
|
||||
onClick={onClick}
|
||||
selected={false}
|
||||
>
|
||||
@ -245,6 +247,10 @@ export const RecentProjectsNavigation: FC<{
|
||||
projectId: string;
|
||||
onClick: () => void;
|
||||
}> = ({ mode, onClick, projectId }) => {
|
||||
const { project, loading } = useProjectOverview(projectId);
|
||||
const projectDeleted = !project.name && !loading;
|
||||
|
||||
if (projectDeleted) return null;
|
||||
return (
|
||||
<Box>
|
||||
{mode === 'full' && (
|
||||
@ -261,6 +267,7 @@ export const RecentProjectsNavigation: FC<{
|
||||
)}
|
||||
<RecentProjectsList
|
||||
projectId={projectId}
|
||||
projectName={project.name}
|
||||
mode={mode}
|
||||
onClick={onClick}
|
||||
/>
|
||||
|
@ -10,6 +10,9 @@ import {
|
||||
} from 'hooks/useLastViewedFlags';
|
||||
import { type FC, useEffect } from 'react';
|
||||
import { useLastViewedProject } from 'hooks/useLastViewedProject';
|
||||
import { testServerRoute, testServerSetup } from 'utils/testServer';
|
||||
|
||||
const server = testServerSetup();
|
||||
|
||||
beforeEach(() => {
|
||||
window.localStorage.clear();
|
||||
@ -95,6 +98,10 @@ const SetupComponent: FC<{ project: string; flags: LastViewedFlag[] }> = ({
|
||||
};
|
||||
|
||||
test('print recent projects and flags', async () => {
|
||||
testServerRoute(server, `/api/admin/projects/projectA/overview`, {
|
||||
name: 'projectNameA',
|
||||
});
|
||||
|
||||
render(
|
||||
<SetupComponent
|
||||
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');
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user