HistoryV2DeleteLabelModalController.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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. define(['../../../base'], App =>
  13. App.controller('HistoryV2DeleteLabelModalController', function(
  14. $scope,
  15. $modalInstance,
  16. ide,
  17. labelDetails
  18. ) {
  19. $scope.labelDetails = labelDetails
  20. $scope.state = {
  21. inflight: false,
  22. error: false
  23. }
  24. return ($scope.deleteLabel = function() {
  25. $scope.state.inflight = true
  26. return ide.historyManager
  27. .deleteLabel(labelDetails)
  28. .then(function(response) {
  29. $scope.state.inflight = false
  30. return $modalInstance.close()
  31. })
  32. .catch(function(response) {
  33. const { data, status } = response
  34. $scope.state.inflight = false
  35. if (status === 400) {
  36. return ($scope.state.error = { message: data })
  37. } else {
  38. return ($scope.state.error = true)
  39. }
  40. })
  41. })
  42. }))