Skip to content

Commit 0981c2e

Browse files
authored
fix: disable My Apps button for users without permission (eclipse-tractusx#1165)
eclipse-tractusx#1157
1 parent 62d669d commit 0981c2e

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed

src/components/pages/Home/components/StageSection/index.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ import { useTranslation } from 'react-i18next'
2222
import { getAssetBase } from 'services/EnvironmentService'
2323
import { SlidingMainHeader } from 'components/shared/frame/SlidingMainHeader/SlidingMainHeader'
2424
import { useNavigate } from 'react-router-dom'
25+
import { userHasPortalRole } from 'services/AccessService'
26+
import { ROLES } from 'types/Constants'
2527

2628
export default function StageSection() {
2729
const { t } = useTranslation()
@@ -39,6 +41,7 @@ export default function StageSection() {
3941
handleClick: () => {
4042
navigate(t('content.home.stage.slider1.navigation'))
4143
},
44+
hasAccess: userHasPortalRole(ROLES.APPMANAGEMENT_VIEW),
4245
},
4346
{
4447
title: t('content.home.stage.slider2.title'),
@@ -57,6 +60,7 @@ export default function StageSection() {
5760
handleClick: () => {
5861
navigate(t('content.home.stage.slider3.navigation'))
5962
},
63+
hasAccess: userHasPortalRole(ROLES.APPSTORE_VIEW),
6064
},
6165
{
6266
title: t('content.home.stage.slider4.title'),
@@ -66,6 +70,7 @@ export default function StageSection() {
6670
handleClick: () => {
6771
navigate(t('content.home.stage.slider4.navigation'))
6872
},
73+
hasAccess: userHasPortalRole(ROLES.USERMANAGEMENT_VIEW),
6974
},
7075
]}
7176
stageHeaderInfo={[

src/components/shared/frame/SlidingMainHeader/Header.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ export interface HeaderProps {
3131
subTitleTextVariant?: 'h1' | 'h2' | 'h3'
3232
buttonText?: string
3333
handleClick: () => void
34+
hasAccess?: boolean
3435
}
3536

3637
//TO-DO - Move this component to cx-shared repo after the yarn upgrade
@@ -44,6 +45,7 @@ export const Header = ({
4445
subTitleTextVariant = 'h2',
4546
buttonText,
4647
handleClick,
48+
hasAccess,
4749
}: HeaderProps) => {
4850
return (
4951
<Box
@@ -91,6 +93,7 @@ export const Header = ({
9193
onClick={() => {
9294
handleClick()
9395
}}
96+
disabled={!(hasAccess ?? true)}
9497
>
9598
{buttonText}
9699
</Button>

src/components/shared/frame/SlidingMainHeader/SlidingMainHeader.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ export interface SlidingMainHeaderProps {
2828
subTitle: string
2929
imagePath: string
3030
buttonText: string
31+
hasAccess?: boolean
3132
handleClick: () => void
3233
}[]
3334
autoplay?: boolean

0 commit comments

Comments
 (0)