mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-09 10:50:24 +00:00
Folder shared out (#5601)
* show if folder has been shared out * [dir view] use special folder icon to identify folders which are shared out * [dir view] improvement: in a library, make only one request to get the data of folders shared out --------- Co-authored-by: llj <lingjun.li1@gmail.com>
This commit is contained in:
@@ -16,6 +16,9 @@ class Dirent {
|
|||||||
this.permission = json.permission || 'rw';
|
this.permission = json.permission || 'rw';
|
||||||
this.isSelected = false; // is check or not
|
this.isSelected = false; // is check or not
|
||||||
this.starred = json.starred || false;
|
this.starred = json.starred || false;
|
||||||
|
if (json.type === 'dir') {
|
||||||
|
this.has_been_shared_out = false;
|
||||||
|
}
|
||||||
if (json.type === 'file') {
|
if (json.type === 'file') {
|
||||||
this.size_original = json.size;
|
this.size_original = json.size;
|
||||||
this.size = Utils.bytesToSize(json.size);
|
this.size = Utils.bytesToSize(json.size);
|
||||||
|
@@ -492,6 +492,22 @@ class LibContentView extends React.Component {
|
|||||||
if (!this.state.repoEncrypted && direntList.length) {
|
if (!this.state.repoEncrypted && direntList.length) {
|
||||||
this.getThumbnails(repoID, path, this.state.direntList);
|
this.getThumbnails(repoID, path, this.state.direntList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.state.currentRepoInfo.is_admin) {
|
||||||
|
if (this.foldersSharedOut) {
|
||||||
|
this.identifyFoldersSharedOut();
|
||||||
|
} else {
|
||||||
|
this.foldersSharedOut = [];
|
||||||
|
seafileAPI.getAllRepoFolderShareInfo(repoID).then(res => {
|
||||||
|
res.data.share_info_list.forEach(item => {
|
||||||
|
if (this.foldersSharedOut.indexOf(item.path) === -1) {
|
||||||
|
this.foldersSharedOut.push(item.path);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
this.identifyFoldersSharedOut();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
}).catch((err) => {
|
}).catch((err) => {
|
||||||
Utils.getErrorMsg(err, true);
|
Utils.getErrorMsg(err, true);
|
||||||
if (err.response && err.response.status === 403) {
|
if (err.response && err.response.status === 403) {
|
||||||
@@ -505,6 +521,21 @@ class LibContentView extends React.Component {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
identifyFoldersSharedOut = () => {
|
||||||
|
const { path, direntList } = this.state;
|
||||||
|
if (this.foldersSharedOut.length == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
direntList.forEach(dirent => {
|
||||||
|
if (dirent.type == 'dir' && this.foldersSharedOut.indexOf(Utils.joinPath(path, dirent.name) + '/') !== -1) {
|
||||||
|
dirent.has_been_shared_out = true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
this.setState({
|
||||||
|
direntList: direntList
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
onListContainerScroll = () => {
|
onListContainerScroll = () => {
|
||||||
let itemsShowLength = this.state.itemsShowLength + 100;
|
let itemsShowLength = this.state.itemsShowLength + 100;
|
||||||
this.setState({itemsShowLength: itemsShowLength});
|
this.setState({itemsShowLength: itemsShowLength});
|
||||||
|
@@ -373,7 +373,7 @@ export const Utils = {
|
|||||||
if (dirent.permission && (dirent.permission === 'r' || dirent.permission === 'preview')) {
|
if (dirent.permission && (dirent.permission === 'r' || dirent.permission === 'preview')) {
|
||||||
readonly = true;
|
readonly = true;
|
||||||
}
|
}
|
||||||
return this.getFolderIconUrl(readonly, size);
|
return this.getFolderIconUrl(readonly, size, dirent.has_been_shared_out);
|
||||||
} else {
|
} else {
|
||||||
return this.getFileIconUrl(dirent.name, size);
|
return this.getFileIconUrl(dirent.name, size);
|
||||||
}
|
}
|
||||||
@@ -389,12 +389,12 @@ export const Utils = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
getFolderIconUrl: function(readonly = false, size) {
|
getFolderIconUrl: function(readonly = false, size, sharedOut) {
|
||||||
if (!size) {
|
if (!size) {
|
||||||
size = Utils.isHiDPI() ? 48 : 24;
|
size = Utils.isHiDPI() ? 48 : 24;
|
||||||
}
|
}
|
||||||
size = size > 24 ? 192 : 24;
|
size = size > 24 ? 192 : 24;
|
||||||
return `${mediaUrl}img/folder${readonly ? '-read-only-' : '-'}${size}.png`;
|
return `${mediaUrl}img/folder${readonly ? '-read-only' : ''}${sharedOut ? '-shared-out' : ''}-${size}.png`;
|
||||||
},
|
},
|
||||||
|
|
||||||
getFileIconUrl: function(filename, size) {
|
getFileIconUrl: function(filename, size) {
|
||||||
|
BIN
media/img/folder-shared-out-192.png
Normal file
BIN
media/img/folder-shared-out-192.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.0 KiB |
BIN
media/img/folder-shared-out-24.png
Normal file
BIN
media/img/folder-shared-out-24.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 422 B |
Reference in New Issue
Block a user