Skip to content

Commit

Permalink
fix(restricted): fix minimum rights display for US
Browse files Browse the repository at this point in the history
ref: MANAGER-16677 PRB0041985

Signed-off-by: David Arsène <[email protected]>
  • Loading branch information
darsene committed Jan 9, 2025
1 parent fdec1f1 commit 6a6c0f7
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
type RIGHT = {
urn: string;
subsidiariesExcluded?: string[];
};

export const MINIMUM_RIGHTS: RIGHT[] = [
{ urn: 'account:apiovh:me/get' },
{
urn: 'account:apiovh:me/supportLevel/get',
subsidiariesExcluded: ['US'],
},
{ urn: 'account:apiovh:me/certificates/get' },
{ urn: 'ccount:apiovh:me/tag/get' },
] as const;
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { useContext } from 'react';
import Context from '@/context';
import { MINIMUM_RIGHTS } from './constants';

export default function useMinimalRights() {
const { ovhSubsidiary } = useContext(Context);
return MINIMUM_RIGHTS.filter(
({ subsidiariesExcluded }) =>
!subsidiariesExcluded || !subsidiariesExcluded.includes(ovhSubsidiary),
);
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import React, { useContext } from 'react';
import React from 'react';
import { useTranslation } from 'react-i18next';

import useMinimalRights from '@/hooks/useMinimalRights/useMinimalRights';
import jumbotron from './error-jumbotron.png';
import './error-jumbotron.styles.scss';
import Context from '@/context';

const ErrorJumbotron = (): JSX.Element => {
const { t } = useTranslation('restricted');
const { region } = useContext(Context);
const isUsRegion = region === 'US';
const minimalRights = useMinimalRights();

return (
<div className="my-5 error-jumbotron d-flex flex-column">
<div className="d-flex justify-content-center">
Expand All @@ -22,14 +22,13 @@ const ErrorJumbotron = (): JSX.Element => {
></span>
<p className="oui-message__body">
{t(`restricted_error_default_start`, {
count: isUsRegion ? 3 : 4,
count: minimalRights.length,
})}
</p>
<ul>
<li>account:apiovh:me/get</li>
{!isUsRegion && <li>account:apiovh:me/supportLevel/get</li>}
<li>account:apiovh:me/certificates/get</li>
<li>account:apiovh:me/tag/get</li>
{minimalRights.map(({ urn }) => (
<li key={urn}>{urn}</li>
))}
</ul>
<p className="oui-message__body">{t('restricted_error_default_end')}</p>
</div>
Expand Down

0 comments on commit 6a6c0f7

Please sign in to comment.