dashboardConfig.ts 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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 controlMigrationRecorder from './control'
  21. import { IMigrationRecorder } from '.'
  22. import { IDashboardConfig } from 'app/containers/Dashboard/types'
  23. import { ControlQueryMode } from 'app/components/Control/constants'
  24. interface IDashboardConfigMigrationRecorder extends IMigrationRecorder {
  25. recorders: {
  26. beta5(config: IDashboardConfig): IDashboardConfig
  27. beta9(config: IDashboardConfig, options?): IDashboardConfig
  28. }
  29. }
  30. const dashboardConfigMigrationRecorder: IDashboardConfigMigrationRecorder = {
  31. versions: ['beta5', 'beta9'],
  32. recorders: {
  33. beta5(config) {
  34. return {
  35. ...config,
  36. filters: (config.filters || []).map((control) =>
  37. controlMigrationRecorder.beta5(control)
  38. ),
  39. linkages: config.linkages || [],
  40. queryMode:
  41. config.queryMode === void 0
  42. ? ControlQueryMode.Immediately
  43. : config.queryMode
  44. }
  45. },
  46. beta9(config, options) {
  47. return {
  48. ...config,
  49. filters: (config.filters || []).map((control) =>
  50. controlMigrationRecorder.beta9(control, options)
  51. )
  52. }
  53. }
  54. }
  55. }
  56. export default dashboardConfigMigrationRecorder