2021-01-27 05:30:55 -05:00
|
|
|
import React from 'react'
|
|
|
|
import PropTypes from 'prop-types'
|
2021-11-03 09:21:14 -04:00
|
|
|
import { useTranslation } from 'react-i18next'
|
2021-01-27 05:30:55 -05:00
|
|
|
import MenuButton from './menu-button'
|
|
|
|
import CobrandingLogo from './cobranding-logo'
|
|
|
|
import BackToProjectsButton from './back-to-projects-button'
|
2022-04-27 11:12:04 -04:00
|
|
|
import UpgradePrompt from './upgrade-prompt'
|
2021-02-09 10:37:48 -05:00
|
|
|
import ChatToggleButton from './chat-toggle-button'
|
2021-11-03 09:21:14 -04:00
|
|
|
import LayoutDropdownButton from './layout-dropdown-button'
|
2021-02-10 05:57:25 -05:00
|
|
|
import OnlineUsersWidget from './online-users-widget'
|
2021-03-10 07:19:54 -05:00
|
|
|
import ProjectNameEditableLabel from './project-name-editable-label'
|
2021-02-23 05:17:41 -05:00
|
|
|
import TrackChangesToggleButton from './track-changes-toggle-button'
|
|
|
|
import HistoryToggleButton from './history-toggle-button'
|
2021-03-10 07:19:54 -05:00
|
|
|
import ShareProjectButton from './share-project-button'
|
2021-04-19 08:38:03 -04:00
|
|
|
import importOverleafModules from '../../../../macros/import-overleaf-module.macro'
|
2024-04-30 09:40:06 -04:00
|
|
|
import BackToEditorButton from './back-to-editor-button'
|
2024-06-18 06:01:37 -04:00
|
|
|
import getMeta from '@/utils/meta'
|
2021-04-19 08:38:03 -04:00
|
|
|
|
|
|
|
const [publishModalModules] = importOverleafModules('publishModal')
|
|
|
|
const PublishButton = publishModalModules?.import.default
|
2021-01-27 05:30:55 -05:00
|
|
|
|
2021-06-21 06:02:38 -04:00
|
|
|
const ToolbarHeader = React.memo(function ToolbarHeader({
|
2021-02-09 10:37:48 -05:00
|
|
|
cobranding,
|
|
|
|
onShowLeftMenuClick,
|
|
|
|
chatIsOpen,
|
|
|
|
toggleChatOpen,
|
2021-02-23 05:17:41 -05:00
|
|
|
reviewPanelOpen,
|
|
|
|
toggleReviewPanelOpen,
|
|
|
|
historyIsOpen,
|
|
|
|
toggleHistoryOpen,
|
2021-02-10 05:57:25 -05:00
|
|
|
unreadMessageCount,
|
|
|
|
onlineUsers,
|
2021-02-23 05:17:41 -05:00
|
|
|
goToUser,
|
2021-03-10 07:19:54 -05:00
|
|
|
isRestrictedTokenMember,
|
2021-06-30 07:03:29 -04:00
|
|
|
hasPublishPermissions,
|
2024-06-25 08:02:30 -04:00
|
|
|
chatVisible,
|
2021-03-10 07:19:54 -05:00
|
|
|
projectName,
|
|
|
|
renameProject,
|
2021-06-25 04:14:07 -04:00
|
|
|
hasRenamePermissions,
|
2021-03-10 07:19:54 -05:00
|
|
|
openShareModal,
|
2021-08-11 04:50:07 -04:00
|
|
|
trackChangesVisible,
|
2021-02-09 10:37:48 -05:00
|
|
|
}) {
|
2021-11-03 09:21:14 -04:00
|
|
|
const { t } = useTranslation()
|
2021-06-30 07:03:29 -04:00
|
|
|
const shouldDisplayPublishButton = hasPublishPermissions && PublishButton
|
2021-06-17 07:50:29 -04:00
|
|
|
|
2021-01-27 05:30:55 -05:00
|
|
|
return (
|
2021-11-03 09:21:14 -04:00
|
|
|
<header
|
|
|
|
className="toolbar toolbar-header toolbar-with-labels"
|
|
|
|
role="navigation"
|
|
|
|
aria-label={t('project_layout_sharing_submission')}
|
|
|
|
>
|
2021-01-27 05:30:55 -05:00
|
|
|
<div className="toolbar-left">
|
|
|
|
<MenuButton onClick={onShowLeftMenuClick} />
|
2021-08-03 06:02:09 -04:00
|
|
|
{cobranding && cobranding.logoImgUrl && (
|
|
|
|
<CobrandingLogo {...cobranding} />
|
|
|
|
)}
|
2021-01-27 05:30:55 -05:00
|
|
|
<BackToProjectsButton />
|
|
|
|
</div>
|
2024-06-18 06:01:37 -04:00
|
|
|
{getMeta('ol-showUpgradePrompt') && <UpgradePrompt />}
|
2021-03-10 07:19:54 -05:00
|
|
|
<ProjectNameEditableLabel
|
|
|
|
className="toolbar-center"
|
|
|
|
projectName={projectName}
|
2021-06-25 04:14:07 -04:00
|
|
|
hasRenamePermissions={hasRenamePermissions}
|
2021-03-10 07:19:54 -05:00
|
|
|
onChange={renameProject}
|
|
|
|
/>
|
|
|
|
|
2021-02-09 10:37:48 -05:00
|
|
|
<div className="toolbar-right">
|
2021-02-10 05:57:25 -05:00
|
|
|
<OnlineUsersWidget onlineUsers={onlineUsers} goToUser={goToUser} />
|
2021-04-19 08:38:03 -04:00
|
|
|
|
2024-04-30 09:40:06 -04:00
|
|
|
{historyIsOpen ? (
|
|
|
|
<BackToEditorButton onClick={toggleHistoryOpen} />
|
|
|
|
) : (
|
|
|
|
<>
|
|
|
|
{trackChangesVisible && (
|
|
|
|
<TrackChangesToggleButton
|
|
|
|
onMouseDown={toggleReviewPanelOpen}
|
|
|
|
disabled={historyIsOpen}
|
|
|
|
trackChangesIsOpen={reviewPanelOpen}
|
|
|
|
/>
|
|
|
|
)}
|
2021-11-30 09:54:14 -05:00
|
|
|
|
2024-04-30 09:40:06 -04:00
|
|
|
<ShareProjectButton onClick={openShareModal} />
|
|
|
|
{shouldDisplayPublishButton && (
|
|
|
|
<PublishButton cobranding={cobranding} />
|
|
|
|
)}
|
2021-11-30 09:54:14 -05:00
|
|
|
|
2024-04-30 09:40:06 -04:00
|
|
|
{!isRestrictedTokenMember && (
|
|
|
|
<HistoryToggleButton onClick={toggleHistoryOpen} />
|
|
|
|
)}
|
2021-11-30 09:54:14 -05:00
|
|
|
|
2024-04-30 09:40:06 -04:00
|
|
|
<LayoutDropdownButton />
|
2021-11-30 09:54:14 -05:00
|
|
|
|
2024-06-25 08:02:30 -04:00
|
|
|
{chatVisible && (
|
2024-04-30 09:40:06 -04:00
|
|
|
<ChatToggleButton
|
|
|
|
chatIsOpen={chatIsOpen}
|
|
|
|
onClick={toggleChatOpen}
|
|
|
|
unreadMessageCount={unreadMessageCount}
|
|
|
|
/>
|
|
|
|
)}
|
|
|
|
</>
|
2021-02-23 05:17:41 -05:00
|
|
|
)}
|
2021-02-09 10:37:48 -05:00
|
|
|
</div>
|
2021-01-27 05:30:55 -05:00
|
|
|
</header>
|
|
|
|
)
|
2021-06-21 06:02:38 -04:00
|
|
|
})
|
2021-01-27 05:30:55 -05:00
|
|
|
|
|
|
|
ToolbarHeader.propTypes = {
|
|
|
|
onShowLeftMenuClick: PropTypes.func.isRequired,
|
2021-02-09 10:37:48 -05:00
|
|
|
cobranding: PropTypes.object,
|
|
|
|
chatIsOpen: PropTypes.bool,
|
|
|
|
toggleChatOpen: PropTypes.func.isRequired,
|
2021-02-23 05:17:41 -05:00
|
|
|
reviewPanelOpen: PropTypes.bool,
|
|
|
|
toggleReviewPanelOpen: PropTypes.func.isRequired,
|
|
|
|
historyIsOpen: PropTypes.bool,
|
|
|
|
toggleHistoryOpen: PropTypes.func.isRequired,
|
2021-02-10 05:57:25 -05:00
|
|
|
unreadMessageCount: PropTypes.number.isRequired,
|
|
|
|
onlineUsers: PropTypes.array.isRequired,
|
2021-02-23 05:17:41 -05:00
|
|
|
goToUser: PropTypes.func.isRequired,
|
2021-03-10 07:19:54 -05:00
|
|
|
isRestrictedTokenMember: PropTypes.bool,
|
2021-06-30 07:03:29 -04:00
|
|
|
hasPublishPermissions: PropTypes.bool,
|
2024-06-25 08:02:30 -04:00
|
|
|
chatVisible: PropTypes.bool,
|
2021-03-10 07:19:54 -05:00
|
|
|
projectName: PropTypes.string.isRequired,
|
|
|
|
renameProject: PropTypes.func.isRequired,
|
2021-06-25 04:14:07 -04:00
|
|
|
hasRenamePermissions: PropTypes.bool,
|
2021-03-10 07:19:54 -05:00
|
|
|
openShareModal: PropTypes.func.isRequired,
|
2021-08-11 04:50:07 -04:00
|
|
|
trackChangesVisible: PropTypes.bool,
|
2021-01-27 05:30:55 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
export default ToolbarHeader
|