Web: Files: added fetchSharedFolder to onSelect function for tree share folder
This commit is contained in:
parent
7fc33a282b
commit
53d2d6af89
@ -1,16 +1,10 @@
|
||||
import React from 'react';
|
||||
import { connect } from 'react-redux';
|
||||
import {
|
||||
utils,
|
||||
TreeMenu,
|
||||
TreeNode,
|
||||
Icons,
|
||||
toastr
|
||||
} from "asc-web-components";
|
||||
import React from "react";
|
||||
import { connect } from "react-redux";
|
||||
import { utils, TreeMenu, TreeNode, Icons, toastr } from "asc-web-components";
|
||||
import {
|
||||
selectFolder,
|
||||
fetchMyFolder,
|
||||
//fetchShareFolder,
|
||||
fetchSharedFolder,
|
||||
fetchCommonFolder,
|
||||
fetchProjectsFolder,
|
||||
fetchTrashFolder
|
||||
@ -27,14 +21,10 @@ const getItems = data => {
|
||||
key={item.key}
|
||||
icon={
|
||||
item.root ? (
|
||||
<Icons.CatalogFolderIcon
|
||||
size="scale"
|
||||
isfill
|
||||
color="#657077"
|
||||
/>
|
||||
<Icons.CatalogFolderIcon size="scale" isfill color="#657077" />
|
||||
) : (
|
||||
""
|
||||
)
|
||||
""
|
||||
)
|
||||
}
|
||||
>
|
||||
{getItems(item.children)}
|
||||
@ -45,13 +35,7 @@ const getItems = data => {
|
||||
<TreeNode
|
||||
key={item.key}
|
||||
title={item.title}
|
||||
icon={
|
||||
<Icons.CatalogFolderIcon
|
||||
size="scale"
|
||||
isfill
|
||||
color="#657077"
|
||||
/>
|
||||
}
|
||||
icon={<Icons.CatalogFolderIcon size="scale" isfill color="#657077" />}
|
||||
/>
|
||||
);
|
||||
});
|
||||
@ -60,9 +44,7 @@ const getItems = data => {
|
||||
class ArticleBodyContent extends React.Component {
|
||||
shouldComponentUpdate(nextProps) {
|
||||
const { selectedKeys, data } = this.props;
|
||||
if (
|
||||
!utils.array.isArrayEqual(nextProps.selectedKeys, selectedKeys)
|
||||
) {
|
||||
if (!utils.array.isArrayEqual(nextProps.selectedKeys, selectedKeys)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -81,37 +63,32 @@ class ArticleBodyContent extends React.Component {
|
||||
if (currentModule !== currentModuleId) {
|
||||
const { my, share, common, project, trash } = rootFolders;
|
||||
|
||||
|
||||
switch (currentModuleId) {
|
||||
case my.id:
|
||||
fetchMyFolder(store.dispatch)
|
||||
.then(() => console.log("fetchMyFolder then"))
|
||||
.catch(() => toastr.error("Error fetchMyFolder") )
|
||||
.finally(() => console.log("fetchMyFolder finally"));
|
||||
fetchMyFolder(store.dispatch).catch(() =>
|
||||
toastr.error("Error fetchMyFolder")
|
||||
);
|
||||
break;
|
||||
case share.id:
|
||||
fetchSharedFolder(store.dispatch).catch(() =>
|
||||
toastr.error("Error fetchSharedFolder")
|
||||
);
|
||||
break;
|
||||
/*case share.id:
|
||||
fetchSharedFolder(store.dispatch)
|
||||
.then(() => console.log("then"))
|
||||
.catch(() => toastr.error("Error fetchSharedFolder"))
|
||||
.finally(() => console.log("finally"));
|
||||
break;*/
|
||||
case common.id:
|
||||
fetchCommonFolder(store.dispatch)
|
||||
.then(() => console.log("fetchCommonFolder then"))
|
||||
.catch(() => toastr.error("Error fetchCommonFolder"))
|
||||
.finally(() => console.log("fetchCommonFolder finally"));
|
||||
fetchCommonFolder(store.dispatch).catch(() =>
|
||||
toastr.error("Error fetchCommonFolder")
|
||||
);
|
||||
break;
|
||||
case project.id:
|
||||
fetchProjectsFolder(store.dispatch)
|
||||
.then(() => console.log("fetchProjectsFolder then"))
|
||||
.catch(() => toastr.error("Error fetchProjectsFolder"))
|
||||
.finally(() => console.log("fetchProjectsFolder finally"));
|
||||
fetchProjectsFolder(store.dispatch).catch(() =>
|
||||
toastr.error("Error fetchProjectsFolder")
|
||||
);
|
||||
|
||||
break;
|
||||
case trash.id:
|
||||
fetchTrashFolder(store.dispatch)
|
||||
.then(() => console.log("fetchTrashFolder then"))
|
||||
.catch(() => toastr.error("Error fetchTrashFolder"))
|
||||
.finally(() => console.log("fetchTrashFolder finally"));
|
||||
fetchTrashFolder(store.dispatch).catch(() =>
|
||||
toastr.error("Error fetchTrashFolder")
|
||||
);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@ -156,9 +133,7 @@ class ArticleBodyContent extends React.Component {
|
||||
</TreeMenu>
|
||||
));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
|
||||
function mapStateToProps(state) {
|
||||
const { rootFolders, selectedFolder } = state.files;
|
||||
@ -177,8 +152,8 @@ function mapStateToProps(state) {
|
||||
export default connect(mapStateToProps, {
|
||||
selectFolder,
|
||||
fetchMyFolder,
|
||||
//fetchShareFolder,
|
||||
fetchSharedFolder,
|
||||
fetchCommonFolder,
|
||||
fetchProjectsFolder,
|
||||
fetchTrashFolder
|
||||
})(ArticleBodyContent);
|
||||
})(ArticleBodyContent);
|
||||
|
@ -94,6 +94,14 @@ export function fetchProjectsFolder(dispatch) {
|
||||
});
|
||||
}
|
||||
|
||||
export function fetchSharedFolder(dispatch) {
|
||||
return files.getSharedFolderList().then(data => {
|
||||
dispatch(setFolders(data.folders));
|
||||
dispatch(setFiles(data.files));
|
||||
return dispatch(setSelectedFolder(data.current));
|
||||
});
|
||||
}
|
||||
|
||||
export function fetchRootFolders(dispatch) {
|
||||
|
||||
//TODO: Make some more Useful
|
||||
@ -114,6 +122,8 @@ export function fetchRootFolders(dispatch) {
|
||||
.then(data => root.project = data.current))
|
||||
.then(() => files.getTrashFolderList()
|
||||
.then(data => root.trash = data.current))
|
||||
.then(() => files.getSharedFolderList()
|
||||
.then(data => root.share = data.current))
|
||||
.then(() => dispatch(setRootFolders(root)));
|
||||
}
|
||||
|
||||
|
@ -28,22 +28,15 @@ const getFakeFolders = count =>
|
||||
});
|
||||
|
||||
export const getRootFolders = files => {
|
||||
const defaultFolders = [
|
||||
"Мои документы",
|
||||
"Доступно для меня",
|
||||
"Общие документы",
|
||||
"Документы проектов",
|
||||
"Корзина"
|
||||
];
|
||||
const { folders, rootFolders } = files;
|
||||
const { my, share, common, project, trash } = rootFolders;
|
||||
|
||||
const myDocumentsFolder = getTreeGroups(folders, my.title, my.id);
|
||||
const sharedWithMeFolder = getTreeGroups(
|
||||
getFakeFolders(4),
|
||||
defaultFolders[1],
|
||||
"2"
|
||||
); //getTreeGroups(getFakeFolders(share.foldersCount), share.title, share.id);
|
||||
getFakeFolders(share.foldersCount),
|
||||
share.title,
|
||||
share.id
|
||||
);
|
||||
const commonDocumentsFolder = getTreeGroups(
|
||||
getFakeFolders(common.foldersCount),
|
||||
common.title,
|
||||
|
Loading…
Reference in New Issue
Block a user