Skip to content

Commit 5cbf7fd

Browse files
committed
fix: remove choices and go with expression
1 parent f104f39 commit 5cbf7fd

File tree

5 files changed

+15
-53
lines changed

5 files changed

+15
-53
lines changed

packages/pluggableWidgets/file-uploader-web/CHANGELOG.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
1010

1111
- We fixed an issue where file uploader can still add more files when refreshed eventhough the number of maximum uploaded files has been reached.
1212

13-
### Added
13+
### Changed
1414

15-
- We added a configuration to set maximum number of uploaded files through expression.
15+
- We change the max file configuration to set maximum number of uploaded files through expression.
1616

1717
## [2.2.2] - 2025-07-01
1818

packages/pluggableWidgets/file-uploader-web/src/FileUploader.editorConfig.ts

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,6 @@ export function getProperties(
4040
hidePropertiesIn(properties, values, ["customButtons"]);
4141
}
4242

43-
if (values.maxFilePerUploadType === "expression") {
44-
hidePropertiesIn(properties, values, ["maxFilesPerUpload"]);
45-
} else {
46-
hidePropertiesIn(properties, values, ["maxFilesPerUploadExpression"]);
47-
}
48-
4943
return properties;
5044
}
5145

@@ -95,12 +89,7 @@ export function check(values: FileUploaderPreviewProps): Problem[] {
9589
}
9690
}
9791

98-
if (!values.maxFilesPerUpload || values.maxFilesPerUpload < 1) {
99-
errors.push({
100-
property: "maxFilesPerUpload",
101-
message: "There must be at least one file per upload allowed."
102-
});
103-
}
92+
// Note: maxFilesPerUpload validation is handled at runtime since it's an expression
10493

