HistoryV2AddLabelModalController.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /* eslint-disable
  2. max-len,
  3. no-return-assign,
  4. no-undef,
  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. * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
  12. */
  13. define(['base'], App =>
  14. App.controller('HistoryV2AddLabelModalController', function(
  15. $scope,
  16. $modalInstance,
  17. ide,
  18. update
  19. ) {
  20. $scope.update = update
  21. $scope.inputs = { labelName: null }
  22. $scope.state = {
  23. inflight: false,
  24. error: false
  25. }
  26. $modalInstance.opened.then(() =>
  27. $scope.$applyAsync(() => $scope.$broadcast('open'))
  28. )
  29. return ($scope.addLabelModalFormSubmit = function() {
  30. $scope.state.inflight = true
  31. return ide.historyManager
  32. .labelCurrentVersion($scope.inputs.labelName)
  33. .then(function(response) {
  34. $scope.state.inflight = false
  35. return $modalInstance.close()
  36. })
  37. .catch(function(response) {
  38. const { data, status } = response
  39. $scope.state.inflight = false
  40. if (status === 400) {
  41. return ($scope.state.error = { message: data })
  42. } else {
  43. return ($scope.state.error = true)
  44. }
  45. })
  46. })
  47. }))