Skip to content
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
f95fa5c
fix: clean up storedFilesRendererBase component and styles
czwe-01 Nov 4, 2025
ecee50c
Merge branch 'main' into thulasizwe/fix/4098
czwe-01 Nov 6, 2025
e8d455f
Merge branch 'main' into thulasizwe/fix/4098
czwe-01 Nov 6, 2025
530866f
style: update sidebar and storedFilesRendererBase styles for improved…
czwe-01 Nov 6, 2025
40839ed
Merge branch 'main' into thulasizwe/fix/4098
czwe-01 Nov 6, 2025
94462ad
Merge remote-tracking branch 'origin' into thulasizwe/fix/4098
czwe-01 Nov 7, 2025
9a39cea
refactor: restructure StoredFilesRendererBase component and update st…
czwe-01 Nov 7, 2025
1f92e8e
lint-fix
czwe-01 Nov 10, 2025
0fc1eb1
Merge remote-tracking branch 'origin' into thulasizwe/fix/4098
czwe-01 Nov 12, 2025
1c0abf0
rm unrelated style
czwe-01 Nov 12, 2025
3452ad7
Update storedFilesRendererBase styles for text alignment and layout
czwe-01 Nov 12, 2025
3cfdab1
Fix formatting issue by adding missing comma for downloadZip prop in …
czwe-01 Nov 12, 2025
c9199d8
Refactor styles in StoredFilesRendererBase component to use consisten…
czwe-01 Nov 12, 2025
10b9dad
Update styles in StoredFilesRendererBase component to improve layout …
czwe-01 Nov 12, 2025
c174372
default font-size
czwe-01 Nov 12, 2025
22342cf
Merge branch 'main' into thulasizwe/fix/4098
czwe-01 Nov 13, 2025
a68db42
Refactor styles in StoredFilesRendererBase component to utilize compu…
czwe-01 Nov 13, 2025
9f9bfb7
Update styles in StoredFilesRendererBase component to dynamically adj…
czwe-01 Nov 13, 2025
9defe95
Update gap property in StoredFilesRendererBase styles to use !important
czwe-01 Nov 13, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 20 additions & 22 deletions shesha-reactjs/src/components/customFile/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,28 +45,26 @@ export const CustomFile: FC<ICustomFileProps> = (props) => {
const { backendUrl } = useSheshaApplication();

return (
<div className="stored-files-renderer-wrapper">
<StoredFilesRendererBase
{...props}
isStub={props.isStub}
disabled={props.disabled || !props.allowAdd}
isDragger={props?.isDragger}
fileList={fileList?.map(({ url, ...rest }) => ({ url: `${backendUrl}${url}`, ...rest }))}
allowUpload={false}
allowDelete={props.allowDelete}
deleteFile={deleteFile}
uploadFile={props.uploadFile ?? uploadFile}
downloadZipFile={downloadZipFile}
downloadZip={props.downloadZip}
downloadFile={downloadFile}
isDownloadingFileListZip={downloadZip}
isDownloadZipSucceeded={downloadZipSuccess}
allowedFileTypes={props?.allowedFileTypes}
maxHeight={props?.maxHeight}
layout={props?.filesLayout}
listType={props?.listType}
/>
</div>
<StoredFilesRendererBase
{...props}
isStub={props.isStub}
disabled={props.disabled || !props.allowAdd}
isDragger={props?.isDragger}
fileList={fileList?.map(({ url, ...rest }) => ({ url: `${backendUrl}${url}`, ...rest }))}
allowUpload={false}
allowDelete={props.allowDelete}
deleteFile={deleteFile}
uploadFile={props.uploadFile ?? uploadFile}
downloadZipFile={downloadZipFile}
downloadZip={props.downloadZip}
downloadFile={downloadFile}
isDownloadingFileListZip={downloadZip}
isDownloadZipSucceeded={downloadZipSuccess}
allowedFileTypes={props?.allowedFileTypes}
maxHeight={props?.maxHeight}
layout={props?.filesLayout}
listType={props?.listType}
/>
);
};

Expand Down
129 changes: 64 additions & 65 deletions shesha-reactjs/src/components/storedFilesRendererBase/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ export const StoredFilesRendererBase: FC<IStoredFilesRendererBaseProps> = ({
hideFileName: rest.hideFileName && listType === 'thumbnail',
isDragger,
isStub,
downloadZip,
},
});

