Skip to content

Commit

Permalink
fix(sonar): fix findings
Browse files Browse the repository at this point in the history
  • Loading branch information
oyo committed Jun 12, 2024
1 parent e140f2d commit 6ff09a7
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 21 deletions.
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<div id="app"></div>
<script>
// Do NOT change 'ENV' without changing 'custom_env_vars_anchor' in scripts/inject-dynamic-env.sh as well
const ENV = {REQUIRE_HTTPS_URL_PATTERN:"true",PORTAL_ASSETS_URL:"https://portal.dev.demo.catena-x.net/assets",PORTAL_BACKEND_URL:"https://portal-backend.dev.demo.catena-x.net",CENTRALIDP_URL:"https://centralidp.dev.demo.catena-x.net/auth",SSI_CREDENTIAL_URL:"https://ssi-credential-issuer.dev.demo.catena-x.net",BPDM_POOL_API_URL:"https://business-partners.dev.demo.catena-x.net/pool/v6",BPDM_GATE_API_URL:"https://business-partners.dev.demo.catena-x.net/companies/test-company/v6",SEMANTICS_URL:"https://semantics.dev.demo.catena-x.net",MANAGED_IDENTITY_WALLETS_NEW_URL:"https://managed-identity-wallets-new.dev.demo.catena-x.net",REALM:"CX-Central",CLIENT_ID:"Cl2-CX-Portal",CLIENT_ID_SEMANTIC:"Cl3-CX-Semantic",CLIENT_ID_MIW:"Cl5-CX-Custodian",CLIENT_ID_SSI_CREDENTIAL:"Cl24-CX-SSI-CredentialIssuer"}
const ENV = {REQUIRE_HTTPS_URL_PATTERN:"true",PORTAL_ASSETS_URL:"http://localhost:3000/assets",PORTAL_BACKEND_URL:"https://portal-backend.example.org",CENTRALIDP_URL:"https://centralidp.example.org/auth",SSI_CREDENTIAL_URL:"https://ssi-credential-issuer.example.org",BPDM_API_URL:"https://business-partners.example.org/pool/v6",SEMANTICS_URL:"https://semantics.example.org",MANAGED_IDENTITY_WALLETS_NEW_URL:"https://managed-identity-wallets-new.example.org",REALM:"CX-Central",CLIENT_ID:"Cl2-CX-Portal",CLIENT_ID_SEMANTIC:"Cl3-CX-Semantic",CLIENT_ID_MIW:"Cl5-CX-Custodian",CLIENT_ID_SSI_CREDENTIAL:"Cl24-CX-SSI-CredentialIssuer"}
</script>
<script type="module" src="/src/index.tsx"></script>
</body>
Expand Down
4 changes: 1 addition & 3 deletions src/components/overlays/CompanyCertificateDetails/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -208,9 +208,7 @@ export default function CompanyCertificateDetails({
</Box>
<Box>
<Button
disabled={
!userHasPortalRole(ROLES.SUBSCRIBE_SERVICE_MARKETPLACE)
}
disabled={!userHasPortalRole(ROLES.SUBSCRIBE_SERVICE)}
startIcon={<DeleteIcon />}
variant="outlined"
size="small"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ export default function CompanyCertificateCard({
borderRadius: '74px',
}}
onClick={handleDelete}
disabled={!userHasPortalRole(ROLES.SUBSCRIBE_SERVICE_MARKETPLACE)}
disabled={!userHasPortalRole(ROLES.SUBSCRIBE_SERVICE)}
>
<DeleteOutlinedIcon
style={{
Expand Down Expand Up @@ -202,7 +202,7 @@ export default function CompanyCertificateCard({
<Typography variant="label3" onClick={handleView}>
{t('content.companyCertificate.view')}{' '}
</Typography>
{userHasPortalRole(ROLES.SUBSCRIBE_SERVICE_MARKETPLACE) &&
{userHasPortalRole(ROLES.SUBSCRIBE_SERVICE) &&
item.companyCertificateStatus ===
CompanyCertificateStatus.ACTIVE && (
<Typography variant="label3" onClick={handleDelete}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export default function MarketplaceHeader({
<Button
color="primary"
className="subscribe-btn"
disabled={!userHasPortalRole(ROLES.SUBSCRIBE_SERVICE_MARKETPLACE)}
disabled={!userHasPortalRole(ROLES.SUBSCRIBE_SERVICE)}
onClick={() => dispatch(show(OVERLAYS.SERVICE_REQUEST, serviceId))}
>
{t('content.appdetail.subscribe')}
Expand Down
12 changes: 3 additions & 9 deletions src/services/AccessService.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,7 @@
* SPDX-License-Identifier: Apache-2.0
********************************************************************************/

import type {
IAction,
IOverlay,
IPage,
RestrictedItem,
Tree,
} from 'types/MainTypes'
import type { IAction, IPage, RestrictedItem, Tree } from 'types/MainTypes'
import { Route } from 'react-router-dom'
import AppInfo from 'components/overlays/AppInfo'
import AddBPN from 'components/overlays/AddBPN'
Expand Down Expand Up @@ -88,7 +82,7 @@ import {

let pageMap: { [page: string]: IPage }
let actionMap: { [action: string]: IAction }
let overlayMap: { [overlay: string]: IOverlay }
let overlayMap: { [overlay: string]: RestrictedItem }

export const userHasAccess = (required: KeycloakResourceAccess): boolean =>
Object.keys(intersectAccess(required, getAccess())).length > 0
Expand Down Expand Up @@ -265,7 +259,7 @@ function init() {
{}
)
overlayMap = ALL_OVERLAYS.reduce(
(map: { [overlay: string]: IOverlay }, overlay: IOverlay) => {
(map: { [overlay: string]: RestrictedItem }, overlay: RestrictedItem) => {
map[overlay.name] = overlay
return map
},
Expand Down
4 changes: 2 additions & 2 deletions src/types/Config.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ import UserManagement from 'components/pages/UserManagement'
import UserDetails from 'components/pages/UserDetail'
import { Route } from 'react-router-dom'
import { ACTIONS, HINTS, OVERLAYS, PAGES, ROLES } from './Constants'
import type { IAction, IOverlay, IPage } from './MainTypes'
import type { IAction, RestrictedItem, IPage } from './MainTypes'
import AppUserManagement from 'components/pages/AppUserManagement'
import IDPManagement from 'components/pages/IDPManagement'
import IDPDetail from 'components/pages/IDPDetail'
Expand Down Expand Up @@ -611,7 +611,7 @@ export const ALL_PAGES: IPage[] = [
},
]

export const ALL_OVERLAYS: IOverlay[] = [
export const ALL_OVERLAYS: RestrictedItem[] = [
{
name: OVERLAYS.ADD_BPN,
allowTo: () => userHasPortalRole(ROLES.MODIFY_USER_ACCOUNT),
Expand Down
1 change: 0 additions & 1 deletion src/types/Constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,6 @@ export enum ROLES {
SETUP_CLIENT = 'setup_client',
APPSTORE_VIEW = 'view_apps',
APPSTORE_VIEW_SERVICES = 'view_service_marketplace',
SUBSCRIBE_SERVICE_MARKETPLACE = 'subscribe_service',
APPSTORE_VIEW_DATASPACES = 'view_dataspaces',
APPSTORE_ADD = 'add_app',
APPSTORE_EDIT = 'edit_apps',
Expand Down
2 changes: 0 additions & 2 deletions src/types/MainTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,6 @@ export type IPage = RestrictedItem & {
children?: string[]
}

export type IOverlay = RestrictedItem

export type IAction = RestrictedItem & {
element: JSX.Element
value?: string
Expand Down

0 comments on commit 6ff09a7

Please sign in to comment.