feat: resolved identity filtering with blur

This commit is contained in:
=
2025-11-09 00:00:48 +05:30
parent 648489589b
commit 2e64f37a2d
3 changed files with 43 additions and 14 deletions

View File

@@ -60,8 +60,14 @@ export const identityProjectServiceFactory = ({
}); });
const totalCount = await identityProjectDAL.getCountByProjectId(projectId, { search }); const totalCount = await identityProjectDAL.getCountByProjectId(projectId, { search });
const filteredMemberships = identityMemberships.filter((el) =>
permission.can(
ProjectPermissionIdentityActions.Read,
subject(ProjectPermissionSub.Identity, { identityId: el.id })
)
);
return { identityMemberships, totalCount }; return { identityMemberships: filteredMemberships, totalCount };
}; };
const getProjectIdentityByIdentityId = async ({ const getProjectIdentityByIdentityId = async ({

View File

@@ -299,7 +299,7 @@ export const membershipIdentityServiceFactory = ({
const { scopeData } = dto; const { scopeData } = dto;
const factory = scopeFactory[scopeData.scope]; const factory = scopeFactory[scopeData.scope];
await factory.onListMembershipIdentityGuard(dto); const listFilter = await factory.onListMembershipIdentityGuard(dto);
const memberships = await membershipIdentityDAL.findIdentities({ const memberships = await membershipIdentityDAL.findIdentities({
scopeData, scopeData,
filter: { filter: {
@@ -317,7 +317,7 @@ export const membershipIdentityServiceFactory = ({
: undefined : undefined
} }
}); });
return memberships; return { ...memberships, data: memberships.data.filter((el) => listFilter({ identityId: el.identity.id })) };
}; };
const getMembershipByIdentityId = async (dto: TGetMembershipIdentityByIdentityIdDTO) => { const getMembershipByIdentityId = async (dto: TGetMembershipIdentityByIdentityIdDTO) => {

View File

@@ -79,6 +79,7 @@ import { usePopUp } from "@app/hooks/usePopUp";
import { ProjectIdentityModal } from "@app/pages/project/AccessControlPage/components/IdentityTab/components/ProjectIdentityModal"; import { ProjectIdentityModal } from "@app/pages/project/AccessControlPage/components/IdentityTab/components/ProjectIdentityModal";
import { ProjectLinkIdentityModal } from "./components/ProjectLinkIdentityModal"; import { ProjectLinkIdentityModal } from "./components/ProjectLinkIdentityModal";
import { Blur } from "@app/components/v2/Blur";
const MAX_ROLES_TO_BE_SHOWN_IN_TABLE = 2; const MAX_ROLES_TO_BE_SHOWN_IN_TABLE = 2;
@@ -174,7 +175,6 @@ export const IdentityTab = withProjectPermission(
handlePopUpClose("deleteIdentity"); handlePopUpClose("deleteIdentity");
}; };
const handleSort = (column: ProjectIdentityOrderBy) => { const handleSort = (column: ProjectIdentityOrderBy) => {
if (column === orderBy) { if (column === orderBy) {
setOrderDirection((prev) => setOrderDirection((prev) =>
@@ -187,6 +187,12 @@ export const IdentityTab = withProjectPermission(
setOrderDirection(OrderByDirection.ASC); setOrderDirection(OrderByDirection.ASC);
}; };
const noAccessIdentityCount = Math.max(
(page * perPage > totalCount ? totalCount % perPage : perPage) -
(data?.identityMemberships?.length || 0),
0
);
return ( return (
<div className="mb-6 rounded-lg border border-mineshaft-600 bg-mineshaft-900 p-4"> <div className="mb-6 rounded-lg border border-mineshaft-600 bg-mineshaft-900 p-4">
<div className="mb-4 flex items-center justify-between"> <div className="mb-4 flex items-center justify-between">
@@ -450,6 +456,20 @@ export const IdentityTab = withProjectPermission(
</Tr> </Tr>
); );
})} })}
{!isPending &&
data &&
data?.totalCount !== 0 &&
Array.from(Array(noAccessIdentityCount)).map((_e, i) => (
<Tr key={`hid-identity-${i + 1}`}>
<Td>No Access</Td>
<Td colSpan={3}>
<Blur
className="w-min"
tooltipText="You do not have permission to read this identity."
/>
</Td>
</Tr>
))}
</TBody> </TBody>
</Table> </Table>
{!isPending && data && totalCount > 0 && ( {!isPending && data && totalCount > 0 && (
@@ -461,16 +481,19 @@ export const IdentityTab = withProjectPermission(
onChangePerPage={handlePerPageChange} onChangePerPage={handlePerPageChange}
/> />
)} )}
{!isPending && data && data?.identityMemberships.length === 0 && ( {!isPending &&
<EmptyState data &&
title={ data?.identityMemberships.length === 0 &&
debouncedSearch.trim().length > 0 data?.totalCount === 0 && (
? "No identities match search filter" <EmptyState
: "No identities have been added to this project" title={
} debouncedSearch.trim().length > 0
icon={faServer} ? "No identities match search filter"
/> : "No identities have been added to this project"
)} }
icon={faServer}
/>
)}
</TableContainer> </TableContainer>
<Modal <Modal
isOpen={popUp.createIdentity.isOpen} isOpen={popUp.createIdentity.isOpen}