diff --git a/.env b/.env index 3588a3c..cb4539f 100644 --- a/.env +++ b/.env @@ -1,4 +1,9 @@ VERSION=1 WEB_URL=https://pinmenote.com IS_PRODUCTION=true -OBJ_LIST_LIMIT=100 \ No newline at end of file +OBJ_LIST_LIMIT=100 + +FF_SYNC_ENABLED=0 +FF_LOGIN_ENABLED=0 +FF_NEW_PIN_PREVIEW=0 +FF_REPORT_BUG=0 \ No newline at end of file diff --git a/.env.development b/.env.development index d5842cb..7995d27 100644 --- a/.env.development +++ b/.env.development @@ -1,4 +1,9 @@ VERSION=1 WEB_URL=http://localhost:5173 -IS_PRODUCTION=false -OBJ_LIST_LIMIT=20 \ No newline at end of file +IS_PRODUCTION=1 +OBJ_LIST_LIMIT=20 + +FF_SYNC_ENABLED=0 +FF_LOGIN_ENABLED=0 +FF_NEW_PIN_PREVIEW=0 +FF_REPORT_BUG=0 \ No newline at end of file diff --git a/src/common/environment.ts b/src/common/environment.ts index a739c90..3b901cc 100644 --- a/src/common/environment.ts +++ b/src/common/environment.ts @@ -42,10 +42,18 @@ interface SettingsInterfaceConfig { optionsDrawerOpen?: boolean; } +interface FeatureFlag { + SYNC_ENABLED: boolean; + LOGIN_ENABLED: boolean; + NEW_PIN_PREVIEW: boolean; + REPORT_BUG: boolean; +} + interface EnvironmentConfig { showAckMessage: boolean; defaultServer: string; isProduction: boolean; + featureFlag: FeatureFlag; settings: SettingsConfig; objListLimit: number; } @@ -53,7 +61,13 @@ interface EnvironmentConfig { export const environmentConfig: EnvironmentConfig = { showAckMessage: false, defaultServer: process.env.WEB_URL || 'https://pinmenote.com', - isProduction: process.env.IS_PRODUCTION === 'true', + isProduction: process.env.IS_PRODUCTION === '1', + featureFlag: { + SYNC_ENABLED: process.env.FF_SYNC_ENABLED === '1', + LOGIN_ENABLED: process.env.FF_LOGIN_ENABLED === '1', + NEW_PIN_PREVIEW: process.env.FF_NEW_PIN_PREVIEW === '1', + REPORT_BUG: process.env.FF_REPORT_BUG === '1' + }, settings: { version: parseInt(process.env.VERSION || '1'), screenshotFormat: 'png', @@ -71,5 +85,5 @@ export const environmentConfig: EnvironmentConfig = { pageNote: false } }, - objListLimit: parseInt(process.env.OBJ_LIST_LIMIT || '100000') + objListLimit: parseInt(process.env.OBJ_LIST_LIMIT || '100') }; diff --git a/src/default-popup/components/main/main-footer.button.tsx b/src/default-popup/components/main/main-footer.button.tsx index cd7fd02..b092bfc 100644 --- a/src/default-popup/components/main/main-footer.button.tsx +++ b/src/default-popup/components/main/main-footer.button.tsx @@ -19,12 +19,24 @@ import { BrowserApi } from '@pinmenote/browser-api'; import BugReportIcon from '@mui/icons-material/BugReport'; import Button from '@mui/material/Button'; import IconButton from '@mui/material/IconButton'; +import { environmentConfig } from '../../../common/environment'; interface Props { openBugReport?: () => void; } export const MainFooterButton: FunctionComponent = (props) => { + const reportBugIcon = environmentConfig.featureFlag.REPORT_BUG ? ( + (props.openBugReport ? props.openBugReport() : '')} + > + + + ) : ( + '' + ); return (
= (props) => { justifyContent: 'center' }} > - (props.openBugReport ? props.openBugReport() : '')} - > - - + {reportBugIcon} + ) : ( + '' + ); return (
@@ -88,15 +104,11 @@ export const HtmlPreviewHeaderComponent: FunctionComponent = (props) => {
- + {newPinIcon}
- - - + {syncIcon} diff --git a/src/service-worker/service-worker.ts b/src/service-worker/service-worker.ts index a295114..24223c3 100644 --- a/src/service-worker/service-worker.ts +++ b/src/service-worker/service-worker.ts @@ -43,6 +43,7 @@ import { SyncManualOutgoingCommand } from './command/sync/manual/sync-manual-out import { SyncServerIncomingCommand } from './command/sync/sync-server-incoming.command'; import { SyncGetProgressCommand } from './command/sync/progress/sync-get-progress.command'; import { SyncTxHelper } from './command/sync/sync-tx.helper'; +import { environmentConfig } from '../common/environment'; const handleMessage = async ( msg: BusMessage, @@ -131,14 +132,13 @@ const handleMessage = async ( } } // Sync command - if ( - ![ - PageComputeMessage.CONTENT_FETCH_CSS, - PageComputeMessage.CONTENT_FETCH_IMAGE, - BusMessageType.OPTIONS_SYNC_OUTGOING_OBJECT, - BusMessageType.OPTIONS_SYNC_INCOMING_CHANGES - ].includes(msg.type as any) - ) { + const skipMessage = [ + PageComputeMessage.CONTENT_FETCH_CSS, + PageComputeMessage.CONTENT_FETCH_IMAGE, + BusMessageType.OPTIONS_SYNC_OUTGOING_OBJECT, + BusMessageType.OPTIONS_SYNC_INCOMING_CHANGES + ].includes(msg.type as any); + if (!skipMessage && environmentConfig.featureFlag.SYNC_ENABLED) { await new SyncServerCommand().execute(); } await TaskExecutor.dequeue();