WizardActions.js 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. /*
  2. Copyright (C) 2017 Cloudbase Solutions SRL
  3. This program is free software: you can redistribute it and/or modify
  4. it under the terms of the GNU Affero General Public License as
  5. published by the Free Software Foundation, either version 3 of the
  6. License, or (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU Affero General Public License for more details.
  11. You should have received a copy of the GNU Affero General Public License
  12. along with this program. If not, see <http://www.gnu.org/licenses/>.
  13. */
  14. import alt from '../alt'
  15. import WizardSource from '../sources/WizardSource'
  16. class WizardActions {
  17. updateData(data) {
  18. return data
  19. }
  20. toggleInstanceSelection(instance) {
  21. return instance
  22. }
  23. clearData() {
  24. return true
  25. }
  26. setCurrentPage(page) {
  27. return page
  28. }
  29. updateOptions({ field, value }) {
  30. return { field, value }
  31. }
  32. updateNetworks({ sourceNic, targetNetwork }) {
  33. return { sourceNic, targetNetwork }
  34. }
  35. addSchedule(schedule) {
  36. return schedule || true
  37. }
  38. updateSchedule(scheduleId, data) {
  39. return { scheduleId, data }
  40. }
  41. removeSchedule(scheduleId) {
  42. return scheduleId
  43. }
  44. create(type, data) {
  45. return {
  46. type,
  47. data,
  48. promise: WizardSource.create(type, data).then(
  49. item => { this.createSuccess(item) },
  50. response => { this.createFailed(response) }
  51. ),
  52. }
  53. }
  54. createSuccess(item) {
  55. return item
  56. }
  57. createFailed(reponse) {
  58. return reponse || true
  59. }
  60. createMultiple(type, data) {
  61. return {
  62. type,
  63. data,
  64. promise: WizardSource.createMultiple(type, data).then(
  65. items => { this.createMultipleSuccess(items) },
  66. response => { this.createMultipleFailed(response) }
  67. ),
  68. }
  69. }
  70. createMultipleSuccess(items) {
  71. return items
  72. }
  73. createMultipleFailed(response) {
  74. return response || true
  75. }
  76. setPermalink(data) {
  77. WizardSource.setPermalink(data)
  78. return data || true
  79. }
  80. getDataFromPermalink() {
  81. let data = WizardSource.getDataFromPermalink()
  82. return data || true
  83. }
  84. }
  85. export default alt.createActions(WizardActions)