Merge pull request #18000 from overleaf/ab-dev-enable-toolbar-default

[web] Enable the dev-toolbar by default in the dev environment

GitOrigin-RevId: 170e59e9b82268e621fe99ffcc82b7d68467e1b3
This commit is contained in:
Alexandre Bourdin 2024-05-24 10:52:00 +02:00 committed by Copybot
parent 418d77522e
commit a0c8cf663a
7 changed files with 43 additions and 19 deletions

View file

@ -237,7 +237,7 @@ async function _getAssignment(
const splitTest = await _getSplitTest(splitTestName) const splitTest = await _getSplitTest(splitTestName)
const currentVersion = SplitTestUtils.getCurrentVersion(splitTest) const currentVersion = SplitTestUtils.getCurrentVersion(splitTest)
if (Settings.splitTest.devToolbar.enabled) { if (Settings.devToolbar.enabled) {
const override = session?.splitTestOverrides?.[splitTestName] const override = session?.splitTestOverrides?.[splitTestName]
if (override) { if (override) {
return _makeAssignment(splitTest, override, currentVersion) return _makeAssignment(splitTest, override, currentVersion)
@ -402,7 +402,7 @@ function getPercentile(analyticsId, splitTestName, splitTestPhase) {
} }
function setOverrideInSession(session, splitTestName, variantName) { function setOverrideInSession(session, splitTestName, variantName) {
if (!Settings.splitTest.devToolbar.enabled) { if (!Settings.devToolbar.enabled) {
return return
} }
if (!session.splitTestOverrides) { if (!session.splitTestOverrides) {
@ -477,7 +477,7 @@ async function _loadSplitTestInfoInLocals(locals, splitTestName, session) {
const override = session?.splitTestOverrides?.[splitTestName] const override = session?.splitTestOverrides?.[splitTestName]
const currentVersion = SplitTestUtils.getCurrentVersion(splitTest) const currentVersion = SplitTestUtils.getCurrentVersion(splitTest)
if (!currentVersion.active && !Settings.splitTest.devToolbar.enabled) { if (!currentVersion.active && !Settings.devToolbar.enabled) {
return return
} }
@ -486,7 +486,7 @@ async function _loadSplitTestInfoInLocals(locals, splitTestName, session) {
phase, phase,
badgeInfo: splitTest.badgeInfo?.[phase], badgeInfo: splitTest.badgeInfo?.[phase],
} }
if (Settings.splitTest.devToolbar.enabled) { if (Settings.devToolbar.enabled) {
info.active = currentVersion.active info.active = currentVersion.active
info.variants = currentVersion.variants.map(variant => ({ info.variants = currentVersion.variants.map(variant => ({
name: variant.name, name: variant.name,
@ -495,7 +495,7 @@ async function _loadSplitTestInfoInLocals(locals, splitTestName, session) {
info.hasOverride = !!override info.hasOverride = !!override
} }
LocalsHelper.setSplitTestInfo(locals, splitTestName, info) LocalsHelper.setSplitTestInfo(locals, splitTestName, info)
} else if (Settings.splitTest.devToolbar.enabled) { } else if (Settings.devToolbar.enabled) {
LocalsHelper.setSplitTestInfo(locals, splitTestName, { LocalsHelper.setSplitTestInfo(locals, splitTestName, {
missing: true, missing: true,
}) })

View file

@ -1,6 +1,6 @@
mixin foot-scripts() mixin foot-scripts()
each file in entrypointScripts(entrypoint) each file in entrypointScripts(entrypoint)
script(type="text/javascript", nonce=scriptNonce, src=file, defer=deferScripts) script(type="text/javascript", nonce=scriptNonce, src=file, defer=deferScripts)
if (settings.splitTest.devToolbar.enabled) if (settings.devToolbar.enabled)
each file in entrypointScripts("devToolbar") each file in entrypointScripts("devToolbar")
script(type="text/javascript", nonce=scriptNonce, src=file, defer=deferScripts) script(type="text/javascript", nonce=scriptNonce, src=file, defer=deferScripts)

View file

@ -80,7 +80,7 @@ html(
block body block body
if (settings.splitTest.devToolbar.enabled) if (settings.devToolbar.enabled)
div#dev-toolbar div#dev-toolbar
block foot-scripts block foot-scripts

View file

@ -316,11 +316,9 @@ module.exports = {
algorithm: process.env.OT_JWT_AUTH_ALG || 'HS256', algorithm: process.env.OT_JWT_AUTH_ALG || 'HS256',
}, },
splitTest: {
devToolbar: { devToolbar: {
enabled: false, enabled: false,
}, },
},
splitTests: [], splitTests: [],

View file

@ -15,6 +15,36 @@
border: none; border: none;
text-decoration: none; text-decoration: none;
} }
.collapse-button {
position: absolute;
padding: 0;
margin-top: -2px;
color: @neutral-50;
span {
font-size: 28px;
}
&:hover {
color: @neutral-30;
}
}
}
.dev-tool-bar-open-button {
position: fixed;
bottom: -2px;
left: 6px;
color: @neutral-50;
span {
font-size: 28px;
}
&:hover {
color: @neutral-30;
}
} }
.dev-toolbar-tooltip { .dev-toolbar-tooltip {

View file

@ -260,11 +260,9 @@ module.exports = {
counterInit: 0, counterInit: 0,
}, },
splitTest: {
devToolbar: { devToolbar: {
enabled: false, enabled: false,
}, },
},
} }
module.exports.mergeWith = function (overrides) { module.exports.mergeWith = function (overrides) {

View file

@ -40,11 +40,9 @@ describe('SplitTestHandler', function () {
this.Settings = { this.Settings = {
moduleImportSequence: [], moduleImportSequence: [],
overleaf: {}, overleaf: {},
splitTest: {
devToolbar: { devToolbar: {
enabled: false, enabled: false,
}, },
},
} }
this.AnalyticsManager = { this.AnalyticsManager = {
getIdsFromSession: sinon.stub(), getIdsFromSession: sinon.stub(),