mirror of
https://github.com/overleaf/overleaf.git
synced 2025-02-19 21:11:03 +00:00
Merge pull request #15976 from overleaf/jdt-jpa-ieee-theme-picker
Hiding the overall theme for IEEE branded projects GitOrigin-RevId: 5f07a7b316aea29ab72183fe4014c1b3e5c94bb8
This commit is contained in:
parent
2cd10df47e
commit
cea7846795
4 changed files with 40 additions and 4 deletions
|
@ -377,6 +377,7 @@ module.exports = function (webRouter, privateApiRouter, publicApiRouter) {
|
||||||
adminEmail: Settings.adminEmail,
|
adminEmail: Settings.adminEmail,
|
||||||
dropboxAppName:
|
dropboxAppName:
|
||||||
Settings.apis.thirdPartyDataStore?.dropboxAppName || 'Overleaf',
|
Settings.apis.thirdPartyDataStore?.dropboxAppName || 'Overleaf',
|
||||||
|
ieeeBrandId: IEEE_BRAND_ID,
|
||||||
hasSamlBeta: req.session.samlBeta,
|
hasSamlBeta: req.session.samlBeta,
|
||||||
hasAffiliationsFeature: Features.hasFeature('affiliations'),
|
hasAffiliationsFeature: Features.hasFeature('affiliations'),
|
||||||
hasSamlFeature: Features.hasFeature('saml'),
|
hasSamlFeature: Features.hasFeature('saml'),
|
||||||
|
|
|
@ -6,6 +6,7 @@ import SettingsMenuSelect, { Option } from './settings-menu-select'
|
||||||
import { useProjectSettingsContext } from '../../context/project-settings-context'
|
import { useProjectSettingsContext } from '../../context/project-settings-context'
|
||||||
import type { OverallThemeMeta } from '../../../../../../types/project-settings'
|
import type { OverallThemeMeta } from '../../../../../../types/project-settings'
|
||||||
import type { OverallTheme } from '../../../source-editor/extensions/theme'
|
import type { OverallTheme } from '../../../source-editor/extensions/theme'
|
||||||
|
import { ExposedSettings } from '../../../../../../types/exposed-settings'
|
||||||
|
|
||||||
export default function SettingsOverallTheme() {
|
export default function SettingsOverallTheme() {
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
|
@ -24,10 +25,11 @@ export default function SettingsOverallTheme() {
|
||||||
[overallThemes]
|
[overallThemes]
|
||||||
)
|
)
|
||||||
|
|
||||||
// TODO: check for IEEE brand by:
|
const brandVariation = getMeta('ol-brandVariation') as any
|
||||||
// - const brandVariation = getMeta('ol-brandVariation') as any[]
|
const { ieeeBrandId } = getMeta('ol-ExposedSettings') as ExposedSettings
|
||||||
// - settings.overleaf != null && !isIEEE(brandVariation)
|
const isIEEEBranded = brandVariation?.brand_id === ieeeBrandId
|
||||||
if (!overallThemes) {
|
|
||||||
|
if (!overallThemes || isIEEEBranded) {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,9 @@ import SettingsOverallTheme from '../../../../../../frontend/js/features/editor-
|
||||||
import type { OverallThemeMeta } from '../../../../../../types/project-settings'
|
import type { OverallThemeMeta } from '../../../../../../types/project-settings'
|
||||||
import { renderWithEditorContext } from '../../../../helpers/render-with-context'
|
import { renderWithEditorContext } from '../../../../helpers/render-with-context'
|
||||||
|
|
||||||
|
const IEEE_BRAND_ID = 1234
|
||||||
|
const OTHER_BRAND_ID = 2234
|
||||||
|
|
||||||
describe('<SettingsOverallTheme />', function () {
|
describe('<SettingsOverallTheme />', function () {
|
||||||
const overallThemes: OverallThemeMeta[] = [
|
const overallThemes: OverallThemeMeta[] = [
|
||||||
{
|
{
|
||||||
|
@ -21,6 +24,9 @@ describe('<SettingsOverallTheme />', function () {
|
||||||
|
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
window.metaAttributesCache.set('ol-overallThemes', overallThemes)
|
window.metaAttributesCache.set('ol-overallThemes', overallThemes)
|
||||||
|
window.metaAttributesCache.set('ol-ExposedSettings', {
|
||||||
|
ieeeBrandId: IEEE_BRAND_ID,
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
afterEach(function () {
|
afterEach(function () {
|
||||||
|
@ -38,4 +44,30 @@ describe('<SettingsOverallTheme />', function () {
|
||||||
expect(option.getAttribute('value')).to.equal(theme.val)
|
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(<SettingsOverallTheme />)
|
||||||
|
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(<SettingsOverallTheme />)
|
||||||
|
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(<SettingsOverallTheme />)
|
||||||
|
const select = screen.getByLabelText('Overall theme')
|
||||||
|
expect(select).to.exist
|
||||||
|
})
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
|
@ -19,6 +19,7 @@ export type ExposedSettings = {
|
||||||
hasLinkedProjectOutputFileFeature: boolean
|
hasLinkedProjectOutputFileFeature: boolean
|
||||||
hasSamlBeta?: boolean
|
hasSamlBeta?: boolean
|
||||||
hasSamlFeature: boolean
|
hasSamlFeature: boolean
|
||||||
|
ieeeBrandId: number
|
||||||
isOverleaf: boolean
|
isOverleaf: boolean
|
||||||
maxEntitiesPerProject: number
|
maxEntitiesPerProject: number
|
||||||
projectUploadTimeout: number
|
projectUploadTimeout: number
|
||||||
|
|
Loading…
Reference in a new issue