HistoryV2AddLabelModalController.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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('HistoryV2AddLabelModalController', [
  14. '$scope',
  15. '$modalInstance',
  16. 'ide',
  17. 'update',
  18. function ($scope, $modalInstance, ide, update) {
  19. $scope.update = update
  20. $scope.inputs = { labelName: null }
  21. $scope.state = {
  22. inflight: false,
  23. error: false,
  24. }
  25. $modalInstance.opened.then(() =>
  26. $scope.$applyAsync(() => $scope.$broadcast('open'))
  27. )
  28. return ($scope.addLabelModalFormSubmit = function () {
  29. $scope.state.inflight = true
  30. return ide.historyManager
  31. .labelCurrentVersion($scope.inputs.labelName)
  32. .then(function (response) {
  33. $scope.state.inflight = false
  34. return $modalInstance.close()
  35. })
  36. .catch(function (response) {
  37. const { data, status } = response
  38. $scope.state.inflight = false
  39. if (status === 400) {
  40. return ($scope.state.error = { message: data })
  41. } else {
  42. return ($scope.state.error = true)
  43. }
  44. })
  45. })
  46. },
  47. ])