HistoryV2DeleteLabelModalController.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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('HistoryV2DeleteLabelModalController', function(
  15. $scope,
  16. $modalInstance,
  17. ide,
  18. labelDetails
  19. ) {
  20. $scope.labelDetails = labelDetails
  21. $scope.state = {
  22. inflight: false,
  23. error: false
  24. }
  25. return ($scope.deleteLabel = function() {
  26. $scope.state.inflight = true
  27. return ide.historyManager
  28. .deleteLabel(labelDetails)
  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. }))