mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-09-22 13:39:35 +00:00
fix: correct project templates empty table display if feature is disabled
This commit is contained in:
+10
-5
@@ -25,6 +25,7 @@ import {
|
|||||||
import { OrgPermissionActions, OrgPermissionSubjects, useSubscription } from "@app/context";
|
import { OrgPermissionActions, OrgPermissionSubjects, useSubscription } from "@app/context";
|
||||||
import { useGetProjectTypeFromRoute, usePopUp } from "@app/hooks";
|
import { useGetProjectTypeFromRoute, usePopUp } from "@app/hooks";
|
||||||
import { TProjectTemplate, useListProjectTemplates } from "@app/hooks/api/projectTemplates";
|
import { TProjectTemplate, useListProjectTemplates } from "@app/hooks/api/projectTemplates";
|
||||||
|
import { ProjectType } from "@app/hooks/api/workspace/types";
|
||||||
|
|
||||||
import { DeleteProjectTemplateModal } from "./DeleteProjectTemplateModal";
|
import { DeleteProjectTemplateModal } from "./DeleteProjectTemplateModal";
|
||||||
|
|
||||||
@@ -40,6 +41,7 @@ export const ProjectTemplatesTable = ({ onEdit }: Props) => {
|
|||||||
const { isPending, data: projectTemplates = [] } = useListProjectTemplates(projectType, {
|
const { isPending, data: projectTemplates = [] } = useListProjectTemplates(projectType, {
|
||||||
enabled: subscription?.projectTemplates && Boolean(projectType)
|
enabled: subscription?.projectTemplates && Boolean(projectType)
|
||||||
});
|
});
|
||||||
|
|
||||||
const [search, setSearch] = useState("");
|
const [search, setSearch] = useState("");
|
||||||
|
|
||||||
const { popUp, handlePopUpOpen, handlePopUpToggle } = usePopUp(["deleteTemplate"] as const);
|
const { popUp, handlePopUpOpen, handlePopUpToggle } = usePopUp(["deleteTemplate"] as const);
|
||||||
@@ -52,7 +54,9 @@ export const ProjectTemplatesTable = ({ onEdit }: Props) => {
|
|||||||
[search, projectTemplates]
|
[search, projectTemplates]
|
||||||
);
|
);
|
||||||
|
|
||||||
const isSecretManagerTemplates = projectType === "secret-manager";
|
const isSecretManagerTemplates = projectType === ProjectType.SecretManager;
|
||||||
|
|
||||||
|
const colSpan = isSecretManagerTemplates ? 4 : 3;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
@@ -73,10 +77,10 @@ export const ProjectTemplatesTable = ({ onEdit }: Props) => {
|
|||||||
</Tr>
|
</Tr>
|
||||||
</THead>
|
</THead>
|
||||||
<TBody>
|
<TBody>
|
||||||
{isPending && (
|
{subscription?.projectTemplates && isPending && (
|
||||||
<TableSkeleton
|
<TableSkeleton
|
||||||
innerKey="project-templates-table"
|
innerKey="project-templates-table"
|
||||||
columns={4}
|
columns={colSpan}
|
||||||
key="project-templates"
|
key="project-templates"
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
@@ -170,9 +174,10 @@ export const ProjectTemplatesTable = ({ onEdit }: Props) => {
|
|||||||
</Tr>
|
</Tr>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
{!isPending && filteredTemplates?.length === 0 && (
|
{(!subscription?.projectTemplates ||
|
||||||
|
(!isPending && filteredTemplates?.length === 0)) && (
|
||||||
<Tr>
|
<Tr>
|
||||||
<Td colSpan={5}>
|
<Td colSpan={colSpan}>
|
||||||
<EmptyState
|
<EmptyState
|
||||||
title={
|
title={
|
||||||
search.trim()
|
search.trim()
|
||||||
|
|||||||
Reference in New Issue
Block a user