-
Notifications
You must be signed in to change notification settings - Fork 3
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
fix missing applying of the translate
service
#77
Merged
fake-join
merged 2 commits into
bpmn-io:main
from
Vovamzur:fix/missing-applying-translate
Apr 22, 2024
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,18 @@ | ||
import Markup from 'preact-markup'; | ||
import { useService } from 'bpmn-js-properties-panel'; | ||
|
||
import { sanitizeHTML } from '../utils/sanitize'; | ||
|
||
export function PropertyDescription(props) { | ||
|
||
const { | ||
description | ||
} = props; | ||
|
||
const translate = useService('translate'); | ||
|
||
return description && ( | ||
<Markup | ||
markup={ sanitizeHTML(description) } | ||
markup={ sanitizeHTML(translate(description)) } | ||
trim={ false } /> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" id="Definitions_1yh3zpj" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="4.4.0"> | ||
<bpmn:process id="Process_1" isExecutable="true"> | ||
<bpmn:serviceTask id="ServiceTask_1" name="name" camunda:modelerTemplate="foo"> | ||
<bpmn:extensionElements> | ||
<camunda:field name="foo"> | ||
<camunda:string>foo</camunda:string> | ||
</camunda:field> | ||
<camunda:field name="bar"> | ||
<camunda:expression>${bar}</camunda:expression> | ||
</camunda:field> | ||
</bpmn:extensionElements> | ||
</bpmn:serviceTask> | ||
</bpmn:process> | ||
<bpmndi:BPMNDiagram id="BPMNDiagram_1"> | ||
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_1"> | ||
<bpmndi:BPMNShape id="ServiceTask_1_di" bpmnElement="ServiceTask_1"> | ||
<dc:Bounds x="0" y="0" width="100" height="80" /> | ||
</bpmndi:BPMNShape> | ||
</bpmndi:BPMNPlane> | ||
</bpmndi:BPMNDiagram> | ||
</bpmn:definitions> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
import TestContainer from 'mocha-test-container-support'; | ||
|
||
import { | ||
query as domQuery, | ||
queryAll as domQueryAll | ||
} from 'min-dom'; | ||
|
||
import { | ||
bootstrapPropertiesPanel, | ||
inject | ||
} from 'test/TestHelper'; | ||
|
||
import { | ||
act | ||
} from '@testing-library/preact'; | ||
|
||
import coreModule from 'bpmn-js/lib/core'; | ||
import elementTemplatesModule from 'src/element-templates'; | ||
import modelingModule from 'bpmn-js/lib/features/modeling'; | ||
import { BpmnPropertiesPanelModule } from 'bpmn-js-properties-panel'; | ||
import camundaModdlePackage from 'camunda-bpmn-moddle/resources/camunda'; | ||
|
||
import diagramXML from './Translate.bpmn'; | ||
|
||
import templates from './Translate.templates'; | ||
|
||
describe('provider/element-templates - Translate', function() { | ||
|
||
let container; | ||
|
||
beforeEach(function() { | ||
container = TestContainer.get(this); | ||
}); | ||
|
||
beforeEach(bootstrapPropertiesPanel(diagramXML, { | ||
container, | ||
modules: [ | ||
BpmnPropertiesPanelModule, | ||
coreModule, | ||
elementTemplatesModule, | ||
modelingModule, | ||
{ | ||
translate: [ | ||
'value', | ||
(template, replacements) => replacements | ||
? `${template}:translated:${JSON.stringify(replacements)}` | ||
: `${template}:translated` | ||
] | ||
} | ||
], | ||
moddleExtensions: { | ||
camunda: camundaModdlePackage | ||
}, | ||
elementTemplates: templates | ||
})); | ||
|
||
beforeEach(inject(async function(elementRegistry, selection) { | ||
const element = elementRegistry.get('ServiceTask_1'); | ||
await act(() => selection.select(element)); | ||
})); | ||
|
||
describe('Template group', function() { | ||
it('should apply the `translate` service for the Template group title', inject(function() { | ||
const titleEl = domQuery('[data-group-id="group-ElementTemplates__Template"] .bio-properties-panel-group-header-title', container); | ||
|
||
expect(titleEl.textContent).to.equal('Template:translated'); | ||
})); | ||
}); | ||
|
||
describe('Custom Properties group', function() { | ||
it('should apply the `translate` service for the Custom Properties group title', inject(function() { | ||
const titleEl = domQuery('[data-group-id="group-ElementTemplates__CustomProperties"] .bio-properties-panel-group-header-title', container); | ||
|
||
expect(titleEl.textContent).to.equal('Custom properties:translated'); | ||
})); | ||
|
||
it('should apply the `translate` service for a Boolean entry', inject(function() { | ||
const booleanEntry = domQuery('[data-group-id="group-ElementTemplates__CustomProperties"] [data-entry-id="custom-entry-foo-0"]', container); | ||
|
||
const labelEl = domQuery('.bio-properties-panel-label', booleanEntry); | ||
expect(labelEl.textContent).to.equal('BooleanLabel:translated'); | ||
|
||
const descriptionEl = domQuery('.bio-properties-panel-description', booleanEntry); | ||
expect(descriptionEl.textContent).to.equal('BooleanDescription:translated'); | ||
})); | ||
|
||
it('should apply the `translate` service for a Dropdown entry', inject(function() { | ||
const dropdownEntry = domQuery('[data-group-id="group-ElementTemplates__CustomProperties"] [data-entry-id="custom-entry-foo-1"]', container); | ||
|
||
const labelEl = domQuery('.bio-properties-panel-label', dropdownEntry); | ||
expect(labelEl.textContent).to.equal('DropdownLabel:translated'); | ||
|
||
const descriptionEl = domQuery('.bio-properties-panel-description', dropdownEntry); | ||
expect(descriptionEl.textContent).to.equal('DropdownDescription:translated'); | ||
|
||
const options = domQueryAll('option', dropdownEntry); | ||
expect(options[0].textContent).to.equal('Choice1:translated'); | ||
expect(options[1].textContent).to.equal('Choice2:translated'); | ||
})); | ||
|
||
it('should apply the `translate` service for a String entry', inject(function() { | ||
const stringEntry = domQuery('[data-group-id="group-ElementTemplates__CustomProperties"] [data-entry-id="custom-entry-foo-2"]', container); | ||
|
||
const labelEl = domQuery('.bio-properties-panel-label', stringEntry); | ||
expect(labelEl.textContent).to.equal('StringLabel:translated'); | ||
|
||
const descriptionEl = domQuery('.bio-properties-panel-description', stringEntry); | ||
expect(descriptionEl.textContent).to.equal('StringDescription:translated'); | ||
})); | ||
|
||
it('should apply the `translate` service for a Text entry', inject(function() { | ||
const textEntry = domQuery('[data-group-id="group-ElementTemplates__CustomProperties"] [data-entry-id="custom-entry-foo-3"]', container); | ||
|
||
const labelEl = domQuery('.bio-properties-panel-label', textEntry); | ||
expect(labelEl.textContent).to.equal('TextLabel:translated'); | ||
|
||
const descriptionEl = domQuery('.bio-properties-panel-description', textEntry); | ||
expect(descriptionEl.textContent).to.equal('TextDescription:translated'); | ||
})); | ||
}); | ||
}); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exactly in the required order. We want to sanitize the translation result :)