1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-06 01:12:03 +00:00

add file filter

This commit is contained in:
Michael An
2019-04-23 17:24:17 +08:00
parent 2eb1e15b05
commit 31228181bf
6 changed files with 20 additions and 0 deletions

View File

@@ -47,6 +47,7 @@ class InsertRepoImageDialog extends React.Component {
render() { render() {
const toggle = this.props.toggleCancel; const toggle = this.props.toggleCancel;
const fileSuffix = ['jpg', 'png', 'jpeg', 'gif', 'bmp'];
let imageUrl; let imageUrl;
if (this.state.repo) { if (this.state.repo) {
imageUrl = siteRoot + 'thumbnail/' + this.state.repo.repo_id + '/1024' + this.state.selectedPath; imageUrl = siteRoot + 'thumbnail/' + this.state.repo.repo_id + '/1024' + this.state.selectedPath;
@@ -63,6 +64,7 @@ class InsertRepoImageDialog extends React.Component {
onDirentItemClick={this.onDirentItemClick} onDirentItemClick={this.onDirentItemClick}
onRepoItemClick={this.onRepoItemClick} onRepoItemClick={this.onRepoItemClick}
mode="current_repo_and_other_repos" mode="current_repo_and_other_repos"
fileSuffix={fileSuffix}
/> />
</div> </div>
<div className="insert-image-container col-6"> <div className="insert-image-container col-6">

View File

@@ -12,6 +12,7 @@ const propTypes = {
dirent: PropTypes.object.isRequired, dirent: PropTypes.object.isRequired,
repo: PropTypes.object.isRequired, repo: PropTypes.object.isRequired,
onDirentItemClick: PropTypes.func.isRequired, onDirentItemClick: PropTypes.func.isRequired,
fileSuffix: PropTypes.array,
}; };
class DirentListItem extends React.Component { class DirentListItem extends React.Component {
@@ -91,6 +92,7 @@ class DirentListItem extends React.Component {
selectedRepo={this.props.selectedRepo} selectedRepo={this.props.selectedRepo}
onDirentItemClick={this.props.onDirentItemClick} onDirentItemClick={this.props.onDirentItemClick}
isShowFile={this.props.isShowFile} isShowFile={this.props.isShowFile}
fileSuffix={this.props.fileSuffix}
/> />
); );
})} })}
@@ -102,6 +104,11 @@ class DirentListItem extends React.Component {
let isCurrentRepo = this.props.selectedRepo.repo_id === this.props.repo.repo_id; let isCurrentRepo = this.props.selectedRepo.repo_id === this.props.repo.repo_id;
let isCurrentPath = this.props.selectedPath === this.state.filePath; let isCurrentPath = this.props.selectedPath === this.state.filePath;
const fileName = this.props.dirent.name;
if (this.props.fileSuffix && fileName && fileName.indexOf('.') !== -1) {
const suffix = fileName.slice(fileName.lastIndexOf('.') + 1).toLowerCase();
if (!this.props.fileSuffix.includes(suffix)) return null;
}
return ( return (
<li className="file-chooser-item"> <li className="file-chooser-item">
{ {

View File

@@ -9,6 +9,7 @@ const propTypes = {
isShowFile: PropTypes.bool, isShowFile: PropTypes.bool,
selectedPath: PropTypes.string, selectedPath: PropTypes.string,
selectedRepo: PropTypes.object, selectedRepo: PropTypes.object,
fileSuffix: PropTypes.array,
repo: PropTypes.object.isRequired, repo: PropTypes.object.isRequired,
isShowChildren: PropTypes.bool.isRequired, isShowChildren: PropTypes.bool.isRequired,
onDirentItemClick: PropTypes.func.isRequired onDirentItemClick: PropTypes.func.isRequired
@@ -57,6 +58,7 @@ class DirentListView extends React.Component {
onDirentItemClick={this.props.onDirentItemClick} onDirentItemClick={this.props.onDirentItemClick}
selectedPath={this.props.selectedPath} selectedPath={this.props.selectedPath}
isShowFile={this.props.isShowFile} isShowFile={this.props.isShowFile}
fileSuffix={this.props.fileSuffix}
/> />
); );
})} })}

View File

