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

feat(PaymentTask): Integrate Altinn Payment Task into ProcessEditor #12562

Merged
merged 7 commits into from
Mar 21, 2024
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { shouldDisplayFeature } from 'app-shared/utils/featureToggleUtils';

const supportedEntries = ['create.exclusive-gateway', 'create.start-event', 'create.end-event'];

class SupportedPaletteProvider {
Expand Down Expand Up @@ -64,6 +66,36 @@
};
}

function createCustomPaymentTask() {
const taskType = 'payment';

return function (event) {
const task = buildAltinnTask(taskType);

Check warning on line 73 in frontend/packages/process-editor/src/bpmnProviders/SupportedPaletteProvider.js

View check run for this annotation

Codecov / codecov/patch

frontend/packages/process-editor/src/bpmnProviders/SupportedPaletteProvider.js#L73

Added line #L73 was not covered by tests

const extensionElements = bpmnFactory.create('bpmn:ExtensionElements', {

Check warning on line 75 in frontend/packages/process-editor/src/bpmnProviders/SupportedPaletteProvider.js

View check run for this annotation

Codecov / codecov/patch

frontend/packages/process-editor/src/bpmnProviders/SupportedPaletteProvider.js#L75

Added line #L75 was not covered by tests
values: [
bpmnFactory.create('altinn:TaskExtension', {
taskType: taskType,
actions: bpmnFactory.create('altinn:Actions', {
action: ['pay', 'reject'],
}),
paymentConfig: bpmnFactory.create('altinn:PaymentConfig', {
paymentDataType: bpmnFactory.create('altinn:PaymentDataType', {
dataType: ['paymentInformation'],
}),
}),
}),
],
});

modeling.updateProperties(task, {

Check warning on line 91 in frontend/packages/process-editor/src/bpmnProviders/SupportedPaletteProvider.js

View check run for this annotation

Codecov / codecov/patch

frontend/packages/process-editor/src/bpmnProviders/SupportedPaletteProvider.js#L91

Added line #L91 was not covered by tests
extensionElements,
});

create.start(event, task);

Check warning on line 95 in frontend/packages/process-editor/src/bpmnProviders/SupportedPaletteProvider.js

View check run for this annotation

Codecov / codecov/patch

frontend/packages/process-editor/src/bpmnProviders/SupportedPaletteProvider.js#L95

Added line #L95 was not covered by tests
};
}

const buildAltinnTask = (taskType) => {
const businessObject = bpmnFactory.create('bpmn:Task', {
name: `Altinn ${taskType} task`,
Expand Down Expand Up @@ -112,6 +144,14 @@
dragstart: createCustomSigningTask(),
},
},
'create.altinn-payment-task': {
group: 'activity',
className: `bpmn-icon-task-generic ${shouldDisplayFeature('displayPaymentTaskProcessEditor') ? 'bpmn-icon-payment-task' : 'payment-is-hidden-based-on-feature-toggle'}`,
title: translate('Payment'),
action: {
dragstart: createCustomPaymentTask(),
},
},
};
return {
...entries,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,13 @@ div[class*='bpmn-icon-signing-task'] {
-webkit-mask: url('../../../img/SignTask.svg') var(--mask-icon-size);
mask: url('../../../img/SignTask.svg') var(--mask-icon-size);
}

div[class*='bpmn-icon-payment-task'] {
-webkit-mask: url('../../../img/PaymentTask.svg') var(--mask-icon-size);
mask: url('../../../img/PaymentTask.svg') var(--mask-icon-size);
}

/* Should be removed when feature flag is removed */
div[class*='payment-is-hidden-based-on-feature-toggle'] {
display: none;
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ export const altinnCustomTasks = {
isMany: false,
type: 'SignatureConfig',
},
{
name: 'paymentConfig',
isMany: false,
type: 'PaymentConfig',
},
],
},
{
Expand Down Expand Up @@ -53,6 +58,27 @@ export const altinnCustomTasks = {
},
],
},
{
name: 'PaymentConfig',
properties: [
{
name: 'paymentDataType',
isMany: false,
type: 'PaymentDataType',
},
],
},
{
name: 'PaymentDataType',
properties: [
{
name: 'paymentType',
isMany: false,
isAttr: false,
type: 'String',
},
],
},
{
name: 'DataTypesToSign',
properties: [
Expand Down
3 changes: 2 additions & 1 deletion frontend/packages/shared/src/utils/featureToggleUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ export type SupportedFeatureFlags =
| 'customizeEndEvent'
| 'componentConfigBeta'
| 'shouldOverrideAppLibCheck'
| 'resourceAccessLists';
| 'resourceAccessLists'
| 'displayPaymentTaskProcessEditor';

/*
* Please add all the features that you want to be toggle on by default here.
Expand Down
Loading