HistoryV2DeleteLabelModalController.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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('HistoryV2DeleteLabelModalController', [
  14. '$scope',
  15. '$modalInstance',
  16. 'ide',
  17. 'labelDetails',
  18. function ($scope, $modalInstance, ide, labelDetails) {
  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. },
  43. ])