Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/pluggable-widgets-tools/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
### Changed

- We increased the minimum node version to 22.
- We changed [System Text XML](https://docs.mendix.com/apidocs-mxsdk/apidocs/pluggable-widgets-property-types/#text) type to use `namespace` instead of `widgetId`, since we now allow Pluggable Widgets to refer to all system texts.

### Fixed

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ export interface SystemTextParameter {

export interface ExternalSystemTextNamespace {
$: {
widgetId: string;
namespace: string;
};
text: ExternalSystemText[];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ const systemProperty = `<systemProperty key="Text">
<parameter caption="Count" />
</parameters>
</text>
<externalTexts widgetId="mendix.textbox.TextBox">
<externalTexts namespace="mendix.textbox.TextBox">
<text key="label" />
<text key="placeholder" />
</externalTexts>
<externalTexts widgetId="mendix.datagrid.DataGrid" />
<externalTexts namespace="mendix.datagrid.DataGrid" />
</systemProperty>`;

export const systemTextsInput = `<?xml version="1.0" encoding="utf-8"?>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { SystemProperty, TextSystemProperty } from "./WidgetXml";

const STAR = "*" as const;
type Star = typeof STAR;
type Text = { key: string; parameters: string[] } | { widgetId: string; key: Star | string[] };
type Text = { key: string; parameters: string[] } | { namespace: string; key: Star | string[] };

function textsFromSystemProperty(node: SystemProperty): Text[] {
if (!isTextSystemProperty(node)) return [];
Expand All @@ -16,7 +16,7 @@ function textsFromSystemProperty(node: SystemProperty): Text[] {
})),
...(node.externalTexts ?? []).map(e => {
return {
widgetId: e.$.widgetId,
namespace: e.$.namespace,
key: e.text === undefined ? STAR : e.text.map(t => t.$.key)
};
})
Expand All @@ -28,11 +28,11 @@ function isTextSystemProperty(node: SystemProperty): node is TextSystemProperty
}

function generateTextType(t: Text): string {
if ("widgetId" in t) {
if ("namespace" in t) {
if (t.key === STAR) {
return `"${t.widgetId}": [key: string, params?: string[]]`;
return `"${t.namespace}": [key: string, params?: string[]]`;
}
return `"${t.widgetId}": [key: ${t.key.map(key => `"${key}"`).join(" | ")}, params?: string[]]`;
return `"${t.namespace}": [key: ${t.key.map(key => `"${key}"`).join(" | ")}, params?: string[]]`;
}

const parameterTypes = t.parameters.map(p => `${normalizeParameterName(p)}: string`);
Expand Down
Loading