HistoryV2DeleteLabelModalController.js 1.2 KB

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