Skip to content

Commit

Permalink
front: Allow creation of new projetc/study/scenario if the user has O…
Browse files Browse the repository at this point in the history
…psWrite role.

Signed-off-by: nncluzu <ngamenichaka@yahoo.fr>
  • Loading branch information
kmer2016 authored and RomainValls committed Oct 28, 2024
1 parent 494f2a2 commit 509ec01
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions front/src/common/AddNewCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import type { ReactNode } from 'react';
import { useTranslation } from 'react-i18next';
import { FaPlus } from 'react-icons/fa';

import RoleBasedContent from './authorization/components/RoleBasedContent';
import { useModal } from './BootstrapSNCF/ModalSNCF';

type AddNewCardProps = {
Expand All @@ -24,16 +25,18 @@ const AddNewCard = ({
const { openModal } = useModal();

return (
<div
data-testid={testId}
className={className}
role="button"
tabIndex={0}
onClick={() => openModal(modalComponent, 'xl', 'no-close-modal')}
>
<FaPlus />
<div className="legend">{t(legendTranslationKey)}</div>
</div>
<RoleBasedContent requiredRoles={['OpsWrite']} disableIfUnauthorized>
<div
data-testid={testId}
className={className}
role="button"
tabIndex={0}
onClick={() => openModal(modalComponent, 'xl', 'no-close-modal')}
>
<FaPlus />
<div className="legend">{t(legendTranslationKey)}</div>
</div>
</RoleBasedContent>
);
};

Expand Down

0 comments on commit 509ec01

Please sign in to comment.