Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix/loader for file operations #459

Merged
merged 15 commits into from
Nov 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
26 changes: 16 additions & 10 deletions packages/asc-web-components/row/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
StyledContent,
StyledRow,
} from "./styled-row";
import Loader from "../loader";

class Row extends React.Component {
constructor(props) {
Expand Down Expand Up @@ -71,19 +72,23 @@ class Row extends React.Component {
this.cm.current.show(e);
};

const { onRowClick, ...rest } = this.props;
const { onRowClick, inProgress, ...rest } = this.props;

return (
<StyledRow ref={this.row} {...rest} onContextMenu={onContextMenu}>
{renderCheckbox && (
<StyledCheckbox className="not-selectable">
<Checkbox
className="checkbox"
isChecked={checked}
isIndeterminate={indeterminate}
onChange={changeCheckbox}
/>
</StyledCheckbox>
{inProgress ? (
<Loader className="row-loader" type="oval" size="16px" />
) : (
renderCheckbox && (
<StyledCheckbox className="not-selectable">
<Checkbox
className="checkbox"
isChecked={checked}
isIndeterminate={indeterminate}
onChange={changeCheckbox}
/>
</StyledCheckbox>
)
)}
{renderElement && (
<StyledElement onClick={onRowClick} className="styled-element">
Expand Down Expand Up @@ -150,6 +155,7 @@ Row.propTypes = {
/** Accepts css style */
style: PropTypes.oneOfType([PropTypes.object, PropTypes.array]),
sectionWidth: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
inProgress: PropTypes.bool,
};

Row.defaultProps = {
Expand Down
4 changes: 4 additions & 0 deletions packages/asc-web-components/row/styled-row.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ const StyledRow = styled.div`
justify-content: flex-start;
align-items: center;
align-content: center;

.row-loader {
padding: 16px 12px 12px 0px;
}
`;
StyledRow.defaultProps = { theme: Base };

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,10 @@ const StyledTableRow = styled.div`
? `${props.theme.dragAndDrop.acceptBackground} !important`
: "none"};
}

.table-container_row-loader {
display: inline-flex;
}
`;

const StyledTableCell = styled.div`
Expand Down
25 changes: 19 additions & 6 deletions packages/asc-web-components/table-container/TableRow.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import TableCell from "./TableCell";
import ContextMenu from "../context-menu";
import ContextMenuButton from "../context-menu-button";
import Checkbox from "../checkbox";
import Loader from "../loader";

const TableRow = (props) => {
const {
Expand All @@ -20,6 +21,7 @@ const TableRow = (props) => {
style,
selectionProp,
hasAccess,
inProgress,
...rest
} = props;

Expand Down Expand Up @@ -60,12 +62,22 @@ const TableRow = (props) => {
style={style}
className={`${selectionProp?.className} table-container_row-checkbox-wrapper`}
>
<div className="table-container_element">{element}</div>
<Checkbox
className="table-container_row-checkbox"
onChange={onChange}
isChecked={checked}
/>
{inProgress ? (
<Loader
className="table-container_row-loader"
type="oval"
size="16px"
/>
) : (
<>
<div className="table-container_element">{element}</div>
<Checkbox
className="table-container_row-checkbox"
onChange={onChange}
isChecked={checked}
/>
</>
)}
</TableCell>
{children}
<div>
Expand Down Expand Up @@ -116,6 +128,7 @@ TableRow.propTypes = {
className: PropTypes.oneOfType([PropTypes.string, PropTypes.array]),
style: PropTypes.object,
hasAccess: PropTypes.bool,
inProgress: PropTypes.bool,
};

export default TableRow;
24 changes: 12 additions & 12 deletions products/ASC.Files/Client/src/HOCs/withFileActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,37 +54,30 @@ export default function withFileActions(WrappedFileItem) {
setStartDrag,
isPrivacy,
isTrashFolder,
onSelectItem,
item,
setBufferSelection,
isActive,
inProgress,
} = this.props;

const { id, isFolder, isThirdPartyFolder } = item;
const { isThirdPartyFolder } = item;

const notSelectable = e.target.classList.contains("not-selectable");
const isFileName = e.target.classList.contains("item-file-name");

if (
isPrivacy ||
isTrashFolder ||
(!draggable && !isFileName && !isActive)
)
return e;

if (
(!draggable && !isFileName && !isActive) ||
window.innerWidth < 1025 ||
notSelectable ||
isMobile ||
isThirdPartyFolder
isThirdPartyFolder ||
inProgress
) {
return e;
}

// if (!draggable) {
// id !== -1 && onSelectItem({ id, isFolder });
// }

const mouseButton = e.which
? e.which !== 1
: e.button
Expand Down Expand Up @@ -338,6 +331,8 @@ export default function withFileActions(WrappedFileItem) {
viewAs,
bufferSelection,
setBufferSelection,
activeFiles,
activeFolders,
} = filesStore;
const { startUpload } = uploadDataStore;
const { type, extension, id } = fileActionStore;
Expand All @@ -361,6 +356,10 @@ export default function withFileActions(WrappedFileItem) {
const canConvert = docserviceStore.canConvert(item.fileExst);
const canViewedDocs = docserviceStore.canViewedDocs(item.fileExst);

const inProgress =
activeFiles.findIndex((x) => x === item.id) !== -1 ||
activeFolders.findIndex((x) => x === item.id && item.isFolder) !== -1;

const isActive =
bufferSelection &&
bufferSelection.id === item.id &&
Expand Down Expand Up @@ -410,6 +409,7 @@ export default function withFileActions(WrappedFileItem) {
isItemsSelected: selection.length > 0,
setNewBadgeCount,
isActive,
inProgress,
setBufferSelection,
bufferSelection,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ const ConflictResolveDialog = (props) => {
conflictResolveDialogData,
items,
itemOperationToFolder,
activeFiles,
setActiveFiles,
} = props;

const {
Expand Down Expand Up @@ -54,12 +56,15 @@ const ConflictResolveDialog = (props) => {
const conflictResolveType = getResolveType();

let newFileIds = fileIds;
let newActiveFiles = activeFiles;
if (conflictResolveType === ConflictResolveType.Skip) {
for (let item of items) {
newFileIds = newFileIds.filter((x) => x.id === item.id);
newActiveFiles = newActiveFiles.filter((f) => f === item.id);
}
}

setActiveFiles(newActiveFiles);
if (!folderIds.length && !newFileIds.length) return onClose();

const data = {
Expand Down Expand Up @@ -168,7 +173,7 @@ const ConflictResolveDialog = (props) => {
);
};

export default inject(({ dialogsStore, uploadDataStore }) => {
export default inject(({ dialogsStore, uploadDataStore, filesStore }) => {
const {
conflictResolveDialogVisible: visible,
setConflictResolveDialogVisible,
Expand All @@ -177,13 +182,16 @@ export default inject(({ dialogsStore, uploadDataStore }) => {
} = dialogsStore;

const { itemOperationToFolder } = uploadDataStore;
const { activeFiles, setActiveFiles } = filesStore;

return {
items,
visible,
conflictResolveDialogData,
setConflictResolveDialogVisible,
itemOperationToFolder,
activeFiles,
setActiveFiles,
};
})(
withRouter(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,13 @@ const StyledSimpleFilesRow = styled(Row)`
!props.isThirdPartyFolder &&
(props.checked || props.isActive) &&
"url(images/cursor.palm.svg), auto"};
${(props) =>
props.inProgress &&
css`
pointer-events: none;
/* cursor: wait; */
`}

margin-top: -2px;

${(props) =>
Expand Down Expand Up @@ -119,6 +126,7 @@ const SimpleFilesRow = (props) => {
isEdit,
showShare,
isActive,
inProgress,
} = props;

const sharedButton =
Expand Down Expand Up @@ -162,6 +170,7 @@ const SimpleFilesRow = (props) => {
contextButtonSpacerWidth={displayShareButton}
dragging={dragging && isDragging}
isActive={isActive}
inProgress={inProgress}
isThirdPartyFolder={item.isThirdPartyFolder}
>
<FilesRowContent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,13 @@ const StyledTableRow = styled(TableRow)`
!props.isThirdPartyFolder &&
(props.checked || props.isActive) &&
"url(images/cursor.palm.svg), auto"};

${(props) =>
props.inProgress &&
css`
pointer-events: none;
/* cursor: wait; */
`}
}

.table-container_element {
Expand Down Expand Up @@ -177,6 +184,7 @@ const FilesTableRow = (props) => {
isActive,
onHideContextMenu,
onFilesClick,
inProgress,
} = props;

const sharedButton =
Expand Down Expand Up @@ -246,6 +254,7 @@ const FilesTableRow = (props) => {
{...contextOptionsProps}
checked={checkedProps}
isActive={isActive}
inProgress={inProgress}
onHideContextMenu={onHideContextMenu}
isThirdPartyFolder={item.isThirdPartyFolder}
onDoubleClick={onFilesClick}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ const FilesTile = (props) => {
showShare,
isActive,
isEdit,
inProgress,
} = props;

const temporaryExtension =
Expand Down Expand Up @@ -93,6 +94,7 @@ const FilesTile = (props) => {
{...contextOptionsProps}
contextButtonSpacerWidth={displayShareButton}
isActive={isActive}
inProgress={inProgress}
isEdit={isEdit}
>
<FilesTileContent
Expand Down
Loading