actions.ts 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  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. import { IServerConfigurations } from 'app/containers/App/types'
  23. export const AppActions = {
  24. getExternalAuthProviders() {
  25. return {
  26. type: ActionTypes.GET_EXTERNAL_AUTH_PROVIDERS
  27. }
  28. },
  29. gotExternalAuthProviders(externalAuthProviders) {
  30. return {
  31. type: ActionTypes.GET_EXTERNAL_AUTH_PROVIDERS_SUCESS,
  32. payload: {
  33. externalAuthProviders
  34. }
  35. }
  36. },
  37. login(username, password, shareToken, resolve, reject?) {
  38. return {
  39. type: ActionTypes.LOGIN,
  40. payload: {
  41. username,
  42. password,
  43. shareToken,
  44. resolve,
  45. reject
  46. }
  47. }
  48. },
  49. logout() {
  50. return {
  51. type: ActionTypes.LOGOUT
  52. }
  53. },
  54. logged(user) {
  55. return {
  56. type: ActionTypes.LOGGED,
  57. payload: {
  58. user
  59. }
  60. }
  61. },
  62. loginFail(error) {
  63. return {
  64. type: ActionTypes.LOGON_FAILURE,
  65. payload: {
  66. error
  67. }
  68. }
  69. },
  70. interceptor(token: string) {
  71. return {
  72. type: ActionTypes.INTERCEPTOR_PREFLIGHT,
  73. payload: {
  74. token
  75. }
  76. }
  77. },
  78. interceptored(shareType, vizType) {
  79. return {
  80. type: ActionTypes.INTERCEPTOR_PREFLIGHT_SUCCESS,
  81. payload: {
  82. shareType,
  83. vizType
  84. }
  85. }
  86. },
  87. interceptorFail() {
  88. return {
  89. type: ActionTypes.INTERCEPTOR_PREFLIGHT_FAIL
  90. }
  91. },
  92. getPermissions(
  93. token: string,
  94. password?: string,
  95. resolve?: () => void,
  96. reject?: () => void
  97. ) {
  98. return {
  99. type: ActionTypes.GET_PERMISSIONS,
  100. payload: {
  101. token,
  102. password,
  103. resolve,
  104. reject
  105. }
  106. }
  107. },
  108. getPermissionsSuccess(download) {
  109. return {
  110. type: ActionTypes.GET_PERMISSIONS_SUCCESS,
  111. payload: {
  112. download
  113. }
  114. }
  115. },
  116. getPermissionsFail() {
  117. return {
  118. type: ActionTypes.GET_PERMISSIONS_FAIL
  119. }
  120. },
  121. getServerConfigurations() {
  122. return {
  123. type: ActionTypes.GET_SERVER_CONFIGURATIONS
  124. }
  125. },
  126. serverConfigurationsGetted(configurations: IServerConfigurations) {
  127. return {
  128. type: ActionTypes.GET_SERVER_CONFIGURATIONS_SUCCESS,
  129. payload: {
  130. configurations
  131. }
  132. }
  133. },
  134. getServerConfigurationsFail(error) {
  135. return {
  136. type: ActionTypes.GET_SERVER_CONFIGURATIONS_FAIL,
  137. payload: {
  138. error
  139. }
  140. }
  141. }
  142. }
  143. const mockAction = returnType(AppActions)
  144. export type AppActionType = typeof mockAction
  145. export default AppActions