Skip to content

Commit 571c14a

Browse files
authored
[PAG-2505] Update generatePreviewTypes to add translate function (#110)
## Checklist - Contains unit tests ✅ - Contains breaking changes ❌ - Compatible with: MX 9️⃣ - Did you update version and changelog? ✅ ❌ - PR title properly formatted (`[XX-000]: description`)? ✅ ## This PR contains - [ x ] Bug fix - [ x ] Feature - [ ] Refactor - [ ] Documentation - [ ] Other (describe) ## What is the purpose of this PR? PAG added the translate function to the preview props, this adds the appropriate typing. We also noticed that the type for the mode (design, structure, x-ray) was made nullable on accident. ## Relevant changes Generated types for the preview props. ## What should be covered while testing? The updated unit tests should be sufficient.
2 parents 8685d2c + 486ca06 commit 571c14a

19 files changed

Lines changed: 49 additions & 23 deletions

packages/pluggable-widgets-tools/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,14 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66

77
## [Unreleased]
88

9+
### Added
10+
11+
- We added the translate function to the preview arguments. This can be used to translate texts show in the widget preview.
12+
913
### Changed
1014

15+
- The renderMode property in the preview arguments is no longer considered optional.
16+
1117
#### Rollup 3
1218

1319
We upgraded the bundling setup. For most packages this meant updating to the latest minor or patch versions, but for Rollup we upgraded from major version 2 to 3. If your widget uses custom configurations you may need to perform some actions.

packages/pluggable-widgets-tools/src/typings-generator/__tests__/outputs/association.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ export interface MyWidgetPreviewProps {
2727
style: string;
2828
styleObject?: CSSProperties;
2929
readOnly: boolean;
30-
renderMode?: "design" | "xray" | "structure";
30+
renderMode: "design" | "xray" | "structure";
31+
translate: (text: string) => string;
3132
reference: string;
3233
referenceSet: string;
3334
referenceOrSet: string;

packages/pluggable-widgets-tools/src/typings-generator/__tests__/outputs/atribute-linked-action.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ export interface MyWidgetContainerProps {
1414
1515
export interface MyWidgetPreviewProps {
1616
readOnly: boolean;
17-
renderMode?: "design" | "xray" | "structure";
17+
renderMode: "design" | "xray" | "structure";
18+
translate: (text: string) => string;
1819
collapsed: string;
1920
onToggleCollapsed: {} | null;
2021
}
@@ -52,7 +53,8 @@ export interface MyWidgetContainerProps {
5253
5354
export interface MyWidgetPreviewProps {
5455
readOnly: boolean;
55-
renderMode?: "design" | "xray" | "structure";
56+
renderMode: "design" | "xray" | "structure";
57+
translate: (text: string) => string;
5658
onToggleCollapsed: {} | null;
5759
datasourceProperties: DatasourcePropertiesPreviewType[];
5860
}

packages/pluggable-widgets-tools/src/typings-generator/__tests__/outputs/containment.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ export interface MyWidgetPreviewProps {
2525
style: string;
2626
styleObject?: CSSProperties;
2727
readOnly: boolean;
28-
renderMode?: "design" | "xray" | "structure";
28+
renderMode: "design" | "xray" | "structure";
29+
translate: (text: string) => string;
2930
content: { widgetCount: number; renderer: ComponentType<{ children: ReactNode; caption?: string }> };
3031
description: string;
3132
action: {} | null;

packages/pluggable-widgets-tools/src/typings-generator/__tests__/outputs/datasource.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ export interface MyWidgetContainerProps {
5252
5353
export interface MyWidgetPreviewProps {
5454
readOnly: boolean;
55-
renderMode?: "design" | "xray" | "structure";
55+
renderMode: "design" | "xray" | "structure";
56+
translate: (text: string) => string;
5657
contentSource: {} | { caption: string } | { type: string } | null;
5758
optionalSource: {} | { caption: string } | { type: string } | null;
5859
content: { widgetCount: number; renderer: ComponentType<{ children: ReactNode; caption?: string }> };

packages/pluggable-widgets-tools/src/typings-generator/__tests__/outputs/expression.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ export interface MyWidgetPreviewProps {
2929
style: string;
3030
styleObject?: CSSProperties;
3131
readOnly: boolean;
32-
renderMode?: "design" | "xray" | "structure";
32+
renderMode: "design" | "xray" | "structure";
33+
translate: (text: string) => string;
3334
myDataSource: {} | { caption: string } | { type: string } | null;
3435
expressionReturnTypeType: string;
3536
expressionReturnTypeTypeDataSource: string;

packages/pluggable-widgets-tools/src/typings-generator/__tests__/outputs/file.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ export interface MyWidgetContainerProps {
1717
1818
export interface MyWidgetPreviewProps {
1919
readOnly: boolean;
20-
renderMode?: "design" | "xray" | "structure";
20+
renderMode: "design" | "xray" | "structure";
21+
translate: (text: string) => string;
2122
file: string;
2223
file2: string;
2324
description: string;

packages/pluggable-widgets-tools/src/typings-generator/__tests__/outputs/icon.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ export interface MyWidgetContainerProps {
2424
2525
export interface MyWidgetPreviewProps {
2626
readOnly: boolean;
27-
renderMode?: "design" | "xray" | "structure";
27+
renderMode: "design" | "xray" | "structure";
28+
translate: (text: string) => string;
2829
icons: IconsPreviewType[];
2930
}
3031
`;

packages/pluggable-widgets-tools/src/typings-generator/__tests__/outputs/index.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ export interface MyWidgetPreviewProps {
5252
style: string;
5353
styleObject?: CSSProperties;
5454
readOnly: boolean;
55-
renderMode?: "design" | "xray" | "structure";
55+
renderMode: "design" | "xray" | "structure";
56+
translate: (text: string) => string;
5657
valueAttribute: string;
5758
mywidgetValue: string;
5859
valueExpression: string;
@@ -125,7 +126,8 @@ export interface MyWidgetPreviewProps {
125126
style: string;
126127
styleObject?: CSSProperties;
127128
readOnly: boolean;
128-
renderMode?: "design" | "xray" | "structure";
129+
renderMode: "design" | "xray" | "structure";
130+
translate: (text: string) => string;
129131
valueAttribute: string;
130132
mywidgetValue: string;
131133
valueExpression: string;
@@ -189,7 +191,8 @@ export interface MyWidgetContainerProps {
189191
190192
export interface MyWidgetPreviewProps {
191193
readOnly: boolean;
192-
renderMode?: "design" | "xray" | "structure";
194+
renderMode: "design" | "xray" | "structure";
195+
translate: (text: string) => string;
193196
valueAttribute: string;
194197
mywidgetValue: string;
195198
valueExpression: string;

packages/pluggable-widgets-tools/src/typings-generator/__tests__/outputs/list-action.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ export interface MyWidgetContainerProps {
2424
2525
export interface MyWidgetPreviewProps {
2626
readOnly: boolean;
27-
renderMode?: "design" | "xray" | "structure";
27+
renderMode: "design" | "xray" | "structure";
28+
translate: (text: string) => string;
2829
actions: ActionsPreviewType[];
2930
}
3031
`;

0 commit comments

Comments
 (0)