2018-09-19 21:19:11 -05:00
|
|
|
import React from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
2020-03-25 20:20:56 +08:00
|
|
|
import { isPro, gettext, showLogoutIcon } from '../../utils/constants';
|
2018-09-19 21:19:11 -05:00
|
|
|
import Search from '../search/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,
|
|
|
|
searchPlaceholder: PropTypes.string
|
2018-09-19 21:19:11 -05:00
|
|
|
};
|
|
|
|
|
2020-11-16 10:45:19 +08:00
|
|
|
class CommonToolbar extends React.Component {
|
|
|
|
|
2018-09-19 21:19:11 -05:00
|
|
|
render() {
|
2023-10-09 17:32:13 +08:00
|
|
|
const { repoID, repoName } = this.props;
|
2018-09-19 21:19:11 -05:00
|
|
|
return (
|
|
|
|
<div className="common-toolbar">
|
2018-11-28 12:41:49 +08:00
|
|
|
{isPro && (
|
2020-11-02 13:56:35 +08:00
|
|
|
<Search
|
2023-10-09 17:32:13 +08:00
|
|
|
repoID={repoID}
|
|
|
|
placeholder={this.props.searchPlaceholder || gettext('Search files')}
|
2020-11-02 13:56:35 +08:00
|
|
|
onSearchedClick={this.props.onSearchedClick}
|
2018-11-28 12:41:49 +08:00
|
|
|
/>
|
|
|
|
)}
|
2020-11-16 10:45:19 +08:00
|
|
|
{this.props.isLibView && !isPro &&
|
|
|
|
<SearchByName
|
2023-10-09 17:32:13 +08:00
|
|
|
repoID={repoID}
|
|
|
|
repoName={repoName}
|
2020-11-16 10:45:19 +08:00
|
|
|
/>
|
|
|
|
}
|
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;
|