Skip to content

Commit

Permalink
fixed minor text bug and change UserService to use AM client V0 for f…
Browse files Browse the repository at this point in the history
…etching party from reportee list
  • Loading branch information
Vedeler committed Dec 19, 2024
1 parent 4df7533 commit 0df30e4
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,25 @@ public class UserService : IUserService
private readonly ILogger _logger;

Check warning on line 21 in backend/src/Altinn.AccessManagement.UI/Altinn.AccessManagement.UI.Core/Services/UserService.cs

View workflow job for this annotation

GitHub Actions / Continous Integration / Analyze

Remove this unread private field '_logger' or refactor the code to use its value. (https://rules.sonarsource.com/csharp/RSPEC-4487)
private readonly IProfileClient _profileClient;
private readonly IAccessManagementClient _accessManagementClient;
private readonly IAccessManagementClientV0 _accessManagementClientV0;

/// <summary>
/// Initializes a new instance of the <see cref="APIDelegationService"/> class.
/// </summary>
/// <param name="logger">handler for logger</param>
/// <param name="profileClient">handler for profile client</param>
/// <param name="accessManagementClient">handler for AM client</param>
/// <param name="accessManagementClientV0">handler for old AM client</param>
public UserService(
ILogger<IAPIDelegationService> logger,

Check warning on line 34 in backend/src/Altinn.AccessManagement.UI/Altinn.AccessManagement.UI.Core/Services/UserService.cs

View workflow job for this annotation

GitHub Actions / Continous Integration / Analyze

Update this logger to use its enclosing type. (https://rules.sonarsource.com/csharp/RSPEC-6672)
IProfileClient profileClient,
IAccessManagementClient accessManagementClient)
IAccessManagementClient accessManagementClient,
IAccessManagementClientV0 accessManagementClientV0)
{
_logger = logger;
_profileClient = profileClient;
_accessManagementClient = accessManagementClient;
_accessManagementClientV0 = accessManagementClientV0;
}

/// <inheritdoc/>
Expand All @@ -48,7 +52,7 @@ public async Task<UserProfileFE> GetUserProfile(int userId)
/// <inheritdoc/>
public async Task<AuthorizedParty> GetPartyFromReporteeListIfExists(int partyId)
{
AuthorizedParty partyInfo = await _accessManagementClient.GetPartyFromReporteeListIfExists(partyId);
AuthorizedParty partyInfo = await _accessManagementClientV0.GetPartyFromReporteeListIfExists(partyId);
return partyInfo;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import { useClearAccessCacheMutation } from '@/rtk/features/singleRights/singleR
import { getCookie } from '@/resources/Cookie/CookieMethods';
import { BaseAttribute } from '@/dataObjects/dtos/BaseAttribute';
import { useDocumentTitle } from '@/resources/hooks/useDocumentTitle';
import { useGetReporteeQuery } from '@/rtk/features/userInfoApi';

import { RecipientErrorAlert } from '../../components/RecipientErrorAlert/RecipientErrorAlert';

Expand Down Expand Up @@ -77,6 +78,8 @@ export const ChooseRightsPage = () => {
isLoading,
} = useFetchRecipientInfo(urlParams.get('userUUID'), urlParams.get('partyUUID'));

const { data: representingParty } = useGetReporteeQuery();

const initializeDelegableServices = () => {
const delegable = servicesWithStatus.filter(
(s: ServiceWithStatus) =>
Expand Down Expand Up @@ -190,6 +193,8 @@ export const ChooseRightsPage = () => {
serviceDescription={service.description}
rightDescription={service.rightDescription}
serviceType={service.type}
serviceOwner={service.serviceOwner}
reportee={representingParty?.name ?? ''}
/>
</RightsActionBar>
));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
margin-bottom: 10px;
}

.alertParagraph {
margin-bottom: 15px;
.undelegableRightsHeader {
margin-top: 15px;
}

.alertErrorContainer {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ export const Default: StoryObj = {
rightDescription: 'Right description',
serviceIdentifier: 'serviceIdentifier',
serviceType: 'serviceType',
serviceOwner: 'serviceOwner',
reportee: 'Superbuisness AS',
rights: [
{
action: 'action A',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable @typescript-eslint/restrict-template-expressions */
import * as React from 'react';
import { Paragraph, Heading, Chip, Alert, Tag } from '@digdir/designsystemet-react';
import { Paragraph, Heading, Chip, Alert } from '@digdir/designsystemet-react';
import { useTranslation } from 'react-i18next';
import { useEffect, useState } from 'react';

Expand Down Expand Up @@ -38,6 +38,12 @@ export interface RightsActionBarContentProps {

/** The type of service */
serviceType: string;

/** Owner of the service */
serviceOwner: string;

/** The reportee on which to delegate on behalf od */
reportee: string;
}

export const RightsActionBarContent = ({
Expand All @@ -47,6 +53,8 @@ export const RightsActionBarContent = ({
rightDescription,
serviceIdentifier,
serviceType,
serviceOwner,
reportee,
}: RightsActionBarContentProps) => {
const { t } = useTranslation();
const hasUndelegableRights =
Expand Down Expand Up @@ -142,14 +150,18 @@ export const RightsActionBarContent = ({
{t('single_rights.one_or_more_rights_is_undelegable', {
reason: t(`${getErrorCodeTextKey(errorList[0])}`, {
you: t('common.you_lowercase'),
resourceowner: serviceOwner,
reporteeorg: reportee,
}),
})}
</Paragraph>
<Paragraph className={classes.alertParagraph}>
{t('single_rights.ceo_or_main_admin_can_help')}
</Paragraph>
{errorList[0] === ErrorCode.MissingRoleAccess ||
(errorList[0] === ErrorCode.MissingDelegationAccess && (
<Paragraph>{t('single_rights.ceo_or_main_admin_can_help')}</Paragraph>
))}

<Heading
className={classes.undelegableRightsHeader}
size='2xs'
level={5}
>
Expand Down
2 changes: 1 addition & 1 deletion src/localizations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@
"add_more_services": "Add more services",
"cannot_delegate_alert_heading": "You cannot give power of attorney to this service",
"ceo_or_main_admin_can_help": "CEO or main administrator can help you with this.",
"one_or_more_rights_is_undelegable": "One or more rights on this service cant be delegated because of {{reason}}",
"one_or_more_rights_is_undelegable": "One or more rights on this service cant be delegated because: {{reason}}",
"missing_recipient_error_title": "Recipient missing",
"missing_recipient_error_message": "The recipient for the delegation is missing. Please go back to the profile page and select who you wish to delegate to.",
"faulty_recipient_error_title": "Cannot delegate to recipient",
Expand Down
2 changes: 1 addition & 1 deletion src/localizations/no_nb.json
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@
"add_more_services": "Legg til flere tjenester",
"cannot_delegate_alert_heading": "Du kan ikke gi fullmakt til denne tjenesten",
"ceo_or_main_admin_can_help": "Daglig leder eller hovedadministrator kan hjelpe deg med dette.",
"one_or_more_rights_is_undelegable": "En eller flere av rettighetene på denne tjenesten blir ikke delegert fordi {{reason}}",
"one_or_more_rights_is_undelegable": "En eller flere av rettighetene på denne tjenesten blir ikke delegert fordi: {{reason}}",
"missing_recipient_error_title": "Mottaker mangler",
"missing_recipient_error_message": "Mottaker for delegeringen mangler. Vennligst gå tilbake til profilsiden og velg hvem du ønsker å delegere til.",
"faulty_recipient_error_title": "Kan ikke delegere til mottaker",
Expand Down
2 changes: 1 addition & 1 deletion src/localizations/no_nn.json
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@
"add_more_services": "Legg til fleire tenester",
"cannot_delegate_alert_heading": "Du kan ikkje gi fullmakt til denne tenesta",
"ceo_or_main_admin_can_help": "Dagleg leiar eller hovudadministrator kan hjelpe deg med dette.",
"one_or_more_rights_is_undelegable": "Ein eller fleire av rettane på denne tenesta blir ikkje delegert fordi {{reason}}",
"one_or_more_rights_is_undelegable": "Ein eller fleire av rettane på denne tenesta blir ikkje delegert fordi: {{reason}}",
"missing_recipient_error_title": "Mottakar manglar",
"missing_recipient_error_message": "Mottakar for delegeringa manglar. Ver venleg og gå tilbake til profilsida og vel kven du ønsker å delegere til.",
"faulty_recipient_error_title": "Kan ikkje delegere til mottakar",
Expand Down

0 comments on commit 0df30e4

Please sign in to comment.