mirror of
https://github.com/Unleash/unleash.git
synced 2025-09-24 17:51:14 +02:00
* refactor: page container * refactor: table page header * feat: new feature toggles list in project overview * feat: sortable enviromnents in project overview * feat: project overview toggles search * feat: project overview features column actions * project overview table column sizing * project overview feature actions permissions * project overview archive feature action * project overview toggle state strategy fallback * remove previous project overview implementation * fix: remove additional prop in sortable table * fix: stale feature refetch * improvements after review * feat: manage visible columns in project overview * improve project overview columns selection * fix: simplify columns * Revert "remove previous project overview implementation" This reverts commit 98b051ff6a5a4fb8a9a0921b661514e15a00249a. * restore legacy project overview table
46 lines
1.2 KiB
TypeScript
46 lines
1.2 KiB
TypeScript
import { useContext, FC, ReactElement } from 'react';
|
|
import AccessContext from 'contexts/AccessContext';
|
|
import {
|
|
ITooltipResolverProps,
|
|
TooltipResolver,
|
|
} from 'component/common/TooltipResolver/TooltipResolver';
|
|
import { formatAccessText } from 'utils/formatAccessText';
|
|
|
|
type IPermissionHOCProps = {
|
|
permission: string;
|
|
projectId?: string;
|
|
environmentId?: string;
|
|
tooltip?: string;
|
|
tooltipProps?: Omit<ITooltipResolverProps, 'children' | 'title'>;
|
|
children: ({ hasAccess }: { hasAccess?: boolean }) => ReactElement;
|
|
};
|
|
|
|
export const PermissionHOC: FC<IPermissionHOCProps> = ({
|
|
permission,
|
|
projectId,
|
|
children,
|
|
environmentId,
|
|
tooltip,
|
|
tooltipProps,
|
|
}) => {
|
|
const { hasAccess } = useContext(AccessContext);
|
|
let access;
|
|
|
|
if (projectId && environmentId) {
|
|
access = hasAccess(permission, projectId, environmentId);
|
|
} else if (projectId) {
|
|
access = hasAccess(permission, projectId);
|
|
} else {
|
|
access = hasAccess(permission);
|
|
}
|
|
|
|
return (
|
|
<TooltipResolver
|
|
{...tooltipProps}
|
|
title={formatAccessText(access, tooltip)}
|
|
>
|
|
{children({ hasAccess: access })}
|
|
</TooltipResolver>
|
|
);
|
|
};
|