diff --git a/services/web/app/src/infrastructure/ExpressLocals.js b/services/web/app/src/infrastructure/ExpressLocals.js index 9bac7d66f8..82bb64944e 100644 --- a/services/web/app/src/infrastructure/ExpressLocals.js +++ b/services/web/app/src/infrastructure/ExpressLocals.js @@ -377,6 +377,7 @@ module.exports = function (webRouter, privateApiRouter, publicApiRouter) { adminEmail: Settings.adminEmail, dropboxAppName: Settings.apis.thirdPartyDataStore?.dropboxAppName || 'Overleaf', + ieeeBrandId: IEEE_BRAND_ID, hasSamlBeta: req.session.samlBeta, hasAffiliationsFeature: Features.hasFeature('affiliations'), hasSamlFeature: Features.hasFeature('saml'), diff --git a/services/web/frontend/js/features/editor-left-menu/components/settings/settings-overall-theme.tsx b/services/web/frontend/js/features/editor-left-menu/components/settings/settings-overall-theme.tsx index 48392dac6e..280169a511 100644 --- a/services/web/frontend/js/features/editor-left-menu/components/settings/settings-overall-theme.tsx +++ b/services/web/frontend/js/features/editor-left-menu/components/settings/settings-overall-theme.tsx @@ -6,6 +6,7 @@ import SettingsMenuSelect, { Option } from './settings-menu-select' import { useProjectSettingsContext } from '../../context/project-settings-context' import type { OverallThemeMeta } from '../../../../../../types/project-settings' import type { OverallTheme } from '../../../source-editor/extensions/theme' +import { ExposedSettings } from '../../../../../../types/exposed-settings' export default function SettingsOverallTheme() { const { t } = useTranslation() @@ -24,10 +25,11 @@ export default function SettingsOverallTheme() { [overallThemes] ) - // TODO: check for IEEE brand by: - // - const brandVariation = getMeta('ol-brandVariation') as any[] - // - settings.overleaf != null && !isIEEE(brandVariation) - if (!overallThemes) { + const brandVariation = getMeta('ol-brandVariation') as any + const { ieeeBrandId } = getMeta('ol-ExposedSettings') as ExposedSettings + const isIEEEBranded = brandVariation?.brand_id === ieeeBrandId + + if (!overallThemes || isIEEEBranded) { return null } diff --git a/services/web/frontend/stories/decorators/scope.tsx b/services/web/frontend/stories/decorators/scope.tsx index 6b3e8a052a..1b4f6e4269 100644 --- a/services/web/frontend/stories/decorators/scope.tsx +++ b/services/web/frontend/stories/decorators/scope.tsx @@ -138,6 +138,7 @@ const initialize = () => { hasLinkedProjectFileFeature: true, hasLinkedProjectOutputFileFeature: true, hasSamlFeature: true, + ieeeBrandId: 15, isOverleaf: true, labsEnabled: true, maxEntitiesPerProject: 10, diff --git a/services/web/test/frontend/components/editor-left-menu/editor-left-menu.spec.tsx b/services/web/test/frontend/components/editor-left-menu/editor-left-menu.spec.tsx index daac892279..ced3ad9d5e 100644 --- a/services/web/test/frontend/components/editor-left-menu/editor-left-menu.spec.tsx +++ b/services/web/test/frontend/components/editor-left-menu/editor-left-menu.spec.tsx @@ -46,6 +46,7 @@ describe('', function () { window.metaAttributesCache.set('ol-anonymous', false) window.metaAttributesCache.set('ol-gitBridgeEnabled', true) window.metaAttributesCache.set('ol-showSupport', true) + window.metaAttributesCache.set('ol-ExposedSettings', { ieeeBrandId: 123 }) window.metaAttributesCache.set('ol-user', { email: 'sherlock@holmes.co.uk', first_name: 'Sherlock', @@ -849,6 +850,7 @@ describe('', function () { }, }) window.metaAttributesCache.set('ol-anonymous', true) + window.metaAttributesCache.set('ol-ExposedSettings', { ieeeBrandId: 123 }) cy.mount( diff --git a/services/web/test/frontend/features/editor-left-menu/components/settings/settings-overall-theme.test.tsx b/services/web/test/frontend/features/editor-left-menu/components/settings/settings-overall-theme.test.tsx index a6773c6d67..bbbbcf0655 100644 --- a/services/web/test/frontend/features/editor-left-menu/components/settings/settings-overall-theme.test.tsx +++ b/services/web/test/frontend/features/editor-left-menu/components/settings/settings-overall-theme.test.tsx @@ -5,6 +5,9 @@ import SettingsOverallTheme from '../../../../../../frontend/js/features/editor- import type { OverallThemeMeta } from '../../../../../../types/project-settings' import { renderWithEditorContext } from '../../../../helpers/render-with-context' +const IEEE_BRAND_ID = 1234 +const OTHER_BRAND_ID = 2234 + describe('', function () { const overallThemes: OverallThemeMeta[] = [ { @@ -21,6 +24,9 @@ describe('', function () { beforeEach(function () { window.metaAttributesCache.set('ol-overallThemes', overallThemes) + window.metaAttributesCache.set('ol-ExposedSettings', { + ieeeBrandId: IEEE_BRAND_ID, + }) }) afterEach(function () { @@ -38,4 +44,30 @@ describe('', function () { expect(option.getAttribute('value')).to.equal(theme.val) } }) + describe('Branded Project', function () { + it('should hide overall theme picker for IEEE branded projects', function () { + window.metaAttributesCache.set('ol-brandVariation', { + brand_id: IEEE_BRAND_ID, + }) + renderWithEditorContext() + const select = screen.queryByText('Overall theme') + expect(select).to.not.exist + }) + + it('should show overall theme picker for branded projects that are not IEEE', function () { + window.metaAttributesCache.set('ol-brandVariation', { + brand_id: OTHER_BRAND_ID, + }) + renderWithEditorContext() + const select = screen.getByLabelText('Overall theme') + expect(select).to.exist + }) + + it('should show overall theme picker for non branded projects', function () { + window.metaAttributesCache.set('ol-brandVariation', undefined) + renderWithEditorContext() + const select = screen.getByLabelText('Overall theme') + expect(select).to.exist + }) + }) }) diff --git a/services/web/types/exposed-settings.ts b/services/web/types/exposed-settings.ts index 474bf28697..2b74fdb8a5 100644 --- a/services/web/types/exposed-settings.ts +++ b/services/web/types/exposed-settings.ts @@ -19,6 +19,7 @@ export type ExposedSettings = { hasLinkedProjectOutputFileFeature: boolean hasSamlBeta?: boolean hasSamlFeature: boolean + ieeeBrandId: number isOverleaf: boolean maxEntitiesPerProject: number projectUploadTimeout: number