actions.ts 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504
  1. /*
  2. * <<
  3. * Davinci
  4. * ==
  5. * Copyright (C) 2016 - 2017 EDP
  6. * ==
  7. * Licensed under the Apache License, Version 2.0 (the "License");
  8. * you may not use this file except in compliance with the License.
  9. * You may obtain a copy of the License at
  10. *
  11. * http://www.apache.org/licenses/LICENSE-2.0
  12. *
  13. * Unless required by applicable law or agreed to in writing, software
  14. * distributed under the License is distributed on an "AS IS" BASIS,
  15. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  16. * See the License for the specific language governing permissions and
  17. * limitations under the License.
  18. * >>
  19. */
  20. import { ActionTypes } from './constants'
  21. import { returnType } from 'utils/redux'
  22. export const ProjectActions = {
  23. loadProjectDetail (id) {
  24. return {
  25. type: ActionTypes.LOAD_PROJECT_DETAIL,
  26. payload: {
  27. id
  28. }
  29. }
  30. },
  31. clearCurrentProject () {
  32. return {
  33. type: ActionTypes.CLEAR_CURRENT_PROJECT
  34. }
  35. }
  36. ,
  37. loadProjects () {
  38. return {
  39. type: ActionTypes.LOAD_PROJECTS
  40. }
  41. },
  42. projectsLoaded (projects) {
  43. return {
  44. type: ActionTypes.LOAD_PROJECTS_SUCCESS,
  45. payload: {
  46. projects
  47. }
  48. }
  49. },
  50. loadProjectsFail () {
  51. return {
  52. type: ActionTypes.LOAD_PROJECTS_FAILURE
  53. }
  54. },
  55. addProject (project, resolve) {
  56. return {
  57. type: ActionTypes.ADD_PROJECT,
  58. payload: {
  59. project,
  60. resolve
  61. }
  62. }
  63. },
  64. projectAdded (result) {
  65. return {
  66. type: ActionTypes.ADD_PROJECT_SUCCESS,
  67. payload: {
  68. result
  69. }
  70. }
  71. },
  72. addProjectFail () {
  73. return {
  74. type: ActionTypes.ADD_PROJECT_FAILURE
  75. }
  76. },
  77. editProject (project, resolve) {
  78. return {
  79. type: ActionTypes.EDIT_PROJECT,
  80. payload: {
  81. project,
  82. resolve
  83. }
  84. }
  85. },
  86. projectEdited (result) {
  87. return {
  88. type: ActionTypes.EDIT_PROJECT_SUCCESS,
  89. payload: {
  90. result
  91. }
  92. }
  93. },
  94. editProjectFail () {
  95. return {
  96. type: ActionTypes.EDIT_PROJECT_FAILURE
  97. }
  98. },
  99. transferProject (id, orgId, resolve?) {
  100. return {
  101. type: ActionTypes.TRANSFER_PROJECT,
  102. payload: {
  103. id,
  104. orgId,
  105. resolve
  106. }
  107. }
  108. },
  109. projectTransfered (result) {
  110. return {
  111. type: ActionTypes.TRANSFER_PROJECT_SUCCESS,
  112. payload: {
  113. result
  114. }
  115. }
  116. },
  117. transferProjectFail () {
  118. return {
  119. type: ActionTypes.TRANSFER_PROJECT_FAILURE
  120. }
  121. },
  122. deleteProject (id, resolve) {
  123. return {
  124. type: ActionTypes.DELETE_PROJECT,
  125. payload: {
  126. id,
  127. resolve
  128. }
  129. }
  130. },
  131. projectDeleted (id) {
  132. return {
  133. type: ActionTypes.DELETE_PROJECT_SUCCESS,
  134. payload: {
  135. id
  136. }
  137. }
  138. },
  139. deleteProjectFail () {
  140. return {
  141. type: ActionTypes.DELETE_PROJECT_FAILURE
  142. }
  143. },
  144. projectDetailLoaded (project) {
  145. return {
  146. type: ActionTypes.LOAD_PROJECT_DETAIL_SUCCESS,
  147. payload: {
  148. project
  149. }
  150. }
  151. }
  152. ,
  153. loadProjectDetailFail () {
  154. return {
  155. type: ActionTypes.LOAD_PROJECT_DETAIL_FAILURE
  156. }
  157. },
  158. searchProject (param) {
  159. return {
  160. type: ActionTypes.SEARCH_PROJECT,
  161. payload: {
  162. param
  163. }
  164. }
  165. },
  166. projectSearched (result) {
  167. return {
  168. type: ActionTypes.SEARCH_PROJECT_SUCCESS,
  169. payload: {
  170. result
  171. }
  172. }
  173. },
  174. searchProjectFail () {
  175. return {
  176. type: ActionTypes.SEARCH_PROJECT_FAILURE
  177. }
  178. },
  179. getProjectStarUser (id) {
  180. return {
  181. type: ActionTypes.GET_PROJECT_STAR_USER,
  182. payload: {
  183. id
  184. }
  185. }
  186. },
  187. getProjectStarUserSuccess (result) {
  188. return {
  189. type: ActionTypes.GET_PROJECT_STAR_USER_SUCCESS,
  190. payload: {
  191. result
  192. }
  193. }
  194. },
  195. getProjectStarUserFail () {
  196. return {
  197. type: ActionTypes.GET_PROJECT_STAR_USER_FAILURE
  198. }
  199. },
  200. unStarProject (id, resolve) {
  201. return {
  202. type: ActionTypes.PROJECT_UNSTAR,
  203. payload: {
  204. id,
  205. resolve
  206. }
  207. }
  208. },
  209. unStarProjectSuccess (result) {
  210. return {
  211. type: ActionTypes.PROJECT_UNSTAR_SUCCESS,
  212. payload: {
  213. result
  214. }
  215. }
  216. },
  217. unStarProjectFail () {
  218. return {
  219. type: ActionTypes.PROJECT_UNSTAR_FAILURE
  220. }
  221. },
  222. loadCollectProjects () {
  223. return {
  224. type: ActionTypes.LOAD_COLLECT_PROJECTS
  225. }
  226. },
  227. collectProjectLoaded (result) {
  228. return {
  229. type: ActionTypes.LOAD_COLLECT_PROJECTS_SUCCESS,
  230. payload: {
  231. result
  232. }
  233. }
  234. },
  235. collectProjectFail () {
  236. return {
  237. type: ActionTypes.LOAD_COLLECT_PROJECTS_FAILURE
  238. }
  239. },
  240. clickCollectProjects (isFavorite, proId, resolve) {
  241. return {
  242. type: ActionTypes.CLICK_COLLECT_PROJECT,
  243. payload: {
  244. isFavorite,
  245. proId,
  246. resolve
  247. }
  248. }
  249. },
  250. collectProjectClicked (result) {
  251. return {
  252. type: ActionTypes.CLICK_COLLECT_PROJECT_SUCCESS,
  253. payload: {
  254. result
  255. }
  256. }
  257. },
  258. clickCollectProjectFail () {
  259. return {
  260. type: ActionTypes.CLICK_COLLECT_PROJECT_FAILURE
  261. }
  262. },
  263. addProjectAdmin (id, adminIds, resolve) {
  264. return {
  265. type: ActionTypes.ADD_PROJECT_ADMIN,
  266. payload: {
  267. id, adminIds, resolve
  268. }
  269. }
  270. },
  271. projectAdminAdded (result) {
  272. return {
  273. type: ActionTypes.ADD_PROJECT_ADMIN_SUCCESS,
  274. payload: {
  275. result
  276. }
  277. }
  278. },
  279. addProjectAdminFail () {
  280. return {
  281. type: ActionTypes.ADD_PROJECT_ADMIN_FAIL
  282. }
  283. },
  284. deleteProjectAdmin (id, relationId , resolve) {
  285. return {
  286. type: ActionTypes.DELETE_PROJECT_ADMIN,
  287. payload: {
  288. id, relationId , resolve
  289. }
  290. }
  291. },
  292. projectAdminDeleted (result) {
  293. return {
  294. type: ActionTypes.DELETE_PROJECT_ADMIN_SUCCESS,
  295. payload: {
  296. result
  297. }
  298. }
  299. },
  300. deleteProjectAdminFail () {
  301. return {
  302. type: ActionTypes.DELETE_PROJECT_ADMIN_FAIL
  303. }
  304. },
  305. addProjectRole (projectId, roleIds, resolve) {
  306. return {
  307. type: ActionTypes.ADD_PROJECT_ROLE,
  308. payload: {
  309. projectId, roleIds, resolve
  310. }
  311. }
  312. },
  313. projectRoleAdded (result) {
  314. return {
  315. type: ActionTypes.ADD_PROJECT_ROLE_SUCCESS,
  316. payload: {
  317. result
  318. }
  319. }
  320. },
  321. addProjectRoleFail () {
  322. return {
  323. type: ActionTypes.ADD_PROJECT_ROLE_FAIL
  324. }
  325. },
  326. deleteProjectRole (id, relationId , resolve) {
  327. return {
  328. type: ActionTypes.DELETE_PROJECT_ROLE,
  329. payload: {
  330. id, relationId , resolve
  331. }
  332. }
  333. },
  334. projectRoleDeleted (result) {
  335. return {
  336. type: ActionTypes.DELETE_PROJECT_ROLE_SUCCESS,
  337. payload: {
  338. result
  339. }
  340. }
  341. },
  342. deleteProjectRoleFail () {
  343. return {
  344. type: ActionTypes.DELETE_PROJECT_ROLE_FAIL
  345. }
  346. },
  347. updateRelRoleProject (roleId, projectId, projectRole) {
  348. return {
  349. type: ActionTypes.UPDATE_RELATION_ROLE_PROJECT,
  350. payload: {
  351. roleId,
  352. projectId,
  353. projectRole
  354. }
  355. }
  356. },
  357. relRoleProjectUpdated (result) {
  358. return {
  359. type: ActionTypes.UPDATE_RELATION_ROLE_PROJECT_SUCCESS,
  360. payload: {
  361. result
  362. }
  363. }
  364. },
  365. updateRelRoleProjectFail () {
  366. return {
  367. type: ActionTypes.UPDATE_RELATION_ROLE_PROJECT_FAIL
  368. }
  369. },
  370. deleteRelRoleProject (roleId, projectId, resolve) {
  371. return {
  372. type: ActionTypes.DELETE_RELATION_ROLE_PROJECT,
  373. payload: {
  374. roleId,
  375. projectId,
  376. resolve
  377. }
  378. }
  379. },
  380. relRoleProjectDeleted (result) {
  381. return {
  382. type: ActionTypes.DELETE_RELATION_ROLE_PROJECT_SUCCESS,
  383. payload: {
  384. result
  385. }
  386. }
  387. },
  388. deleteRelRoleProjectFail () {
  389. return {
  390. type: ActionTypes.DELETE_RELATION_ROLE_PROJECT_FAIL
  391. }
  392. },
  393. loadRelRoleProject (id, roleId) {
  394. return {
  395. type: ActionTypes.LOAD_RELATION_ROLE_PROJECT,
  396. payload: {
  397. id,
  398. roleId
  399. }
  400. }
  401. },
  402. relRoleProjectLoaded (result) {
  403. return {
  404. type: ActionTypes.RELATION_ROLE_PROJECT_LOADED,
  405. payload: {
  406. result
  407. }
  408. }
  409. },
  410. loadRelRoleProjectFail () {
  411. return {
  412. type: ActionTypes.LOAD_RELATION_ROLE_PROJECT_FAIL
  413. }
  414. }
  415. ,
  416. excludeRoles (type, id, resolve) {
  417. return {
  418. type: ActionTypes.EXCLUDE_ROLES,
  419. payload: {type, id, resolve}
  420. }
  421. },
  422. rolesExcluded (result) {
  423. return {
  424. type: ActionTypes.EXCLUDE_ROLES_SUCCESS,
  425. payload: {
  426. result
  427. }
  428. }
  429. },
  430. excludeRolesFail (err) {
  431. return {
  432. type: ActionTypes.EXCLUDE_ROLES_FAIL,
  433. payload: {
  434. err
  435. }
  436. }
  437. }
  438. }
  439. const mockAction = returnType(ProjectActions)
  440. export type ProjectActionType = typeof mockAction
  441. export default ProjectActions