Skip to content

Commit cefb908

Browse files
authored
refactor: remove "Bpmn" prefix from renderer ignore option names (#3484)
Rename ignoreBpmnLabelStyles, ignoreBpmnActivityLabelBounds, and ignoreBpmnTaskLabelBounds to ignoreLabelStyles, ignoreActivityLabelBounds, and ignoreTaskLabelBounds. There is no reason to add the BPMN prefix as we know here that the options apply to BPMN concepts. Also rename the corresponding test utility properties (rendererIgnoreBpmn* → rendererIgnore*).
1 parent 993603b commit cefb908

8 files changed

Lines changed: 37 additions & 38 deletions

File tree

dev/ts/shared/main.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -244,9 +244,9 @@ function getRendererOptionsFromParameters(config: BpmnVisualizationDemoConfigura
244244
// Mapping between query parameter names and RendererOptions boolean properties
245245
const rendererParameterMappings: Record<string, Exclude<keyof RendererOptions, 'iconPainter'>> = {
246246
'renderer.ignore.bpmn.colors': 'ignoreBpmnColors',
247-
'renderer.ignore.label.style': 'ignoreBpmnLabelStyles',
248-
'renderer.ignore.activity.label.bounds': 'ignoreBpmnActivityLabelBounds',
249-
'renderer.ignore.task.label.bounds': 'ignoreBpmnTaskLabelBounds',
247+
'renderer.ignore.label.style': 'ignoreLabelStyles',
248+
'renderer.ignore.activity.label.bounds': 'ignoreActivityLabelBounds',
249+
'renderer.ignore.task.label.bounds': 'ignoreTaskLabelBounds',
250250
};
251251

252252
// Process renderer parameters

src/component/mxgraph/BpmnRenderer.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,17 +34,17 @@ import StyleComputer from './renderer/StyleComputer';
3434
* @internal
3535
*/
3636
export class BpmnRenderer {
37-
private readonly ignoreBpmnActivityLabelBounds: boolean;
38-
private readonly ignoreBpmnTaskLabelBounds: boolean;
37+
private readonly ignoreActivityLabelBounds: boolean;
38+
private readonly ignoreTaskLabelBounds: boolean;
3939

4040
constructor(
4141
readonly graph: BpmnGraph,
4242
readonly coordinatesTranslator: CoordinatesTranslator,
4343
readonly styleComputer: StyleComputer,
4444
rendererOptions: RendererOptions,
4545
) {
46-
this.ignoreBpmnActivityLabelBounds = rendererOptions?.ignoreBpmnActivityLabelBounds ?? false;
47-
this.ignoreBpmnTaskLabelBounds = rendererOptions?.ignoreBpmnTaskLabelBounds ?? false;
46+
this.ignoreActivityLabelBounds = rendererOptions?.ignoreActivityLabelBounds ?? false;
47+
this.ignoreTaskLabelBounds = rendererOptions?.ignoreTaskLabelBounds ?? false;
4848
}
4949

5050
render(renderedModel: RenderedModel): void {
@@ -78,7 +78,7 @@ export class BpmnRenderer {
7878
const bpmnElement = shape.bpmnElement;
7979
const parent = this.getParent(bpmnElement);
8080
const bounds = shape.bounds;
81-
const labelBounds = isLabelBoundsIgnored(shape, this.ignoreBpmnActivityLabelBounds, this.ignoreBpmnTaskLabelBounds) ? undefined : shape.label?.bounds;
81+
const labelBounds = isLabelBoundsIgnored(shape, this.ignoreActivityLabelBounds, this.ignoreTaskLabelBounds) ? undefined : shape.label?.bounds;
8282
const style = this.styleComputer.computeStyle(shape, labelBounds);
8383

8484
this.insertVertex(parent, bpmnElement.id, bpmnElement.name, bounds, labelBounds, style);
@@ -147,12 +147,12 @@ export class BpmnRenderer {
147147
/**
148148
* @internal
149149
*/
150-
export function isLabelBoundsIgnored(shape: Shape, ignoreBpmnActivityLabelBounds: boolean, ignoreBpmnTaskLabelBounds: boolean): boolean {
150+
export function isLabelBoundsIgnored(shape: Shape, ignoreActivityLabelBounds: boolean, ignoreTaskLabelBounds: boolean): boolean {
151151
const kind = shape.bpmnElement.kind;
152152
return (
153153
ShapeUtil.isPoolOrLane(kind) || // pool/lane label bounds are not managed for now (use hard coded values)
154-
(ignoreBpmnActivityLabelBounds && ShapeUtil.isActivity(kind)) ||
155-
(ignoreBpmnTaskLabelBounds && ShapeUtil.isTask(kind))
154+
(ignoreActivityLabelBounds && ShapeUtil.isActivity(kind)) ||
155+
(ignoreTaskLabelBounds && ShapeUtil.isTask(kind))
156156
);
157157
}
158158

src/component/mxgraph/renderer/StyleComputer.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,11 @@ import { BpmnStyleIdentifier } from '../style';
3939
*/
4040
export default class StyleComputer {
4141
private readonly ignoreBpmnColors: boolean;
42-
private readonly ignoreBpmnLabelStyles: boolean;
42+
private readonly ignoreLabelStyles: boolean;
4343

4444
constructor(options?: RendererOptions) {
4545
this.ignoreBpmnColors = options?.ignoreBpmnColors ?? true;
46-
this.ignoreBpmnLabelStyles = options?.ignoreBpmnLabelStyles ?? false;
46+
this.ignoreLabelStyles = options?.ignoreLabelStyles ?? false;
4747
}
4848

4949
computeStyle(bpmnCell: Shape | Edge, labelBounds: Bounds): string {
@@ -112,7 +112,7 @@ export default class StyleComputer {
112112
const styleValues = new Map<string, string | number>();
113113

114114
const font = bpmnCell.label?.font;
115-
if (font && !this.ignoreBpmnLabelStyles) {
115+
if (font && !this.ignoreLabelStyles) {
116116
styleValues.set(mxConstants.STYLE_FONTFAMILY, font.name);
117117
styleValues.set(mxConstants.STYLE_FONTSIZE, font.size);
118118
styleValues.set(mxConstants.STYLE_FONTSTYLE, getFontStyleValue(font));

src/component/options.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ export type RendererOptions = {
235235
* @default false
236236
* @since 0.48.0
237237
*/
238-
ignoreBpmnActivityLabelBounds?: boolean;
238+
ignoreActivityLabelBounds?: boolean;
239239
/**
240240
* If set to `false`, support the "BPMN in Color" specification with a fallback with bpmn.io colors. For more details about the support, see
241241
* {@link https://github.com/process-analytics/bpmn-visualization-js/pull/2614}.
@@ -252,16 +252,16 @@ export type RendererOptions = {
252252
* @default false
253253
* @since 0.48.0
254254
*/
255-
ignoreBpmnLabelStyles?: boolean;
255+
ignoreLabelStyles?: boolean;
256256
/**
257257
* If set to `true`, ignore the label bounds configuration defined in the BPMN diagram for tasks only.
258258
* This forces the use of default label positioning for tasks instead of the bounds specified in the BPMN source.
259-
* This option is more restrictive than `ignoreBpmnActivityLabelBounds` as it only affects tasks, not sub-processes or call activities.
259+
* This option is more restrictive than {@link ignoreActivityLabelBounds} as it only affects tasks, not sub-processes or call activities.
260260
*
261-
* **Note**: When `ignoreBpmnActivityLabelBounds` is `true`, this option is ignored as the more general activity option takes precedence.
261+
* **Note**: When {@link ignoreActivityLabelBounds} is `true`, this option is ignored as the more general activity option takes precedence.
262262
*
263263
* @default false
264264
* @since 0.48.0
265265
*/
266-
ignoreBpmnTaskLabelBounds?: boolean;
266+
ignoreTaskLabelBounds?: boolean;
267267
};

test/e2e/bpmn.rendering.ignore.options.test.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -159,16 +159,16 @@ describe('BPMN rendering - ignore options', () => {
159159
describe('Ignore activity label bounds', () => {
160160
const bpmnDiagramName = 'activities.with.wrongly.positioned.labels';
161161

162-
describe.each([false, true])('ignoreBpmnActivityLabelBounds: %s', (ignoreBpmnActivityLabelBounds: boolean) => {
162+
describe.each([false, true])('ignoreActivityLabelBounds: %s', (ignoreActivityLabelBounds: boolean) => {
163163
const imageSnapshotConfigurator = new ImageSnapshotConfigurator(new ImageSnapshotThresholdsActivityLabelBounds(), 'bpmn-rendering-ignore-options');
164164

165165
it(`${bpmnDiagramName}`, async () => {
166166
await pageTester.gotoPageAndLoadBpmnDiagram(bpmnDiagramName, {
167-
rendererIgnoreBpmnActivityLabelBounds: ignoreBpmnActivityLabelBounds,
167+
rendererIgnoreActivityLabelBounds: ignoreActivityLabelBounds,
168168
});
169169

170170
const image = await page.screenshot({ fullPage: true });
171-
const config = imageSnapshotConfigurator.getConfig(getConfigName(bpmnDiagramName, ignoreBpmnActivityLabelBounds));
171+
const config = imageSnapshotConfigurator.getConfig(getConfigName(bpmnDiagramName, ignoreActivityLabelBounds));
172172
expect(image).toMatchImageSnapshot(config);
173173
});
174174
});
@@ -177,16 +177,16 @@ describe('BPMN rendering - ignore options', () => {
177177
describe('Ignore label styles', () => {
178178
const bpmnDiagramName = 'labels.with.font.styles';
179179

180-
describe.each([false, true])('ignoreBpmnLabelStyles: %s', (ignoreBpmnLabelStyles: boolean) => {
180+
describe.each([false, true])('ignoreLabelStyles: %s', (ignoreLabelStyles: boolean) => {
181181
const imageSnapshotConfigurator = new ImageSnapshotConfigurator(new ImageSnapshotThresholdsLabelStyles(), 'bpmn-rendering-ignore-options');
182182

183183
it(`${bpmnDiagramName}`, async () => {
184184
await pageTester.gotoPageAndLoadBpmnDiagram(bpmnDiagramName, {
185-
rendererIgnoreBpmnLabelStyles: ignoreBpmnLabelStyles,
185+
rendererIgnoreLabelStyles: ignoreLabelStyles,
186186
});
187187

188188
const image = await page.screenshot({ fullPage: true });
189-
const config = imageSnapshotConfigurator.getConfig(getConfigName(bpmnDiagramName, ignoreBpmnLabelStyles));
189+
const config = imageSnapshotConfigurator.getConfig(getConfigName(bpmnDiagramName, ignoreLabelStyles));
190190
expect(image).toMatchImageSnapshot(config);
191191
});
192192
});

test/shared/visu/bpmn-page-utils.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,8 @@ export interface PageOptions {
143143
bpmnElementIdToCollapse?: string;
144144
poolIdsToFilter?: string | string[];
145145
rendererIgnoreBpmnColors?: boolean;
146-
rendererIgnoreBpmnLabelStyles?: boolean;
147-
rendererIgnoreBpmnActivityLabelBounds?: boolean;
146+
rendererIgnoreLabelStyles?: boolean;
147+
rendererIgnoreActivityLabelBounds?: boolean;
148148
}
149149

150150
export interface Point {
@@ -258,9 +258,8 @@ export class PageTester {
258258
otherPageOptions?.poolIdsToFilter && (url += `&bpmn.filter.pool.ids=${otherPageOptions.poolIdsToFilter}`);
259259
// renderer options
260260
otherPageOptions?.rendererIgnoreBpmnColors !== undefined && (url += `&renderer.ignore.bpmn.colors=${otherPageOptions.rendererIgnoreBpmnColors}`);
261-
otherPageOptions?.rendererIgnoreBpmnLabelStyles !== undefined && (url += `&renderer.ignore.label.style=${otherPageOptions.rendererIgnoreBpmnLabelStyles}`);
262-
otherPageOptions?.rendererIgnoreBpmnActivityLabelBounds !== undefined &&
263-
(url += `&renderer.ignore.activity.label.bounds=${otherPageOptions.rendererIgnoreBpmnActivityLabelBounds}`);
261+
otherPageOptions?.rendererIgnoreLabelStyles !== undefined && (url += `&renderer.ignore.label.style=${otherPageOptions.rendererIgnoreLabelStyles}`);
262+
otherPageOptions?.rendererIgnoreActivityLabelBounds !== undefined && (url += `&renderer.ignore.activity.label.bounds=${otherPageOptions.rendererIgnoreActivityLabelBounds}`);
264263

265264
return url;
266265
}

test/unit/component/mxgraph/BpmnRenderer.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ describe('isLabelBoundsIgnored', () => {
3939
});
4040
});
4141

42-
describe('with ignoreBpmnActivityLabelBounds option', () => {
43-
describe.each([true, false])('with ignoreBpmnTaskLabelBounds option set to %s', (ignoreBpmnTaskLabelBounds: boolean) => {
42+
describe('with ignoreActivityLabelBounds option', () => {
43+
describe.each([true, false])('with ignoreTaskLabelBounds option set to %s', (ignoreTaskLabelBounds: boolean) => {
4444
test.each([
4545
[ShapeBpmnElementKind.POOL, true],
4646
[ShapeBpmnElementKind.LANE, true],
@@ -54,12 +54,12 @@ describe('isLabelBoundsIgnored', () => {
5454
[ShapeBpmnElementKind.GATEWAY_PARALLEL, false],
5555
])('should ignore %s label bounds? %s', (kind, expected) => {
5656
const shape = new Shape('id', new ShapeBpmnElement('id', 'name', kind));
57-
expect(isLabelBoundsIgnored(shape, true, ignoreBpmnTaskLabelBounds)).toBe(expected);
57+
expect(isLabelBoundsIgnored(shape, true, ignoreTaskLabelBounds)).toBe(expected);
5858
});
5959
});
6060
});
6161

62-
describe('with ignoreBpmnTaskLabelBounds option', () => {
62+
describe('with ignoreTaskLabelBounds option', () => {
6363
test.each([
6464
[ShapeBpmnElementKind.POOL, true],
6565
[ShapeBpmnElementKind.LANE, true],

test/unit/component/mxgraph/renderer/StyleComputer.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -479,10 +479,10 @@ describe('Style Computer', () => {
479479
);
480480
});
481481

482-
describe('compute style - ignore BPMN label styles', () => {
483-
describe.each([[undefined], [false], [true]])(`Ignore BPMN label styles (renderer option): %s`, (ignoreBpmnLabelStyles: boolean) => {
484-
const styleComputer = new StyleComputer(ignoreBpmnLabelStyles === undefined ? {} : { ignoreBpmnLabelStyles });
485-
const expectFontStyles = !(ignoreBpmnLabelStyles ?? false);
482+
describe('compute style - ignore label styles', () => {
483+
describe.each([[undefined], [false], [true]])(`Ignore label styles (renderer option): %s`, (ignoreLabelStyles: boolean) => {
484+
const styleComputer = new StyleComputer(ignoreLabelStyles === undefined ? {} : { ignoreLabelStyles });
485+
const expectFontStyles = !(ignoreLabelStyles ?? false);
486486

487487
function computeStyleWithIgnoreLabelStyles(element: Shape | Edge): string {
488488
return styleComputer.computeStyle(element, element.label?.bounds);

0 commit comments

Comments
 (0)