Skip to content

Commit

Permalink
feat(ospm): enhance permission validation (#1176)
Browse files Browse the repository at this point in the history
  • Loading branch information
lavanya-bmw authored Oct 7, 2024
1 parent 2e60493 commit 7bc70e4
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 5 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
- updated technical user details with user type and service endpoint fields. Also, updated copy icon color for better view and made copy icon available only when value is available [#1137](https://github.com/eclipse-tractusx/portal-frontend/pull/1137)
- **Company Subscriptions**
- update API query parameters and fix tab UI scroll [#1131](https://github.com/eclipse-tractusx/portal-frontend/pull/1131)
- **Onboarding Service Provider**
- enhanced permission and company role validation for Onboarding Service Provider [#1176](https://github.com/eclipse-tractusx/portal-frontend/pull/1176)

### Bugfixes

Expand Down
4 changes: 2 additions & 2 deletions DEPENDENCIES
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ npm/npmjs/-/arg/4.1.3, MIT, approved, clearlydefined
npm/npmjs/-/argparse/1.0.10, MIT, approved, #2174
npm/npmjs/-/argparse/2.0.1, Python-2.0, approved, CQ22954
npm/npmjs/-/aria-query/5.1.3, Apache-2.0, approved, clearlydefined
npm/npmjs/-/aria-query/5.3.0, Apache-2.0, approved, clearlydefined
npm/npmjs/-/aria-query/5.3.0, Apache-2.0, approved, #16427
npm/npmjs/-/array-buffer-byte-length/1.0.1, MIT, approved, #7548
npm/npmjs/-/array-includes/3.1.8, MIT, approved, #4577
npm/npmjs/-/array-union/2.1.0, MIT, approved, clearlydefined
Expand Down Expand Up @@ -696,7 +696,7 @@ npm/npmjs/@react-hook/cache/1.1.1, MIT, approved, clearlydefined
npm/npmjs/@react-hook/latest/1.0.3, MIT, approved, clearlydefined
npm/npmjs/@reduxjs/toolkit/2.2.7, MIT AND (BSD-2-Clause AND ISC AND MIT) AND Apache-2.0, approved, #14170
npm/npmjs/@remix-run/router/1.15.3, MIT, approved, clearlydefined
npm/npmjs/@rollup/pluginutils/5.1.0, MIT, approved, clearlydefined
npm/npmjs/@rollup/pluginutils/5.1.0, MIT, approved, #16428
npm/npmjs/@rollup/rollup-android-arm-eabi/4.17.2, MIT, approved, clearlydefined
npm/npmjs/@rollup/rollup-android-arm64/4.17.2, MIT, approved, clearlydefined
npm/npmjs/@rollup/rollup-darwin-arm64/4.17.2, MIT, approved, clearlydefined
Expand Down
21 changes: 18 additions & 3 deletions src/components/shared/frame/Header/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* SPDX-License-Identifier: Apache-2.0
********************************************************************************/

import { useState } from 'react'
import { useEffect, useState } from 'react'
import { NavLink } from 'react-router-dom'
import { useSelector, useDispatch } from 'react-redux'
import { Trans, useTranslation } from 'react-i18next'
Expand Down Expand Up @@ -49,6 +49,8 @@ import RegistrationReviewOverlay from './RegistrationReviewOverlay'
import './Header.scss'
import RegistrationReviewContent from './RegistrationReviewOverlay/RegistrationReviewContent'
import RegistrationDeclinedOverlay from './RegistrationDeclinedOverlay'
import { useFetchOwnCompanyDetailsQuery } from 'features/admin/userApiSlice'
import { PAGES } from 'types/Constants'

export const Header = ({
main,
Expand All @@ -69,11 +71,24 @@ export const Header = ({

const { data } = useFetchApplicationsQuery()
const companyData = data?.[0]

const { data: companyDetails } = useFetchOwnCompanyDetailsQuery('')
const [submittedOverlayOpen, setSubmittedOverlayOpen] = useState(
companyData?.applicationStatus === ApplicationStatus.SUBMITTED
)
const [headerNote, setHeaderNote] = useState(false)
const [pages, setPages] = useState<string[]>([])

useEffect(() => {
if (companyDetails?.companyRole.includes('ONBOARDING_SERVICE_PROVIDER')) {
setPages(user)
} else {
setPages(
user.filter(
(item) => item !== PAGES.MANAGEMENT_ONBOARDING_SERVICE_PROVIDER
)
)
}
}, [companyDetails?.companyRole])

const addTitle = (items: Tree[] | undefined) =>
items?.map(
Expand Down Expand Up @@ -187,7 +202,7 @@ export const Header = ({
>
{t('pages.help')}
</Button>
<UserInfo pages={user} />
<UserInfo pages={pages} />
</div>
</MainNavigation>
</header>
Expand Down
1 change: 1 addition & 0 deletions src/types/Config.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -599,6 +599,7 @@ export const ALL_PAGES: IPage[] = [
},
{
name: PAGES.MANAGEMENT_ONBOARDING_SERVICE_PROVIDER,
allowTo: () => userHasPortalRole(ROLES.CONFIGURE_PARTNER_REGISTRATION),
element: <OnboardingServiceProvider />,
},
]
Expand Down
1 change: 1 addition & 0 deletions src/types/Constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ export enum ROLES {
REVOKE_CREDENTIALS_ISSUER = 'revoke_credentials_issuer',
VIEW_REGISTRATION = 'view_registration',
READ_PARTNER = 'read_partner',
CONFIGURE_PARTNER_REGISTRATION = 'configure_partner_registration',
}

export enum HINTS {
Expand Down

0 comments on commit 7bc70e4

Please sign in to comment.