mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-15 06:33:55 +01:00
[web] Consolidate ide settings in `features/ide-settings` GitOrigin-RevId: cbf0ff069399f418d8cb0d8165628df190046ea9
50 lines
1.6 KiB
TypeScript
50 lines
1.6 KiB
TypeScript
import { useProjectSettingsContext } from '@/features/ide-settings/context/project-settings-context'
|
|
import DropdownSetting from '../dropdown-setting'
|
|
import type { Option } from '../dropdown-setting'
|
|
import { useTranslation } from 'react-i18next'
|
|
import { usePermissionsContext } from '@/features/ide-react/context/permissions-context'
|
|
import { useMemo } from 'react'
|
|
import getMeta from '@/utils/meta'
|
|
import { useSetCompilationSettingWithEvent } from '@/features/ide-settings/hooks/use-set-compilation-setting'
|
|
|
|
export default function ImageNameSetting() {
|
|
const { imageName, setImageName } = useProjectSettingsContext()
|
|
const { t } = useTranslation()
|
|
const { write } = usePermissionsContext()
|
|
const changeImageName = useSetCompilationSettingWithEvent(
|
|
'image-name',
|
|
setImageName
|
|
)
|
|
|
|
const imageNames = useMemo(() => getMeta('ol-imageNames') || [], [])
|
|
|
|
const options: Array<Option> = useMemo(
|
|
() =>
|
|
imageNames
|
|
// filter out images that aren't allowed, unless thats the current image the project is on
|
|
.filter(image => image.allowed || image.imageName === imageName)
|
|
.map(({ imageName, imageDesc }) => ({
|
|
value: imageName,
|
|
label: imageDesc,
|
|
})),
|
|
[imageNames, imageName]
|
|
)
|
|
|
|
if (imageNames.length === 0) {
|
|
return null
|
|
}
|
|
|
|
return (
|
|
<DropdownSetting
|
|
id="imageName"
|
|
label={t('tex_live_version')}
|
|
description={t('the_version_of_tex_live_used_for_compiling')}
|
|
disabled={!write}
|
|
options={options}
|
|
onChange={changeImageName}
|
|
value={imageName}
|
|
translateOptions="no"
|
|
/>
|
|
)
|
|
}
|