feat: resolved additional privilege not taking priority and dummy column miscalculation

This commit is contained in:
=
2024-10-18 00:33:37 +05:30
parent 6158b8a91d
commit 700c5409bf
5 changed files with 60 additions and 48 deletions
@@ -67,7 +67,7 @@ export const permissionServiceFactory = ({
throw new NotFoundError({ name: "OrgRoleInvalid", message: "Organization role not found" }); throw new NotFoundError({ name: "OrgRoleInvalid", message: "Organization role not found" });
} }
}) })
.reduce((curr, prev) => prev.concat(curr), []); .reduce((prev, curr) => prev.concat(curr), []);
return createMongoAbility<OrgPermissionSet>(rules, { return createMongoAbility<OrgPermissionSet>(rules, {
conditionsMatcher conditionsMatcher
@@ -98,7 +98,7 @@ export const permissionServiceFactory = ({
}); });
} }
}) })
.reduce((curr, prev) => prev.concat(curr), []); .reduce((prev, curr) => prev.concat(curr), []);
return rules; return rules;
}; };
@@ -394,7 +394,7 @@ export const secretV2BridgeServiceFactory = ({
subject(ProjectPermissionSub.Secrets, { subject(ProjectPermissionSub.Secrets, {
environment, environment,
secretPath, secretPath,
secretName: inputSecret.secretName, secretName: inputSecret.newSecretName,
secretTags: tags?.map((el) => el.slug) secretTags: tags?.map((el) => el.slug)
}) })
); );
@@ -210,8 +210,20 @@ export const SecretMainPage = () => {
isPaused: !canDoReadRollback isPaused: !canDoReadRollback
}); });
const noAccessSecretCount = Math.max(
(page * perPage > totalCount ? totalCount % perPage : perPage) -
(imports?.length || 0) -
(folders?.length || 0) -
(secrets?.length || 0) -
(dynamicSecrets?.length || 0),
0
);
const isNotEmpty = Boolean( const isNotEmpty = Boolean(
secrets?.length || folders?.length || imports?.length || dynamicSecrets?.length secrets?.length ||
folders?.length ||
imports?.length ||
dynamicSecrets?.length ||
noAccessSecretCount
); );
const handleSortToggle = () => const handleSortToggle = () =>
@@ -405,18 +417,7 @@ export const SecretMainPage = () => {
isProtectedBranch={isProtectedBranch} isProtectedBranch={isProtectedBranch}
/> />
)} )}
{canReadSecret && ( {canReadSecret && <SecretNoAccessListView count={noAccessSecretCount} />}
<SecretNoAccessListView
count={Math.max(
(page * perPage > totalCount ? totalCount % perPage : perPage) -
(imports?.length || 0) -
(folders?.length || 0) -
(secrets?.length || 0) -
(dynamicSecrets?.length || 0),
0
)}
/>
)}
{!canReadSecret && {!canReadSecret &&
!canReadDynamicSecret && !canReadDynamicSecret &&
!canReadSecretImports && !canReadSecretImports &&
@@ -1,4 +1,4 @@
import { FontAwesomeSymbol, Input } from "@app/components/v2"; import { FontAwesomeSymbol, Input, Tooltip } from "@app/components/v2";
import { FontAwesomeSpriteName } from "./SecretListView.utils"; import { FontAwesomeSpriteName } from "./SecretListView.utils";
@@ -10,34 +10,39 @@ export const SecretNoAccessListView = ({ count }: Props) => {
return ( return (
<> <>
{Array.from(Array(count)).map((_, i) => ( {Array.from(Array(count)).map((_, i) => (
<div <Tooltip
className="flex border-b border-mineshaft-600 bg-mineshaft-800 shadow-none hover:bg-mineshaft-700" className="max-w-sm"
asChild
content="You do not have permission to view this secret"
key={`no-access-secret-${i + 1}`} key={`no-access-secret-${i + 1}`}
> >
<div className="flex h-11 w-11 items-center justify-center px-4 py-3"> <div className="flex border-b border-mineshaft-600 bg-mineshaft-800 shadow-none hover:bg-mineshaft-700">
<FontAwesomeSymbol <div className="flex h-11 w-11 items-center justify-center px-4 py-3">
className="ml-3 block h-3.5 w-3.5" <FontAwesomeSymbol
symbolName={FontAwesomeSpriteName.KeyLock} className="ml-3 block h-3.5 w-3.5"
/> symbolName={FontAwesomeSpriteName.KeyLock}
/>
</div>
<div className="flex h-11 w-80 flex-shrink-0 items-center px-4 py-2">
<Input
autoComplete="off"
isReadOnly
variant="plain"
value="NO ACCESS"
isDisabled
className="w-full px-0 blur-sm placeholder:text-red-500 focus:text-bunker-100 focus:ring-transparent"
/>
</div>
<div
className="flex w-80 flex-grow items-center border-x border-mineshaft-600 py-1 pl-4 pr-2"
tabIndex={0}
role="button"
>
<span className="blur">********</span>
</div>
</div> </div>
<div className="flex h-11 w-80 flex-shrink-0 items-center px-4 py-2"> </Tooltip>
<Input
autoComplete="off"
isReadOnly
variant="plain"
value="NO ACCESS"
isDisabled
className="w-full px-0 blur-sm placeholder:text-red-500 focus:text-bunker-100 focus:ring-transparent"
/>
</div>
<div
className="flex w-80 flex-grow items-center border-x border-mineshaft-600 py-1 pl-4 pr-2"
tabIndex={0}
role="button"
>
<span className="blur">********</span>
</div>
</div>
))} ))}
</> </>
); );
@@ -2,7 +2,7 @@ import { faCircle } from "@fortawesome/free-regular-svg-icons";
import { faLock } from "@fortawesome/free-solid-svg-icons"; import { faLock } from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { Td, Tr } from "@app/components/v2"; import { Td, Tooltip, Tr } from "@app/components/v2";
type Props = { type Props = {
environments: { name: string; slug: string }[]; environments: { name: string; slug: string }[];
@@ -16,12 +16,18 @@ export const SecretNoAccessOverviewTableRow = ({ environments = [], count }: Pro
<Tr key={`no-access-secret-overview-${j + 1}`} isHoverable isSelectable className="group"> <Tr key={`no-access-secret-overview-${j + 1}`} isHoverable isSelectable className="group">
<Td className="sticky left-0 z-10 bg-mineshaft-800 bg-clip-padding py-0 px-0 group-hover:bg-mineshaft-700"> <Td className="sticky left-0 z-10 bg-mineshaft-800 bg-clip-padding py-0 px-0 group-hover:bg-mineshaft-700">
<div className="h-full w-full border-r border-mineshaft-600 py-2.5 px-5"> <div className="h-full w-full border-r border-mineshaft-600 py-2.5 px-5">
<div className="flex items-center space-x-5"> <Tooltip
<div className="text-bunker-300"> asChild
<FontAwesomeIcon className="block" icon={faLock} /> content="You do not have permission to view this secret"
className="max-w-sm"
>
<div className="flex items-center space-x-5">
<div className="text-bunker-300">
<FontAwesomeIcon className="block" icon={faLock} />
</div>
<div className="blur-sm">NO ACCESS</div>
</div> </div>
<div className="blur-sm">NO ACCESS</div> </Tooltip>
</div>
</div> </div>
</Td> </Td>
{environments.map(({ slug }, i) => { {environments.map(({ slug }, i) => {