mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-07 15:27:46 +00:00
improvement: revise access restricted banner and refactor/update relevant locations
This commit is contained in:
@@ -1,26 +1,14 @@
|
|||||||
import { FunctionComponent, ReactNode } from "react";
|
import { FunctionComponent, ReactNode } from "react";
|
||||||
import { BoundCanProps, Can } from "@casl/react";
|
import { BoundCanProps, Can } from "@casl/react";
|
||||||
import { faLock } from "@fortawesome/free-solid-svg-icons";
|
|
||||||
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
|
||||||
|
|
||||||
import { TOrgPermission, useOrgPermission } from "@app/context/OrgPermissionContext";
|
import { TOrgPermission, useOrgPermission } from "@app/context/OrgPermissionContext";
|
||||||
|
|
||||||
import { Tooltip } from "../v2";
|
import { AccessRestrictedBanner, Tooltip } from "../v2";
|
||||||
|
|
||||||
export const OrgPermissionGuardBanner = () => {
|
export const OrgPermissionGuardBanner = () => {
|
||||||
return (
|
return (
|
||||||
<div className="container mx-auto flex h-full items-center justify-center">
|
<div className="container mx-auto flex h-full items-center justify-center">
|
||||||
<div className="flex items-end space-x-12 rounded-md bg-mineshaft-800 p-16 text-bunker-300">
|
<AccessRestrictedBanner />
|
||||||
<div>
|
|
||||||
<FontAwesomeIcon icon={faLock} size="6x" />
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<div className="mb-2 text-4xl font-medium">Access Restricted</div>
|
|
||||||
<div className="text-sm">
|
|
||||||
Your role has limited permissions, please <br /> contact your admin to gain access
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,15 +1,12 @@
|
|||||||
import { ReactNode } from "react";
|
|
||||||
import { faLock } from "@fortawesome/free-solid-svg-icons";
|
|
||||||
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
|
||||||
import { twMerge } from "tailwind-merge";
|
import { twMerge } from "tailwind-merge";
|
||||||
|
|
||||||
|
import { AccessRestrictedBanner } from "@app/components/v2";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
containerClassName?: string;
|
containerClassName?: string;
|
||||||
className?: string;
|
|
||||||
children?: ReactNode;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const PermissionDeniedBanner = ({ containerClassName, className, children }: Props) => {
|
export const PermissionDeniedBanner = ({ containerClassName }: Props) => {
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className={twMerge(
|
className={twMerge(
|
||||||
@@ -17,22 +14,7 @@ export const PermissionDeniedBanner = ({ containerClassName, className, children
|
|||||||
containerClassName
|
containerClassName
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
<div className={twMerge("rounded-md bg-mineshaft-800 p-16 text-bunker-300", className)}>
|
<AccessRestrictedBanner />
|
||||||
<div className="flex items-end space-x-12">
|
|
||||||
<div>
|
|
||||||
<FontAwesomeIcon icon={faLock} size="6x" />
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<div className="mb-2 text-4xl font-medium">Access Restricted</div>
|
|
||||||
{children || (
|
|
||||||
<div className="text-sm">
|
|
||||||
Your role has limited permissions, please <br /> contact your administrator to gain
|
|
||||||
access
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
import { FunctionComponent, ReactNode } from "react";
|
import { FunctionComponent, ReactNode } from "react";
|
||||||
import { AbilityTuple, MongoAbility } from "@casl/ability";
|
import { AbilityTuple, MongoAbility } from "@casl/ability";
|
||||||
import { Can } from "@casl/react";
|
import { Can } from "@casl/react";
|
||||||
import { faLock } from "@fortawesome/free-solid-svg-icons";
|
|
||||||
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
|
||||||
|
|
||||||
|
import { AccessRestrictedBanner } from "@app/components/v2";
|
||||||
import { ProjectPermissionSet, useProjectPermission } from "@app/context/ProjectPermissionContext";
|
import { ProjectPermissionSet, useProjectPermission } from "@app/context/ProjectPermissionContext";
|
||||||
|
|
||||||
import { Tooltip } from "../v2/Tooltip";
|
import { Tooltip } from "../v2/Tooltip";
|
||||||
@@ -11,17 +10,7 @@ import { Tooltip } from "../v2/Tooltip";
|
|||||||
export const ProjectPermissionGuardBanner = () => {
|
export const ProjectPermissionGuardBanner = () => {
|
||||||
return (
|
return (
|
||||||
<div className="container mx-auto flex h-full items-center justify-center">
|
<div className="container mx-auto flex h-full items-center justify-center">
|
||||||
<div className="flex items-end space-x-12 rounded-md bg-mineshaft-800 p-16 text-bunker-300">
|
<AccessRestrictedBanner />
|
||||||
<div>
|
|
||||||
<FontAwesomeIcon icon={faLock} size="6x" />
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<div className="mb-2 text-4xl font-medium">Access Restricted</div>
|
|
||||||
<div className="text-sm">
|
|
||||||
Your role has limited permissions, please <br /> contact your admin to gain access
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -0,0 +1,26 @@
|
|||||||
|
import { ReactNode } from "react";
|
||||||
|
|
||||||
|
type Props = {
|
||||||
|
title?: string;
|
||||||
|
body?: ReactNode;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const AccessRestrictedBanner = ({
|
||||||
|
title = "Access Restricted",
|
||||||
|
|
||||||
|
body = (
|
||||||
|
<>
|
||||||
|
Your current role doesn't provide access to this feature.
|
||||||
|
<br /> Contact your administrator to request access.
|
||||||
|
</>
|
||||||
|
)
|
||||||
|
}: Props) => {
|
||||||
|
return (
|
||||||
|
<div className="flex items-center space-x-6 rounded-md border border-mineshaft-500 bg-gradient-to-br from-mineshaft-900 to-mineshaft-600 px-16 py-12 text-center text-bunker-300">
|
||||||
|
<div>
|
||||||
|
<div className="text-4xl font-medium text-bunker-100">{title}</div>
|
||||||
|
<div className="-mt-1 text-sm">{body}</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
export * from "./AccessRestrictedBanner";
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
/* eslint-disable react-refresh/only-export-components */
|
/* eslint-disable react-refresh/only-export-components */
|
||||||
|
export * from "./AccessRestrictedBanner";
|
||||||
export * from "./Accordion";
|
export * from "./Accordion";
|
||||||
export * from "./Alert";
|
export * from "./Alert";
|
||||||
export * from "./Badge";
|
export * from "./Badge";
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
import { ComponentType } from "react";
|
import { ComponentType } from "react";
|
||||||
import { Abilities, AbilityTuple, Generics, SubjectType } from "@casl/ability";
|
import { Abilities, AbilityTuple, Generics, SubjectType } from "@casl/ability";
|
||||||
import { faLock } from "@fortawesome/free-solid-svg-icons";
|
|
||||||
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
|
||||||
import { twMerge } from "tailwind-merge";
|
import { twMerge } from "tailwind-merge";
|
||||||
|
|
||||||
|
import { AccessRestrictedBanner } from "@app/components/v2";
|
||||||
import { TOrgPermission, useOrgPermission } from "@app/context";
|
import { TOrgPermission, useOrgPermission } from "@app/context";
|
||||||
|
|
||||||
type Props<T extends Abilities> = (T extends AbilityTuple
|
type Props<T extends Abilities> = (T extends AbilityTuple
|
||||||
@@ -14,11 +13,11 @@ type Props<T extends Abilities> = (T extends AbilityTuple
|
|||||||
: {
|
: {
|
||||||
action: string;
|
action: string;
|
||||||
subject: string;
|
subject: string;
|
||||||
}) & { className?: string; containerClassName?: string };
|
}) & { containerClassName?: string };
|
||||||
|
|
||||||
export const withPermission = <T extends object, J extends TOrgPermission>(
|
export const withPermission = <T extends object, J extends TOrgPermission>(
|
||||||
Component: ComponentType<T>,
|
Component: ComponentType<T>,
|
||||||
{ action, subject, className, containerClassName }: Props<Generics<J>["abilities"]>
|
{ action, subject, containerClassName }: Props<Generics<J>["abilities"]>
|
||||||
) => {
|
) => {
|
||||||
const HOC = (hocProps: T) => {
|
const HOC = (hocProps: T) => {
|
||||||
const { permission } = useOrgPermission();
|
const { permission } = useOrgPermission();
|
||||||
@@ -33,22 +32,7 @@ export const withPermission = <T extends object, J extends TOrgPermission>(
|
|||||||
containerClassName
|
containerClassName
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
<div
|
<AccessRestrictedBanner />
|
||||||
className={twMerge(
|
|
||||||
"flex items-end space-x-12 rounded-md bg-mineshaft-800 p-16 text-bunker-300",
|
|
||||||
className
|
|
||||||
)}
|
|
||||||
>
|
|
||||||
<div>
|
|
||||||
<FontAwesomeIcon icon={faLock} size="6x" />
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<div className="mb-2 text-4xl font-medium">Access Restricted</div>
|
|
||||||
<div className="text-sm">
|
|
||||||
Your role has limited permissions, please <br /> contact your admin to gain access
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,14 +1,12 @@
|
|||||||
import { ComponentType } from "react";
|
import { ComponentType } from "react";
|
||||||
import { AbilityTuple } from "@casl/ability";
|
import { AbilityTuple } from "@casl/ability";
|
||||||
import { faLock } from "@fortawesome/free-solid-svg-icons";
|
|
||||||
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
|
||||||
import { twMerge } from "tailwind-merge";
|
import { twMerge } from "tailwind-merge";
|
||||||
|
|
||||||
|
import { AccessRestrictedBanner } from "@app/components/v2";
|
||||||
import { useProjectPermission } from "@app/context";
|
import { useProjectPermission } from "@app/context";
|
||||||
import { ProjectPermissionSet } from "@app/context/ProjectPermissionContext";
|
import { ProjectPermissionSet } from "@app/context/ProjectPermissionContext";
|
||||||
|
|
||||||
type Props<T extends AbilityTuple> = {
|
type Props<T extends AbilityTuple> = {
|
||||||
className?: string;
|
|
||||||
containerClassName?: string;
|
containerClassName?: string;
|
||||||
action: T[0];
|
action: T[0];
|
||||||
subject: T[1];
|
subject: T[1];
|
||||||
@@ -16,7 +14,7 @@ type Props<T extends AbilityTuple> = {
|
|||||||
|
|
||||||
export const withProjectPermission = <T extends object>(
|
export const withProjectPermission = <T extends object>(
|
||||||
Component: ComponentType<Omit<Props<ProjectPermissionSet>, "action" | "subject"> & T>,
|
Component: ComponentType<Omit<Props<ProjectPermissionSet>, "action" | "subject"> & T>,
|
||||||
{ action, subject, className, containerClassName }: Props<ProjectPermissionSet>
|
{ action, subject, containerClassName }: Props<ProjectPermissionSet>
|
||||||
) => {
|
) => {
|
||||||
const HOC = (hocProps: Omit<Props<ProjectPermissionSet>, "action" | "subject"> & T) => {
|
const HOC = (hocProps: Omit<Props<ProjectPermissionSet>, "action" | "subject"> & T) => {
|
||||||
const { permission } = useProjectPermission();
|
const { permission } = useProjectPermission();
|
||||||
@@ -31,23 +29,7 @@ export const withProjectPermission = <T extends object>(
|
|||||||
containerClassName
|
containerClassName
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
<div
|
<AccessRestrictedBanner />
|
||||||
className={twMerge(
|
|
||||||
"flex items-end space-x-12 rounded-md bg-mineshaft-800 p-16 text-bunker-300",
|
|
||||||
className
|
|
||||||
)}
|
|
||||||
>
|
|
||||||
<div>
|
|
||||||
<FontAwesomeIcon icon={faLock} size="6x" />
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<div className="mb-2 text-4xl font-medium">Permission Denied</div>
|
|
||||||
<div className="text-sm">
|
|
||||||
You do not have permission to this page. <br /> Kindly contact your organization
|
|
||||||
administrator
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -948,12 +948,12 @@ const Page = () => {
|
|||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
{noAccessSecretCount > 0 && <SecretNoAccessListView count={noAccessSecretCount} />}
|
{noAccessSecretCount > 0 && <SecretNoAccessListView count={noAccessSecretCount} />}
|
||||||
{!canReadSecret &&
|
|
||||||
!canReadDynamicSecret &&
|
|
||||||
!canReadSecretImports &&
|
|
||||||
folders?.length === 0 && <PermissionDeniedBanner />}
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
{!canReadSecret &&
|
||||||
|
!canReadDynamicSecret &&
|
||||||
|
!canReadSecretImports &&
|
||||||
|
folders?.length === 0 && <PermissionDeniedBanner />}
|
||||||
{!isDetailsLoading &&
|
{!isDetailsLoading &&
|
||||||
(totalCount > 0 ||
|
(totalCount > 0 ||
|
||||||
pendingChanges.secrets.length > 0 ||
|
pendingChanges.secrets.length > 0 ||
|
||||||
|
|||||||
+6
-8
@@ -1,6 +1,6 @@
|
|||||||
import { faBan } from "@fortawesome/free-solid-svg-icons";
|
import { faBan } from "@fortawesome/free-solid-svg-icons";
|
||||||
|
|
||||||
import { ContentLoader, EmptyState } from "@app/components/v2";
|
import { AccessRestrictedBanner, ContentLoader, EmptyState } from "@app/components/v2";
|
||||||
import { useSubscription, useWorkspace } from "@app/context";
|
import { useSubscription, useWorkspace } from "@app/context";
|
||||||
import { useGetSecretScanningConfig } from "@app/hooks/api/secretScanningV2";
|
import { useGetSecretScanningConfig } from "@app/hooks/api/secretScanningV2";
|
||||||
|
|
||||||
@@ -16,16 +16,14 @@ export const ProjectScanningConfigTab = () => {
|
|||||||
|
|
||||||
if (!subscription.secretScanning) {
|
if (!subscription.secretScanning) {
|
||||||
return (
|
return (
|
||||||
<div className="flex h-full w-full items-center justify-center px-20">
|
<div className="mt-60 flex h-full w-full items-center justify-center px-20">
|
||||||
<EmptyState
|
<AccessRestrictedBanner
|
||||||
className="rounded-md text-center"
|
body={
|
||||||
icon={faBan}
|
<>
|
||||||
title={
|
|
||||||
<span>
|
|
||||||
Your current plan doesn't support Secret Scanning.
|
Your current plan doesn't support Secret Scanning.
|
||||||
<br /> Please contact Infisical Support or reach out through our Slack channel for
|
<br /> Please contact Infisical Support or reach out through our Slack channel for
|
||||||
assistance.
|
assistance.
|
||||||
</span>
|
</>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user