HistoryV2AddLabelModalController.js 1.3 KB

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