[web] Hide docx import behind setting (#32499)

GitOrigin-RevId: 72406af0ea7dffac579991acc114e43ceed03a50
This commit is contained in:
Mathias Jakobsen
2026-03-27 13:04:30 +00:00
committed by Copybot
parent a1bd2e9b93
commit 9542334fef
9 changed files with 41 additions and 9 deletions

View File

@@ -26,13 +26,15 @@ export default {
ProjectUploadController.uploadProject
)
webRouter.post(
'/project/new/import-docx',
AuthenticationController.requireLogin(),
RateLimiterMiddleware.rateLimit(rateLimiters.projectUpload),
ProjectUploadController.multerMiddleware,
ProjectUploadController.importDocx
)
if (Settings.enablePandocConversions) {
webRouter.post(
'/project/new/import-docx',
AuthenticationController.requireLogin(),
RateLimiterMiddleware.rateLimit(rateLimiters.projectUpload),
ProjectUploadController.multerMiddleware,
ProjectUploadController.importDocx
)
}
const fileUploadEndpoint = '/Project/:Project_id/upload'
const fileUploadRateLimit = RateLimiterMiddleware.rateLimit(

View File

@@ -417,6 +417,7 @@ export default async function (webRouter, privateApiRouter, publicApiRouter) {
cioWriteKey: Settings.analytics?.cio?.writeKey,
cioSiteId: Settings.analytics?.cio?.siteId,
linkedInInsightsPartnerId: Settings.analytics?.linkedIn?.partnerId,
enablePandocConversions: Settings.enablePandocConversions,
}
next()
})

View File

@@ -1104,6 +1104,8 @@ module.exports = {
managedUsers: {
enabled: false,
},
enablePandocConversions: process.env.ENABLE_PANDOC_CONVERSIONS === 'true',
}
module.exports.mergeWith = function (overrides) {

View File

@@ -9,6 +9,7 @@ export function resetMeta() {
hasLinkedProjectFileFeature: true,
hasLinkedProjectOutputFileFeature: true,
hasLinkUrlFeature: true,
enablePandocConversions: true,
})
}

View File

@@ -50,3 +50,4 @@ DEVICE_HISTORY_SECRET=1b46e6cdf72db02845da06c9517c9cfbbfa0d87357479f4e1df3ce160b
QUEUE_PROCESSING_ENABLED=true
CURRENT_IMAGE_NAME=texlive-full:2025.1
ALLOWED_IMAGE_NAMES=[{"imageName":"texlive-full:2025.1","imageDesc":"2025"},{"imageName":"wl_texlive:2018.1","imageDesc":"2018"}]
ENABLE_PANDOC_CONVERSIONS=true

View File

@@ -58,7 +58,9 @@ function NewProjectButton({
const portalTemplates = getMeta('ol-portalTemplates') || []
const { show: enableAddAffiliationWidget } = useAddAffiliation()
const sendProjectListMB = useSendProjectListMB()
const docxImportEnabled = useFeatureFlag('import-docx')
const docxImportEnabled =
useFeatureFlag('import-docx') &&
getMeta('ol-ExposedSettings').enablePandocConversions
const sendTrackingEvent = useCallback(
({
dropdownMenu,

View File

@@ -60,7 +60,9 @@ function WelcomeMessageCreateNewProjectDropdown({
}: WelcomeMessageCreateNewProjectDropdownProps) {
const { t } = useTranslation()
const portalTemplates = getMeta('ol-portalTemplates') || []
const docxImportEnabled = useFeatureFlag('import-docx')
const docxImportEnabled =
useFeatureFlag('import-docx') &&
getMeta('ol-ExposedSettings').enablePandocConversions
const { isOverleaf } = getMeta('ol-ExposedSettings')

View File

@@ -14,10 +14,15 @@ const WelcomeMessage = () => {
describe('<WelcomeMessage />', function () {
beforeEach(function () {
window.metaAttributesCache.set('ol-splitTestVariants', {
'import-docx': 'enabled',
})
Object.assign(getMeta('ol-ExposedSettings'), {
isOverleaf: true,
wikiEnabled: true,
templatesEnabled: true,
enablePandocConversions: true,
})
})
@@ -42,9 +47,24 @@ describe('<WelcomeMessage />', function () {
screen.getByText('Blank project')
screen.getByText('Example project')
screen.getByText('Upload project')
screen.getByText('Import Word document')
screen.getByText('Import from GitHub')
})
it('does not show the import from Word document when the feature is disabled', function () {
getMeta('ol-ExposedSettings').enablePandocConversions = false
render(<WelcomeMessage />)
const button = screen.getByRole('button', {
name: 'Create a new project',
})
fireEvent.click(button)
screen.getByText('Blank project')
expect(screen.queryByText('Import Word document')).to.not.exist
})
it('show the correct dropdown menu for affiliated users', function () {
window.metaAttributesCache.set('ol-portalTemplates', [
{

View File

@@ -51,4 +51,5 @@ export type ExposedSettings = {
wikiEnabled?: boolean
templatesEnabled?: boolean
linkedInInsightsPartnerId?: string
enablePandocConversions: boolean
}