selectors.ts 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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 { createSelector } from 'reselect'
  21. import { initialState } from './reducer'
  22. const selectGlobal = (state) => state.global || initialState
  23. const makeSelectLoginLoading = () => createSelector(
  24. selectGlobal,
  25. (globalState) => globalState.loading
  26. )
  27. const makeSelectLogged = () => createSelector(
  28. selectGlobal,
  29. (globalState) => globalState.logged
  30. )
  31. const makeSelectLoginUser = () => createSelector(
  32. selectGlobal,
  33. (globalState) => globalState.loginUser
  34. )
  35. const makeSelectShareType = () => createSelector(
  36. selectGlobal,
  37. (globalState) => {
  38. return globalState.shareType
  39. }
  40. )
  41. const makeSelectVizType = () => createSelector(
  42. selectGlobal,
  43. (globalState) => {
  44. return globalState.vizType
  45. }
  46. )
  47. const makeSelectPermission = () => createSelector(
  48. selectGlobal,
  49. (globalState) => {
  50. return globalState.download
  51. }
  52. )
  53. const makeSelectPermissionLoading = () => createSelector(
  54. selectGlobal,
  55. (globalState) => {
  56. return globalState.permissionLoading
  57. }
  58. )
  59. const makeSelectExternalAuthProviders = () =>
  60. createSelector(
  61. selectGlobal,
  62. (globalState) => globalState.externalAuthProviders
  63. )
  64. const makeSelectOauth2Enabled = () =>
  65. createSelector(
  66. selectGlobal,
  67. (globalState) => globalState.oauth2Enabled
  68. )
  69. export {
  70. selectGlobal,
  71. makeSelectLoginLoading,
  72. makeSelectLogged,
  73. makeSelectLoginUser,
  74. makeSelectShareType,
  75. makeSelectVizType,
  76. makeSelectPermission,
  77. makeSelectPermissionLoading,
  78. makeSelectExternalAuthProviders,
  79. makeSelectOauth2Enabled
  80. }