Skip to content

Commit

Permalink
fixing final comments from PR
Browse files Browse the repository at this point in the history
  • Loading branch information
wrt95 committed Dec 14, 2023
1 parent 1043623 commit f95fde1
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 68 deletions.
2 changes: 1 addition & 1 deletion frontend/language/src/nb.json
Original file line number Diff line number Diff line change
Expand Up @@ -657,7 +657,7 @@
"process_editor.not_found_process_error_message": "Det finnes ingen prosess definert innenfor BPMN, Du kan verifisere om prosessen finnes i BPMN-filen.",
"process_editor.not_found_process_heading": "Ingen tilgjengelig prosess",
"process_editor.save": "Lagre",
"process_editor.too_old_version_helptext_content": "Applikasjonen din har versjon {{ version }} av app-lib-pakken. \nVersjonen er for gammel for å kunne redigere denne modellen.\nDu kan se på prosessen, men vi anbefaler at du oppgraderer til versjon 8 eller nyere.",
"process_editor.too_old_version_helptext_content": "Applikasjonen din har versjon {{ version }} av app-lib-pakken. \nVersjonen er for gammel for å kunne redigere denne modellen.\nDu kan se på prosessen og konfigurere oppsett tilknyttet prosessen, men vi anbefaler at du oppgraderer til versjon 8 eller nyere.",
"process_editor.too_old_version_helptext_title": "Du kan ikke redigere prosessen",
"process_editor.too_old_version_title": "Du kan ikke redigere denne prosessen",
"process_editor.unknown_heading_error_message": "Obs, noe gikk galt!",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import classes from './ConfigIcon.module.css';
import { BpmnTaskType } from '../../../types/BpmnTaskType';
import { BpmnTaskType } from '../../../../types/BpmnTaskType';
import { ConfirmationTask, DataTask, FeedbackTask, SignTask } from '@studio/icons';

export type ConfigIconProps = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,7 @@ export interface BpmnBusinessObjectViewer {
$type: BpmnTypeEnum;
id: string;
name?: string;
extensionElements?: BpmnExtensionElementsViewer;
}

export interface BpmnExtensionElementsViewer {
values?: Array<{
$children: Array<{
$body: BpmnTaskType;
$type: string;
}>;
}>;
$attrs: {
'altinn:tasktype': BpmnTaskType;
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,7 @@ import { BpmnTaskType } from '../../types/BpmnTaskType';
*
*/
export const getConfigTitleKey = (taskType: BpmnTaskType) => {
switch (taskType) {
case 'data':
return 'process_editor.configuration_panel_data_task';
case 'confirmation':
return 'process_editor.configuration_panel_confirmation_task';
case 'feedback':
return 'process_editor.configuration_panel_feedback_task';
case 'signing':
return 'process_editor.configuration_panel_signing_task';
}
return `process_editor.configuration_panel_${taskType}_task`;
};

/**
Expand All @@ -25,14 +16,5 @@ export const getConfigTitleKey = (taskType: BpmnTaskType) => {
* @returns the correct helptext key
*/
export const getConfigTitleHelpTextKey = (taskType: BpmnTaskType) => {
switch (taskType) {
case 'data':
return 'process_editor.configuration_panel_header_help_text_data';
case 'confirmation':
return 'process_editor.configuration_panel_header_help_text_confirmation';
case 'feedback':
return 'process_editor.configuration_panel_header_help_text_feedback';
case 'signing':
return 'process_editor.configuration_panel_header_help_text_signing';
}
return `process_editor.configuration_panel_header_help_text_${taskType}`;
};
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import { BpmnTypeEnum } from '../../enum/BpmnTypeEnum';
import {
BpmnBusinessObjectViewer,
BpmnExtensionElementsViewer,
} from '../../types/BpmnBusinessObjectViewer';
import { BpmnBusinessObjectViewer } from '../../types/BpmnBusinessObjectViewer';
import {
BpmnBusinessObjectEditor,
BpmnExtensionElementsEditor,
Expand All @@ -23,19 +20,13 @@ describe('hookUtils', () => {
const mockName: string = 'mockName';
const mockTaskTypeData: BpmnTaskType = 'data';

const mockBpmnExtensionElements: BpmnExtensionElementsViewer = {
values: [
{
$children: [{ $body: mockTaskTypeData, $type: 'altinn:taskType' }],
},
],
};

const mockBpmnBusinessObject: BpmnBusinessObjectViewer = {
$type: mockTypeTask,
id: mockId,
name: mockName,
extensionElements: mockBpmnExtensionElements,
$attrs: {
'altinn:tasktype': mockTaskTypeData,
},
};

it('returns the BpmnDetails with correct values', () => {
Expand All @@ -47,25 +38,10 @@ describe('hookUtils', () => {
expect(bpmnDetails.taskType).toEqual(mockTaskTypeData);
});

it('returns taskType with value "null" when etensionElements are not present', () => {
it('returns taskType with value "null" when $attrs are not present', () => {
const bpmnBusinessObject: BpmnBusinessObjectViewer = {
...mockBpmnBusinessObject,
extensionElements: undefined,
};
const bpmnDetails: BpmnDetails = getBpmnViewerDetailsFromBusinessObject(bpmnBusinessObject);
expect(bpmnDetails.id).toEqual(mockId);
expect(bpmnDetails.name).toEqual(mockName);
expect(bpmnDetails.type).toEqual(mockTypeTask);
expect(bpmnDetails.taskType).toBeNull();
});

it('returns taskType with value "null" when etensionElements.values are not present', () => {
const bpmnBusinessObject: BpmnBusinessObjectViewer = {
...mockBpmnBusinessObject,
extensionElements: {
...mockBpmnExtensionElements,
values: undefined,
},
$attrs: undefined,
};
const bpmnDetails: BpmnDetails = getBpmnViewerDetailsFromBusinessObject(bpmnBusinessObject);
expect(bpmnDetails.id).toEqual(mockId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,17 @@ import type { BpmnBusinessObjectEditor } from '../../types/BpmnBusinessObjectEdi
export const getBpmnViewerDetailsFromBusinessObject = (
businessObject: BpmnBusinessObjectViewer,
): BpmnDetails => {
console.log('businessobject', businessObject);
const bpmnType = businessObject?.$type;
const bpmnId = businessObject?.id;
const bpmnName = businessObject?.name;

const extensionElements = businessObject?.extensionElements;
const values = extensionElements?.values;
const $children = values ? values[0].$children : null;
const $body = $children ? $children[0].$body : null;
const bpmnAttrs = businessObject?.$attrs;
const bpmnTasktype = bpmnAttrs ? bpmnAttrs['altinn:tasktype'] : null;

const bpmnDetails: BpmnDetails = {
id: bpmnId,
name: bpmnName,
taskType: $body,
taskType: bpmnTasktype,
type: bpmnType,
};
return bpmnDetails;
Expand Down

0 comments on commit f95fde1

Please sign in to comment.