Fix/1521/excel export ignore hidden columns#4363
Fix/1521/excel export ignore hidden columns#4363EthanJappie wants to merge 4 commits intoshesha-io:releases/0.44from
Conversation
WalkthroughThe Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
IvanIlyichev
left a comment
There was a problem hiding this comment.
Hi @EthanJappie. Your changes don't address issue #1521. Make sure it works as expected
Exclude Id column |
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (1)
shesha-reactjs/src/providers/dataTable/repository/backendRepository.tsx(1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{ts,tsx}
📄 CodeRabbit inference engine (CodeRabbitReview-Project-Specific-Guidelines.md)
**/*.{ts,tsx}: Eliminate theanytype; useunknowntype instead for values with unknown types, forcing explicit type checking
Prefer type guards over type casting for type checking
Avoid monolithic types; use discriminated unions with a discriminator property instead
Leverage TypeScript to its full potential as a type system, not merely as a linter
Files:
shesha-reactjs/src/providers/dataTable/repository/backendRepository.tsx
🧠 Learnings (1)
📚 Learning: 2025-06-12T16:55:57.638Z
Learnt from: teboho
Repo: shesha-io/shesha-framework PR: 3397
File: shesha-reactjs/src/designer-components/charts/bar.tsx:49-52
Timestamp: 2025-06-12T16:55:57.638Z
Learning: For the chart components’ migrators (e.g., BarChartComponent in shesha-reactjs/src/designer-components/charts/bar.tsx), the version 5 step intentionally spreads `{ ...prev, ...defaultConfigFiller }` so that values from `defaultConfigFiller` override any existing properties in `prev`. This reset to new defaults is by design and should not be flagged as an issue.
Applied to files:
shesha-reactjs/src/providers/dataTable/repository/backendRepository.tsx
🔇 Additional comments (1)
shesha-reactjs/src/providers/dataTable/repository/backendRepository.tsx (1)
258-260: Remove the undefinedisVisiblehandling concern—the property is a required boolean.The second concern in this review is incorrect. The
ITableDataColumninterface extendsITableColumn, which definesisVisible: booleanas a required property (not optional). TypeScript guarantees thatisVisibleis always a boolean value and cannot beundefinedornull, so the filter correctly excludes only columns whereisVisibleisfalse.The code properly leverages TypeScript's type system and follows the coding guidelines—no type guards are needed for
isVisiblesince its type is guaranteed by the interface.The first concern about empty columns is valid: if all columns have
isVisible === false, theexcelColumnsarray will be empty. However, this is a behavioral question rather than a code defect. Confirm whether the backend/ExportToExcelendpoint gracefully handles empty column arrays or if a user-facing message is needed when no visible columns exist.
| @@ -256,12 +256,9 @@ const createRepository = (args: ICreateBackendRepositoryArgs): IBackendRepositor | |||
|
|
|||
| const exportToExcel = (payload: IGetListDataPayload): Promise<void> => { | |||
| let excelColumns = payload.columns | |||
There was a problem hiding this comment.
🧹 Nitpick | 🔵 Trivial
Use const instead of let for immutable variable.
The excelColumns variable is never reassigned, so it should be declared with const to prevent accidental mutations and improve code clarity.
Apply this diff:
- let excelColumns = payload.columns
+ const excelColumns = payload.columns
.filter(c => c.isVisible)
.map<IExcelColumn>(c => ({ propertyName: c.propertyName, label: c.caption }));📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| let excelColumns = payload.columns | |
| const excelColumns = payload.columns | |
| .filter(c => c.isVisible) | |
| .map<IExcelColumn>(c => ({ propertyName: c.propertyName, label: c.caption })); |
🤖 Prompt for AI Agents
In shesha-reactjs/src/providers/dataTable/repository/backendRepository.tsx
around line 258, the variable declaration uses "let excelColumns =
payload.columns" but excelColumns is never reassigned; change the declaration to
"const excelColumns = payload.columns" to make it immutable and prevent
accidental reassignments, leaving the rest of the code unchanged.
Excel export should ignore hidden (isVisible == false) columns when exporting data tables
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.