mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-29 20:53:39 -05:00
Merge pull request #3680 from overleaf/as-em-tm-remove-uiconfig
Remove unused uiConfig global variable from frontend and tests GitOrigin-RevId: 390abdc097cd9904f7a1c1849e58baf70bea5c72
This commit is contained in:
parent
195785194d
commit
2138bd2a80
10 changed files with 13 additions and 86 deletions
|
@ -317,22 +317,6 @@ module.exports = function(webRouter, privateApiRouter, publicApiRouter) {
|
|||
next()
|
||||
})
|
||||
|
||||
webRouter.use(function(req, res, next) {
|
||||
res.locals.uiConfig = {
|
||||
defaultResizerSizeOpen: 7,
|
||||
defaultResizerSizeClosed: 7,
|
||||
eastResizerCursor: 'ew-resize',
|
||||
westResizerCursor: 'ew-resize',
|
||||
chatResizerSizeOpen: 7,
|
||||
chatResizerSizeClosed: 0,
|
||||
chatMessageBorderSaturation: '85%',
|
||||
chatMessageBorderLightness: '40%',
|
||||
chatMessageBgSaturation: '85%',
|
||||
chatMessageBgLightness: '40%'
|
||||
}
|
||||
next()
|
||||
})
|
||||
|
||||
webRouter.use(function(req, res, next) {
|
||||
// TODO
|
||||
if (Settings.overleaf != null) {
|
||||
|
|
|
@ -194,7 +194,6 @@ block content
|
|||
window.aceBasePath = "/js/#{lib('ace')}"
|
||||
//- Set path for PDFjs CMaps
|
||||
window.pdfCMapsPath = "/js/cmaps/"
|
||||
window.uiConfig = JSON.parse('!{StringHelper.stringifyJsonForScript(uiConfig)}');
|
||||
//- enable doc hash checking for all projects
|
||||
//- used in public/js/libs/sharejs.js
|
||||
window.useShareJsHash = true
|
||||
|
|
|
@ -4,33 +4,20 @@ import ColorManager from '../../../ide/colors/ColorManager'
|
|||
import MessageContent from './message-content'
|
||||
|
||||
function Message({ message, userId }) {
|
||||
const {
|
||||
chatMessageBorderSaturation,
|
||||
chatMessageBorderLightness,
|
||||
chatMessageBgSaturation,
|
||||
chatMessageBgLightness
|
||||
} = window.uiConfig
|
||||
|
||||
function hue(user) {
|
||||
return user ? ColorManager.getHueForUserId(user.id) : 0
|
||||
}
|
||||
|
||||
function getMessageStyle(user) {
|
||||
return {
|
||||
borderColor: `hsl(${hue(
|
||||
user
|
||||
)}, ${chatMessageBorderSaturation}, ${chatMessageBorderLightness})`,
|
||||
backgroundColor: `hsl(${hue(
|
||||
user
|
||||
)}, ${chatMessageBgSaturation}, ${chatMessageBgLightness})`
|
||||
borderColor: `hsl(${hue(user)}, 85%, 40%)`,
|
||||
backgroundColor: `hsl(${hue(user)}, 85%, 40%`
|
||||
}
|
||||
}
|
||||
|
||||
function getArrowStyle(user) {
|
||||
return {
|
||||
borderColor: `hsl(${hue(
|
||||
user
|
||||
)}, ${chatMessageBorderSaturation}, ${chatMessageBorderLightness})`
|
||||
borderColor: `hsl(${hue(user)}, 85%, 40%)`
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -103,8 +103,8 @@ App.controller('IdeController', function(
|
|||
pdfWidth: 0,
|
||||
reviewPanelOpen: localStorage(`ui.reviewPanelOpen.${window.project_id}`),
|
||||
miniReviewPanelVisible: false,
|
||||
chatResizerSizeOpen: window.uiConfig.chatResizerSizeOpen,
|
||||
chatResizerSizeClosed: window.uiConfig.chatResizerSizeClosed
|
||||
chatResizerSizeOpen: 7,
|
||||
chatResizerSizeClosed: 7
|
||||
}
|
||||
$scope.user = window.user
|
||||
|
||||
|
|
|
@ -35,13 +35,13 @@ export default App.directive('layout', ($parse, $compile, ide) => ({
|
|||
if (attrs.spacingOpen != null) {
|
||||
spacingOpen = parseInt(attrs.spacingOpen, 10)
|
||||
} else {
|
||||
spacingOpen = window.uiConfig.defaultResizerSizeOpen
|
||||
spacingOpen = 7
|
||||
}
|
||||
|
||||
if (attrs.spacingClosed != null) {
|
||||
spacingClosed = parseInt(attrs.spacingClosed, 10)
|
||||
} else {
|
||||
spacingClosed = window.uiConfig.defaultResizerSizeClosed
|
||||
spacingClosed = 7
|
||||
}
|
||||
|
||||
const options = {
|
||||
|
@ -93,13 +93,8 @@ export default App.directive('layout', ($parse, $compile, ide) => ({
|
|||
}
|
||||
}
|
||||
|
||||
if (window.uiConfig.eastResizerCursor != null) {
|
||||
options.east.resizerCursor = window.uiConfig.eastResizerCursor
|
||||
}
|
||||
|
||||
if (window.uiConfig.westResizerCursor != null) {
|
||||
options.west.resizerCursor = window.uiConfig.westResizerCursor
|
||||
}
|
||||
options.east.resizerCursor = 'ew-resize'
|
||||
options.west.resizerCursor = 'ew-resize'
|
||||
|
||||
const repositionControls = function() {
|
||||
state = element.layout().readState()
|
||||
|
|
|
@ -4,10 +4,7 @@ import { v4 as uuid } from 'uuid'
|
|||
|
||||
import { ContextRoot } from '../js/shared/context/root-context'
|
||||
import ChatPane from '../js/features/chat/components/chat-pane'
|
||||
import {
|
||||
stubUIConfig,
|
||||
stubMathJax
|
||||
} from '../../test/frontend/features/chat/components/stubs'
|
||||
import { stubMathJax } from '../../test/frontend/features/chat/components/stubs'
|
||||
import { setupContext } from './fixtures/context'
|
||||
|
||||
const ONE_MINUTE = 60 * 1000
|
||||
|
@ -43,7 +40,6 @@ function generateMessages(count) {
|
|||
return messages
|
||||
}
|
||||
|
||||
stubUIConfig()
|
||||
stubMathJax()
|
||||
setupContext()
|
||||
|
||||
|
|
|
@ -8,12 +8,7 @@ import {
|
|||
renderWithChatContext,
|
||||
cleanUpContext
|
||||
} from '../../../helpers/render-with-context'
|
||||
import {
|
||||
stubMathJax,
|
||||
stubUIConfig,
|
||||
tearDownMathJaxStubs,
|
||||
tearDownUIConfigStubs
|
||||
} from './stubs'
|
||||
import { stubMathJax, tearDownMathJaxStubs } from './stubs'
|
||||
|
||||
describe('<ChatPane />', function() {
|
||||
const user = {
|
||||
|
@ -41,12 +36,10 @@ describe('<ChatPane />', function() {
|
|||
fetchMock.reset()
|
||||
cleanUpContext()
|
||||
|
||||
stubUIConfig()
|
||||
stubMathJax()
|
||||
})
|
||||
|
||||
afterEach(function() {
|
||||
tearDownUIConfigStubs()
|
||||
tearDownMathJaxStubs()
|
||||
})
|
||||
|
||||
|
|
|
@ -4,12 +4,7 @@ import { expect } from 'chai'
|
|||
import { screen, render, fireEvent } from '@testing-library/react'
|
||||
|
||||
import MessageList from '../../../../../frontend/js/features/chat/components/message-list'
|
||||
import {
|
||||
stubMathJax,
|
||||
stubUIConfig,
|
||||
tearDownMathJaxStubs,
|
||||
tearDownUIConfigStubs
|
||||
} from './stubs'
|
||||
import { stubMathJax, tearDownMathJaxStubs } from './stubs'
|
||||
|
||||
describe('<MessageList />', function() {
|
||||
const currentUser = {
|
||||
|
@ -36,12 +31,10 @@ describe('<MessageList />', function() {
|
|||
}
|
||||
|
||||
before(function() {
|
||||
stubUIConfig()
|
||||
stubMathJax()
|
||||
})
|
||||
|
||||
after(function() {
|
||||
tearDownUIConfigStubs()
|
||||
tearDownMathJaxStubs()
|
||||
})
|
||||
|
||||
|
|
|
@ -3,12 +3,7 @@ import React from 'react'
|
|||
import { render, screen } from '@testing-library/react'
|
||||
|
||||
import Message from '../../../../../frontend/js/features/chat/components/message'
|
||||
import {
|
||||
stubMathJax,
|
||||
stubUIConfig,
|
||||
tearDownMathJaxStubs,
|
||||
tearDownUIConfigStubs
|
||||
} from './stubs'
|
||||
import { stubMathJax, tearDownMathJaxStubs } from './stubs'
|
||||
|
||||
describe('<Message />', function() {
|
||||
const currentUser = {
|
||||
|
@ -19,13 +14,11 @@ describe('<Message />', function() {
|
|||
|
||||
beforeEach(function() {
|
||||
window.user = currentUser
|
||||
stubUIConfig()
|
||||
stubMathJax()
|
||||
})
|
||||
|
||||
afterEach(function() {
|
||||
delete window.user
|
||||
tearDownUIConfigStubs()
|
||||
tearDownMathJaxStubs()
|
||||
})
|
||||
|
||||
|
|
|
@ -1,18 +1,5 @@
|
|||
import sinon from 'sinon'
|
||||
|
||||
export function stubUIConfig() {
|
||||
window.uiConfig = {
|
||||
chatMessageBorderSaturation: '85%',
|
||||
chatMessageBorderLightness: '40%',
|
||||
chatMessageBgSaturation: '85%',
|
||||
chatMessageBgLightness: '40%'
|
||||
}
|
||||
}
|
||||
|
||||
export function tearDownUIConfigStubs() {
|
||||
delete window.uiConfig
|
||||
}
|
||||
|
||||
export function stubMathJax() {
|
||||
window.MathJax = {
|
||||
Hub: {
|
||||
|
|
Loading…
Reference in a new issue