import {Trans} from '@common/i18n/trans';
import {Link} from 'react-router-dom';
import {LinkStyle} from '@common/ui/buttons/external-link';
import {ReactElement, ReactNode} from 'react';
import {SectionHelper, SectionHelperProps} from '@common/ui/section-helper';
import {useSettings} from '@common/core/settings/use-settings';
import {PolicyFailReason} from '@common/billing/upgrade/policy-fail-reason';
interface Props {
className?: string;
// plural name in lowercase (e.g. 'projects')
resourceName?: ReactElement | string;
reason?: PolicyFailReason;
size?: SectionHelperProps['size'];
color?: SectionHelperProps['color'];
message?: ReactNode;
}
export function PolicyFailMessage({
resourceName,
className,
size = 'md',
color = 'bgAlt',
reason = 'overQuota',
...other
}: Props) {
const message = other.message ?? (
);
return (
);
}
interface MessageTextProps {
resourceName: ReactElement | string;
reason?: PolicyFailReason;
}
function MessageText({resourceName, reason}: MessageTextProps) {
const {billing} = useSettings();
if (reason === 'noWorkspacePermission') {
return (
);
}
const upgradeMsgValues = {
name: resourceName,
a: (text: ReactNode) => (
{text}
),
};
if (reason === 'overQuota' && billing.enable) {
return (
);
}
if (reason === 'noPermission' && billing.enable) {
return (
);
}
return ;
}