Merge pull request #3555 from overleaf/jpa-word-count-clsi-persistence

[frontend] word-count-modal: bring back query param for clsi persistence

GitOrigin-RevId: ec32b8525875e87b696929cb9c6f09c00bc58131
This commit is contained in:
Jakob Ackermann 2021-01-12 11:24:47 +00:00 committed by Copybot
parent a3176e2b6b
commit fb83d27476
2 changed files with 10 additions and 3 deletions

View file

@ -3,7 +3,7 @@ import { Modal } from 'react-bootstrap'
import PropTypes from 'prop-types'
import WordCountModalContent from './word-count-modal-content'
function WordCountModal({ handleHide, show, projectId }) {
function WordCountModal({ clsiServerId, handleHide, projectId, show }) {
const [loading, setLoading] = useState(true)
const [error, setError] = useState(false)
const [data, setData] = useState()
@ -21,7 +21,12 @@ function WordCountModal({ handleHide, show, projectId }) {
const _abortController = new AbortController()
setAbortController(_abortController)
fetch(`/project/${projectId}/wordcount`, {
let query = ''
if (clsiServerId) {
query = `?clsiserverid=${clsiServerId}`
}
fetch(`/project/${projectId}/wordcount${query}`, {
signal: _abortController.signal
})
.then(async response => {
@ -42,7 +47,7 @@ function WordCountModal({ handleHide, show, projectId }) {
return () => {
_abortController.abort()
}
}, [show, projectId])
}, [show, projectId, clsiServerId])
const abortAndHide = useCallback(() => {
abortController.abort()
@ -62,6 +67,7 @@ function WordCountModal({ handleHide, show, projectId }) {
}
WordCountModal.propTypes = {
clsiServerId: PropTypes.string,
handleHide: PropTypes.func.isRequired,
projectId: PropTypes.string.isRequired,
show: PropTypes.bool.isRequired

View file

@ -20,6 +20,7 @@ export default App.controller('WordCountModalController', function(
$scope.openWordCountModal = () => {
$scope.$applyAsync(() => {
$scope.clsiServerId = ide.clsiServerId
$scope.projectId = ide.project_id
$scope.show = true
})