@@ -17,6 +17,7 @@ const propTypes = {
onDirentItemClick: PropTypes.func, onDirentItemClick: PropTypes.func,
onRepoItemClick: PropTypes.func, onRepoItemClick: PropTypes.func,
mode: PropTypes.oneOf(['current_repo_and_other_repos', 'only_all_repos', 'only_current_library']), mode: PropTypes.oneOf(['current_repo_and_other_repos', 'only_all_repos', 'only_current_library']),
fileSuffix: PropTypes.array,
}; };
class FileChooser extends React.Component { class FileChooser extends React.Component {
@@ -308,6 +309,7 @@ class FileChooser extends React.Component {
onRepoItemClick={this.onRepoItemClick} onRepoItemClick={this.onRepoItemClick}
onDirentItemClick={this.onDirentItemClick} onDirentItemClick={this.onDirentItemClick}
isShowFile={this.props.isShowFile} isShowFile={this.props.isShowFile}
fileSuffix={this.props.fileSuffix}
/> />
} }
</div> </div>
@@ -326,6 +328,7 @@ class FileChooser extends React.Component {
onRepoItemClick={this.onRepoItemClick} onRepoItemClick={this.onRepoItemClick}
onDirentItemClick={this.onDirentItemClick} onDirentItemClick={this.onDirentItemClick}
isShowFile={this.props.isShowFile} isShowFile={this.props.isShowFile}
fileSuffix={this.props.fileSuffix}
/> />
} }
</div> </div>
@@ -347,6 +350,7 @@ class FileChooser extends React.Component {
onRepoItemClick={this.onRepoItemClick} onRepoItemClick={this.onRepoItemClick}
onDirentItemClick={this.onDirentItemClick} onDirentItemClick={this.onDirentItemClick}
isShowFile={this.props.isShowFile} isShowFile={this.props.isShowFile}
fileSuffix={this.props.fileSuffix}
/> />
} }
</div> </div>
@@ -366,6 +370,7 @@ class FileChooser extends React.Component {
onRepoItemClick={this.onRepoItemClick} onRepoItemClick={this.onRepoItemClick}
onDirentItemClick={this.onDirentItemClick} onDirentItemClick={this.onDirentItemClick}
isShowFile={this.props.isShowFile} isShowFile={this.props.isShowFile}
fileSuffix={this.props.fileSuffix}
/> />
</div> </div>
</div> </div>

View File

@@ -10,6 +10,7 @@ const propTypes = {
initToShowChildren: PropTypes.bool.isRequired, initToShowChildren: PropTypes.bool.isRequired,
onDirentItemClick: PropTypes.func.isRequired, onDirentItemClick: PropTypes.func.isRequired,
onRepoItemClick: PropTypes.func.isRequired, onRepoItemClick: PropTypes.func.isRequired,
fileSuffix: PropTypes.array,
}; };
class RepoListItem extends React.Component { class RepoListItem extends React.Component {
@@ -64,6 +65,7 @@ class RepoListItem extends React.Component {
selectedRepo={this.props.selectedRepo} selectedRepo={this.props.selectedRepo}
selectedPath={this.props.selectedPath} selectedPath={this.props.selectedPath}
isShowFile={this.props.isShowFile} isShowFile={this.props.isShowFile}
fileSuffix={this.props.fileSuffix}
/> />
)} )}
</li> </li>

View File

@@ -12,6 +12,7 @@ const propTypes = {
selectedPath: PropTypes.string, selectedPath: PropTypes.string,
onDirentItemClick: PropTypes.func.isRequired, onDirentItemClick: PropTypes.func.isRequired,
onRepoItemClick: PropTypes.func.isRequired, onRepoItemClick: PropTypes.func.isRequired,
fileSuffix: PropTypes.array,
}; };
class RepoListView extends React.Component { class RepoListView extends React.Component {
@@ -35,6 +36,7 @@ class RepoListView extends React.Component {
onRepoItemClick={this.props.onRepoItemClick} onRepoItemClick={this.props.onRepoItemClick}
onDirentItemClick={this.props.onDirentItemClick} onDirentItemClick={this.props.onDirentItemClick}
isShowFile={this.props.isShowFile} isShowFile={this.props.isShowFile}
fileSuffix={this.props.fileSuffix}
/> />
); );
})} })}