Skip to content

Thulasizwe/b/4098#4455

Merged
James-Baloyi merged 16 commits intoshesha-io:mainfrom
czwe-01:thulasizwe/b/4098
Jan 27, 2026
Merged

Thulasizwe/b/4098#4455
James-Baloyi merged 16 commits intoshesha-io:mainfrom
czwe-01:thulasizwe/b/4098

Conversation

@czwe-01
Copy link
Copy Markdown
Collaborator

@czwe-01 czwe-01 commented Jan 26, 2026

#4098

Summary by CodeRabbit

  • New Features

    • File names now use a compact display component and show human-readable sizes in tooltips across list and thumbnail views
    • File actions are consolidated into a popover for clearer interaction
  • Style

    • Refined file-display visuals, nested typography, and responsive layout for upload lists and thumbnails
    • Code editor container now fills available height
  • Bug Fixes

    • Removed upload button click interaction in non-dragger mode to prevent unintended actions

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Jan 26, 2026

Walkthrough

Replaces inline filename rendering with a new FileNameDisplay component (tooltip showing human-readable size) used across list and thumbnail views, removes upload trigger onClick in non-dragger mode, removes isDragger from styles, and adds height: 100% to the code editor container.

Changes

Cohort / File(s) Summary
Renderer logic
shesha-reactjs/src/components/storedFilesRendererBase/index.tsx
Replaced direct file.name rendering with FileNameDisplay in text/list and thumbnail branches; passed actions as popoverContent; removed upload trigger onClick in non-dragger mode; ensured actions are encapsulated in the FileNameDisplay popover.
Utilities / New component
shesha-reactjs/src/components/storedFilesRendererBase/utils.tsx
Added formatFileSize helper and exported FileNameDisplay component (FC<{ file: UploadFile; className?: string; popoverContent?: React.ReactNode; popoverClassName?: string }>), rendering truncated filename with a tooltip title including human-readable size.
Styles / Layout
shesha-reactjs/src/components/storedFilesRendererBase/styles/styles.ts
Removed isDragger?: boolean from the model interface; moved filename rules into nested .ant-typography blocks; consolidated many containers to 100% width/height; adjusted thumbnail, icon, list/text, and dragger spacing and responsive behavior driven by layout/hasFiles.
Code editor layout
shesha-reactjs/src/designer-components/codeEditor/styles.ts
Added height: 100% to .sha-code-editor-container.

Sequence Diagram(s)

(Skipped — UI rendering/styling changes; no new multi-actor sequential flow meeting diagram criteria.)

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • James-Baloyi
  • IvanIlyichev

Poem

🐰 I hopped through code with whiskers bright,
I wrapped each name in tooltip light,
A popover cradles icon and size,
Styles stretched full — the editor rise,
Filenames snug — I nibble with delight. ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Title check ⚠️ Warning The pull request title "Thulasizwe/b/4098" is a branch name reference that does not describe the actual changes made. The summary shows significant refactoring of file rendering (FileNameDisplay component, styling updates, popover removal), but the title provides no meaningful information about these changes. Replace the branch name with a descriptive title summarizing the main change, such as "Refactor file name rendering with FileNameDisplay component" or "Remove popover from stored files renderer and improve file display"
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@czwe-01 czwe-01 requested a review from James-Baloyi January 26, 2026 14:15
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 5

🤖 Fix all issues with AI agents
In `@shesha-reactjs/src/components/storedFilesRendererBase/index.tsx`:
- Around line 444-449: The wrapper div and FileNameDisplay both receive the same
styles.fileName, causing nested elements with identical classes; remove the
duplicate by dropping the className prop from the FileNameDisplay call (leave
styles.fileName on the outer div) so FileNameDisplay does not receive className,
or alternatively remove the class from the outer div if you prefer the inner to
own styling—update the JSX around Popover/iconRender/FileNameDisplay accordingly
to only apply styles.fileName once.

