2018-09-19 21:19:11 -05:00
|
|
|
import React from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
2023-11-20 18:22:01 +08:00
|
|
|
import { isPro, gettext, showLogoutIcon, enableSeafileAI } from '../../utils/constants';
|
2018-09-19 21:19:11 -05:00
|
|
|
import Search from '../search/search';
|
2023-11-20 18:22:01 +08:00
|
|
|
import AISearch from '../search/ai-search';
|
2020-11-16 10:45:19 +08:00
|
|
|
import SearchByName from '../search/search-by-name';
|
2018-09-19 21:19:11 -05:00
|
|
|
import Notification from '../common/notification';
|
|
|
|
import Account from '../common/account';
|
2020-03-25 18:03:04 +08:00
|
|
|
import Logout from '../common/logout';
|
2018-09-19 21:19:11 -05:00
|
|
|
|
|
|
|
const propTypes = {
|
2018-12-07 10:36:59 +08:00
|
|
|
repoID: PropTypes.string,
|
2020-11-16 10:45:19 +08:00
|
|
|
repoName: PropTypes.string,
|
|
|
|
isLibView: PropTypes.bool,
|
2018-09-25 09:13:06 +08:00
|
|
|
onSearchedClick: PropTypes.func.isRequired,
|
2024-01-09 18:23:11 +08:00
|
|
|
searchPlaceholder: PropTypes.string,
|
|
|
|
currentRepoInfo: PropTypes.object,
|
2018-09-19 21:19:11 -05:00
|
|
|
};
|
|
|
|
|
2020-11-16 10:45:19 +08:00
|
|
|
class CommonToolbar extends React.Component {
|
|
|
|
|
2023-11-20 18:22:01 +08:00
|
|
|
renderSearch = () => {
|
|
|
|
const { repoID, repoName, isLibView, searchPlaceholder } = this.props;
|
|
|
|
const placeholder = searchPlaceholder || gettext('Search files');
|
|
|
|
|
|
|
|
if (isPro) {
|
|
|
|
if (enableSeafileAI && isLibView) {
|
|
|
|
return (
|
|
|
|
<AISearch
|
2023-10-09 17:32:13 +08:00
|
|
|
repoID={repoID}
|
2023-11-20 18:22:01 +08:00
|
|
|
placeholder={placeholder}
|
2020-11-02 13:56:35 +08:00
|
|
|
onSearchedClick={this.props.onSearchedClick}
|
2023-10-21 11:38:12 +08:00
|
|
|
repoName={repoName}
|
2024-01-09 18:23:11 +08:00
|
|
|
currentRepoInfo={this.props.currentRepoInfo}
|
2018-11-28 12:41:49 +08:00
|
|
|
/>
|
2023-11-20 18:22:01 +08:00
|
|
|
);
|
|
|
|
} else {
|
|
|
|
return (
|
|
|
|
<Search
|
2023-10-09 17:32:13 +08:00
|
|
|
repoID={repoID}
|
2023-11-20 18:22:01 +08:00
|
|
|
placeholder={placeholder}
|
|
|
|
onSearchedClick={this.props.onSearchedClick}
|
|
|
|
isPublic={false}
|
2020-11-16 10:45:19 +08:00
|
|
|
/>
|
2023-11-20 18:22:01 +08:00
|
|
|
);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (isLibView) {
|
|
|
|
return (
|
|
|
|
<SearchByName repoID={repoID} repoName={repoName} />
|
|
|
|
);
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
render() {
|
|
|
|
return (
|
|
|
|
<div className="common-toolbar">
|
|
|
|
{this.renderSearch()}
|
2019-12-31 16:58:45 +08:00
|
|
|
<Notification />
|
2018-09-19 21:19:11 -05:00
|
|
|
<Account />
|
2020-03-25 20:20:56 +08:00
|
|
|
{showLogoutIcon && (<Logout />)}
|
2018-09-19 21:19:11 -05:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
CommonToolbar.propTypes = propTypes;
|
|
|
|
|
2019-12-31 16:58:45 +08:00
|
|
|
export default CommonToolbar;
|