🚩(frontend) Add feature flag for document import

We want to be able to enable/disable the document
import feature for testing and gradual rollout
purposes. This commit adds a feature flag for
document import and updates the relevant components
and tests to respect this flag.
This commit is contained in:
Anthony LC 2026-03-30 12:02:18 +02:00 committed by Manuel Raynaud
parent f4ded8ee55
commit f166e75921
No known key found for this signature in database
GPG key ID: 3F45EEDEBF44E874
6 changed files with 27 additions and 4 deletions

View file

@ -102,3 +102,5 @@ SEARCH_INDEXER_SECRET=find-api-key-for-docs-with-exactly-50-chars-length # Key
INDEXING_URL=http://find:8000/api/v1.0/documents/index/
SEARCH_URL=http://find:8000/api/v1.0/documents/search/
SEARCH_INDEXER_QUERY_LIMIT=50
CONVERSION_UPLOAD_ENABLED=true

View file

@ -3,6 +3,7 @@ import path from 'path';
import { Page, expect, test } from '@playwright/test';
import { overrideConfig } from './utils-common';
import { getEditor } from './utils-editor';
test.beforeEach(async ({ page }) => {
@ -10,6 +11,16 @@ test.beforeEach(async ({ page }) => {
});
test.describe('Doc Import', () => {
test('import is not enabled if flag is disabled', async ({ page }) => {
await overrideConfig(page, {
CONVERSION_UPLOAD_ENABLED: false,
});
await page.goto('/');
await expect(page.getByLabel('Open the upload dialog')).toBeHidden();
});
test('it imports 2 docs with the import icon', async ({ page }) => {
const fileChooserPromise = page.waitForEvent('filechooser');
await page.getByLabel('Open the upload dialog').click();

View file

@ -20,6 +20,7 @@ export const CONFIG = {
CRISP_WEBSITE_ID: null,
COLLABORATION_WS_URL: 'ws://localhost:4444/collaboration/ws/',
COLLABORATION_WS_NOT_CONNECTED_READY_ONLY: true,
CONVERSION_UPLOAD_ENABLED: true,
CONVERSION_FILE_EXTENSIONS_ALLOWED: ['.docx', '.md'],
CONVERSION_FILE_MAX_SIZE: 20971520,
ENVIRONMENT: 'development',

View file

@ -40,6 +40,7 @@ export interface ConfigResponse {
COLLABORATION_WS_NOT_CONNECTED_READY_ONLY?: boolean;
CONVERSION_FILE_EXTENSIONS_ALLOWED: string[];
CONVERSION_FILE_MAX_SIZE: number;
CONVERSION_UPLOAD_ENABLED?: boolean;
CRISP_WEBSITE_ID?: string;
ENVIRONMENT: string;
FRONTEND_CSS_URL?: string;

View file

@ -44,6 +44,7 @@ export const DocsGrid = ({
getInputProps,
open,
isPending: isImportPending,
isEnabled: isImportEnabled,
} = useImport({
onDragOver: (dragOver: boolean) => {
setIsDragOver(dragOver);
@ -51,9 +52,10 @@ export const DocsGrid = ({
});
const withUpload =
!target ||
(!target ||
target === DocDefaultFilter.ALL_DOCS ||
target === DocDefaultFilter.MY_DOCS;
target === DocDefaultFilter.MY_DOCS) &&
isImportEnabled;
const { isDesktop } = useResponsiveStore();
const { flexLeft, flexRight } = useResponsiveDocGrid();

View file

@ -112,5 +112,11 @@ export const useImport = ({ onDragOver }: UseImportProps) => {
});
const { mutate: importDoc, isPending } = useImportDoc();
return { getRootProps, getInputProps, open, isPending };
return {
getRootProps,
getInputProps,
open,
isEnabled: config?.CONVERSION_UPLOAD_ENABLED || false,
isPending,
};
};