mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-06-10 22:50:46 +02:00
If reviwer, show only from project files option in figure modal (#23500)
GitOrigin-RevId: 88796fb9a51f82ac79bc849ef9225efcdf29ad35
This commit is contained in:
committed by
Copybot
parent
9b24600b62
commit
8801e8de71
+20
-13
@@ -9,6 +9,7 @@ import getMeta from '@/utils/meta'
|
||||
import MaterialIcon from '@/shared/components/material-icon'
|
||||
import BootstrapVersionSwitcher from '@/features/ui/components/bootstrap-5/bootstrap-version-switcher'
|
||||
import { bsVersion } from '@/features/utils/bootstrap-5'
|
||||
import { usePermissionsContext } from '@/features/ide-react/context/permissions-context'
|
||||
|
||||
export const FigureModalSourcePicker: FC = () => {
|
||||
const { t } = useTranslation()
|
||||
@@ -17,26 +18,32 @@ export const FigureModalSourcePicker: FC = () => {
|
||||
hasLinkedProjectOutputFileFeature,
|
||||
hasLinkUrlFeature,
|
||||
} = getMeta('ol-ExposedSettings')
|
||||
|
||||
const { write } = usePermissionsContext()
|
||||
|
||||
return (
|
||||
<div className="figure-modal-source-button-grid">
|
||||
<FigureModalSourceButton
|
||||
type={FigureModalSource.FILE_UPLOAD}
|
||||
title={t('replace_from_computer')}
|
||||
icon={bsVersion({ bs3: 'upload', bs5: 'upload' })}
|
||||
/>
|
||||
{write && (
|
||||
<FigureModalSourceButton
|
||||
type={FigureModalSource.FILE_UPLOAD}
|
||||
title={t('replace_from_computer')}
|
||||
icon={bsVersion({ bs3: 'upload', bs5: 'upload' })}
|
||||
/>
|
||||
)}
|
||||
<FigureModalSourceButton
|
||||
type={FigureModalSource.FILE_TREE}
|
||||
title={t('replace_from_project_files')}
|
||||
icon={bsVersion({ bs3: 'archive', bs5: 'inbox' })}
|
||||
/>
|
||||
{(hasLinkedProjectFileFeature || hasLinkedProjectOutputFileFeature) && (
|
||||
<FigureModalSourceButton
|
||||
type={FigureModalSource.OTHER_PROJECT}
|
||||
title={t('replace_from_another_project')}
|
||||
icon={bsVersion({ bs3: 'folder-open', bs5: 'folder_open' })}
|
||||
/>
|
||||
)}
|
||||
{hasLinkUrlFeature && (
|
||||
{write &&
|
||||
(hasLinkedProjectFileFeature || hasLinkedProjectOutputFileFeature) && (
|
||||
<FigureModalSourceButton
|
||||
type={FigureModalSource.OTHER_PROJECT}
|
||||
title={t('replace_from_another_project')}
|
||||
icon={bsVersion({ bs3: 'folder-open', bs5: 'folder_open' })}
|
||||
/>
|
||||
)}
|
||||
{write && hasLinkUrlFeature && (
|
||||
<FigureModalSourceButton
|
||||
type={FigureModalSource.FROM_URL}
|
||||
title={t('replace_from_url')}
|
||||
|
||||
+17
@@ -10,10 +10,13 @@ import { emitToolbarEvent } from '../../extensions/toolbar/utils/analytics'
|
||||
import { useCodeMirrorViewContext } from '../codemirror-context'
|
||||
import { insertFigure } from '../../extensions/toolbar/commands'
|
||||
import getMeta from '@/utils/meta'
|
||||
import { usePermissionsContext } from '@/features/ide-react/context/permissions-context'
|
||||
import { ToolbarButton } from './toolbar-button'
|
||||
|
||||
export const InsertFigureDropdown = memo(function InsertFigureDropdown() {
|
||||
const { t } = useTranslation()
|
||||
const view = useCodeMirrorViewContext()
|
||||
const { write } = usePermissionsContext()
|
||||
const openFigureModal = useCallback(
|
||||
(source: FigureModalSource, sourceName: string) => {
|
||||
emitToolbarEvent(view, `toolbar-figure-modal-${sourceName}`)
|
||||
@@ -30,6 +33,20 @@ export const InsertFigureDropdown = memo(function InsertFigureDropdown() {
|
||||
hasLinkedProjectOutputFileFeature,
|
||||
hasLinkUrlFeature,
|
||||
} = getMeta('ol-ExposedSettings')
|
||||
|
||||
if (!write) {
|
||||
return (
|
||||
<ToolbarButton
|
||||
id="toolbar-figure"
|
||||
label={t('toolbar_insert_figure')}
|
||||
command={() =>
|
||||
openFigureModal(FigureModalSource.FILE_TREE, 'current-project')
|
||||
}
|
||||
icon="add_photo_alternate"
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
<ToolbarButtonMenu
|
||||
id="toolbar-figure"
|
||||
|
||||
Reference in New Issue
Block a user