In `@shesha-reactjs/src/components/storedFilesRendererBase/styles/styles.ts`:
- Around line 256-277: The CSS block for .ant-upload-list-text has a misplaced
child selector (> .downloaded-icon) and an extra closing brace; move the >
.downloaded-icon rule either inside the .ant-upload-list-text block before its
closing brace or convert it into a separate top-level selector, and remove the
unmatched closing brace so braces balance; update the styles around
.ant-upload-list-text and > .downloaded-icon accordingly to maintain intended
scoping and remove the syntax error.
- Around line 106-121: The CSS-in-JS block for .ant-typography accesses
downloadedFileStyles.color without optional chaining which can throw if
downloadedFileStyles is undefined; update the usage in the .ant-typography rule
to use downloadedFileStyles?.color (consistent with
downloadedFileStyles?.fontSize, ?.fontWeight, ?.fontFamily, ?.textAlign) so all
references to downloadedFileStyles are null-safe and won’t cause runtime errors
in styles.ts.

In `@shesha-reactjs/src/components/storedFilesRendererBase/utils.tsx`:
- Around line 177-183: The formatFileSize function currently checks for null
only, which lets undefined fall through and produce NaN; update the initial
guard in formatFileSize to treat both null and undefined (e.g., replace the
`bytes === null` check with a nullish/loose equality check like `bytes == null`
or an explicit `bytes === undefined || bytes === null`) so the function returns
an empty string when bytes is missing and avoids running the arithmetic that
yields "NaN GB".
- Around line 176-183: Replace the custom formatting in formatFileSize with the
existing filesize library to ensure consistent output; update the
formatFileSize(bytes?: number) implementation to return an empty string for
null/undefined and otherwise call filesize(bytes) (or filesize(bytes, { base: 2
} if you need KB/MB as powers of 1024 to match current behavior), preserving the
function signature so callers like FileVersionsButton keep working and types
remain correct.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@shesha-reactjs/src/components/storedFilesRendererBase/index.tsx`:
- Around line 482-485: The thumbnail filename is rendered even when isDragger is
true (dragger mode shouldn't render thumbnail UI); update the condition that
currently checks listType === 'thumbnail' to also require !isDragger (e.g.,
change to !isDragger && listType === 'thumbnail') or normalize listType earlier
so FileNameDisplay (used here along with isDownloaded and styles.fileName) is
only rendered for non-dragger thumbnail mode; ensure this prevents
duplicate/awkward UI in dragger mode.
♻️ Duplicate comments (2)
shesha-reactjs/src/components/storedFilesRendererBase/index.tsx (1)

444-449: Remove duplicate styles.fileName class on nested wrappers.

styles.fileName is applied to both the outer <div> and FileNameDisplay, which already wraps its own container. This can double-apply ellipsis/layout styles. Keep it on just one element.

♻️ Suggested change
-            <Popover content={actions} trigger="hover" placement="top" classNames={{ root: styles.actionsPopover }}>
-              <div className={styles.fileName}>
-                {iconRender(file)}
-                <FileNameDisplay file={file} className={styles.fileName} />
-              </div>
-            </Popover>
+            <Popover content={actions} trigger="hover" placement="top" classNames={{ root: styles.actionsPopover }}>
+              <div>
+                {iconRender(file)}
+                <FileNameDisplay file={file} className={styles.fileName} />
+              </div>
+            </Popover>
shesha-reactjs/src/components/storedFilesRendererBase/styles/styles.ts (1)

107-123: Avoid unsafe access of downloadedFileStyles.color.

Line 111 dereferences downloadedFileStyles.color without optional chaining, which can throw if the prop is undefined. Use downloadedFileStyles?.color like the other fields.

🐛 Suggested fix
-        color: ${downloadedFileStyles.color ?? color} !important;
+        color: ${downloadedFileStyles?.color ?? color} !important;

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@shesha-reactjs/src/components/storedFilesRendererBase/styles/styles.ts`:
- Line 116: The CSS template currently concatenates the conditional
`justify-content` with `margin` on one line; refactor the string in styles.ts so
the `justify-content` expression (using `downloadedFileStyles?.textAlign` and
its ternary branches) is its own CSS declaration ending with a semicolon, and
place `margin: 2px 0px;` on the next line as a separate declaration to match the
readability of the `fileName` class; update the template literal where
`downloadedFileStyles?.textAlign` is referenced to produce `justify-content:
center|flex-end|flex-start;` and then add `margin: 2px 0px;` after it.
♻️ Duplicate comments (1)
shesha-reactjs/src/components/storedFilesRendererBase/index.tsx (1)

445-450: Duplicate styles.fileName class application.

The styles.fileName class is applied to both the wrapper <div> (line 446) and passed to FileNameDisplay (line 448). Since FileNameDisplay applies the className to its internal wrapper, this creates nested elements with the same class, potentially causing unintended style cascading.

♻️ Consider removing the duplicate className from the outer div
           <Popover content={actions} trigger="hover" placement="top" classNames={{ root: styles.actionsPopover }}>
-              <div className={styles.fileName}>
+              <div>
                 {iconRender(file)}
                 <FileNameDisplay file={file} className={styles.fileName} />
               </div>
             </Popover>

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Fix all issues with AI agents
In `@shesha-reactjs/src/components/storedFilesRendererBase/styles/styles.ts`:
- Around line 308-318: The CSS-in-JS injection uses the short-circuit pattern
that can produce the literal "false" when hasFiles is falsy; update the
expression inside the .${prefixCls}-upload-drag block to use a ternary so it
emits the rule only when hasFiles is true (e.g., replace the ${hasFiles &&
'border: unset !important;'} usage with a ternary that returns the string when
hasFiles is truthy and an empty string otherwise), targeting the styles.ts code
around the .${prefixCls}-upload-drag / ${prefixCls}-upload-btn definitions so
the conditional border rule no longer injects "false".
- Around line 259-277: The template literal in the .ant-upload-list-text block
injects the literal "false" when hasFiles is true; replace the short-circuit
expression `${!hasFiles && 'display: none;'}` with a ternary that outputs either
the CSS or an empty string (e.g. `${!hasFiles ? 'display: none;' : ''}`) so no
"false" text is produced; update the CSS inside the .ant-upload-list-text rule
where hasFiles is referenced.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Fix all issues with AI agents
In `@shesha-reactjs/src/components/storedFilesRendererBase/styles/styles.ts`:
- Around line 279-286: The CSS template is using redundant nested template
literals for width/height; replace `${`width: ${layout ? thumbnailWidth :
'100%'} !important;`}` and similar lines with direct template interpolations
like `width: ${layout ? thumbnailWidth : '100%'} !important;` and do the same
for `height` and the `.ant-upload` block so the expressions for `layout`,
`thumbnailWidth`, and `thumbnailHeight` are interpolated directly without the
extra `${`...`}` wrapper.
- Around line 42-72: The styles duplicate typography rules between the parent
const fileName (class "item-file-name") and its nested ".ant-typography"; remove
the redundant typography properties from the parent and keep them on
".ant-typography" (font-size, font-weight, font-family, text-align,
justify-content, color) so the nested element controls text rendering, while
preserving parent-only layout rules (display, gap, white-space, overflow,
text-overflow, min-width) and the conditional visibility using
model.hideFileName in ".ant-typography".

…t and update styles for improved file name visibility
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@shesha-reactjs/src/components/storedFilesRendererBase/utils.tsx`:
- Around line 186-216: The inline props type for the FileNameDisplay component
should be extracted into a named interface for clarity and reusability: create
and export a new interface (e.g., FileNameDisplayProps) that defines file:
UploadFile; className?: string; popoverContent?: React.ReactNode;
popoverClassName?: string, then update the component declaration to use
FC<FileNameDisplayProps> and replace the inline destructured type with the same
props name in the parameter list; ensure any existing imports/types (UploadFile,
React) remain valid and adjust any other references to this component if
necessary.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@shesha-reactjs/src/components/storedFilesRendererBase/index.tsx`:
- Around line 447-452: The Popover used inside FileNameDisplay is only passing
popoverClassName to the Popover root, so the popover body doesn't receive the
same styling; update the Popover invocation (the one rendering textElement
inside FileNameDisplay / storedFilesRendererBase's component) to pass classNames
with both root and body keys (i.e., classNames={{ root: popoverClassName, body:
popoverClassName }}) so the popover body uses the same styles as the root.

@James-Baloyi James-Baloyi merged commit b644331 into shesha-io:main Jan 27, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants