overleaf/services/web/app/coffee/infrastructure/Features.coffee

34 lines
986 B
CoffeeScript
Raw Normal View History

2017-11-20 11:43:02 +00:00
Settings = require 'settings-sharelatex'
module.exports = Features =
externalAuthenticationSystemUsed: ->
Settings.ldap? or Settings.saml? or Settings.overleaf?.oauth?
hasFeature: (feature) ->
switch feature
when 'homepage'
return Settings.enableHomepage
2017-11-20 11:43:02 +00:00
when 'registration'
return not Features.externalAuthenticationSystemUsed()
2017-11-20 11:48:06 +00:00
when 'github-sync'
return Settings.enableGithubSync
when 'v1-return-message'
return Settings.accountMerge? and Settings.overleaf?
when 'v2-banner'
return Settings.showV2Banner
2018-03-22 12:10:34 +00:00
when 'custom-togglers'
return Settings.overleaf?
when 'publish-templates'
return true
when 'view-templates'
return !Settings.overleaf?
when 'affiliations'
return Settings?.apis?.v1?.url?
when 'rich-text'
2018-07-17 16:33:41 +00:00
isEnabled = true # Switch to false to disable
Settings.overleaf? and isEnabled
when 'redirect-sl'
return Settings.redirectToV2?
2017-11-20 11:43:02 +00:00
else
throw new Error("unknown feature: #{feature}")