Features.coffee 1008 B

123456789101112131415161718192021222324252627282930313233
  1. Settings = require 'settings-sharelatex'
  2. module.exports = Features =
  3. externalAuthenticationSystemUsed: ->
  4. Settings.ldap? or Settings.saml? or Settings.overleaf?.oauth?
  5. hasFeature: (feature) ->
  6. switch feature
  7. when 'homepage'
  8. return Settings.enableHomepage
  9. when 'registration'
  10. return not Features.externalAuthenticationSystemUsed() or Settings.overleaf?
  11. when 'github-sync'
  12. return Settings.enableGithubSync
  13. when 'v1-return-message'
  14. return Settings.accountMerge? and Settings.overleaf?
  15. when 'v2-banner'
  16. return Settings.showV2Banner
  17. when 'custom-togglers'
  18. return Settings.overleaf?
  19. when 'publish-templates'
  20. return true
  21. when 'view-templates'
  22. return !Settings.overleaf?
  23. when 'affiliations'
  24. return Settings?.apis?.v1?.url?
  25. when 'rich-text'
  26. isEnabled = true # Switch to false to disable
  27. Settings.overleaf? and isEnabled
  28. when 'redirect-sl'
  29. return Settings.redirectToV2?
  30. else
  31. throw new Error("unknown feature: #{feature}")