enhancement
major
minor
defect
critical
major
minor
Problem
An upload is only possible as an `<upload-command> ` within the commands of a `<panel>`. A `<button> ` in a form or dialog with the same upload action does not display a file selection dialog when clicked.
Version: 8.0.0-alpha12, React View Layer (tl-layout-view/tl-layout-react).
Reproduction (Prime)
"New Version" dialog (prime/project/document-version-dialog.view.xml): The file selection should be a "Select File..." button next to the comment field.
- Place a `<button> ` with an upload action in the dialog and click it: Nothing happens.
Prime: “Select File...” appears as an `<upload-command> ` in the commands of a `<panel> ` in the dialog and writes to the ` file` channel.
Expected Behavior
Upload actions should work in any command location, including as a <button> and as a command within a <form>.
Solution
File selection and uploading are handled by the ReactUploadButtonControl (Client TLUploadButton); clicking a <upload-command> in a normal ReactButtonControl has no effect. Previously, only the toolbar (ToolbarBuilder) selected the upload control; <button>, <floating-action>, the actions of an <alert>, and the chat data list always created a normal button.
The command model now generates the appropriate button itself (CommandModel.createButton(ReactContext), overridden by UploadCommandModel ). All locations that create a button for a command model use this method, so that upload commands open the file selection dialog wherever they appear.
A configured command (ViewCommandModel) always runs in the view context in which it is declared, regardless of where its button or menu item is displayed. The commands in the `<commands> ` section of a `<form> ` appear in the toolbar of the surrounding panel but still run within the form (using that form’s model); an `<upload-command> ` there opens the file dialog. Similarly, the entries in a `<context-menu> ` run in the context of the declaring element and see its channels, even if the menu is opened outside the window frame. The previous wrappers, which only swapped the context (FormElement.FormScopedCommandModel, DataListControl.InListContext in tl-chat), are no longer needed.
Demo (tl-demo-react, Demos → Document View): The “Select File...” button below the prompt uploads documents; the “Properties” form below the document list offers “Replace File” as a form command in edit mode; the selected file is added to the form and applied when “Save” is clicked.
Migration
Only Java code that directly uses `com.top_logic.layout.view.command.ViewCommandModel`:
- ViewCommandModel.execute(ReactContext, Object) is now called execute(Object); the command runs in the context used to create the model. The context argument is no longer required.
- The public constructors of ViewCommandModel and ViewUploadCommandModel expect the ViewContext in which the command runs as their first argument. ViewCommandModel.create(...) / forCommand(...) no longer accept a null context.
- RowCommandColumn.RowCommand.of(...) no longer expects a context.
- A custom wrapper around a ViewCommandModel that merely uses a different execution context is redundant and can be omitted.