diff --git a/frontend/src/assets/icons/file.svg b/frontend/src/assets/icons/file.svg
index 447119c1fc..cf122ab0d4 100644
--- a/frontend/src/assets/icons/file.svg
+++ b/frontend/src/assets/icons/file.svg
@@ -3,17 +3,16 @@
diff --git a/frontend/src/assets/icons/files.svg b/frontend/src/assets/icons/files.svg
new file mode 100644
index 0000000000..dd9d0898e8
--- /dev/null
+++ b/frontend/src/assets/icons/files.svg
@@ -0,0 +1,22 @@
+
+
+
diff --git a/frontend/src/pages/wiki2/css/view-structure.css b/frontend/src/pages/wiki2/css/view-structure.css
index f9782481d3..622e130f39 100644
--- a/frontend/src/pages/wiki2/css/view-structure.css
+++ b/frontend/src/pages/wiki2/css/view-structure.css
@@ -94,7 +94,7 @@
padding-left: 20px;
}
-.view-structure .view-folder-wrapper .icon-expand-folder {
+.view-structure .icon-expand-folder {
display: inline-block;
font-size: 12px;
transform: scale(0.8);
@@ -145,10 +145,13 @@
}
.view-structure .view-folder-wrapper .more-view-folder-operation .seafile-multicolor-icon-more-level,
+.view-structure .view-item .fas.fa-plus,
.view-structure .view-item .more-view-operation .seafile-multicolor-icon-more-level {
+ cursor: pointer;
opacity: 0;
}
+.view-structure .view-item:hover .fas.fa-plus,
.view-structure .view-folder-wrapper:hover .more-view-folder-operation .seafile-multicolor-icon-more-level,
.view-structure .view-item:hover .more-view-operation .seafile-multicolor-icon-more-level {
opacity: 1;
@@ -166,6 +169,7 @@
}
.view-structure .folder-list .view-folder.fold-freezed .btn-folder-operation,
+.view-structure .view-item.view-freezed .fas.fa-plus,
.view-structure .view-item.view-freezed .seafile-multicolor-icon-more-level {
opacity: 1;
}
@@ -358,21 +362,24 @@
/* dark mode */
.view-structure-dark.view-structure,
-.view-structure-dark.view-structure .view-folder .icon-expand-folder {
+.view-structure-dark.view-structure .icon-expand-folder {
color: #fff;
}
/* light mode */
.view-structure-light.view-structure,
+.view-structure-light.view-structure .view-item .fas.fa-plus:hover,
.view-structure-light.view-structure .view-item .seafile-multicolor-icon-more-level:hover,
.view-structure-light.view-structure .view-folder .seafile-multicolor-icon-more-level:hover,
-.view-structure-light.view-structure .view-folder .icon-expand-folder:hover {
+.view-structure-light.view-structure .icon-expand-folder:hover {
color: #212529;
}
+
+.view-structure-light.view-structure .view-item .fas.fa-plus,
.view-structure-light.view-structure .view-item .seafile-multicolor-icon-more-level,
.view-structure-light.view-structure .view-folder .seafile-multicolor-icon-more-level,
-.view-structure-light.view-structure .view-folder .icon-expand-folder {
+.view-structure-light.view-structure .icon-expand-folder {
color: #666;
}
diff --git a/frontend/src/pages/wiki2/models/page.js b/frontend/src/pages/wiki2/models/page.js
index 528861131e..e602394b57 100644
--- a/frontend/src/pages/wiki2/models/page.js
+++ b/frontend/src/pages/wiki2/models/page.js
@@ -1,9 +1,12 @@
-export default class Page {
+class Page {
constructor(object) {
this.id = object.id;
this.name = object.name;
this.path = object.path;
this.icon = object.icon;
this.docUuid = object.docUuid;
+ this.children = Array.isArray(object.children) ? object.children.map(item => new Page(item)) : [];
}
}
+
+export default Page;
diff --git a/frontend/src/pages/wiki2/models/wiki-config.js b/frontend/src/pages/wiki2/models/wiki-config.js
index d08fc9ccd8..cd814932c0 100644
--- a/frontend/src/pages/wiki2/models/wiki-config.js
+++ b/frontend/src/pages/wiki2/models/wiki-config.js
@@ -11,6 +11,7 @@ export default class WikiConfig {
return {
id: item.id,
type: item.type,
+ children: item.children || [],
};
}
return null;
diff --git a/frontend/src/pages/wiki2/side-panel.js b/frontend/src/pages/wiki2/side-panel.js
index dc01abb621..068bbf0ec3 100644
--- a/frontend/src/pages/wiki2/side-panel.js
+++ b/frontend/src/pages/wiki2/side-panel.js
@@ -47,6 +47,7 @@ class SidePanel extends Component {
config.pages.splice(index, 1);
PageUtils.deletePage(navigation, pageId);
this.props.saveWikiConfig(config);
+ // TODO: To delete a page, do you need to delete all subpages at once (requires a new API)
wikiAPI.deleteWiki2Page(wikiId, pageId);
if (config.pages.length > 0) {
this.props.setCurrentPage(config.pages[0].id);
@@ -55,12 +56,20 @@ class SidePanel extends Component {
}
};
+ addPageInside = async ({ parentPageId, name, icon, path, docUuid, successCallback, errorCallback }) => {
+ const { config } = this.props;
+ const navigation = config.navigation;
+ const pageId = generateUniqueId(navigation);
+ const newPage = new Page({ id: pageId, name, icon, path, docUuid });
+ this.addPage(newPage, parentPageId, successCallback, errorCallback);
+ };
+
onAddNewPage = async ({ name, icon, path, docUuid, successCallback, errorCallback }) => {
const { config } = this.props;
const navigation = config.navigation;
const pageId = generateUniqueId(navigation);
const newPage = new Page({ id: pageId, name, icon, path, docUuid });
- this.addPage(newPage, successCallback, errorCallback);
+ this.addPage(newPage, this.current_folder_id, successCallback, errorCallback);
};
duplicatePage = async (fromPageConfig, successCallback, errorCallback) => {
@@ -75,15 +84,15 @@ class SidePanel extends Component {
name,
};
const newPage = new Page({ ...newPageConfig });
- this.addPage(newPage, successCallback, errorCallback);
+ this.addPage(newPage, this.current_folder_id, successCallback, errorCallback);
};
- addPage = (page, successCallback, errorCallback) => {
+ addPage = (page, parentId, successCallback, errorCallback) => {
const { config } = this.props;
const navigation = config.navigation;
const pageId = page.id;
config.pages.push(page);
- PageUtils.addPage(navigation, pageId, this.current_folder_id);
+ PageUtils.addPage(navigation, pageId, parentId);
config.navigation = navigation;
const onSuccess = () => {
this.props.setCurrentPage(pageId, successCallback);
@@ -113,10 +122,10 @@ class SidePanel extends Component {
this.props.saveWikiConfig(config);
};
- movePageOut = (moved_page_id, source_folder_id, target_folder_id, move_position) => {
+ movePageOut = (moved_page_id, source_id, target_id, move_position) => {
let config = deepCopy(this.props.config);
let { navigation } = config;
- PageUtils.movePageOut(navigation, moved_page_id, source_folder_id, target_folder_id, move_position);
+ PageUtils.movePageOut(navigation, moved_page_id, source_id, target_id, move_position);
config.navigation = navigation;
this.props.saveWikiConfig(config);
};
@@ -164,12 +173,13 @@ class SidePanel extends Component {
const { config } = this.props;
const { navigation, pages } = config;
PageUtils.deleteFolder(navigation, pages, page_folder_id);
+ // TODO: delete all pages inside the folder, A new API is required
config.navigation = navigation;
this.props.saveWikiConfig(config);
};
// Drag a folder to the front and back of another folder
- onMoveFolder = (moved_folder_id, target_folder_id, move_position) => {
+ onMoveFolder = (moved_folder_id, target_id, move_position) => {
const { config } = this.props;
const { navigation } = config;
let updatedNavigation = deepCopy(navigation);
@@ -196,11 +206,11 @@ class SidePanel extends Component {
indexOffset++;
}
// Get the location of the release
- let target_folder_index = PageUtils.getFolderIndexById(updatedNavigation, target_folder_id);
+ let target_folder_index = PageUtils.getFolderIndexById(updatedNavigation, target_id);
if (target_folder_index === -1) {
updatedNavigation.forEach(item => {
if (item.type === FOLDER) {
- target_folder_index = PageUtils.getFolderIndexById(item.children, target_folder_id);
+ target_folder_index = PageUtils.getFolderIndexById(item.children, target_id);
if (target_folder_index > -1) {
item.children.splice(target_folder_index + indexOffset, 0, moved_folder);
}
@@ -217,12 +227,12 @@ class SidePanel extends Component {
};
// Not support yet: Move a folder into another folder
- moveFolderToFolder = (moved_folder_id, target_folder_id) => {
+ moveFolderToFolder = (moved_folder_id, target_id) => {
let { config } = this.props;
let { navigation } = config;
// Find the folder and move it to this new folder
- let target_folder = PageUtils.getFolderById(navigation, target_folder_id);
+ let target_folder = PageUtils.getFolderById(navigation, target_id);
if (!target_folder) {
toaster.danger('Only_support_two_level_folders');
return;
@@ -299,6 +309,7 @@ class SidePanel extends Component {
duplicatePage={this.duplicatePage}
onSetFolderId={this.onSetFolderId}
currentPageId={this.props.currentPageId}
+ addPageInside={this.addPageInside}
/>
{this.state.isShowNewFolderDialog &&