Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hotfix/pin-5752-hide-signal-hub-eservices #1025

Merged
merged 10 commits into from
Dec 10, 2024

Conversation

martinaCampoli
Copy link
Contributor

Added check on eservices ids to hide signal hub eservices

Comment on lines 38 to 52
const sxCardProps: SxProps =
disabled === true
? {
height: '100%',
display: 'flex',
flexDirection: 'column',
minHeight: 410,
opacity: 0.5,
}
: {
height: '100%',
display: 'flex',
flexDirection: 'column',
minHeight: 410,
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const sxCardProps: SxProps =
disabled === true
? {
height: '100%',
display: 'flex',
flexDirection: 'column',
minHeight: 410,
opacity: 0.5,
}
: {
height: '100%',
display: 'flex',
flexDirection: 'column',
minHeight: 410,
}
const sxCardProps: SxProps = {
height: '100%',
display: 'flex',
flexDirection: 'column',
minHeight: 410,
opacity: disabled ? 0.5 : 1,
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be simplified as such.
Plus, since it is used just once, I would put it "inside" the prop

Comment on lines 54 to 76
const linkEservice = (
<>
<Tooltip key="subscribe-tooltip" title={disabled ? t('subscribeTooltip') : ''} arrow>
<span>
<Link
as="button"
size="small"
variant="contained"
to="SUBSCRIBE_CATALOG_VIEW"
params={{
eserviceId: eservice.id,
descriptorId: eservice.activeDescriptor?.id ?? '',
}}
onFocusVisible={handlePrefetch}
color="primary"
disabled={disabled}
>
{tCommon('actions.inspect')}
</Link>
</span>
</Tooltip>
</>
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you extract it in a separate constant?
The React fragments and the key prop are not needed.
To make the Tooltip "optional" you need to pass the open prop and optionally pass false or undefined, you can see an example here /src/components/shared/StepActions.tsx.
You can also remove the ternary on the title prop

Comment on lines 41 to 52
export const SH_ESERVICES_ATT_TEMP = ['9b6993ee-60e3-4901-9a32-e6987d690ec4'] //signal hub eservices to hide
export const SH_ESERVICES_UAT_TEMP = [
//signal hub eservices to hide
'7ab0a0fc-7d22-4007-b2f3-fddd68fe2f17',
'e8c087eb-627b-4488-a9b7-65b70fd1301b',
'407edf51-23b5-462b-af6e-128bbaa4d9ff',
'3b0fbe47-2e2c-4d8b-9cff-b2381c92d003',
'260e45e1-9a61-49d6-8b6d-da0643da68ac',
'a2b84a6e-34cf-44ca-85a4-de21fd232668',
'6b14c622-dad2-44ea-82bc-2dd4010364d5',
'03c34a8a-a79a-4928-9afc-8647eefabdb1',
]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would make this more flexible:

export const SH_ESERVICES_TO_HIDE: Partial<Record<PagoPAEnvVars['STAGE'], Array<string>>> = {
  ATT: ['9b6993ee-60e3-4901-9a32-e6987d690ec4'],
  UAT: [
    '7ab0a0fc-7d22-4007-b2f3-fddd68fe2f17',
    'e8c087eb-627b-4488-a9b7-65b70fd1301b',
    '407edf51-23b5-462b-af6e-128bbaa4d9ff',
    '3b0fbe47-2e2c-4d8b-9cff-b2381c92d003',
    '260e45e1-9a61-49d6-8b6d-da0643da68ac',
    'a2b84a6e-34cf-44ca-85a4-de21fd232668',
    '6b14c622-dad2-44ea-82bc-2dd4010364d5',
    '03c34a8a-a79a-4928-9afc-8647eefabdb1',
  ],
}

This would also semplify the logic that uses those

Comment on lines 24 to 35
{(STAGE === 'ATT' &&
SH_ESERVICES_ATT_TEMP.some(
(shEservice) => shEservice === eservice.activeDescriptor?.id
)) ||
(STAGE === 'UAT' &&
SH_ESERVICES_UAT_TEMP.some(
(shEservice) => shEservice === eservice.activeDescriptor?.id
)) ? (
<CatalogCard key={eservice.activeDescriptor?.id} eservice={eservice} disabled={true} />
) : (
<CatalogCard key={eservice.activeDescriptor?.id} eservice={eservice} disabled={false} />
)}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
{(STAGE === 'ATT' &&
SH_ESERVICES_ATT_TEMP.some(
(shEservice) => shEservice === eservice.activeDescriptor?.id
)) ||
(STAGE === 'UAT' &&
SH_ESERVICES_UAT_TEMP.some(
(shEservice) => shEservice === eservice.activeDescriptor?.id
)) ? (
<CatalogCard key={eservice.activeDescriptor?.id} eservice={eservice} disabled={true} />
) : (
<CatalogCard key={eservice.activeDescriptor?.id} eservice={eservice} disabled={false} />
)}
<CatalogCard
key={eservice.activeDescriptor?.id}
eservice={eservice}
disabled={!!SH_ESERVICES_TO_HIDE[STAGE]?.includes(eservice.id)}
/>

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are the SH_ESERVICES_TO_HIDE eservice or descriptor ids?

Comment on lines 81 to 119
{disabled ? (
<Tooltip open={disabled ? undefined : false} title={t('subscribeTooltip')} arrow>
<span>
<Link
as="button"
size="small"
variant="contained"
to="SUBSCRIBE_CATALOG_VIEW"
params={{
eserviceId: eservice.id,
descriptorId: eservice.activeDescriptor?.id ?? '',
}}
onFocusVisible={handlePrefetch}
color="primary"
disabled={disabled}
>
{tCommon('actions.inspect')}
</Link>
</span>
</Tooltip>
) : (
<span>
<Link
as="button"
size="small"
variant="contained"
to="SUBSCRIBE_CATALOG_VIEW"
params={{
eserviceId: eservice.id,
descriptorId: eservice.activeDescriptor?.id ?? '',
}}
onFocusVisible={handlePrefetch}
color="primary"
disabled={disabled}
>
{tCommon('actions.inspect')}
</Link>
</span>
)}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no need to put the ternary here

@martinaCampoli martinaCampoli changed the base branch from dev to main December 10, 2024 11:15
@martinaCampoli martinaCampoli changed the title feature/pin-5752-hide-signal-hub-eservices hotfix/pin-5752-hide-signal-hub-eservices Dec 10, 2024
@Carminepo2 Carminepo2 merged commit 5c219d8 into main Dec 10, 2024
6 checks passed
@Carminepo2 Carminepo2 deleted the feature/pin-5752-hide-signal-hub-eservices branch December 10, 2024 11:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants