Merge branch 'release/1.0.0' into bugfix/fixed-styles-selcted-row

This commit is contained in:
Artem Tarasov 2021-09-30 16:27:51 +03:00
commit fe3459a0ba
14 changed files with 223 additions and 186 deletions

View File

@ -14,6 +14,7 @@ import TableGroupMenu from "./TableGroupMenu";
const minColumnSize = 150;
const settingsSize = 24;
const containerMargin = 25;
class TableHeader extends React.Component {
constructor(props) {
@ -131,6 +132,8 @@ class TableHeader extends React.Component {
.filter((x) => x.key !== this.props.columns[columnIndex - 1].key)
.filter((x) => !x.defaultSize);
const defaultSize = this.props.columns[columnIndex - 1]?.defaultSize;
let index = this.props.columns.length;
while (index !== 0) {
index--;
@ -140,7 +143,9 @@ class TableHeader extends React.Component {
if (isFind) {
const someItemById = document.getElementById("column_" + (index + 1));
const columnSize = someItemById.clientWidth - minColumnSize;
const columnSize =
someItemById.clientWidth -
(defaultSize ? defaultSize : minColumnSize);
if (columnSize >= minColumnSize) {
return (gridTemplateColumns[index + 1] = columnSize + "px");
@ -211,7 +216,6 @@ class TableHeader extends React.Component {
: document.getElementById("table-container");
const minSize = size.tablet;
const containerMargin = 25;
if (
!container ||
@ -227,8 +231,7 @@ class TableHeader extends React.Component {
: container.style.gridTemplateColumns.split(" ");
const containerWidth = +container.clientWidth;
const newContainerWidth =
containerWidth - this.getSubstring(checkboxSize) - 80 - settingsSize; // TODO: 80
const newContainerWidth = containerWidth - this.getSubstring(checkboxSize);
const oldWidth = tableContainer
.map((column) => this.getSubstring(column))
@ -242,7 +245,6 @@ class TableHeader extends React.Component {
const isSingleTable = enableColumns.length > 0;
let str = "";
let disableColumnWidth = 0;
if (tableContainer.length > 1) {
const gridTemplateColumns = [];
@ -255,6 +257,7 @@ class TableHeader extends React.Component {
index == 0 ||
index == tableContainer.length - 1 ||
(column ? column.dataset.enable === "true" : item !== "0px");
const defaultSize = column && column.dataset.defaultSize;
const isActiveNow = item === "0px" && enable;
if (isActiveNow && column) activeColumnIndex = index;
@ -265,21 +268,18 @@ class TableHeader extends React.Component {
this.getSubstring(gridTemplateColumns[1]) +
this.getSubstring(item) +
"px";
} else if (
item !== `${settingsSize}px` &&
item !== checkboxSize &&
item !== "80px"
) {
} else if (item !== `${settingsSize}px` && item !== checkboxSize) {
const percent = (this.getSubstring(item) / oldWidth) * 100;
if (index == 1) {
const newItemWidth =
(containerWidth * percent) / 100 + disableColumnWidth + "px";
const newItemWidth = (containerWidth * percent) / 100 + "px";
gridTemplateColumns.push(newItemWidth);
} else {
const newItemWidth =
percent === 0
? `${minColumnSize}px`
? defaultSize
? `${defaultSize}px`
: `${minColumnSize}px`
: (containerWidth * percent) / 100 + "px";
gridTemplateColumns.push(newItemWidth);
@ -295,8 +295,14 @@ class TableHeader extends React.Component {
str = gridTemplateColumns.join(" ");
} else {
const defaultSize = this.props.columns.find((col) => col.defaultSize)
?.defaultSize;
const column =
(newContainerWidth * (isSingleTable ? 60 : 100)) / 100 + "px";
(newContainerWidth * (isSingleTable ? 60 : 100)) / 100 -
(defaultSize || 0) -
containerMargin +
"px";
const percent = 40 / enableColumns.length;
const otherColumns = (newContainerWidth * percent) / 100 + "px";
@ -387,6 +393,7 @@ class TableHeader extends React.Component {
sorted={sorted}
sortBy={sortBy}
resizable={resizable}
defaultSize={column.defaultSize}
onMouseDown={this.onMouseDown}
/>
);

View File

@ -12,6 +12,7 @@ const TableHeaderCell = ({
resizable,
sortBy,
sorted,
defaultSize,
}) => {
const { title, enable, active, minWidth } = column;
@ -35,6 +36,7 @@ const TableHeaderCell = ({
id={`column_${index + 1}`}
data-enable={enable}
data-min-width={minWidth}
data-default-size={defaultSize}
onClick={onClick}
>
<div className="table-container_header-item">
@ -73,6 +75,7 @@ TableHeaderCell.propTypes = {
resizable: PropTypes.bool,
sorted: PropTypes.bool,
sortBy: PropTypes.string,
defaultSize: PropTypes.number,
};
export default TableHeaderCell;

View File

@ -233,8 +233,17 @@ export default function withContent(WrappedContent) {
onFilesClick,
viewAs,
element,
isDesktop,
} = this.props;
const { id, fileExst, updated, createdBy, access, fileStatus } = item;
const {
id,
fileExst,
updated,
createdBy,
access,
fileStatus,
href,
} = item;
const titleWithoutExt = getTitleWithoutExst(item);
@ -259,6 +268,10 @@ export default function withContent(WrappedContent) {
? { noHover: true }
: { onClick: onFilesClick };
if (!isDesktop && !isTrashFolder) {
linkStyles.href = item.href;
}
const newItems = item.new || fileStatus === 2;
const showNew = !!newItems;

View File

@ -122,10 +122,10 @@ class TreeFolders extends React.Component {
iconUrl = "/static/images/cloud.services.onedrive.react.svg";
break;
case "kDrive":
iconUrl = "/static/images/catalog.folder.react.svg";
iconUrl = "/static/images/cloud.services.kdrive.react.svg";
break;
case "Yandex":
iconUrl = "/static/images/catalog.folder.react.svg";
iconUrl = "/static/images/cloud.services.yandex.react.svg";
break;
case "NextCloud":
iconUrl = "/static/images/cloud.services.nextcloud.react.svg";
@ -134,7 +134,7 @@ class TreeFolders extends React.Component {
iconUrl = "/static/images/catalog.folder.react.svg";
break;
case "WebDav":
iconUrl = "/static/images/catalog.folder.react.svg";
iconUrl = "/static/images/cloud.services.webdav.react.svg";
break;
default:
break;

View File

@ -59,7 +59,6 @@ const FilesRowContent = ({
updatedDate,
fileOwner,
linkStyles,
//onFilesClick,
badgesComponent,
isAdmin,
}) => {
@ -90,7 +89,6 @@ const FilesRowContent = ({
fontWeight="600"
fontSize="15px"
target="_blank"
href={item.href}
{...linkStyles}
color="#333"
isTextOverflow={true}

View File

@ -10,7 +10,6 @@ const FileNameCell = ({ item, titleWithoutExt, linkStyles }) => {
title={titleWithoutExt}
fontWeight="600"
fontSize="13px"
href={item.href}
{...linkStyles}
color="#333"
isTextOverflow

View File

@ -77,7 +77,6 @@ const FilesTileContent = ({
item,
titleWithoutExt,
linkStyles,
onFilesClick,
badgesComponent,
}) => {
const { fileExst } = item;
@ -97,7 +96,6 @@ const FilesTileContent = ({
fontWeight="600"
fontSize="14px"
target="_blank"
href={item.href}
{...linkStyles}
color="#333"
isTextOverflow

View File

@ -339,7 +339,7 @@ class FilesStore {
if (!requestCounter) return;
requestCounter--;
if (folderId === "@my" && !this.isInit) {
if (folderId === "@my" /* && !this.isInit */) {
setTimeout(() => {
return request();
}, 5000);

View File

@ -1,15 +1,9 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Collections.Generic;
using System.Text.Json;
using System.Threading.Tasks;
using ASC.Api.Collections;
using ASC.Web.Files.Services.WCFService.FileOperations;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc.ModelBinding;
namespace ASC.Files.Model
{
public class BaseBatchModel
@ -38,88 +32,6 @@ namespace ASC.Files.Model
public bool Immediately { get; set; }
}
public class DeleteBatchModelBinder : BaseBatchModelBinder
{
public override Task BindModelAsync(ModelBindingContext bindingContext)
{
base.BindModelAsync(bindingContext);
if (bindingContext == null)
{
throw new ArgumentNullException(nameof(bindingContext));
}
var baseResult = bindingContext.Result.Model as BaseBatchModel;
var result = new DeleteBatchModel();
result.FileIds = baseResult.FileIds;
result.FolderIds = baseResult.FolderIds;
var modelName = nameof(result.DeleteAfter);
var valueProviderResult = bindingContext.ValueProvider.GetValue(modelName);
if (valueProviderResult != ValueProviderResult.None)
{
bindingContext.ModelState.SetModelValue(modelName, valueProviderResult);
if (bool.TryParse(valueProviderResult.FirstValue, out var deleteAfter))
{
result.DeleteAfter = deleteAfter;
}
}
modelName = nameof(result.Immediately);
valueProviderResult = bindingContext.ValueProvider.GetValue(modelName);
if (valueProviderResult != ValueProviderResult.None)
{
bindingContext.ModelState.SetModelValue(modelName, valueProviderResult);
if (bool.TryParse(valueProviderResult.FirstValue, out var immediately))
{
result.Immediately = immediately;
}
}
bindingContext.Result = ModelBindingResult.Success(result);
return Task.CompletedTask;
}
}
public class BaseBatchModelBinder : IModelBinder
{
public virtual Task BindModelAsync(ModelBindingContext bindingContext)
{
if (bindingContext == null)
{
throw new ArgumentNullException(nameof(bindingContext));
}
var result = new BaseBatchModel();
result.FileIds = ParseQuery(bindingContext, nameof(result.FileIds));
result.FolderIds = ParseQuery(bindingContext, nameof(result.FolderIds));
bindingContext.Result = ModelBindingResult.Success(result);
return Task.CompletedTask;
}
internal List<JsonElement> ParseQuery(ModelBindingContext bindingContext, string modelName)
{
var valueProviderResult = bindingContext.ValueProvider.GetValue(modelName);
if (valueProviderResult != ValueProviderResult.None)
{
bindingContext.ModelState.SetModelValue(modelName, valueProviderResult);
return valueProviderResult.Select(BatchModel.ParseQueryParam).ToList();
}
return new List<JsonElement>();
}
}
public class DeleteModel
{
public bool DeleteAfter { get; set; }
@ -131,73 +43,5 @@ namespace ASC.Files.Model
public JsonElement DestFolderId { get; set; }
public FileConflictResolveType ConflictResolveType { get; set; }
public bool DeleteAfter { get; set; }
public static BatchModel FromQuery(HttpContext httpContext)
{
var result = new BatchModel();
var query = httpContext.Request.Query;
var destId = query["DestFolderId"];
if (destId.Any())
{
result.DestFolderId = ParseQueryParam(destId.First());
}
var conflictResolveType = query["ConflictResolveType"];
if (conflictResolveType.Any())
{
if (Enum.TryParse<FileConflictResolveType>(conflictResolveType.First(), out var crf))
{
result.ConflictResolveType = crf;
}
}
var deleteAfter = query["DeleteAfter"];
if (deleteAfter.Any())
{
if (bool.TryParse(deleteAfter.First(), out var d))
{
result.DeleteAfter = d;
}
}
var fileIdsQuery = query["FileIds"];
if (fileIdsQuery.Any())
{
var fileIds = new List<JsonElement>();
foreach (var f in fileIdsQuery)
{
fileIds.Add(ParseQueryParam(f));
}
result.FileIds = fileIds;
}
var folderIdsQuery = query["FolderIds"];
if (folderIdsQuery.Any())
{
var folderIds = new List<JsonElement>();
foreach (var f in folderIdsQuery)
{
folderIds.Add(ParseQueryParam(f));
}
result.FolderIds = folderIds;
}
return result;
}
public static JsonElement ParseQueryParam(string data)
{
if (int.TryParse(data, out _))
{
return JsonSerializer.Deserialize<JsonElement>(data);
}
return JsonSerializer.Deserialize<JsonElement>($"\"{data}\"");
}
}
}

View File

@ -0,0 +1,159 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.Json;
using System.Threading.Tasks;
using ASC.Web.Files.Services.WCFService.FileOperations;
using Microsoft.AspNetCore.Mvc.ModelBinding;
namespace ASC.Files.Model
{
public class BaseBatchModelBinder : IModelBinder
{
public virtual Task BindModelAsync(ModelBindingContext bindingContext)
{
if (bindingContext == null)
{
throw new ArgumentNullException(nameof(bindingContext));
}
var result = new BaseBatchModel();
result.FileIds = ParseQuery(bindingContext, nameof(result.FileIds));
result.FolderIds = ParseQuery(bindingContext, nameof(result.FolderIds));
bindingContext.Result = ModelBindingResult.Success(result);
return Task.CompletedTask;
}
internal List<JsonElement> ParseQuery(ModelBindingContext bindingContext, string modelName)
{
var valueProviderResult = bindingContext.ValueProvider.GetValue(modelName);
if (valueProviderResult != ValueProviderResult.None)
{
bindingContext.ModelState.SetModelValue(modelName, valueProviderResult);
return valueProviderResult.Select(ParseQueryParam).ToList();
}
return new List<JsonElement>();
}
public static JsonElement ParseQueryParam(string data)
{
if (int.TryParse(data, out _))
{
return JsonSerializer.Deserialize<JsonElement>(data);
}
return JsonSerializer.Deserialize<JsonElement>($"\"{data}\"");
}
}
public class DeleteBatchModelBinder : BaseBatchModelBinder
{
public override Task BindModelAsync(ModelBindingContext bindingContext)
{
base.BindModelAsync(bindingContext);
if (bindingContext == null)
{
throw new ArgumentNullException(nameof(bindingContext));
}
var baseResult = bindingContext.Result.Model as BaseBatchModel;
var result = new DeleteBatchModel();
result.FileIds = baseResult.FileIds;
result.FolderIds = baseResult.FolderIds;
var modelName = nameof(result.DeleteAfter);
var valueProviderResult = bindingContext.ValueProvider.GetValue(modelName);
if (valueProviderResult != ValueProviderResult.None)
{
bindingContext.ModelState.SetModelValue(modelName, valueProviderResult);
if (bool.TryParse(valueProviderResult.FirstValue, out var deleteAfter))
{
result.DeleteAfter = deleteAfter;
}
}
modelName = nameof(result.Immediately);
valueProviderResult = bindingContext.ValueProvider.GetValue(modelName);
if (valueProviderResult != ValueProviderResult.None)
{
bindingContext.ModelState.SetModelValue(modelName, valueProviderResult);
if (bool.TryParse(valueProviderResult.FirstValue, out var immediately))
{
result.Immediately = immediately;
}
}
bindingContext.Result = ModelBindingResult.Success(result);
return Task.CompletedTask;
}
}
public class BatchModelBinder : BaseBatchModelBinder
{
public override Task BindModelAsync(ModelBindingContext bindingContext)
{
base.BindModelAsync(bindingContext);
if (bindingContext == null)
{
throw new ArgumentNullException(nameof(bindingContext));
}
var baseResult = bindingContext.Result.Model as BaseBatchModel;
var result = new BatchModel();
result.FileIds = baseResult.FileIds;
result.FolderIds = baseResult.FolderIds;
var modelName = nameof(result.DeleteAfter);
var valueProviderResult = bindingContext.ValueProvider.GetValue(modelName);
if (valueProviderResult != ValueProviderResult.None)
{
bindingContext.ModelState.SetModelValue(modelName, valueProviderResult);
if (bool.TryParse(valueProviderResult.FirstValue, out var deleteAfter))
{
result.DeleteAfter = deleteAfter;
}
}
modelName = nameof(result.ConflictResolveType);
valueProviderResult = bindingContext.ValueProvider.GetValue(modelName);
if (valueProviderResult != ValueProviderResult.None)
{
bindingContext.ModelState.SetModelValue(modelName, valueProviderResult);
if (Enum.TryParse<FileConflictResolveType>(valueProviderResult.FirstValue, out var conflictResolveType))
{
result.ConflictResolveType = conflictResolveType;
}
}
modelName = nameof(result.DestFolderId);
valueProviderResult = bindingContext.ValueProvider.GetValue(modelName);
if (valueProviderResult != ValueProviderResult.None)
{
bindingContext.ModelState.SetModelValue(modelName, valueProviderResult);
result.DestFolderId = BaseBatchModelBinder.ParseQueryParam(valueProviderResult.FirstValue);
}
bindingContext.Result = ModelBindingResult.Success(result);
return Task.CompletedTask;
}
}
}

View File

@ -1237,9 +1237,9 @@ namespace ASC.Api.Documents
/// <param name="fileIds">File ID list</param>
/// <returns>Conflicts file ids</returns>
[Read("fileops/move")]
public IEnumerable<FileEntryWrapper> MoveOrCopyBatchCheck()
public IEnumerable<FileEntryWrapper> MoveOrCopyBatchCheck([ModelBinder(BinderType = typeof(BatchModelBinder))] BatchModel batchModel)
{
return FilesControllerHelperString.MoveOrCopyBatchCheck(BatchModel.FromQuery(HttpContext));
return FilesControllerHelperString.MoveOrCopyBatchCheck(batchModel);
}
/// <summary>
@ -1261,7 +1261,7 @@ namespace ASC.Api.Documents
[Update("fileops/move")]
[Consumes("application/x-www-form-urlencoded")]
public IEnumerable<FileOperationWraper> MoveBatchItemsFromForm([FromForm] BatchModel batchModel)
public IEnumerable<FileOperationWraper> MoveBatchItemsFromForm([FromForm][ModelBinder(BinderType = typeof(BatchModelBinder))] BatchModel batchModel)
{
return FilesControllerHelperString.MoveBatchItems(batchModel);
}
@ -1285,7 +1285,7 @@ namespace ASC.Api.Documents
[Update("fileops/copy")]
[Consumes("application/x-www-form-urlencoded")]
public IEnumerable<FileOperationWraper> CopyBatchItemsFromForm([FromForm] BatchModel batchModel)
public IEnumerable<FileOperationWraper> CopyBatchItemsFromForm([FromForm][ModelBinder(BinderType = typeof(BatchModelBinder))] BatchModel batchModel)
{
return FilesControllerHelperString.CopyBatchItems(batchModel);
}

View File

@ -0,0 +1,10 @@
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<g clip-path="url(#clip0)">
<path fill-rule="evenodd" clip-rule="evenodd" d="M6.89898 0.0620605L8.24997 0.640145C8.45675 0.728622 8.61661 0.903485 8.68915 1.12053L9.2263 2.72763C9.31277 2.98634 9.52206 3.18214 9.78155 3.2471L15.4025 4.65427C15.7533 4.74207 16 5.0638 16 5.43337V12.1466C16 12.5895 15.6492 12.9486 15.2164 12.9486C15.1383 12.9486 15.0606 12.9367 14.9859 12.9132L14.5 12.7601V6.61704C14.5 6.246 14.0934 5.92299 13.7491 5.83484L8.23121 4.4221C7.97648 4.35688 7.77103 4.1603 7.68615 3.90056L7.15885 2.28708C7.08764 2.06918 6.93071 1.89362 6.72773 1.80479L5.81314 1.40455V0.802064C5.81314 0.359096 6.16397 0 6.59674 0C6.70051 0 6.80324 0.0210949 6.89898 0.0620605ZM6.29099 2.24366L4.94 1.66558C4.84426 1.62461 4.74153 1.60352 4.63776 1.60352C4.20499 1.60352 3.85416 1.96261 3.85416 2.40558V2.8241L4.74998 3.20742C4.95676 3.29589 5.11662 3.47076 5.18916 3.6878L5.72631 5.2949C5.81278 5.55361 6.02207 5.74942 6.28156 5.81438L11.9026 7.22154C12.2533 7.30934 12.5 7.63107 12.5 8.00064V14.3507L13.027 14.5167C13.1016 14.5402 13.1793 14.5521 13.2574 14.5521C13.6902 14.5521 14.041 14.193 14.041 13.7501V7.03688C14.041 6.66731 13.7943 6.34558 13.4436 6.25778L7.82257 4.85062C7.56307 4.78566 7.35379 4.58986 7.26732 4.33114L6.73017 2.72404C6.65763 2.507 6.49776 2.33214 6.29099 2.24366ZM4.33191 3.60694L2.98092 3.02886C2.88518 2.98789 2.78245 2.9668 2.67868 2.9668C2.24591 2.9668 1.89508 3.32589 1.89508 3.76886V6.31855C1.9204 6.32305 1.94557 6.32885 1.9705 6.33594L10 8.5C10.2628 8.57473 10.4688 8.78399 10.5437 9.05246L12.0819 14.869V8.40017C12.0819 8.0306 11.8352 7.70887 11.4845 7.62107L5.86349 6.2139C5.604 6.14894 5.39471 5.95314 5.30824 5.69442L4.77109 4.08733C4.69855 3.87028 4.53868 3.69542 4.33191 3.60694ZM9.69983 9.06129L0.993544 6.5859C0.838761 6.54189 0.674504 6.54764 0.523018 6.60237C0.114918 6.74979 -0.0991488 7.20793 0.0448865 7.62565L1.76376 12.6105C1.84637 12.8501 2.035 13.0355 2.27224 13.1102L11.3915 15.9822C11.4641 16.005 11.5415 16.0058 11.6144 15.9845C11.8225 15.9237 11.9429 15.7017 11.8835 15.4887L10.2436 9.61375C10.1686 9.34528 9.96267 9.13602 9.69983 9.06129Z" fill="#657077"/>
</g>
<defs>
<clipPath id="clip0">
<rect width="16" height="16" fill="white"/>
</clipPath>
</defs>
</svg>

After

Width:  |  Height:  |  Size: 2.3 KiB

View File

@ -0,0 +1,3 @@
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M12.9 6.775C12.4467 4.61875 10.4267 3 8 3C6.07333 3 4.4 4.025 3.56667 5.525C1.56 5.725 0 7.31875 0 9.25C0 11.3188 1.79333 13 4 13H12.6667C14.5067 13 16 11.6 16 9.875C16 8.225 14.6333 6.8875 12.9 6.775Z" fill="#657077"/>
</svg>

After

Width:  |  Height:  |  Size: 332 B

View File

@ -0,0 +1,3 @@
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M3.7649 7.31245C4.61331 6.76813 5.57236 6.23859 6.60119 5.74937C10.9771 3.92142 14.8286 3.36083 15.8829 4.77407C16.542 6.17478 14.3984 9.29288 9.95598 11.4862C6.14703 13.2363 1.5049 13.5315 0.284105 12.043C0.201753 11.9044 0.149389 11.7576 0.125178 11.6039C0.0757866 11.4569 0.0305027 11.2968 0.0119316 11.1606C-0.136458 10.0721 1.14826 8.53906 1.14826 8.53906L2.18773 7.38027C2.29614 7.14053 2.38993 6.91549 2.47886 6.70208C2.97027 5.52293 3.31369 4.69888 5.15941 3.71251C7.04786 2.70333 8.92277 2.89363 10.6402 3.4969C10.6402 3.4969 12.4287 3.47684 13.4864 3.61398C13.5849 3.62674 13.6777 3.63761 13.7661 3.64797C14.301 3.7665 14.7748 3.87692 15.2984 4.20036C15.5395 4.34926 15.6899 4.52786 15.8151 4.68539C14.6683 3.38335 10.8874 3.95831 6.6039 5.74763C5.57397 6.23737 4.61398 6.76752 3.7649 7.31245ZM12.3439 7.78779C12.7039 8.45547 11.4289 9.61949 9.31088 10.6598C7.49849 11.4966 5.47858 11.8996 4.92194 11.2135C4.52652 10.5611 5.90777 9.27563 7.91823 8.31963C9.99528 7.43551 11.8596 7.14507 12.3439 7.78779Z" fill="#657077"/>
</svg>

After

Width:  |  Height:  |  Size: 1.2 KiB