Merge branch 'develop' into feature/people-filter-empty-screen

This commit is contained in:
Alexey Safronov 2020-10-19 20:53:59 +03:00 committed by GitHub
commit 05a6034b05
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 258 additions and 25 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

View File

@ -97,7 +97,10 @@ class TreeFolders extends React.Component {
<Icons.CatalogPortfolioIcon size="scale" isfill color="#657077" />
);
case "0-3":
return <Icons.CatalogTrashIcon size="scale" isfill color="#657077" />;
return <Icons.CatalogFavoritesIcon size="scale" isfill color="#657077" />
case "0-4":
return <Icons.CatalogTrashIcon size="scale" isfill color="#657077" />;;
default:
return <Icons.CatalogFolderIcon size="scale" isfill color="#657077" />;
}

View File

@ -51,6 +51,11 @@ class ArticleBodyContent extends React.Component {
}
}
componentDidMount() {
const currentId = [this.props.currentId + ""];
this.props.setSelectedNode(currentId);
}
onSelect = (data, e) => {
const {
filter,

View File

@ -70,10 +70,14 @@ const SimpleFilesRowContent = styled(RowContent)`
align-items: center;
}
.share-icon {
margin-top: -4px;
padding-right: 8px;
}
.favorite {
cursor: pointer;
}
.share-icon {
margin-top: -4px;
padding-right: 8px;
}
.row_update-text {
overflow: hidden;
@ -512,6 +516,16 @@ class FilesRowContent extends React.PureComponent {
color="#A3A9AE"
/>
)}
{(fileStatus === 32 && !isTrashFolder) &&
<Icons.FavoriteIcon
className='favorite'
size='small'
data-action='remove'
data-id={item.id}
data-title={item.title}
onClick={this.props.onClickFavorite}
/>
}
{fileStatus === 1 && (
<Icons.FileActionsConvertEditDocIcon
className="badge"

View File

@ -32,7 +32,11 @@ import {
} from "asc-web-common";
import {
clearProgressData,
markItemAsFavorite,
removeItemFromFavorite,
fetchFavoritesFolder,
deselectFile,
updateFile,
fetchFiles,
selectFile,
setAction,
@ -45,7 +49,7 @@ import {
setSelected,
setSelection,
setTreeFolders,
loopFilesOperations,
getFileInfo
} from "../../../../../store/files/actions";
import {
getCurrentFolderCount,
@ -77,6 +81,7 @@ import {
getIsCommonFolder,
getIsRecycleBinFolder,
getIsMyFolder,
getIsFavoritesFolder,
getMyFolderId,
getTooltipLabel,
} from "../../../../../store/files/selectors";
@ -171,16 +176,16 @@ class SectionBodyContent extends React.Component {
document.removeEventListener("dragleave", this.onDragLeaveDoc);
}
/* componentDidUpdate(prevProps, prevState) {
Object.entries(this.props).forEach(([key, val]) =>
prevProps[key] !== val && console.log(`Prop '${key}' changed`)
);
if (this.state) {
Object.entries(this.state).forEach(([key, val]) =>
prevState[key] !== val && console.log(`State '${key}' changed`)
);
}
} */
// componentDidUpdate(prevProps, prevState) {
// Object.entries(this.props).forEach(([key, val]) =>
// prevProps[key] !== val && console.log(`Prop '${key}' changed`)
// );
// if (this.state) {
// Object.entries(this.state).forEach(([key, val]) =>
// prevState[key] !== val && console.log(`State '${key}' changed`)
// );
// }
// }
shouldComponentUpdate(nextProps, nextState) {
if (this.props && this.props.firstLoad) return true;
@ -212,6 +217,35 @@ class SectionBodyContent extends React.Component {
return false;
}
onClickFavorite = e => {
const { markItemAsFavorite,
removeItemFromFavorite,
getFileInfo,
fetchFavoritesFolder,
isFavorites,
selectedFolderId,
//selection,
t } = this.props;
const { action, id } = e.currentTarget.dataset;
//let data = selection.map(item => item.id)
switch (action) {
case "mark":
return markItemAsFavorite([id])
.then(() => getFileInfo(id))
.then(() => toastr.success(t("MarkedAsFavorite")))
.catch(e => toastr.error(e));
case "remove":
return removeItemFromFavorite([id])
.then(() => {
return isFavorites ? fetchFavoritesFolder(selectedFolderId) : getFileInfo(id)
})
.then(() => toastr.success(t("RemovedFromFavorites")))
.catch(e => toastr.error(e));
default:
return;
}
}
onClickRename = () => {
const { id, fileExst } = this.props.selection[0];
@ -498,6 +532,17 @@ class SectionBodyContent extends React.Component {
case "separator1":
case "separator2":
return { key: option, isSeparator: true };
case "mark-as-favorite":
return {
key: option,
label: t("MarkAsFavorite"),
icon: "FavoritesIcon",
onClick: this.onClickFavorite,
disabled: false,
"data-action": "mark",
"data-id": item.id,
"data-title": item.title
};
case "block-unblock-version":
return {
key: option,
@ -603,6 +648,17 @@ class SectionBodyContent extends React.Component {
onClick: this.onClickDelete,
disabled: false,
};
case "remove-from-favorites":
return {
key: option,
label: t("RemoveFromFavorites"),
icon: "FavoritesIcon",
onClick: this.onClickFavorite,
disabled: false,
"data-action": "remove",
"data-id": item.id,
"data-title": item.title
};
default:
break;
}
@ -690,12 +746,13 @@ class SectionBodyContent extends React.Component {
};
renderEmptyRootFolderContainer = () => {
const { isMy, isShare, isCommon, isRecycleBin, title, t } = this.props;
const { isMy, isShare, isCommon, isRecycleBin, isFavorites, title, t } = this.props;
const subheadingText = t("SubheadingEmptyText");
const myDescription = t("MyEmptyContainerDescription");
const shareDescription = t("SharedEmptyContainerDescription");
const commonDescription = t("CommonEmptyContainerDescription");
const trashDescription = t("TrashEmptyContainerDescription");
const favoritesDescription = t("FavoritesEmptyContainerDescription");
const commonButtons = (
<>
@ -788,6 +845,15 @@ class SectionBodyContent extends React.Component {
buttons={trashButtons}
/>
);
} else if (isFavorites) {
return (
<EmptyFolderContainer
headerText={title}
subheadingText={subheadingText}
descriptionText={favoritesDescription}
imageSrc="images/empty_screen_favorites.png"
/>
);
} else {
return;
}
@ -1475,6 +1541,7 @@ class SectionBodyContent extends React.Component {
culture={settings.culture}
onEditComplete={this.onEditComplete}
onMediaFileClick={this.onMediaFileClick}
onClickFavorite={this.onClickFavorite}
/>
</SimpleFilesRow>
</DragAndDrop>
@ -1532,6 +1599,7 @@ const mapStateToProps = (state) => {
folders: getFolders(state),
isAdmin: isAdmin(state),
isCommon: getIsCommonFolder(state),
isFavorites: getIsFavoritesFolder(state),
isLoading: getIsLoading(state),
isMy: getIsMyFolder(state),
isRecycleBin: getIsRecycleBinFolder(state),
@ -1555,6 +1623,7 @@ const mapStateToProps = (state) => {
export default connect(mapStateToProps, {
deselectFile,
updateFile,
fetchFiles,
selectFile,
setAction,
@ -1568,5 +1637,8 @@ export default connect(mapStateToProps, {
setUpdateTree,
setIsLoading,
clearProgressData,
loopFilesOperations,
markItemAsFavorite,
removeItemFromFavorite,
fetchFavoritesFolder,
getFileInfo
})(withRouter(withTranslation()(SectionBodyContent)));

View File

@ -8,6 +8,10 @@
"SendByEmail": "Send by e-mail",
"LinkForPortalUsers": "Link for portal users",
"LinkCopySuccess": "Link has been copied to the clipboard",
"MarkAsFavorite": "Mark as favorite",
"MarkedAsFavorite": "Added to favorites",
"RemoveFromFavorites": "Remove from favorites",
"RemovedFromFavorites": "Removed from favorites",
"Edit": "Edit",
"Preview": "Preview",
"View": "View",
@ -68,6 +72,7 @@
"SharedEmptyContainerDescription": "The 'Shared with Me' section is used to show the files which your friends or colleagues gave you access to. In case you haven't seen the latest changes in the documents they are marked 'new'. You can remove the files from the list clicking the appropriate button.",
"CommonEmptyContainerDescription": "The 'Common Documents' section shows all the documents shared by portal administrator for common access. Only portal administrator can create folders in this section, but with the access granted the portal users can also upload their files here. Drag-and-drop the files from your computer here to upload them to your portal even more easily.",
"TrashEmptyContainerDescription": "The 'Recycle Bin' section is where all the deleted files are moved. You can either restore them in case they are deleted by mistake or delete them permanently. Please note, that when you delete the files from the 'Recycle Bin' they cannot be restored any longer.",
"FavoritesEmptyContainerDescription": "To mark files as favorites or remove them from this list, use the context menu.",
"GoToMyButton": "Go to My Documents",
"BackToParentFolderButton": "Back to parent folder",
"EmptyFolderHeader": "No files in this folder",

View File

@ -8,6 +8,10 @@
"SendByEmail": "Отправить по почте",
"LinkForPortalUsers": "Ссылка для пользователей портала",
"LinkCopySuccess": "Ссылка скопирована в буфер обмена",
"MarkAsFavorite": "Добавить в избранное",
"MarkedAsFavorite": "Добавлено в избранное",
"RemoveFromFavorites": "Удалить из избранного",
"RemovedFromFavorites": "Удалено из избранного",
"Edit": "Редактировать",
"Preview": "Просмотр",
"View": "Просмотр",
@ -68,6 +72,7 @@
"SharedEmptyContainerDescription": "Раздел «Доступно для меня» используется для отображения файлов, к которым ваши друзья или коллеги предоставили вам доступ. Если вы не видели последние изменения в документах, они помечаются как «новые». Вы можете удалить файлы из списка, нажав соответствующую кнопку.",
"CommonEmptyContainerDescription": "В разделе «Общие документы» отображаются все документы, которыми администратор портала предоставил общий доступ. Только администраторы портала могут создавать папки в этом разделе, но с предоставленным доступом пользователи портала также могут загружать свои файлы здесь. Перетащите файлы со своего компьютера сюда, чтобы загрузить их на свой портал еще проще.",
"TrashEmptyContainerDescription": "В разделе «Корзина» находятся все удаленные файлы. Вы можете восстановить их, если они были удалены по ошибке, или удалить их навсегда. Обратите внимание, что когда вы удаляете файлы из корзины, они больше не могут быть восстановлены.",
"FavoritesEmptyContainerDescription": "Чтобы добавить файлы в избранное или удалить их из этого списка, используйте контекстное меню.",
"GoToMyButton": "Перейти к моим документам",
"BackToParentFolderButton": "Вернуться в папку на уровень выше",
"EmptyFolderHeader": "В этой папке нет файлов",

View File

@ -369,6 +369,42 @@ export function fetchCommonFolder(dispatch) {
});
}
export function fetchFavoritesFolder(folderId) {
return dispatch => {
return files.getFolder(folderId).then((data) => {
dispatch(setFolders(data.folders));
dispatch(setFiles(data.files));
return dispatch(
setSelectedFolder({
folders: data.folders,
...data.current,
pathParts: data.pathParts,
})
);
});
}
}
export function markItemAsFavorite(id) {
return dispatch => {
return files.markAsFavorite(id);
}
}
export function removeItemFromFavorite(id) {
return dispatch => {
return files.removeFromFavorite(id);
}
}
export function getFileInfo(id) {
return dispatch => {
return files.getFileInfo(id).then(data => {
dispatch(setFile(data));
});
}
}
export function fetchProjectsFolder(dispatch) {
return files.getProjectsFolderList().then((data) => {
dispatch(setFolders(data.folders));

View File

@ -595,6 +595,7 @@ const getFilesContextOptions = (item, isRecycleBin, canOpenPlayer) => {
const options = [];
const isFile = !!item.fileExst;
const isFavorite = item.fileStatus === 32;
if (item.id <= 0) return [];
@ -619,6 +620,9 @@ const getFilesContextOptions = (item, isRecycleBin, canOpenPlayer) => {
options.push("finalize-version");
options.push("block-unblock-version");
options.push("separator1");
if (!isFavorite) {
options.push("mark-as-favorite");
}
if (canOpenPlayer) {
options.push("view");
@ -640,6 +644,10 @@ const getFilesContextOptions = (item, isRecycleBin, canOpenPlayer) => {
options.push("rename");
options.push("delete");
}
if (isFavorite && !isRecycleBin) {
options.push("remove-from-favorites");
}
return options;
};
@ -674,6 +682,10 @@ const getRecycleBinFolder = createSelector(getTreeFolders, (treeFolders) => {
return treeFolders.find((x) => x.rootFolderName === "@trash");
});
const getFavoritesFolder = createSelector(getTreeFolders, (treeFolders) => {
return treeFolders.find((x) => x.rootFolderName === "@favorites");
});
export const getMyFolderId = createSelector(getMyFolder, (myFolder) => {
if (myFolder) return myFolder.id;
});
@ -699,6 +711,13 @@ export const getRecycleBinFolderId = createSelector(
}
);
export const getFavoritesFolderId = createSelector(
getFavoritesFolder,
(favoritesFolder) => {
if (favoritesFolder) return favoritesFolder.id;
}
);
export const getIsMyFolder = createSelector(
getMyFolder,
getSelectedFolderId,
@ -731,6 +750,14 @@ export const getIsRecycleBinFolder = createSelector(
}
);
export const getIsFavoritesFolder = createSelector(
getFavoritesFolder,
getSelectedFolderId,
(favoritesFolder, id) => {
return favoritesFolder && favoritesFolder.id === id;
}
);
export const getFileActionId = (state) => {
return state.files.fileAction.id;
};

View File

@ -4,6 +4,7 @@ import { utils, TreeMenu, TreeNode, Icons, Link } from "asc-web-components";
import {
selectGroup,
setIsVisibleDataLossDialog,
setIsLoading,
} from "../../../store/people/actions";
import { getSelectedGroup } from "../../../store/people/selectors";
import { withTranslation, I18nextProvider } from "react-i18next";
@ -113,13 +114,14 @@ class ArticleBodyContent extends React.Component {
}
};
onSelect = (data) => {
const { setIsLoading } = this.props
return () => {
const { selectGroup } = this.props;
setIsLoading(true);
this.changeTitleDocument(data);
selectGroup(
data && data.length === 1 && data[0] !== "root" ? data[0] : null
);
).finally(() => setIsLoading(false))
};
};
switcherIcon = (obj) => {
@ -249,4 +251,5 @@ function mapStateToProps(state) {
export default connect(mapStateToProps, {
selectGroup,
setIsVisibleDataLossDialog,
setIsLoading,
})(BodyContent);

View File

@ -33,6 +33,7 @@ import {
DeleteProfileEverDialog,
} from "../../../../dialogs";
import { createI18N } from "../../../../../helpers/i18n";
import { isMobile } from "react-device-detect";
const i18n = createI18N({
page: "Home",
@ -376,11 +377,12 @@ class SectionBodyContent extends React.PureComponent {
widthProp,
isMobile,
selectGroup,
isLoading
} = this.props;
const { dialogsVisible, user } = this.state;
return !isLoaded ? (
return !isLoaded || (isMobile && isLoading) ? (
<Loaders.Rows />
) : peopleList.length > 0 ? (
<>
@ -509,10 +511,11 @@ class SectionBodyContent extends React.PureComponent {
const mapStateToProps = (state) => {
const { isLoaded } = state.auth;
const { filter } = state.people;
const { filter, isLoading } = state.people;
return {
isLoaded,
filter,
isLoading,
peopleList: getPeopleList(state),
settings: getSettings(state),
};

View File

@ -48,7 +48,9 @@ export function getFoldersTree() {
"@my",
"@share",
"@common",
/*'@projects',*/ "@trash",
/*'@projects',*/
"@favorites",
"@trash",
]; //TODO: need get from settings
const requestsArray = rootFoldersPaths.map((path) =>
request({ method: "get", url: `/files/${path}?filterType=2` })
@ -103,6 +105,15 @@ export function getCommonFolderList(filter = FilesFilter.getDefault()) {
return request(options);
}
export function getFavoritesFolderList(filter = FilesFilter.getDefault()) {
const options = {
method: "get",
url: `/files/@favorites`
};
return request(options);
}
export function getProjectsFolderList(filter = FilesFilter.getDefault()) {
const options = {
method: "get",
@ -462,9 +473,33 @@ export function thirdParty(val) {
}
export function getSettingsFiles() {
return request({ method: "get", url: `/files/settings` });
return request({ method: "get", url: `/files/settings` });
}
export function markAsFavorite(ids) {
let items = ids.map(id => +id)
const data = { fileIds: items };
const options = {
method: "post",
url: "/files/favorites",
data
};
return request(options);
}
export function removeFromFavorite(ids) {
let items = ids.map(id => +id)
const data = { fileIds: items };
const options = {
method: "delete",
url: "/files/favorites",
data
};
return request(options);
}
export function getDocServiceUrl() {
return request({ method: "get", url: `/files/docservice` });
}
}

View File

@ -0,0 +1,3 @@
<svg width="18" height="16" viewBox="0 0 18 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M9.23442 13.6372C9.0878 13.5594 8.91209 13.5594 8.76546 13.6372L4.43263 15.9378C4.05995 16.1357 3.62484 15.8114 3.70794 15.3977L4.66116 10.6524C4.69316 10.4931 4.64578 10.3282 4.53413 10.2102L1.11339 6.59532C0.829893 6.29574 1.01062 5.80108 1.42048 5.75482L6.06754 5.23028C6.24266 5.21052 6.39445 5.10001 6.46705 4.93943L8.54435 0.344916C8.72159 -0.0471014 9.2783 -0.0470999 9.45554 0.344917L11.5328 4.93943C11.6054 5.10001 11.7572 5.21052 11.9324 5.23028L16.5794 5.75482C16.9893 5.80108 17.17 6.29574 16.8865 6.59533L13.4658 10.2102C13.3541 10.3282 13.3067 10.4931 13.3387 10.6524L14.292 15.3977C14.3751 15.8114 13.94 16.1357 13.5673 15.9378L9.23442 13.6372Z" fill="#657077"/>
</svg>

After

Width:  |  Height:  |  Size: 790 B

View File

@ -0,0 +1,3 @@
<svg width="12" height="12" viewBox="0 0 12 12" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M6.23444 10.26C6.08781 10.1822 5.9121 10.1822 5.76548 10.26L2.80763 11.8305C2.43495 12.0284 1.99985 11.7041 2.08295 11.2905L2.73312 8.05376C2.76511 7.89449 2.71774 7.72961 2.60608 7.61162L0.257285 5.12949C-0.0262119 4.8299 0.154519 4.33524 0.564378 4.28898L3.73005 3.93166C3.90517 3.91189 4.05696 3.80139 4.12956 3.6408L5.54436 0.511585C5.7216 0.119568 6.27831 0.119568 6.45556 0.511585L7.87035 3.6408C7.94296 3.80139 8.09474 3.91189 8.26987 3.93166L11.4355 4.28898C11.8454 4.33524 12.0261 4.8299 11.7426 5.12949L9.39383 7.61162C9.28218 7.72961 9.23481 7.89449 9.2668 8.05376L9.91701 11.2904C10.0001 11.7041 9.565 12.0284 9.19232 11.8305L6.23444 10.26Z" fill="#EDC409"/>
</svg>

After

Width:  |  Height:  |  Size: 783 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 d="M8.23442 13.6372C8.0878 13.5594 7.91209 13.5594 7.76546 13.6372L3.43263 15.9378C3.05995 16.1357 2.62484 15.8114 2.70794 15.3977L3.66116 10.6524C3.69316 10.4931 3.64578 10.3282 3.53413 10.2102L0.11339 6.59532C-0.170107 6.29574 0.0106237 5.80108 0.420483 5.75482L5.06754 5.23028C5.24266 5.21052 5.39445 5.10001 5.46705 4.93943L7.54435 0.344916C7.72159 -0.0471014 8.2783 -0.0470999 8.45554 0.344917L10.5328 4.93943C10.6054 5.10001 10.7572 5.21052 10.9324 5.23028L15.5794 5.75482C15.9893 5.80108 16.17 6.29574 15.8865 6.59533L12.4658 10.2102C12.3541 10.3282 12.3067 10.4931 12.3387 10.6524L13.292 15.3977C13.3751 15.8114 12.94 16.1357 12.5673 15.9378L8.23442 13.6372Z" fill="#333333"/>
</svg>

After

Width:  |  Height:  |  Size: 794 B

View File

@ -190,6 +190,10 @@ import OrigFlipVertical from "./flip.vertical.react.svg";
import OrigRotateLeft from "./rotate.left.react.svg";
import OrigRotateRight from "./rotate.right.react.svg";
import OrigFavorites from "./favorites.react.svg";
import OrigCatalogFavoritesIcon from "./catalog.favorites.react.svg";
import OrigFavoriteIcon from "./favorite.react.svg";
export const AZSortingIcon = createStyledIcon(
OrigAZSortingIcon,
"AZSortingIcon"
@ -745,3 +749,15 @@ export const RotateRightIcon = createStyledIcon(
OrigRotateRight,
"RotateRightIcon"
);
export const FavoritesIcon = createStyledIcon(
OrigFavorites,
"FavoritesIcon"
);
export const CatalogFavoritesIcon = createStyledIcon(
OrigCatalogFavoritesIcon,
"CatalogFavoritesIcon"
);
export const FavoriteIcon = createStyledIcon(
OrigFavoriteIcon,
"FavoriteIcon"
);