mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-14 14:13:43 +01:00
Make Template Gallery optional; rename environment variables
Refactor Template Gallery; resolves #38 and #39:
- replace free-text license input with a select box
- improve visual presentation of modals and enhance keyboard interaction
Template Gallery: replace markdown-it with marked
Fix template publishing to align with upstream project context changes
Template gallery: ui components were moved to shared folder
Fix style of Templates button in navbar
Template gallery: Fix `OLModal` usage (see upstream commit 19b3834)
Template gallery: Fix import after upstream converted `CompileManager`, `ClsiManager` and `RateLimiterMiddleware` to ESM
Template gallery: Fix import after upstream converted `AuthenticationController`, `ProjectGetter`, ProjectLocator` and `DocumentUpdaterHandler` to ESM
Template Gallery: migration to 6.1.0
- enable menu for editor redisign
- move frontend code to modules
Template gallery: add template management authorization middleware
- middleware to enforce template access rules
- introduce template manager role
- fix minor issues
Template Gallery: fix for 6.2.0
Template Gallery: fix for 6.3.0 and show language in the details
101 lines
3.1 KiB
JavaScript
101 lines
3.1 KiB
JavaScript
import _ from 'lodash'
|
|
import Settings from '@overleaf/settings'
|
|
|
|
const supportModuleAvailable =
|
|
Settings.moduleImportSequence?.includes('support')
|
|
|
|
const symbolPaletteModuleAvailable =
|
|
Settings.moduleImportSequence?.includes('symbol-palette')
|
|
|
|
const trackChangesModuleAvailable =
|
|
Settings.moduleImportSequence?.includes('track-changes')
|
|
|
|
/**
|
|
* @typedef {Object} Settings
|
|
* @property {Object | undefined} apis
|
|
* @property {Object | undefined} apis.linkedUrlProxy
|
|
* @property {string | undefined} apis.linkedUrlProxy.url
|
|
* @property {boolean | undefined} enableGithubSync
|
|
* @property {boolean | undefined} enableGitBridge
|
|
* @property {boolean | undefined} enableHomepage
|
|
* @property {boolean | undefined} enableSaml
|
|
* @property {boolean | undefined} ldap
|
|
* @property {boolean | undefined} oauth
|
|
* @property {Object | undefined} overleaf
|
|
* @property {Object | undefined} overleaf.oauth
|
|
* @property {boolean | undefined} saml
|
|
*/
|
|
|
|
const Features = {
|
|
/**
|
|
* @returns {boolean}
|
|
*/
|
|
externalAuthenticationSystemUsed() {
|
|
return (
|
|
(Boolean(Settings.ldap) && Boolean(Settings.ldap.enable)) ||
|
|
(Boolean(Settings.saml) && Boolean(Settings.saml.enable)) ||
|
|
Boolean(Settings.overleaf)
|
|
)
|
|
},
|
|
|
|
/**
|
|
* Whether a feature is enabled in the appliation's configuration
|
|
*
|
|
* @param {string} feature
|
|
* @returns {boolean}
|
|
*/
|
|
hasFeature(feature) {
|
|
switch (feature) {
|
|
case 'saas':
|
|
return Boolean(Settings.overleaf)
|
|
case 'homepage':
|
|
return Boolean(Settings.enableHomepage)
|
|
case 'registration-page':
|
|
return (
|
|
!Features.externalAuthenticationSystemUsed() ||
|
|
Boolean(Settings.overleaf)
|
|
)
|
|
case 'registration':
|
|
return Boolean(Settings.overleaf)
|
|
case 'chat':
|
|
return Boolean(Settings.disableChat) === false
|
|
case 'link-sharing':
|
|
return Boolean(Settings.disableLinkSharing) === false
|
|
case 'github-sync':
|
|
return Boolean(Settings.enableGithubSync)
|
|
case 'git-bridge':
|
|
return Boolean(Settings.enableGitBridge)
|
|
case 'oauth':
|
|
return Boolean(Settings.oauth)
|
|
case 'templates-server-pro':
|
|
return Boolean(Settings.templates)
|
|
case 'affiliations':
|
|
case 'analytics':
|
|
return Boolean(_.get(Settings, ['apis', 'v1', 'url']))
|
|
case 'saml':
|
|
return Boolean(Settings.enableSaml)
|
|
case 'linked-project-file':
|
|
return Boolean(Settings.enabledLinkedFileTypes.includes('project_file'))
|
|
case 'linked-project-output-file':
|
|
return Boolean(
|
|
Settings.enabledLinkedFileTypes.includes('project_output_file')
|
|
)
|
|
case 'link-url':
|
|
return Boolean(
|
|
_.get(Settings, ['apis', 'linkedUrlProxy', 'url']) &&
|
|
Settings.enabledLinkedFileTypes.includes('url')
|
|
)
|
|
case 'support':
|
|
return supportModuleAvailable
|
|
case 'symbol-palette':
|
|
return symbolPaletteModuleAvailable
|
|
case 'track-changes':
|
|
return trackChangesModuleAvailable
|
|
default:
|
|
throw new Error(`unknown feature: ${feature}`)
|
|
}
|
|
},
|
|
}
|
|
|
|
export default Features
|