HistoryV2DeleteLabelModalController.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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', 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. })