1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-10-27 11:02:16 +01:00
unleash.unleash/frontend/src/component/changeRequest/ProjectChangeRequests/ProjectChangeRequests.tsx
Tymoteusz Czech 1433878f32
fix: change requests placeholder (#8724)
If project does not have CRs configured, show correct info.
2024-11-25 17:54:25 +01:00

55 lines
2.2 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { usePageTitle } from 'hooks/usePageTitle';
import { useRequiredPathParam } from 'hooks/useRequiredPathParam';
import { ChangeRequestsTabs } from './ChangeRequestsTabs/ChangeRequestsTabs';
import { useProjectChangeRequests } from 'hooks/api/getters/useProjectChangeRequests/useProjectChangeRequests';
import useUiConfig from 'hooks/api/getters/useUiConfig/useUiConfig';
import { PageContent } from 'component/common/PageContent/PageContent';
import { PremiumFeature } from 'component/common/PremiumFeature/PremiumFeature';
import { useProjectOverviewNameOrId } from 'hooks/api/getters/useProjectOverview/useProjectOverview';
import { useChangeRequestConfig } from 'hooks/api/getters/useChangeRequestConfig/useChangeRequestConfig';
import { Link } from 'react-router-dom';
export const ProjectChangeRequests = () => {
const projectId = useRequiredPathParam('projectId');
const projectName = useProjectOverviewNameOrId(projectId);
const { isOss, isPro } = useUiConfig();
usePageTitle(`Change requests ${projectName}`);
const { changeRequests, loading } = useProjectChangeRequests(projectId);
const { data: configData, loading: configLoading } =
useChangeRequestConfig(projectId);
const isConfigured = configData.some(
(config) => config.changeRequestEnabled,
);
if (isOss() || isPro()) {
return (
<PageContent sx={{ justifyContent: 'center' }}>
<PremiumFeature feature='change-requests' />
</PageContent>
);
}
return (
<ChangeRequestsTabs
changeRequests={changeRequests}
projectId={projectId}
loading={loading}
placeholder={
!configLoading && !isConfigured ? (
<p>
Change requests are not configured for this project.
<br />
<Link
to={`/projects/${projectId}/settings/change-requests`}
>
Configure change requests
</Link>
</p>
) : undefined
}
/>
);
};