actions.ts 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575
  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 OrganizationActions = {
  23. loadOrganizationProjects (param) {
  24. return {
  25. type: ActionTypes.LOAD_ORGANIZATIONS_PROJECTS,
  26. payload: {
  27. param
  28. }
  29. }
  30. },
  31. organizationsProjectsLoaded (projects) {
  32. return {
  33. type: ActionTypes.LOAD_ORGANIZATIONS_PROJECTS_SUCCESS,
  34. payload: {
  35. projects
  36. }
  37. }
  38. },
  39. loadOrganizationsProjectsFail () {
  40. return {
  41. type: ActionTypes.LOAD_ORGANIZATIONS_PROJECTS_FAILURE
  42. }
  43. },
  44. loadOrganizationMembers (id) {
  45. return {
  46. type: ActionTypes.LOAD_ORGANIZATIONS_MEMBERS,
  47. payload: {
  48. id
  49. }
  50. }
  51. }
  52. ,
  53. organizationsMembersLoaded (members) {
  54. return {
  55. type: ActionTypes.LOAD_ORGANIZATIONS_MEMBERS_SUCCESS,
  56. payload: {
  57. members
  58. }
  59. }
  60. },
  61. loadOrganizationsMembersFail () {
  62. return {
  63. type: ActionTypes.LOAD_ORGANIZATIONS_MEMBERS_FAILURE
  64. }
  65. },
  66. loadOrganizationRole (id) {
  67. return {
  68. type: ActionTypes.LOAD_ORGANIZATIONS_ROLE,
  69. payload: {
  70. id
  71. }
  72. }
  73. },
  74. organizationsRoleLoaded (role) {
  75. return {
  76. type: ActionTypes.LOAD_ORGANIZATIONS_ROLE_SUCCESS,
  77. payload: {
  78. role
  79. }
  80. }
  81. },
  82. loadOrganizationsRoleFail () {
  83. return {
  84. type: ActionTypes.LOAD_ORGANIZATIONS_ROLE_FAILURE,
  85. payload: {}
  86. }
  87. },
  88. loadOrganizations () {
  89. return {
  90. type: ActionTypes.LOAD_ORGANIZATIONS
  91. }
  92. },
  93. organizationsLoaded (organizations) {
  94. return {
  95. type: ActionTypes.LOAD_ORGANIZATIONS_SUCCESS,
  96. payload: {
  97. organizations
  98. }
  99. }
  100. },
  101. loadOrganizationsFail () {
  102. return {
  103. type: ActionTypes.LOAD_ORGANIZATIONS_FAILURE,
  104. payload: {}
  105. }
  106. },
  107. addOrganization (organization, resolve) {
  108. return {
  109. type: ActionTypes.ADD_ORGANIZATION,
  110. payload: {
  111. organization,
  112. resolve
  113. }
  114. }
  115. },
  116. organizationAdded (result) {
  117. return {
  118. type: ActionTypes.ADD_ORGANIZATION_SUCCESS,
  119. payload: {
  120. result
  121. }
  122. }
  123. },
  124. addOrganizationFail () {
  125. return {
  126. type: ActionTypes.ADD_ORGANIZATION_FAILURE,
  127. payload: {}
  128. }
  129. },
  130. editOrganization (organization) {
  131. return {
  132. type: ActionTypes.EDIT_ORGANIZATION,
  133. payload: {
  134. organization
  135. }
  136. }
  137. },
  138. organizationEdited (result) {
  139. return {
  140. type: ActionTypes.EDIT_ORGANIZATION_SUCCESS,
  141. payload: {
  142. result
  143. }
  144. }
  145. },
  146. editOrganizationFail () {
  147. return {
  148. type: ActionTypes.EDIT_ORGANIZATION_FAILURE,
  149. payload: {}
  150. }
  151. },
  152. deleteOrganization (id, resolve) {
  153. return {
  154. type: ActionTypes.DELETE_ORGANIZATION,
  155. payload: {
  156. id,
  157. resolve
  158. }
  159. }
  160. },
  161. organizationDeleted (id) {
  162. return {
  163. type: ActionTypes.DELETE_ORGANIZATION_SUCCESS,
  164. payload: {
  165. id
  166. }
  167. }
  168. },
  169. deleteOrganizationFail () {
  170. return {
  171. type: ActionTypes.DELETE_ORGANIZATION_FAILURE,
  172. payload: {}
  173. }
  174. },
  175. loadOrganizationDetail (id) {
  176. return {
  177. type: ActionTypes.LOAD_ORGANIZATION_DETAIL,
  178. payload: {
  179. id
  180. }
  181. }
  182. },
  183. organizationDetailLoaded (organization) {
  184. return {
  185. type: ActionTypes.LOAD_ORGANIZATION_DETAIL_SUCCESS,
  186. payload: {
  187. organization
  188. }
  189. }
  190. },
  191. loadOrganizationDetailFail (organization, widgets) {
  192. return {
  193. type: ActionTypes.LOAD_ORGANIZATION_DETAIL_FAILURE,
  194. payload: {
  195. organization,
  196. widgets
  197. }
  198. }
  199. },
  200. addRole (name, description, id, resolve) {
  201. return {
  202. type: ActionTypes.ADD_ROLE,
  203. payload: {
  204. name,
  205. description,
  206. id,
  207. resolve
  208. }
  209. }
  210. },
  211. roleAdded (result) {
  212. return {
  213. type: ActionTypes.ADD_ROLE_SUCCESS,
  214. payload: {
  215. result
  216. }
  217. }
  218. },
  219. addRoleFail () {
  220. return {
  221. type: ActionTypes.ADD_ROLE_FAILURE,
  222. payload: {}
  223. }
  224. },
  225. deleteRole (id, resolve) {
  226. return {
  227. type: ActionTypes.DELETE_ROLE,
  228. payload: {
  229. id,
  230. resolve
  231. }
  232. }
  233. },
  234. roleDeleted (result) {
  235. return {
  236. type: ActionTypes.DELETE_ROLE_SUCCESS,
  237. payload: {
  238. result
  239. }
  240. }
  241. },
  242. deleteRoleFail () {
  243. return {
  244. type: ActionTypes.DELETE_ROLE_FAILURE,
  245. payload: {}
  246. }
  247. },
  248. editRole (name, description, id, resolve) {
  249. return {
  250. type: ActionTypes.EDIT_ROLE,
  251. payload: {
  252. name, description, id, resolve
  253. }
  254. }
  255. },
  256. roleEdited (result) {
  257. return {
  258. type: ActionTypes.EDIT_ROLE_SUCCESS,
  259. payload: {
  260. result
  261. }
  262. }
  263. },
  264. editRoleFail () {
  265. return {
  266. type: ActionTypes.EDIT_ROLE_FAILURE,
  267. payload: {}
  268. }
  269. },
  270. searchMember (keyword) {
  271. return {
  272. type: ActionTypes.SEARCH_MEMBER,
  273. payload: {
  274. keyword
  275. }
  276. }
  277. },
  278. memberSearched (result) {
  279. return {
  280. type: ActionTypes.SEARCH_MEMBER_SUCCESS,
  281. payload: {
  282. result
  283. }
  284. }
  285. },
  286. searchMemberFail () {
  287. return {
  288. type: ActionTypes.SEARCH_MEMBER_FAILURE,
  289. payload: {}
  290. }
  291. },
  292. inviteMember (orgId, members, needEmail, resolve) {
  293. return {
  294. type: ActionTypes.INVITE_MEMBER,
  295. payload: {
  296. orgId,
  297. members,
  298. needEmail,
  299. resolve
  300. }
  301. }
  302. },
  303. inviteMemberSuccess (result) {
  304. return {
  305. type: ActionTypes.INVITE_MEMBER_SUCCESS,
  306. payload: {
  307. result
  308. }
  309. }
  310. },
  311. inviteMemberFail () {
  312. return {
  313. type: ActionTypes.INVITE_MEMBER_FAILURE,
  314. payload: {}
  315. }
  316. }
  317. ,
  318. deleteOrganizationMember (relationId, resolve) {
  319. return {
  320. type: ActionTypes.DELETE_ORGANIZATION_MEMBER,
  321. payload: {
  322. relationId,
  323. resolve
  324. }
  325. }
  326. },
  327. organizationMemberDeleted (id) {
  328. return {
  329. type: ActionTypes.DELETE_ORGANIZATION_MEMBER_SUCCESS,
  330. payload: {
  331. id
  332. }
  333. }
  334. },
  335. deleteOrganizationMemberFail () {
  336. return {
  337. type: ActionTypes.DELETE_ORGANIZATION_MEMBER_ERROR,
  338. payload: {}
  339. }
  340. },
  341. changeOrganizationMemberRole (relationId, newRole, resolve) {
  342. return {
  343. type: ActionTypes.CHANGE_MEMBER_ROLE_ORGANIZATION,
  344. payload: {
  345. relationId,
  346. newRole,
  347. resolve
  348. }
  349. }
  350. },
  351. organizationMemberRoleChanged (relationId, newRole) {
  352. return {
  353. type: ActionTypes.CHANGE_MEMBER_ROLE_ORGANIZATION_SUCCESS,
  354. payload: {
  355. relationId,
  356. newRole
  357. }
  358. }
  359. },
  360. changeOrganizationMemberRoleFail () {
  361. return {
  362. type: ActionTypes.CHANGE_MEMBER_ROLE_ORGANIZATION_ERROR,
  363. payload: {}
  364. }
  365. },
  366. relRoleMember (id, memberIds, resolve) {
  367. return {
  368. type: ActionTypes.REL_ROLE_MEMBER,
  369. payload: {
  370. id,
  371. memberIds,
  372. resolve
  373. }
  374. }
  375. },
  376. relRoleMemberSuccess () {
  377. return {
  378. type: ActionTypes.REL_ROLE_MEMBER_SUCCESS,
  379. payload: {}
  380. }
  381. },
  382. relRoleMemberFail () {
  383. return {
  384. type: ActionTypes.REL_ROLE_MEMBER_FAILURE,
  385. payload: {}
  386. }
  387. },
  388. getRelRoleMember (id, resolve) {
  389. return {
  390. type: ActionTypes.GET_REL_ROLE_MEMBER,
  391. payload: {
  392. id,
  393. resolve
  394. }
  395. }
  396. },
  397. getRelRoleMemberSuccess () {
  398. return {
  399. type: ActionTypes.GET_REL_ROLE_MEMBER_SUCCESS,
  400. payload: {}
  401. }
  402. },
  403. getRelRoleMemberFail () {
  404. return {
  405. type: ActionTypes.GET_REL_ROLE_MEMBER_FAILURE,
  406. payload: {}
  407. }
  408. },
  409. setCurrentProject (option) {
  410. return {
  411. type: ActionTypes.SET_CURRENT_ORIGANIZATION_PROJECT,
  412. payload: {
  413. option
  414. }
  415. }
  416. },
  417. loadProjectAdmin (projectId) {
  418. return {
  419. type: ActionTypes.LOAD_PROJECT_ADMINS,
  420. payload: {
  421. projectId
  422. }
  423. }
  424. },
  425. projectAdminLoaded (result) {
  426. return {
  427. type: ActionTypes.LOAD_PROJECT_ADMINS_SUCCESS,
  428. payload: {
  429. result
  430. }
  431. }
  432. },
  433. loadProjectAdminFail () {
  434. return {
  435. type: ActionTypes.LOAD_PROJECT_ADMINS_FAIL,
  436. payload: {}
  437. }
  438. }
  439. ,
  440. loadProjectRoles (projectId) {
  441. return {
  442. type: ActionTypes.LOAD_PROJECT_ROLES,
  443. payload: {
  444. projectId
  445. }
  446. }
  447. },
  448. projectRolesLoaded (result) {
  449. return {
  450. type: ActionTypes.LOAD_PROJECT_ROLES_SUCCESS,
  451. payload: {
  452. result
  453. }
  454. }
  455. },
  456. loadProjectRolesFail () {
  457. return {
  458. type: ActionTypes.LOAD_PROJECT_ROLES_FAIL,
  459. payload: {}
  460. }
  461. },
  462. getVizVisbility (roleId, projectId, resolve) {
  463. return {
  464. type: ActionTypes.GET_VIZ_VISBILITY,
  465. payload: {
  466. roleId, projectId, resolve
  467. }
  468. }
  469. },
  470. postVizVisbility (id, permission, resolve) {
  471. return {
  472. type: ActionTypes.POST_VIZ_VISBILITY,
  473. payload: {
  474. id,
  475. resolve,
  476. permission
  477. }
  478. }
  479. },
  480. getRoleListByMemberId (orgId: number, memberId: number, resolve: (res: any) => void) {
  481. return {
  482. type: ActionTypes.GET_ROLELISTS_BY_MEMBERID,
  483. payload: {
  484. orgId,
  485. memberId,
  486. resolve
  487. }
  488. }
  489. },
  490. getRoleListByMemberIdSuccess (result, memberId: number) {
  491. return {
  492. type: ActionTypes.GET_ROLELISTS_BY_MEMBERID_SUCCESS,
  493. payload: {
  494. result,
  495. memberId
  496. }
  497. }
  498. },
  499. getRoleListByMemberIdFail (error, memberId: number) {
  500. return {
  501. type: ActionTypes.GET_ROLELISTS_BY_MEMBERID_ERROR,
  502. payload: {
  503. error,
  504. memberId
  505. }
  506. }
  507. }
  508. }
  509. const mockAction = returnType(OrganizationActions)
  510. export type OrganizationActionType = typeof mockAction
  511. export default OrganizationActions