zyratlo commented on code in PR #9578:
URL: https://github.com/apache/texera/pull/9578#discussion_r4656346951


##########
frontend/src/app/dashboard/component/user/user-workflow/user-workflow.component.ts:
##########
@@ -76,20 +78,63 @@ 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 }> = {
+// What each language accepts, and where the modal takes it, so a mismatch can 
name the right place.
+const MIGRATION_INPUTS: Record<
+  MigrationLanguage,
+  {
+    name: string;
+    article: string;
+    // As a notebook's kernelspec.language or language_info.name gives it, 
lowercased.
+    kernelLanguage: string;
+    extension: string;
+    uploadHint: string;
+    notebookType: string;
+    fileTab: string;
+    folderTab: string;
+  }
+> = {
   python: {
     name: "Python",
+    article: "a",
+    kernelLanguage: "python",
     extension: "py",
     uploadHint: "Please upload a Jupyter Notebook (.ipynb) or a Python (.py) 
file.",
+    notebookType: "Python Notebook",
+    fileTab: "Python File",
+    folderTab: "Python Folder",
   },
   r: {
     name: "R",
+    article: "an",
+    kernelLanguage: "r",
     extension: "R",
     uploadHint: "Please upload an R Jupyter Notebook (.ipynb) or an R (.R) 
file.",
+    notebookType: "R Notebook",
+    fileTab: "R File",
+    folderTab: "R Folder",
   },
 };
 
+const MIGRATION_LANGUAGES = Object.keys(MIGRATION_INPUTS) as 
MigrationLanguage[];
+
+const MIGRATION_ERROR_DURATION_MS = 8000;
+
+/** The language a notebook declares, lowercased. Undefined when it declares 
none. */
+function notebookKernelLanguage(notebook: Notebook): string | undefined {
+  // Each field is normalized first, so a blank kernelspec still falls back to 
language_info.
+  return [notebook.metadata?.["kernelspec"]?.language, 
notebook.metadata?.["language_info"]?.name]
+    .map(value => `${value ?? ""}`.trim().toLowerCase())

Review Comment:
   Fixed in 
[110c505](https://github.com/apache/texera/pull/9578/commits/110c505e2aea9c62b5b8d46bfb6511c96b1aef24).
 Only string values are normalized now, and any other value is treated as 
undeclared, so malformed metadata falls through to the other field instead of 
throwing. Added a test with a non string language_info.name next to a valid 
kernelspec.



-- 
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]

Reply via email to