modal-controllers.js 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. /* eslint-disable
  2. handle-callback-err,
  3. max-len,
  4. no-return-assign,
  5. */
  6. // TODO: This file was created by bulk-decaffeinate.
  7. // Fix any style issues and re-enable lint.
  8. /*
  9. * decaffeinate suggestions:
  10. * DS102: Remove unnecessary code created because of implicit returns
  11. * DS207: Consider shorter variations of null checks
  12. * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
  13. */
  14. import App from '../../base'
  15. App.controller('RenameProjectModalController', function(
  16. $scope,
  17. $modalInstance,
  18. $timeout,
  19. project,
  20. queuedHttp
  21. ) {
  22. $scope.inputs = { projectName: project.name }
  23. $scope.state = {
  24. inflight: false,
  25. error: false
  26. }
  27. $modalInstance.opened.then(() =>
  28. $timeout(() => $scope.$broadcast('open'), 200)
  29. )
  30. $scope.rename = function() {
  31. $scope.state.inflight = true
  32. $scope.state.error = false
  33. return $scope
  34. .renameProject(project, $scope.inputs.projectName)
  35. .then(function() {
  36. $scope.state.inflight = false
  37. $scope.state.error = false
  38. return $modalInstance.close()
  39. })
  40. .catch(function(response) {
  41. const { data, status } = response
  42. $scope.state.inflight = false
  43. if (status === 400) {
  44. return ($scope.state.error = { message: data })
  45. } else {
  46. return ($scope.state.error = true)
  47. }
  48. })
  49. }
  50. return ($scope.cancel = () => $modalInstance.dismiss('cancel'))
  51. })
  52. App.controller('CloneProjectModalController', function(
  53. $scope,
  54. $modalInstance,
  55. $timeout,
  56. project
  57. ) {
  58. $scope.inputs = { projectName: project.name + ' (Copy)' }
  59. $scope.state = {
  60. inflight: false,
  61. error: false
  62. }
  63. $modalInstance.opened.then(() =>
  64. $timeout(() => $scope.$broadcast('open'), 200)
  65. )
  66. $scope.clone = function() {
  67. $scope.state.inflight = true
  68. return $scope
  69. .cloneProject(project, $scope.inputs.projectName)
  70. .then(function() {
  71. $scope.state.inflight = false
  72. $scope.state.error = false
  73. return $modalInstance.close()
  74. })
  75. .catch(function(response) {
  76. const { data, status } = response
  77. $scope.state.inflight = false
  78. if (status === 400) {
  79. return ($scope.state.error = { message: data })
  80. } else {
  81. return ($scope.state.error = true)
  82. }
  83. })
  84. }
  85. return ($scope.cancel = () => $modalInstance.dismiss('cancel'))
  86. })
  87. App.controller('NewProjectModalController', function(
  88. $scope,
  89. $modalInstance,
  90. $timeout,
  91. template
  92. ) {
  93. $scope.inputs = { projectName: '' }
  94. $scope.state = {
  95. inflight: false,
  96. error: false
  97. }
  98. $modalInstance.opened.then(() =>
  99. $timeout(() => $scope.$broadcast('open'), 200)
  100. )
  101. $scope.create = function() {
  102. $scope.state.inflight = true
  103. $scope.state.error = false
  104. return $scope
  105. .createProject($scope.inputs.projectName, template)
  106. .then(function(response) {
  107. const { data } = response
  108. $scope.state.inflight = false
  109. $scope.state.error = false
  110. return $modalInstance.close(data.project_id)
  111. })
  112. .catch(function(response) {
  113. const { data, status } = response
  114. $scope.state.inflight = false
  115. if (status === 400) {
  116. return ($scope.state.error = { message: data })
  117. } else {
  118. return ($scope.state.error = true)
  119. }
  120. })
  121. }
  122. return ($scope.cancel = () => $modalInstance.dismiss('cancel'))
  123. })
  124. App.controller('ArchiveTrashLeaveOrDeleteProjectsModalController', function(
  125. $scope,
  126. $modalInstance,
  127. $timeout,
  128. projects,
  129. action
  130. ) {
  131. $scope.projects = projects
  132. $scope.action = action
  133. $scope.confirm = () => $modalInstance.close({ projects, action })
  134. $scope.cancel = () => $modalInstance.dismiss('cancel')
  135. })
  136. App.controller('UploadProjectModalController', function(
  137. $scope,
  138. $modalInstance,
  139. $timeout
  140. ) {
  141. $scope.cancel = () => $modalInstance.dismiss('cancel')
  142. return ($scope.onComplete = function(error, name, response) {
  143. if (response.project_id != null) {
  144. return (window.location = `/project/${response.project_id}`)
  145. }
  146. })
  147. })
  148. App.controller('V1ImportModalController', function(
  149. $scope,
  150. $modalInstance,
  151. project
  152. ) {
  153. $scope.project = project
  154. return ($scope.dismiss = () => $modalInstance.dismiss('cancel'))
  155. })
  156. export default App.controller('ShowErrorModalController', function(
  157. $scope,
  158. $modalInstance,
  159. error
  160. ) {
  161. $scope.error = error
  162. return ($scope.cancel = () => $modalInstance.dismiss('cancel'))
  163. })