PermissionsManager.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /* eslint-disable
  2. no-return-assign,
  3. no-unused-vars,
  4. */
  5. // TODO: This file was created by bulk-decaffeinate.
  6. // Fix any style issues and re-enable lint.
  7. /*
  8. * decaffeinate suggestions:
  9. * DS102: Remove unnecessary code created because of implicit returns
  10. * DS207: Consider shorter variations of null checks
  11. * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
  12. */
  13. let PermissionsManager
  14. export default PermissionsManager = class PermissionsManager {
  15. constructor(ide, $scope) {
  16. this.ide = ide
  17. this.$scope = $scope
  18. this.$scope.permissions = {
  19. read: false,
  20. write: false,
  21. admin: false,
  22. comment: false,
  23. }
  24. this.$scope.$watch('permissionsLevel', permissionsLevel => {
  25. if (permissionsLevel != null) {
  26. if (permissionsLevel === 'readOnly') {
  27. this.$scope.permissions.read = true
  28. this.$scope.permissions.write = false
  29. this.$scope.permissions.admin = false
  30. this.$scope.permissions.comment = true
  31. } else if (permissionsLevel === 'readAndWrite') {
  32. this.$scope.permissions.read = true
  33. this.$scope.permissions.write = true
  34. this.$scope.permissions.comment = true
  35. } else if (permissionsLevel === 'owner') {
  36. this.$scope.permissions.read = true
  37. this.$scope.permissions.write = true
  38. this.$scope.permissions.admin = true
  39. this.$scope.permissions.comment = true
  40. }
  41. }
  42. if (this.$scope.anonymous) {
  43. return (this.$scope.permissions.comment = false)
  44. }
  45. })
  46. }
  47. }