Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

improvement: fix 0 groups display for add group to project, add field description and fix empty state race

Scott Wilsondeb0fc3a3c10
diff --git a/frontend/src/pages/project/AccessControlPage/components/GroupsTab/components/GroupsSection/GroupModal.tsx b/frontend/src/pages/project/AccessControlPage/components/GroupsTab/components/GroupsSection/GroupModal.tsx
index 2457d51166..0dd8170cc2 100644
--- a/frontend/src/pages/project/AccessControlPage/components/GroupsTab/components/GroupsSection/GroupModal.tsx
+++ b/frontend/src/pages/project/AccessControlPage/components/GroupsTab/components/GroupsSection/GroupModal.tsx
@@ -15,6 +15,7 @@ import {
DialogHeader,
DialogTitle,
Field,
+ FieldDescription,
FieldError,
FieldLabel,
FilterableSelect
@@ -37,6 +38,8 @@ const schema = z.object({
export type FormData = z.infer<typeof schema>;
+const GROUP_PAGE_SIZE = 20;
+
type Props = {
popUp: UsePopUpState<["group"]>;
handlePopUpToggle: (popUpName: keyof UsePopUpState<["group"]>, state?: boolean) => void;
@@ -60,7 +63,7 @@ const Content = ({ onClose }: { onClose: () => void }) => {
} = useSearchOrganizationGroups({
organizationId: orgId,
search: debouncedSearch,
- limit: 20
+ limit: GROUP_PAGE_SIZE
});
const { data: groupMemberships } = useListWorkspaceGroups(
currentProject?.id || "",
@@ -109,8 +112,17 @@ const Content = ({ onClose }: { onClose: () => void }) => {
const totalOrgGroups = orgGroupsData?.totalCount ?? 0;
const assignedCount = groupMemberships?.length ?? 0;
+ // totalCount is scoped to the active search, so only trust it against the project's group count
+ // once both the input and the debounced query it drives are clear.
+ const hasSearchTerm = Boolean(searchInput || debouncedSearch);
const hasNoAvailableGroups =
- !isLoadingGroups && !searchInput && totalOrgGroups > 0 && assignedCount >= totalOrgGroups;
+ !isLoadingGroups && !hasSearchTerm && assignedCount >= totalOrgGroups;
+ const isGroupListTruncated = totalOrgGroups > GROUP_PAGE_SIZE;
+
+ const noOptionsMessage = () => {
+ if (hasSearchTerm) return "No groups match your search";
+ return `The first ${GROUP_PAGE_SIZE} groups are already added. Search by name to find others.`;
+ };
return !hasNoAvailableGroups ? (
<form onSubmit={handleSubmit(onFormSubmit)} className="flex flex-col gap-4">
@@ -137,7 +149,11 @@ const Content = ({ onClose }: { onClose: () => void }) => {
filterOption={() => true}
getOptionValue={(option) => option.id}
getOptionLabel={(option) => option.name}
+ noOptionsMessage={noOptionsMessage}
/>
+ <FieldDescription>
+ {isGroupListTruncated ? "Search by name to find groups that are not listed." : null}
+ </FieldDescription>
<FieldError>{error?.message}</FieldError>
</Field>
)}
@@ -175,18 +191,21 @@ const Content = ({ onClose }: { onClose: () => void }) => {
) : (
<div className="flex flex-col gap-4">
<p className="text-sm">
- Every group in your organization is already added. To add another group, create one at the
- organization level first.
+ {totalOrgGroups === 0
+ ? "Your organization has no groups yet. Create one at the organization level to add it to this project."
+ : "Every group in your organization is already added. To add another group, create one at the organization level first."}
</p>
- <Button asChild variant="outline" className="self-end">
- <Link
- to={"/organizations/$orgId/access-management" as const}
- params={{ orgId }}
- search={{ selectedTab: "groups" }}
- >
- Go to organization groups <ArrowRightIcon />
- </Link>
- </Button>
+ <DialogFooter>
+ <Button asChild variant="outline">
+ <Link
+ to={"/organizations/$orgId/access-management" as const}
+ params={{ orgId }}
+ search={{ selectedTab: "groups" }}
+ >
+ Go to organization groups <ArrowRightIcon />
+ </Link>
+ </Button>
+ </DialogFooter>
</div>
);
};