Expand Down Expand Up @@ -284,71 +285,69 @@ export const StoredFilesRendererBase: FC<IStoredFilesRendererBaseProps> = ({
};

return (
<div className={`${styles.shaStoredFilesRenderer} ${layout === 'horizontal' && listTypeAndLayout !== 'text' ? styles.shaStoredFilesRendererHorizontal
: layout === 'vertical' && listTypeAndLayout !== 'text' ? styles.shaStoredFilesRendererVertical
: layout === 'grid' && listTypeAndLayout !== 'text' ? styles.shaStoredFilesRendererGrid : ''}`}
>
{isStub
? (isDragger
? <Dragger disabled><DraggerStub styles={styles} /></Dragger>
: (
<div
className={listType === 'thumbnail' ? 'ant-upload-list-item-thumbnail ant-upload-list-item thumbnail-stub' : ''}
>
{renderUploadContent()}
{listType !== 'text' && !rest.hideFileName && (
<span className="ant-upload-list-item-name ant-upload-list-item-name-stub">
file name
</span>
)}
</div>
))
: (props.disabled && fileList.length === 0
? (
<div className={listType === 'thumbnail' ? styles.thumbnailReadOnly : ''}>
{renderUploadContent()}
</div>
)
: props.disabled
? <Upload {...props} style={model?.allStyles?.fullStyle} listType={listTypeAndLayout} />
: isDragger
? (
<Dragger {...props}>
<DraggerStub styles={styles} />
</Dragger>
)
: <Upload {...props} listType={listTypeAndLayout}>{renderUploadContent()}</Upload>)}
{previewImage && (
<Image
wrapperStyle={{ display: 'none' }}
preview={{
visible: previewOpen,
onVisibleChange: (visible) => setPreviewOpen(visible),
afterOpenChange: (visible) => !visible && setPreviewImage(null),
toolbarRender: (original) => {
return <div style={{ display: 'flex', flexDirection: 'row-reverse' }}><DownloadOutlined className={styles.antPreviewDownloadIcon} onClick={() => downloadFile({ fileId: previewImage.uid, fileName: previewImage.name })} />{original}</div>;
},
}}
src={previewImage.url}
/>
)}

{fetchFilesError && (
<Alert message="Error" description="Sorry, an error occurred while trying to fetch file list." type="error" />
)}

{downloadZipFileError && (
<Alert message="Error" description="Sorry, an error occurred while trying to download zip file." type="error" />
)}

{downloadZip && hasFiles && !!downloadZipFile && (
<div className={styles.storedFilesRendererBtnContainer}>
<Button size="small" type="link" icon onClick={() => downloadZipFile()} loading={isDownloadingFileListZip}>
{!isDownloadingFileListZip && <FileZipOutlined />} Download Zip
</Button>
</div>
)}

<div className={styles.storedFilesRendererWrapper}>
<div className={`${styles.shaStoredFilesRenderer} ${layout === 'horizontal' && listTypeAndLayout !== 'text' ? styles.shaStoredFilesRendererHorizontal
: layout === 'vertical' && listTypeAndLayout !== 'text' ? styles.shaStoredFilesRendererVertical
: layout === 'grid' && listTypeAndLayout !== 'text' ? styles.shaStoredFilesRendererGrid : ''}`}
>
{isStub
? (isDragger
? <Dragger disabled><DraggerStub styles={styles} /></Dragger>
: (
<div
className={listType === 'thumbnail' ? 'ant-upload-list-item-thumbnail ant-upload-list-item thumbnail-stub' : ''}
>
{renderUploadContent()}
{listType !== 'text' && !rest.hideFileName && (
<span className="ant-upload-list-item-name ant-upload-list-item-name-stub">
file name
</span>
)}
</div>
))
: (props.disabled && fileList.length === 0
? null
: props.disabled
? <Upload {...props} style={model?.allStyles?.fullStyle} listType={listTypeAndLayout} />
: isDragger
? (
<Dragger {...props}>
<DraggerStub styles={styles} />
</Dragger>
)
: <Upload {...props} listType={listTypeAndLayout}>{renderUploadContent()}</Upload>)}
{previewImage && (
<Image
wrapperStyle={{ display: 'none' }}
preview={{
visible: previewOpen,
onVisibleChange: (visible) => setPreviewOpen(visible),
afterOpenChange: (visible) => !visible && setPreviewImage(null),
toolbarRender: (original) => {
return <div style={{ display: 'flex', flexDirection: 'row-reverse' }}><DownloadOutlined className={styles.antPreviewDownloadIcon} onClick={() => downloadFile({ fileId: previewImage.uid, fileName: previewImage.name })} />{original}</div>;
},
}}
src={previewImage.url}
/>
)}

{fetchFilesError && (
<Alert message="Error" description="Sorry, an error occurred while trying to fetch file list." type="error" />
)}

{downloadZipFileError && (
<Alert message="Error" description="Sorry, an error occurred while trying to download zip file." type="error" />
)}

{downloadZip && hasFiles && !!downloadZipFile && (
<div className={styles.storedFilesRendererBtnContainer}>
<Button size="small" type="link" icon onClick={() => downloadZipFile()} loading={isDownloadingFileListZip}>
{!isDownloadingFileListZip && <FileZipOutlined />} Download Zip
</Button>
</div>
)}

</div>
</div>
);
};
Expand Down
Loading