mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-06 09:21:54 +00:00
add file filter
This commit is contained in:
@@ -47,6 +47,7 @@ class InsertRepoImageDialog extends React.Component {
|
||||
|
||||
render() {
|
||||
const toggle = this.props.toggleCancel;
|
||||
const fileSuffix = ['jpg', 'png', 'jpeg', 'gif', 'bmp'];
|
||||
let imageUrl;
|
||||
if (this.state.repo) {
|
||||
imageUrl = siteRoot + 'thumbnail/' + this.state.repo.repo_id + '/1024' + this.state.selectedPath;
|
||||
@@ -63,6 +64,7 @@ class InsertRepoImageDialog extends React.Component {
|
||||
onDirentItemClick={this.onDirentItemClick}
|
||||
onRepoItemClick={this.onRepoItemClick}
|
||||
mode="current_repo_and_other_repos"
|
||||
fileSuffix={fileSuffix}
|
||||
/>
|
||||
</div>
|
||||
<div className="insert-image-container col-6">
|
||||
|
@@ -12,6 +12,7 @@ const propTypes = {
|
||||
dirent: PropTypes.object.isRequired,
|
||||
repo: PropTypes.object.isRequired,
|
||||
onDirentItemClick: PropTypes.func.isRequired,
|
||||
fileSuffix: PropTypes.array,
|
||||
};
|
||||
|
||||
class DirentListItem extends React.Component {
|
||||
@@ -91,6 +92,7 @@ class DirentListItem extends React.Component {
|
||||
selectedRepo={this.props.selectedRepo}
|
||||
onDirentItemClick={this.props.onDirentItemClick}
|
||||
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 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 (
|
||||
<li className="file-chooser-item">
|
||||
{
|
||||
|
@@ -9,6 +9,7 @@ const propTypes = {
|
||||
isShowFile: PropTypes.bool,
|
||||
selectedPath: PropTypes.string,
|
||||
selectedRepo: PropTypes.object,
|
||||
fileSuffix: PropTypes.array,
|
||||
repo: PropTypes.object.isRequired,
|
||||
isShowChildren: PropTypes.bool.isRequired,
|
||||
onDirentItemClick: PropTypes.func.isRequired
|
||||
@@ -57,6 +58,7 @@ class DirentListView extends React.Component {
|
||||
onDirentItemClick={this.props.onDirentItemClick}
|
||||
selectedPath={this.props.selectedPath}
|
||||
isShowFile={this.props.isShowFile}
|
||||
fileSuffix={this.props.fileSuffix}
|
||||
/>
|
||||
);
|
||||
})}
|
||||
|
@@ -17,6 +17,7 @@ const propTypes = {
|
||||
onDirentItemClick: PropTypes.func,
|
||||
onRepoItemClick: PropTypes.func,
|
||||
mode: PropTypes.oneOf(['current_repo_and_other_repos', 'only_all_repos', 'only_current_library']),
|
||||
fileSuffix: PropTypes.array,
|
||||
};
|
||||
|
||||
class FileChooser extends React.Component {
|
||||
@@ -308,6 +309,7 @@ class FileChooser extends React.Component {
|
||||
onRepoItemClick={this.onRepoItemClick}
|
||||
onDirentItemClick={this.onDirentItemClick}
|
||||
isShowFile={this.props.isShowFile}
|
||||
fileSuffix={this.props.fileSuffix}
|
||||
/>
|
||||
}
|
||||
</div>
|
||||
@@ -326,6 +328,7 @@ class FileChooser extends React.Component {
|
||||
onRepoItemClick={this.onRepoItemClick}
|
||||
onDirentItemClick={this.onDirentItemClick}
|
||||
isShowFile={this.props.isShowFile}
|
||||
fileSuffix={this.props.fileSuffix}
|
||||
/>
|
||||
}
|
||||
</div>
|
||||
@@ -347,6 +350,7 @@ class FileChooser extends React.Component {
|
||||
onRepoItemClick={this.onRepoItemClick}
|
||||
onDirentItemClick={this.onDirentItemClick}
|
||||
isShowFile={this.props.isShowFile}
|
||||
fileSuffix={this.props.fileSuffix}
|
||||
/>
|
||||
}
|
||||
</div>
|
||||
@@ -366,6 +370,7 @@ class FileChooser extends React.Component {
|
||||
onRepoItemClick={this.onRepoItemClick}
|
||||
onDirentItemClick={this.onDirentItemClick}
|
||||
isShowFile={this.props.isShowFile}
|
||||
fileSuffix={this.props.fileSuffix}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
@@ -10,6 +10,7 @@ const propTypes = {
|
||||
initToShowChildren: PropTypes.bool.isRequired,
|
||||
onDirentItemClick: PropTypes.func.isRequired,
|
||||
onRepoItemClick: PropTypes.func.isRequired,
|
||||
fileSuffix: PropTypes.array,
|
||||
};
|
||||
|
||||
class RepoListItem extends React.Component {
|
||||
@@ -64,6 +65,7 @@ class RepoListItem extends React.Component {
|
||||
selectedRepo={this.props.selectedRepo}
|
||||
selectedPath={this.props.selectedPath}
|
||||
isShowFile={this.props.isShowFile}
|
||||
fileSuffix={this.props.fileSuffix}
|
||||
/>
|
||||
)}
|
||||
</li>
|
||||
|
@@ -12,6 +12,7 @@ const propTypes = {
|
||||
selectedPath: PropTypes.string,
|
||||
onDirentItemClick: PropTypes.func.isRequired,
|
||||
onRepoItemClick: PropTypes.func.isRequired,
|
||||
fileSuffix: PropTypes.array,
|
||||
};
|
||||
|
||||
class RepoListView extends React.Component {
|
||||
@@ -35,6 +36,7 @@ class RepoListView extends React.Component {
|
||||
onRepoItemClick={this.props.onRepoItemClick}
|
||||
onDirentItemClick={this.props.onDirentItemClick}
|
||||
isShowFile={this.props.isShowFile}
|
||||
fileSuffix={this.props.fileSuffix}
|
||||
/>
|
||||
);
|
||||
})}
|
||||
|
Reference in New Issue
Block a user