Copilot commented on code in PR #8963:
URL: https://github.com/apache/texera/pull/8963#discussion_r4557151063
##########
frontend/src/app/dashboard/component/user/user-workflow/user-workflow.component.ts:
##########
@@ -76,6 +76,20 @@ import { FiltersInstructionsComponent } from
"../filters-instructions/filters-in
import { NzSelectComponent } from "ng-zorro-antd/select";
import { FormsModule } from "@angular/forms";
+// The single-file input each language accepts besides .ipynb.
+const SCRIPT_INPUTS: Record<MigrationLanguage, { name: string; extension:
string; uploadHint: string }> = {
+ python: {
+ name: "Python",
+ extension: "py",
+ uploadHint: "Please upload a Jupyter Notebook (.ipynb) or a Python (.py)
file.",
+ },
+ r: {
+ name: "R",
+ extension: "R",
+ uploadHint: "Please upload an R Jupyter Notebook (.ipynb) or an R (.R)
file.",
Review Comment:
The UI and tests accept both `.R` and `.r`, but the user-facing hints/errors
only mention `.R`. This is confusing when a user has a lowercase `.r` script.
Consider modeling allowed extensions as a list (e.g., `extensions: ["R", "r"]`)
and generating consistent hints/errors like “(.R/.r)”, or standardize the
messaging to explicitly include both forms.
##########
frontend/src/app/workspace/component/notebook-import-modal/notebook-import-modal.component.spec.ts:
##########
@@ -627,15 +627,21 @@ describe("NotebookImportModalComponent", () => {
});
});
+ function tooltipOn(text: string) {
+ return fixture.debugElement
+ .queryAll(By.directive(NzTooltipDirective))
+ .find(element => element.nativeElement.textContent.trim() === text)!
+ .injector.get(NzTooltipDirective).title;
Review Comment:
This helper relies on matching `textContent` and uses a non-null assertion
(`!`), which can make failures hard to diagnose (it will throw a generic
runtime error if the tooltip host text changes). A more robust approach is to
query the specific element via a stable selector (e.g., a dedicated attribute
on the tab title span) and then read its `NzTooltipDirective`, or have
`tooltipOn` throw an explicit error when the element is not found.
##########
frontend/src/app/dashboard/component/user/user-workflow/user-workflow.component.ts:
##########
@@ -381,19 +392,26 @@ export class UserWorkflowComponent implements
AfterViewInit, OnDestroy {
}
}
- /** Read and convert a .py. The notebook comes back derived, since the
upload had no cells. */
- private async generateFromScript(file: NzUploadFile, model: string):
Promise<GeneratedWorkflowContent | null> {
+ /** Read and convert a script. The notebook comes back derived, since the
upload had no cells. */
+ private async generateFromScript(
+ file: NzUploadFile,
+ model: string,
+ language: MigrationLanguage
+ ): Promise<GeneratedWorkflowContent | null> {
+ const { name, extension } = SCRIPT_INPUTS[language];
let scriptSource: string;
try {
scriptSource = await this.notebookMigrationService.parseScriptFile(file
as unknown as File);
} catch (error) {
- this.notificationService.error("Failed to read the Python file. Please
upload a valid, non-empty .py file.");
- console.error("Python file read failed:", error);
+ this.notificationService.error(
+ `Failed to read the ${name} file. Please upload a valid, non-empty
.${extension} file.`
+ );
Review Comment:
The UI and tests accept both `.R` and `.r`, but the user-facing hints/errors
only mention `.R`. This is confusing when a user has a lowercase `.r` script.
Consider modeling allowed extensions as a list (e.g., `extensions: ["R", "r"]`)
and generating consistent hints/errors like “(.R/.r)”, or standardize the
messaging to explicitly include both forms.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]