selectors.ts 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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 { RouterState } from 'connected-react-router'
  22. const selectGlobal = (state) => state.global
  23. const selectRouter = (state: { router: RouterState }) => state.router
  24. const makeSelectExternalAuthProviders = () =>
  25. createSelector(
  26. selectGlobal,
  27. (globalState) => globalState.externalAuthProviders
  28. )
  29. const makeSelectLogged = () =>
  30. createSelector(
  31. selectGlobal,
  32. (globalState) => globalState.logged
  33. )
  34. const makeSelectLoginUser = () =>
  35. createSelector(
  36. selectGlobal,
  37. (globalState) => globalState.loginUser
  38. )
  39. const makeSelectLoginLoading = () =>
  40. createSelector(
  41. selectGlobal,
  42. (globalState) => globalState.loginLoading
  43. )
  44. const makeSelectNavigator = () =>
  45. createSelector(
  46. selectGlobal,
  47. (globalState) => globalState.navigator
  48. )
  49. const makeSelectDownloadList = () =>
  50. createSelector(
  51. selectGlobal,
  52. (globalState) => globalState.downloadList
  53. )
  54. const makeSelectDownloadListLoading = () =>
  55. createSelector(
  56. selectGlobal,
  57. (globalState) => globalState.downloadListLoading
  58. )
  59. const makeSelectLocation = () =>
  60. createSelector(
  61. selectRouter,
  62. (routerState) => routerState.location
  63. )
  64. const makeSelectVersion = () =>
  65. createSelector(
  66. selectGlobal,
  67. (globalState) => globalState.version
  68. )
  69. const makeSelectOauth2Enabled = () =>
  70. createSelector(
  71. selectGlobal,
  72. (globalState) => globalState.oauth2Enabled
  73. )
  74. export {
  75. selectGlobal,
  76. makeSelectVersion,
  77. makeSelectOauth2Enabled,
  78. makeSelectExternalAuthProviders,
  79. makeSelectLogged,
  80. makeSelectLoginUser,
  81. makeSelectLoginLoading,
  82. makeSelectNavigator,
  83. makeSelectLocation,
  84. makeSelectDownloadList,
  85. makeSelectDownloadListLoading
  86. }