mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-05 08:53:14 +00:00
@@ -6,6 +6,7 @@ import { seafileAPI } from '../../utils/seafile-api';
|
|||||||
import { gettext, siteRoot, username } from '../../utils/constants';
|
import { gettext, siteRoot, username } from '../../utils/constants';
|
||||||
import SearchResultItem from './search-result-item';
|
import SearchResultItem from './search-result-item';
|
||||||
import { Utils } from '../../utils/utils';
|
import { Utils } from '../../utils/utils';
|
||||||
|
import { isMac } from '../../utils/extra-attributes';
|
||||||
import toaster from '../toast';
|
import toaster from '../toast';
|
||||||
|
|
||||||
const propTypes = {
|
const propTypes = {
|
||||||
@@ -16,6 +17,7 @@ const propTypes = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const PER_PAGE = 10;
|
const PER_PAGE = 10;
|
||||||
|
const controlKey = isMac() ? '⌘' : 'Ctrl';
|
||||||
|
|
||||||
class Search extends Component {
|
class Search extends Component {
|
||||||
|
|
||||||
@@ -294,20 +296,21 @@ class Search extends Component {
|
|||||||
render() {
|
render() {
|
||||||
let width = this.state.width !== 'default' ? this.state.width : '';
|
let width = this.state.width !== 'default' ? this.state.width : '';
|
||||||
let style = {'width': width};
|
let style = {'width': width};
|
||||||
const { searchPageUrl } = this.state;
|
const { searchPageUrl, isMaskShow } = this.state;
|
||||||
|
const placeholder = `${this.props.placeholder}${isMaskShow ? '' : ` (${controlKey} + f )`}`;
|
||||||
return (
|
return (
|
||||||
<Fragment>
|
<Fragment>
|
||||||
<MediaQuery query="(min-width: 768px)">
|
<MediaQuery query="(min-width: 768px)">
|
||||||
<div className="search">
|
<div className="search">
|
||||||
<div className={`search-mask ${this.state.isMaskShow ? 'show' : 'hide'}`} onClick={this.onCloseHandler}></div>
|
<div className={`search-mask ${isMaskShow ? 'show' : 'hide'}`} onClick={this.onCloseHandler}></div>
|
||||||
<div className={`search-container ${this.state.isMaskShow ? 'show' : ''}`}>
|
<div className={`search-container ${isMaskShow ? 'show' : ''}`}>
|
||||||
<div className="input-icon">
|
<div className={`input-icon ${isMaskShow ? 'mb-1' : ''}`}>
|
||||||
<i className="search-icon-left input-icon-addon fas fa-search"></i>
|
<i className="search-icon-left input-icon-addon fas fa-search"></i>
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
className="form-control search-input"
|
className="form-control search-input"
|
||||||
name="query"
|
name="query"
|
||||||
placeholder={this.props.placeholder}
|
placeholder={placeholder}
|
||||||
style={style}
|
style={style}
|
||||||
value={this.state.value}
|
value={this.state.value}
|
||||||
onFocus={this.onFocusHandler}
|
onFocus={this.onFocusHandler}
|
||||||
@@ -334,7 +337,7 @@ class Search extends Component {
|
|||||||
</div>
|
</div>
|
||||||
{this.state.isSearchInputShow &&
|
{this.state.isSearchInputShow &&
|
||||||
<div className="search">
|
<div className="search">
|
||||||
<div className={`search-mask ${this.state.isMaskShow ? '' : 'hide'}`} onClick={this.onCloseHandler}></div>
|
<div className={`search-mask ${isMaskShow ? '' : 'hide'}`} onClick={this.onCloseHandler}></div>
|
||||||
<div className="search-container">
|
<div className="search-container">
|
||||||
<div className="input-icon">
|
<div className="input-icon">
|
||||||
<i className="search-icon-left input-icon-addon fas fa-search"></i>
|
<i className="search-icon-left input-icon-addon fas fa-search"></i>
|
||||||
@@ -342,7 +345,7 @@ class Search extends Component {
|
|||||||
type="text"
|
type="text"
|
||||||
className="form-control search-input"
|
className="form-control search-input"
|
||||||
name="query"
|
name="query"
|
||||||
placeholder={this.props.placeholder}
|
placeholder={placeholder}
|
||||||
style={style}
|
style={style}
|
||||||
value={this.state.value}
|
value={this.state.value}
|
||||||
onFocus={this.onFocusHandler}
|
onFocus={this.onFocusHandler}
|
||||||
|
@@ -18,20 +18,20 @@ const propTypes = {
|
|||||||
class CommonToolbar extends React.Component {
|
class CommonToolbar extends React.Component {
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
let searchPlaceholder = this.props.searchPlaceholder || gettext('Search Files');
|
const { repoID, repoName } = this.props;
|
||||||
return (
|
return (
|
||||||
<div className="common-toolbar">
|
<div className="common-toolbar">
|
||||||
{isPro && (
|
{isPro && (
|
||||||
<Search
|
<Search
|
||||||
repoID={this.props.repoID}
|
repoID={repoID}
|
||||||
placeholder={searchPlaceholder}
|
placeholder={this.props.searchPlaceholder || gettext('Search files')}
|
||||||
onSearchedClick={this.props.onSearchedClick}
|
onSearchedClick={this.props.onSearchedClick}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
{this.props.isLibView && !isPro &&
|
{this.props.isLibView && !isPro &&
|
||||||
<SearchByName
|
<SearchByName
|
||||||
repoID={this.props.repoID}
|
repoID={repoID}
|
||||||
repoName={this.props.repoName}
|
repoName={repoName}
|
||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
<Notification />
|
<Notification />
|
||||||
|
@@ -87,7 +87,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.search-result-container .search-result-list {
|
.search-result-container .search-result-list {
|
||||||
margin: 10px 0;
|
margin: 4px 0;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
list-style: none;
|
list-style: none;
|
||||||
}
|
}
|
||||||
@@ -98,7 +98,7 @@
|
|||||||
|
|
||||||
.search-result-container .search-result-item {
|
.search-result-container .search-result-item {
|
||||||
display: flex;
|
display: flex;
|
||||||
padding: 0.25rem 0;
|
padding: 10px 0 10px 8px;
|
||||||
font-size: 0.8125rem;
|
font-size: 0.8125rem;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
margin-right: 1rem;
|
margin-right: 1rem;
|
||||||
@@ -106,7 +106,7 @@
|
|||||||
|
|
||||||
.search-result-container .search-result-item:hover {
|
.search-result-container .search-result-item:hover {
|
||||||
background-color: #f0f0f0;
|
background-color: #f0f0f0;
|
||||||
border-radius: 5px;
|
border-radius: 4px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.search-result-item .item-img {
|
.search-result-item .item-img {
|
||||||
|
@@ -80,7 +80,13 @@ class LibContentToolbar extends React.Component {
|
|||||||
/>
|
/>
|
||||||
<ViewModeToolbar currentMode={this.props.currentMode} switchViewMode={this.props.switchViewMode} isCustomPermission={isCustomPermission} />
|
<ViewModeToolbar currentMode={this.props.currentMode} switchViewMode={this.props.switchViewMode} isCustomPermission={isCustomPermission} />
|
||||||
</div>
|
</div>
|
||||||
<CommonToolbar isLibView={true} repoID={this.props.repoID} repoName={this.props.repoName} onSearchedClick={this.props.onSearchedClick} searchPlaceholder={gettext('Search files in this library')}/>
|
<CommonToolbar
|
||||||
|
isLibView={true}
|
||||||
|
repoID={this.props.repoID}
|
||||||
|
repoName={this.props.repoName}
|
||||||
|
onSearchedClick={this.props.onSearchedClick}
|
||||||
|
searchPlaceholder={gettext('Search files')}
|
||||||
|
/>
|
||||||
</Fragment>
|
</Fragment>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -132,7 +138,13 @@ class LibContentToolbar extends React.Component {
|
|||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
<CommonToolbar isLibView={true} repoID={this.props.repoID} repoName={this.props.repoName} onSearchedClick={this.props.onSearchedClick} searchPlaceholder={gettext('Search files in this library')}/>
|
<CommonToolbar
|
||||||
|
isLibView={true}
|
||||||
|
repoID={this.props.repoID}
|
||||||
|
repoName={this.props.repoName}
|
||||||
|
onSearchedClick={this.props.onSearchedClick}
|
||||||
|
searchPlaceholder={gettext('Search files')}
|
||||||
|
/>
|
||||||
</Fragment>
|
</Fragment>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@@ -300,7 +300,7 @@ class SearchViewPanel extends React.Component {
|
|||||||
name="query"
|
name="query"
|
||||||
autoComplete="off"
|
autoComplete="off"
|
||||||
value={this.state.q}
|
value={this.state.q}
|
||||||
placeholder={gettext('Search Files')}
|
placeholder={gettext('Search files')}
|
||||||
onChange={this.handleSearchInput}
|
onChange={this.handleSearchInput}
|
||||||
onKeyDown={this.handleKeyDown}
|
onKeyDown={this.handleKeyDown}
|
||||||
/>
|
/>
|
||||||
|
@@ -78,9 +78,7 @@ class MainPanel extends Component {
|
|||||||
|
|
||||||
render() {
|
render() {
|
||||||
let { onSearchedClick } = this.props;
|
let { onSearchedClick } = this.props;
|
||||||
let searchPlaceholder = gettext('Search files in this library');
|
|
||||||
const errMessage = (<div className="message err-tip">{gettext('Folder does not exist.')}</div>);
|
const errMessage = (<div className="message err-tip">{gettext('Folder does not exist.')}</div>);
|
||||||
|
|
||||||
const isViewingFile = this.props.pathExist && !this.props.isDataLoading && this.props.isViewFile;
|
const isViewingFile = this.props.pathExist && !this.props.isDataLoading && this.props.isViewFile;
|
||||||
return (
|
return (
|
||||||
<div className="main-panel wiki-main-panel">
|
<div className="main-panel wiki-main-panel">
|
||||||
@@ -93,7 +91,7 @@ class MainPanel extends Component {
|
|||||||
</div>
|
</div>
|
||||||
<div className="common-toolbar">
|
<div className="common-toolbar">
|
||||||
{isPro && (
|
{isPro && (
|
||||||
<Search isPublic={true} repoID={repoID} onSearchedClick={onSearchedClick} placeholder={searchPlaceholder}/>
|
<Search isPublic={true} repoID={repoID} onSearchedClick={onSearchedClick} placeholder={gettext('Search files')}/>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</Fragment>
|
</Fragment>
|
||||||
@@ -110,7 +108,7 @@ class MainPanel extends Component {
|
|||||||
</div>
|
</div>
|
||||||
<div className="common-toolbar">
|
<div className="common-toolbar">
|
||||||
{isPro && (
|
{isPro && (
|
||||||
<Search isPublic={true} repoID={repoID} onSearchedClick={onSearchedClick} placeholder={searchPlaceholder}/>
|
<Search isPublic={true} repoID={repoID} onSearchedClick={onSearchedClick} placeholder={gettext('Search files')}/>
|
||||||
)}
|
)}
|
||||||
<Notification />
|
<Notification />
|
||||||
<Account />
|
<Account />
|
||||||
|
Reference in New Issue
Block a user