Merge pull request #10348 from overleaf/mj-outline-fixes-redo

[cm6] File outline improvements

GitOrigin-RevId: 9f4859cb35476d4baf0b3e3c2c2cb5d1678fd4a8
This commit is contained in:
Mathias Jakobsen 2022-11-08 16:45:19 +00:00 committed by Copybot
parent f803563673
commit 8ddfd958d2
6 changed files with 56 additions and 0 deletions

View file

@ -438,6 +438,7 @@
"owner": "",
"page_current": "",
"pagination_navigation": "",
"partial_outline_warning": "",
"password": "",
"password_managed_externally": "",
"pdf_compile_in_progress_error": "",

View file

@ -8,6 +8,7 @@ import Icon from '../../../shared/components/icon'
import localStorage from '../../../infrastructure/local-storage'
import withErrorBoundary from '../../../infrastructure/error-boundary'
import { useProjectContext } from '../../../shared/context/project-context'
import Tooltip from '../../../shared/components/tooltip'
const OutlinePane = React.memo(function OutlinePane({
isTexFile,
@ -17,6 +18,7 @@ const OutlinePane = React.memo(function OutlinePane({
eventTracking,
highlightedLine,
show,
isPartial = false,
}) {
const { t } = useTranslation()
@ -67,6 +69,20 @@ const OutlinePane = React.memo(function OutlinePane({
className="outline-caret-icon"
/>
<h4 className="outline-header-name">{t('file_outline')}</h4>
{isPartial && (
<Tooltip
id="partial-outline"
description={t('partial_outline_warning')}
overlayProps={{ placement: 'top' }}
>
<span role="status">
<Icon
type="exclamation-triangle"
aria-label={t('partial_outline_warning')}
/>
</span>
</Tooltip>
)}
</button>
</header>
{expanded && isTexFile ? (
@ -90,6 +106,7 @@ OutlinePane.propTypes = {
eventTracking: PropTypes.object.isRequired,
highlightedLine: PropTypes.number,
show: PropTypes.bool.isRequired,
isPartial: PropTypes.bool,
}
export default withErrorBoundary(OutlinePane)

View file

@ -43,6 +43,7 @@ export default BinaryFilesManager = class BinaryFilesManager {
this.$scope.$apply()
this.$scope.$broadcast('file-view:file-opened')
window.dispatchEvent(new Event('file-view:file-opened'))
},
0,
this

View file

@ -39,6 +39,11 @@ NonTexFile.args = {
isTexFile: false,
}
export const PartialResult = args => <OutlinePane {...args} />
PartialResult.args = {
isPartial: true,
}
export default {
title: 'Editor / Outline',
component: OutlinePane,

View file

@ -76,6 +76,7 @@
"expand": "Expand",
"collapse": "Collapse",
"file_outline": "File outline",
"partial_outline_warning": "The File outline is out of date. It will update itself as you edit the document",
"we_cant_find_any_sections_or_subsections_in_this_file": "We cant find any sections or subsections in this file",
"find_out_more_about_the_file_outline": "Find out more about the file outline",
"invalid_institutional_email": "Your institutions SSO service returned your email address as __email__, which is at an unexpected domain that we do not recognise as belonging to it. You may be able to change your primary email address via your user profile at your institution to one at your institutions domain. Please contact your IT department if you have any questions.",

View file

@ -115,4 +115,35 @@ describe('<OutlinePane />', function () {
expect(global.localStorage.setItem).to.be.calledWithMatch(/123abc/, 'true')
expect(onToggle).to.be.calledTwice
})
it('shows warning on partial result', function () {
render(
<OutlinePane
isTexFile
outline={[]}
jumpToLine={jumpToLine}
onToggle={onToggle}
eventTracking={eventTracking}
show
isPartial
/>
)
expect(screen.queryByRole('status')).to.exist
})
it('shows no warning on non-partial result', function () {
render(
<OutlinePane
isTexFile
outline={[]}
jumpToLine={jumpToLine}
onToggle={onToggle}
eventTracking={eventTracking}
show
isPartial={false}
/>
)
expect(screen.queryByRole('status')).to.not.exist
})
})