mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
Merge pull request #4064 from overleaf/jel-tidy-algolia
Tidy Algolia usage GitOrigin-RevId: 8d33da3d9f2bb9f0df90e5f9273fba591c6b8eec
This commit is contained in:
parent
1b63923f8c
commit
ed889a078c
5 changed files with 11 additions and 75 deletions
|
@ -584,18 +584,7 @@ const ProjectController = {
|
||||||
hasSubscription: results.hasSubscription,
|
hasSubscription: results.hasSubscription,
|
||||||
reconfirmedViaSAML,
|
reconfirmedViaSAML,
|
||||||
zipFileSizeLimit: Settings.maxUploadSize,
|
zipFileSizeLimit: Settings.maxUploadSize,
|
||||||
}
|
isOverleaf: !!Settings.overleaf,
|
||||||
|
|
||||||
if (
|
|
||||||
Settings.algolia &&
|
|
||||||
Settings.algolia.app_id &&
|
|
||||||
Settings.algolia.read_only_api_key
|
|
||||||
) {
|
|
||||||
viewModel.showUserDetailsArea = true
|
|
||||||
viewModel.algolia_api_key = Settings.algolia.read_only_api_key
|
|
||||||
viewModel.algolia_app_id = Settings.algolia.app_id
|
|
||||||
} else {
|
|
||||||
viewModel.showUserDetailsArea = false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const paidUser =
|
const paidUser =
|
||||||
|
|
|
@ -87,7 +87,7 @@ html(
|
||||||
meta(name="ol-ExposedSettings" data-type="json" content=ExposedSettings)
|
meta(name="ol-ExposedSettings" data-type="json" content=ExposedSettings)
|
||||||
|
|
||||||
if (typeof(settings.algolia) != "undefined")
|
if (typeof(settings.algolia) != "undefined")
|
||||||
meta(name="ol-sharelatex.algolia" data-type="json" content={
|
meta(name="ol-algolia" data-type="json" content={
|
||||||
app_id: settings.algolia.app_id,
|
app_id: settings.algolia.app_id,
|
||||||
api_key: settings.algolia.read_only_api_key,
|
api_key: settings.algolia.read_only_api_key,
|
||||||
indexes: settings.algolia.indexes
|
indexes: settings.algolia.indexes
|
||||||
|
|
|
@ -13,12 +13,6 @@ block append meta
|
||||||
meta(name="ol-userHasNoSubscription" data-type="boolean" content=!!(settings.enableSubscriptions && !hasSubscription))
|
meta(name="ol-userHasNoSubscription" data-type="boolean" content=!!(settings.enableSubscriptions && !hasSubscription))
|
||||||
meta(name="ol-allInReconfirmNotificationPeriods" data-type="json" content=allInReconfirmNotificationPeriods)
|
meta(name="ol-allInReconfirmNotificationPeriods" data-type="json" content=allInReconfirmNotificationPeriods)
|
||||||
meta(name="ol-reconfirmedViaSAML" content=reconfirmedViaSAML)
|
meta(name="ol-reconfirmedViaSAML" content=reconfirmedViaSAML)
|
||||||
meta(name="ol-algolia" data-type="json" content={
|
|
||||||
institutions: {
|
|
||||||
app_id: algolia_app_id,
|
|
||||||
api_key: algolia_api_key
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
block content
|
block content
|
||||||
|
|
||||||
|
|
|
@ -121,7 +121,7 @@
|
||||||
div
|
div
|
||||||
strong #{translate("create_your_first_project")}
|
strong #{translate("create_your_first_project")}
|
||||||
|
|
||||||
if (showUserDetailsArea)
|
if (isOverleaf)
|
||||||
span(ng-controller="LeftHandMenuPromoController", ng-cloak)
|
span(ng-controller="LeftHandMenuPromoController", ng-cloak)
|
||||||
|
|
||||||
.row-spaced#userProfileInformation(ng-if="hasProjects")
|
.row-spaced#userProfileInformation(ng-if="hasProjects")
|
||||||
|
|
|
@ -1,67 +1,20 @@
|
||||||
/* eslint-disable
|
import _ from 'lodash'
|
||||||
max-len,
|
|
||||||
*/
|
|
||||||
// TODO: This file was created by bulk-decaffeinate.
|
|
||||||
// Fix any style issues and re-enable lint.
|
|
||||||
/*
|
|
||||||
* decaffeinate suggestions:
|
|
||||||
* DS102: Remove unnecessary code created because of implicit returns
|
|
||||||
* DS103: Rewrite code to no longer use __guard__
|
|
||||||
* DS207: Consider shorter variations of null checks
|
|
||||||
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
|
||||||
*/
|
|
||||||
import App from '../base'
|
import App from '../base'
|
||||||
import AlgoliaSearch from 'algoliasearch'
|
import AlgoliaSearch from 'algoliasearch'
|
||||||
|
import getMeta from '../utils/meta'
|
||||||
|
|
||||||
export default App.factory('algoliaSearch', function () {
|
export default App.factory('algoliaSearch', function () {
|
||||||
let kbIdx, wikiIdx
|
let wikiIdx
|
||||||
if (
|
const algoliaConfig = getMeta('ol-algolia')
|
||||||
(window.sharelatex != null ? window.sharelatex.algolia : undefined) !=
|
const wikiIndex = _.get(algoliaConfig, 'indexes.wiki')
|
||||||
null &&
|
if (wikiIndex) {
|
||||||
__guard__(
|
const client = AlgoliaSearch(algoliaConfig.app_id, algoliaConfig.api_key)
|
||||||
window.sharelatex.algolia != null
|
wikiIdx = client.initIndex(wikiIndex)
|
||||||
? window.sharelatex.algolia.indexes
|
|
||||||
: undefined,
|
|
||||||
x => x.wiki
|
|
||||||
) != null
|
|
||||||
) {
|
|
||||||
const client = AlgoliaSearch(
|
|
||||||
window.sharelatex.algolia != null
|
|
||||||
? window.sharelatex.algolia.app_id
|
|
||||||
: undefined,
|
|
||||||
window.sharelatex.algolia != null
|
|
||||||
? window.sharelatex.algolia.api_key
|
|
||||||
: undefined
|
|
||||||
)
|
|
||||||
wikiIdx = client.initIndex(
|
|
||||||
__guard__(
|
|
||||||
window.sharelatex.algolia != null
|
|
||||||
? window.sharelatex.algolia.indexes
|
|
||||||
: undefined,
|
|
||||||
x1 => x1.wiki
|
|
||||||
)
|
|
||||||
)
|
|
||||||
kbIdx = client.initIndex(
|
|
||||||
__guard__(
|
|
||||||
window.sharelatex.algolia != null
|
|
||||||
? window.sharelatex.algolia.indexes
|
|
||||||
: undefined,
|
|
||||||
x2 => x2.kb
|
|
||||||
)
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// searchKB is deprecated
|
|
||||||
const service = {
|
const service = {
|
||||||
searchWiki: wikiIdx ? wikiIdx.search.bind(wikiIdx) : null,
|
searchWiki: wikiIdx ? wikiIdx.search.bind(wikiIdx) : null,
|
||||||
searchKB: kbIdx ? kbIdx.search.bind(kbIdx) : null,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return service
|
return service
|
||||||
})
|
})
|
||||||
|
|
||||||
function __guard__(value, transform) {
|
|
||||||
return typeof value !== 'undefined' && value !== null
|
|
||||||
? transform(value)
|
|
||||||
: undefined
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in a new issue