10594
if (values.enableCustomButtons) {
10695
// check that at max one actions is default

packages/pluggableWidgets/file-uploader-web/src/FileUploader.xml

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -80,23 +80,11 @@
8080
</propertyGroup>
8181
</properties>
8282
</property>
83-
<property key="maxFilePerUploadType" type="enumeration" defaultValue="number">
84-
<caption>Maximum number of files per upload type</caption>
85-
<description />
86-
<enumerationValues>
87-
<enumerationValue key="number">Number</enumerationValue>
88-
<enumerationValue key="expression">Expression</enumerationValue>
89-
</enumerationValues>
90-
</property>
91-
<property key="maxFilesPerUploadExpression" type="expression" defaultValue="10">
83+
<property key="maxFilesPerUpload" type="expression" defaultValue="10">
9284
<caption>Maximum number of files</caption>
9385
<description>Limit the number of files per upload.</description>
9486
<returnType type="Integer" />
9587
</property>
96-
<property key="maxFilesPerUpload" type="integer" defaultValue="10">
97-
<caption>Maximum number of files</caption>
98-
<description>Limit the number of files per upload.</description>
99-
</property>
10088
<property key="maxFileSize" type="integer" defaultValue="25">
10189
<caption>Maximum file size (MB)</caption>
10290
<description>Reject files that are bigger than specified size.</description>

packages/pluggableWidgets/file-uploader-web/src/stores/FileUploaderStore.ts

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { DynamicValue, ListValue, ObjectItem } from "mendix";
2-
import { FileUploaderContainerProps, MaxFilePerUploadTypeEnum, UploadModeEnum } from "../../typings/FileUploaderProps";
2+
import { FileUploaderContainerProps, UploadModeEnum } from "../../typings/FileUploaderProps";
33
import { action, computed, makeObservable, observable } from "mobx";
44
import { Big } from "big.js";
55
import { getImageUploaderFormats, parseAllowedFormats } from "../utils/parseAllowedFormats";
@@ -27,9 +27,7 @@ export class FileUploaderStore {
2727
_maxFileSizeMiB = 0;
2828
_maxFileSize = 0;
2929
_ds?: ListValue;
30-
_maxFilesPerUpload: number;
31-
_maxFilePerUploadType: MaxFilePerUploadTypeEnum;
32-
_maxFilesPerUploadExpression: DynamicValue<Big>;
30+
_maxFilesPerUpload: DynamicValue<Big>;
3331

3432
errorMessage?: string = undefined;
3533

@@ -40,8 +38,6 @@ export class FileUploaderStore {
4038
this._maxFileSizeMiB = props.maxFileSize;
4139
this._maxFileSize = this._maxFileSizeMiB * 1024 * 1024;
4240
this._maxFilesPerUpload = props.maxFilesPerUpload;
43-
this._maxFilePerUploadType = props.maxFilePerUploadType;
44-
this._maxFilesPerUploadExpression = props.maxFilesPerUploadExpression;
4541
this._uploadMode = props.uploadMode;
4642

4743
this.objectCreationHelper = new ObjectCreationHelper(this._widgetName, props.objectCreationTimeout);
@@ -103,8 +99,6 @@ export class FileUploaderStore {
10399

104100
// Update max files properties
105101
this._maxFilesPerUpload = props.maxFilesPerUpload;
106-
this._maxFilePerUploadType = props.maxFilePerUploadType;
107-
this._maxFilesPerUploadExpression = props.maxFilesPerUploadExpression;
108102

109103
this.translations.updateProps(props);
110104
this.updateProcessor.processUpdate(this._ds);
@@ -125,23 +119,20 @@ export class FileUploaderStore {
125119
.join(", ");
126120
}
127121

128-
get maxFilesPerUpload(): number | undefined {
129-
if (this._maxFilePerUploadType === "expression") {
130-
const expressionValue = this._maxFilesPerUploadExpression.value;
131-
if (expressionValue && !isNaN(Number(expressionValue))) {
132-
return Number(expressionValue);
133-
}
134-
// Fallback to default if expression is invalid
135-
return undefined;
122+
get maxFilesPerUpload(): number {
123+
const expressionValue = this._maxFilesPerUpload.value;
124+
if (expressionValue && !isNaN(Number(expressionValue))) {
125+
return Number(expressionValue);
136126
}
137-
return this._maxFilesPerUpload;
127+
// Fallback to unlimited
128+
return 0;
138129
}
139130

140131
get isFileUploadLimitReached(): boolean {
141132
const activeFiles = this.files.filter(
142133
file => file.fileStatus !== "missing" && file.fileStatus !== "removedFile"
143134
);
144-
if (!this.maxFilesPerUpload || this.maxFilesPerUpload === 0) {
135+
if (this.maxFilesPerUpload === 0) {
145136
return false;
146137
}
147138
return activeFiles.length >= this.maxFilesPerUpload;

packages/pluggableWidgets/file-uploader-web/typings/FileUploaderProps.d.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ export interface AllowedFileFormatsType {
2121
typeFormatDescription: DynamicValue<string>;
2222
}
2323

24-
export type MaxFilePerUploadTypeEnum = "number" | "expression";
25-
2624
export interface CustomButtonsType {
2725
buttonCaption: DynamicValue<string>;
2826
buttonIcon: DynamicValue<WebIcon>;
@@ -61,9 +59,7 @@ export interface FileUploaderContainerProps {
6159
createFileAction?: ActionValue;
6260
createImageAction?: ActionValue;
6361
allowedFileFormats: AllowedFileFormatsType[];
64-
maxFilePerUploadType: MaxFilePerUploadTypeEnum;
65-
maxFilesPerUploadExpression: DynamicValue<Big>;
66-
maxFilesPerUpload: number;
62+
maxFilesPerUpload: DynamicValue<Big>;
6763
maxFileSize: number;
6864
dropzoneIdleMessage: DynamicValue<string>;
6965
dropzoneAcceptedMessage: DynamicValue<string>;
@@ -102,9 +98,7 @@ export interface FileUploaderPreviewProps {
10298
createFileAction: {} | null;
10399
createImageAction: {} | null;
104100
allowedFileFormats: AllowedFileFormatsPreviewType[];
105-
maxFilePerUploadType: MaxFilePerUploadTypeEnum;
106-
maxFilesPerUploadExpression: string;
107-
maxFilesPerUpload: number | null;
101+
maxFilesPerUpload: string;
108102
maxFileSize: number | null;
109103
dropzoneIdleMessage: string;
110104
dropzoneAcceptedMessage: string;

0 commit comments

Comments
 (0)