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

add expression support for organisation instance owner name #3232

Merged
merged 21 commits into from
Apr 8, 2025
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
abf9bc5
deletes unused hook
cammiida Apr 1, 2025
cbc7e45
improves PartySelection error message
cammiida Apr 1, 2025
971011c
gets instance owner party from backend and correctly determines on be…
cammiida Apr 1, 2025
961904b
fixes eslint warning
cammiida Apr 1, 2025
398ae96
adds enabled prop to instance owner query, and improves useInstanceOw…
cammiida Apr 1, 2025
d0dc061
gets instance owner party from new data on instance from backend with…
cammiida Apr 3, 2025
746cd63
removes cookie utils
cammiida Apr 3, 2025
4939d8d
add expression support for organisation instance owner name
HauklandJ Apr 3, 2025
b3534ce
update tests
HauklandJ Apr 3, 2025
7a44a8b
add shared-tests
HauklandJ Apr 4, 2025
1c3ad57
expose instace owner name always
HauklandJ Apr 4, 2025
d2abb91
fixes flattening parties and checking if same party by partyId in app…
cammiida Apr 7, 2025
4aefa3a
fixes sonarqube maintainability complaint
cammiida Apr 7, 2025
26ec10a
fixes another sonarqube maintainability complaint
cammiida Apr 7, 2025
417cf15
removes unused query key
cammiida Apr 7, 2025
4a35e73
Merge branch 'fix/current-party-2' into feature/instanceOwnerName
cammiida Apr 7, 2025
2c3c1b0
gets instance owner name straight from cache instead of zustand which…
cammiida Apr 7, 2025
5efc37c
Merge branch 'main' into fix/current-party-2
cammiida Apr 7, 2025
5b97201
Merge branch 'fix/current-party-2' into feature/instanceOwnerName
cammiida Apr 7, 2025
4863aae
gets instance owner data from cache instead of performing another query
cammiida Apr 8, 2025
67180b9
Merge branch 'main' into feature/instanceOwnerName
cammiida Apr 8, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/features/expressions/expression-functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,7 @@ export const ExprFunctionImplementations: { [K in ExprFunctionName]: Implementat
appId: true,
instanceOwnerPartyId: true,
instanceOwnerPartyType: true,
instanceOwnerName: true,
};

if (key === null || instanceDataSourcesKeys[key] !== true) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"name": "Instance owner name when instance owner is Person",
"expression": [
"instanceContext",
"instanceOwnerName"
],
"expects": "My Org AS",
"instance": {
"id": "d00ce51c-800b-416a-a906-ccab55f597e9",
"appId": "org/app-name",
"instanceOwner": {
"organisationNumber": "1234567",
"party": {
"name": "My Org AS"
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"name": "Instance owner name when instance owner is Person",
"expression": [
"instanceContext",
"instanceOwnerName"
],
"expects": "unknown",
"instance": {
"id": "d00ce51c-800b-416a-a906-ccab55f597e9",
"appId": "org/app-name",
"instanceOwner": {
"party": {
"name": "Secret Name"
}
}
}
}
2 changes: 2 additions & 0 deletions src/types/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ export interface IInstanceOwner {
personNumber?: string;
organisationNumber?: string | null;
username?: string;
party?: IParty | null;
}

export interface IInstanceState {
Expand Down Expand Up @@ -292,6 +293,7 @@ export interface IInstanceDataSources {
appId: string;
instanceOwnerPartyId: string;
instanceOwnerPartyType: InstanceOwnerPartyType;
instanceOwnerName?: string;
}

export type IActionType = 'instantiate' | 'confirm' | 'sign' | 'reject';
Expand Down
32 changes: 32 additions & 0 deletions src/utils/instanceDataSources.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ describe('instanceDataSources/instanceContext', () => {
appId,
instanceOwner: {
partyId,
party: {
name: 'My secret person name',
},
},
} as IInstance;

Expand All @@ -19,6 +22,35 @@ describe('instanceDataSources/instanceContext', () => {
instanceId: instaceId,
instanceOwnerPartyId: partyId,
instanceOwnerPartyType: 'unknown',
instanceOwnerName: 'unknown',
};
const actual = buildInstanceDataSources(mockInstance);

expect(actual).toEqual(expected);
});

it('should build a valid instance context with instance owner name if organisation', () => {
const partyId = '1337';
const appId = 'tdd/enapp';
const instaceId = `${partyId}/super-secret-uuid-000`;
const mockInstance: IInstance = {
id: instaceId,
appId,
instanceOwner: {
partyId,
organisationNumber: '123456789',
party: {
name: 'My Organisation AS',
},
},
} as IInstance;

const expected: IInstanceDataSources = {
appId,
instanceId: instaceId,
instanceOwnerPartyId: partyId,
instanceOwnerPartyType: 'org',
instanceOwnerName: 'My Organisation AS',
};
const actual = buildInstanceDataSources(mockInstance);

Expand Down
6 changes: 5 additions & 1 deletion src/utils/instanceDataSources.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { IInstance, IInstanceDataSources } from 'src/types/shared';

export function buildInstanceDataSources(instance?: IInstance | null | undefined): IInstanceDataSources | null {
if (!instance || !instance.instanceOwner) {
if (!instance?.instanceOwner) {
return null;
}
const instanceOwnerPartyType = instance.instanceOwner.organisationNumber
Expand All @@ -12,10 +12,14 @@ export function buildInstanceDataSources(instance?: IInstance | null | undefined
? 'selfIdentified'
: 'unknown';

// instanceOwnerName is set to 'unknown' if the instanceOwner is not an organisation
const instanceOwnerName = instance.instanceOwner.organisationNumber ? instance.instanceOwner?.party?.name : 'unknown';

return {
appId: instance.appId,
instanceId: instance.id,
instanceOwnerPartyId: instance.instanceOwner?.partyId,
instanceOwnerPartyType,
instanceOwnerName,
};
}
Loading