Fix dev bulk-delete button gate + reposition inside campaigns
Gate was process.env.NODE_ENV === 'development' — unsafe default. react-scripts inlines NODE_ENV=development when unset, so prod deploys forgetting the env var exposed the delete-all button. Switched to explicit opt-in REACT_APP_DEV_TOOLS=1. process.env.REACT_APP_DEV_TOOLS as static literal gets inlined by DefinePlugin at webpack build time — runtime mutations in tests had no effect, and dev-start without the env produced bundles with the branch dead-stripped. Extracted gate to src/config/devTools.js using dynamic key access (process.env['REACT_APP_' + 'DEV_TOOLS']) so DefinePlugin cannot inline it; the value is read at runtime. dev-start.sh now exports REACT_APP_DEV_TOOLS=1. Button had also drifted outside the campaigns collapse block to the page bottom; moved it back inside the campaigns section after the grid. Tests cover both paths: gate logic (unset/0/arbitrary/1) in BulkDelete.gate.test.js, prod safety render (button absent when unset) in BulkDelete.render-hidden.test.js, dev feature render (button present when DEV_TOOLS=1) in BulkDelete.render-shown.test.js.
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
// Dev-tools gate. Explicit opt-in via REACT_APP_DEV_TOOLS=1.
|
||||
// Safe default: any value other than exactly '1' = off.
|
||||
// Dynamic key access so react-scripts DefinePlugin does NOT inline the value
|
||||
// at build time — allows tests + runtime env changes to take effect.
|
||||
const KEY = 'REACT_APP_' + 'DEV_TOOLS';
|
||||
export const isDevToolsEnabled = () => process.env[KEY] === '1';
|
||||
Reference in New Issue
Block a user