Skip to content

Commit

Permalink
feat: when insights are enabled hide those widgets in other pages (#6675
Browse files Browse the repository at this point in the history
)
  • Loading branch information
kwasniew authored Mar 22, 2024
1 parent e0994b0 commit a471f73
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 23 deletions.
37 changes: 22 additions & 15 deletions frontend/src/component/project/Project/Project.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,15 @@ export const Project = () => {
path: basePath,
name: 'overview',
},
...(projectOverviewRefactor
? [
{
title: 'Insights',
path: `${basePath}/insights`,
name: 'insights',
},
]
: []),
{
title: 'Health',
path: `${basePath}/health`,
Expand All @@ -109,12 +118,16 @@ export const Project = () => {
name: 'change-request',
isEnterprise: true,
},
{
title: 'Metrics',
path: `${basePath}/metrics`,
name: 'dora',
isEnterprise: true,
},
...(!projectOverviewRefactor
? [
{
title: 'Metrics',
path: `${basePath}/metrics`,
name: 'dora',
isEnterprise: true,
},
]
: []),
{
title: 'Applications',
path: `${basePath}/applications`,
Expand All @@ -133,14 +146,6 @@ export const Project = () => {
},
];

if (projectOverviewRefactor) {
tabs.splice(1, 0, {
title: 'Insights',
path: `${basePath}/insights`,
name: 'insights',
});
}

const filteredTabs = tabs
.filter((tab) => {
if (tab.flag) {
Expand Down Expand Up @@ -335,7 +340,9 @@ export const Project = () => {
}
/>
<Route path='settings/*' element={<ProjectSettings />} />
<Route path='metrics' element={<ProjectDoraMetrics />} />
{Boolean(!projectOverviewRefactor) && (
<Route path='metrics' element={<ProjectDoraMetrics />} />
)}
<Route path='applications' element={<ProjectApplications />} />
<Route path='*' element={<ProjectOverview />} />
</Routes>
Expand Down
29 changes: 21 additions & 8 deletions frontend/src/component/project/Project/ProjectOverview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import useProjectOverview, {
} from 'hooks/api/getters/useProjectOverview/useProjectOverview';
import { usePageTitle } from 'hooks/usePageTitle';
import { useLastViewedProject } from 'hooks/useLastViewedProject';
import { useUiFlag } from 'hooks/useUiFlag';
import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender';

const refreshInterval = 15 * 1000;

Expand Down Expand Up @@ -36,6 +38,7 @@ const StyledContentContainer = styled(Box)(({ theme }) => ({
const ProjectOverview: FC<{
storageKey?: string;
}> = ({ storageKey = 'project-overview-v2' }) => {
const projectOverviewRefactor = useUiFlag('projectOverviewRefactor');
const projectId = useRequiredPathParam('projectId');
const projectName = useProjectOverviewNameOrId(projectId);
const { project } = useProjectOverview(projectId, {
Expand All @@ -58,16 +61,26 @@ const ProjectOverview: FC<{

return (
<StyledContainer key={projectId}>
<ProjectInfo
id={projectId}
description={description}
memberCount={members}
health={health}
featureTypeCounts={featureTypeCounts}
stats={stats}
<ConditionallyRender
condition={!projectOverviewRefactor}
show={
<ProjectInfo
id={projectId}
description={description}
memberCount={members}
health={health}
featureTypeCounts={featureTypeCounts}
stats={stats}
/>
}
/>

<StyledContentContainer>
<ProjectStats stats={project.stats} />
<ConditionallyRender
condition={!projectOverviewRefactor}
show={<ProjectStats stats={project.stats} />}
/>

<StyledProjectToggles>
<ProjectFeatureToggles
environments={environments}
Expand Down

0 comments on commit a471f73

Please sign in to comment.