1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-14 06:11:16 +00:00

[dir view] added 'creating different types of file' options to the co… (#5653)

* [dir view] added 'creating different types of file' options to the context menu

* [dir view] update for 'New SeaDoc File' in the context menu
This commit is contained in:
llj
2023-09-20 11:13:34 +08:00
committed by GitHub
parent 1e0a59c793
commit 087eaa7c40
3 changed files with 90 additions and 9 deletions

View File

@@ -1,6 +1,6 @@
import React, { Fragment } from 'react';
import PropTypes from 'prop-types';
import { siteRoot, username } from '../../utils/constants';
import { siteRoot, username, enableSeadoc } from '../../utils/constants';
import { Utils } from '../../utils/utils';
import { seafileAPI } from '../../utils/seafile-api';
import URLDecorator from '../../utils/url-decorator';
@@ -68,6 +68,7 @@ class DirentGridView extends React.Component {
isRenameDialogShow: false,
isCreateFolderDialogShow: false,
isCreateFileDialogShow: false,
fileType: '',
isPermissionDialogOpen: false,
isMutipleOperation: false,
@@ -77,9 +78,10 @@ class DirentGridView extends React.Component {
this.isRepoOwner = props.currentRepoInfo.owner_email === username;
}
onCreateFileToggle = () => {
onCreateFileToggle = (fileType) => {
this.setState({
isCreateFileDialogShow: !this.state.isCreateFileDialogShow,
fileType: fileType || ''
});
};
@@ -173,7 +175,22 @@ class DirentGridView extends React.Component {
this.onCreateFolderToggle(currentObject);
break;
case 'New File':
this.onCreateFileToggle();
this.onCreateFileToggle('');
break;
case 'New Markdown File':
this.onCreateFileToggle('.md');
break;
case 'New Excel File':
this.onCreateFileToggle('.xlsx');
break;
case 'New PowerPoint File':
this.onCreateFileToggle('.pptx');
break;
case 'New Word File':
this.onCreateFileToggle('.docx');
break;
case 'New SeaDoc File':
this.onCreateFileToggle('.sdoc');
break;
case 'Access Log':
this.onAccessLog(currentObject);
@@ -407,7 +424,25 @@ class DirentGridView extends React.Component {
return;
}
let id = 'dirent-grid-container-menu';
let menuList = [TextTranslation.NEW_FOLDER, TextTranslation.NEW_FILE];
const {
NEW_FOLDER, NEW_FILE,
NEW_MARKDOWN_FILE,
NEW_EXCEL_FILE,
NEW_POWERPOINT_FILE,
NEW_WORD_FILE,
NEW_SEADOC_FILE
} = TextTranslation;
const menuList = [
NEW_FOLDER, NEW_FILE, 'Divider',
NEW_MARKDOWN_FILE,
NEW_EXCEL_FILE,
NEW_POWERPOINT_FILE,
NEW_WORD_FILE
];
if (enableSeadoc) {
menuList.push(NEW_SEADOC_FILE);
}
this.handleContextClick(event, id, menuList);
};
@@ -513,6 +548,7 @@ class DirentGridView extends React.Component {
<ModalPortal>
<CreateFile
parentPath={this.props.path}
fileType={this.state.fileType}
onAddFile={this.props.onAddFile}
checkDuplicatedName={this.checkDuplicatedName}
toggleDialog={this.onCreateFileToggle}