Web:When clicking on a file, a loader appears.

This commit is contained in:
gazizova-vlada 2023-09-11 11:23:42 +03:00
parent fcf4a16de1
commit 8ecc18f927
2 changed files with 18 additions and 8 deletions

View File

@ -52,6 +52,7 @@ const NewFilesPanel = (props) => {
const [listFiles, setListFiles] = useState(newFiles); const [listFiles, setListFiles] = useState(newFiles);
const [inProgress, setInProgress] = useState(false); const [inProgress, setInProgress] = useState(false);
const [currentOpenFileId, setCurrentOpenFileId] = useState(null);
const onClose = () => { const onClose = () => {
if (inProgress) return; if (inProgress) return;
@ -108,6 +109,8 @@ const NewFilesPanel = (props) => {
const { id, extension: fileExst } = e.target.dataset; const { id, extension: fileExst } = e.target.dataset;
setCurrentOpenFileId(id);
const fileIds = fileExst ? [id] : []; const fileIds = fileExst ? [id] : [];
const folderIds = fileExst ? [] : [id]; const folderIds = fileExst ? [] : [id];
@ -127,7 +130,10 @@ const NewFilesPanel = (props) => {
.catch((err) => { .catch((err) => {
toastr.error(err); toastr.error(err);
}) })
.finally(() => setInProgress(false)); .finally(() => {
setInProgress(false);
setCurrentOpenFileId(null);
});
}; };
const onFileClick = (item) => { const onFileClick = (item) => {
@ -228,7 +234,11 @@ const NewFilesPanel = (props) => {
const element = getItemIcon(file); const element = getItemIcon(file);
return ( return (
<Row key={file.id} element={element}> <Row
key={file.id}
element={element}
inProgress={currentOpenFileId === file.id.toString()}
>
<StyledLink <StyledLink
onClick={onNewFileClick} onClick={onNewFileClick}
containerWidth="100%" containerWidth="100%"
@ -247,7 +257,7 @@ const NewFilesPanel = (props) => {
</Row> </Row>
); );
}); });
}, [onNewFileClick, getItemIcon]); }, [onNewFileClick, getItemIcon, currentOpenFileId]);
const element = ( const element = (
<StyledAsidePanel visible={visible}> <StyledAsidePanel visible={visible}>

View File

@ -144,13 +144,13 @@ class Row extends React.Component {
/> />
</StyledCheckbox> </StyledCheckbox>
)} )}
{mode == "default" && renderElement && (
<StyledElement onClick={onRowClick} className="styled-element">
{element}
</StyledElement>
)}
</> </>
)} )}
{mode == "default" && renderElement && (
<StyledElement onClick={onRowClick} className="styled-element">
{element}
</StyledElement>
)}
<StyledContent onClick={onRowClick} className="row_content"> <StyledContent onClick={onRowClick} className="row_content">
{children} {children}