History.tsx 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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 React from 'react'
  21. import { Icon, Breadcrumb } from 'antd'
  22. export interface IDataDrillHistoryProps {
  23. itemId?: number
  24. widgetId: number
  25. drillHistory?: any
  26. onSelectDrillHistory?: (
  27. history?: any,
  28. item?: number,
  29. itemId?: number,
  30. widgetId?: number
  31. ) => void
  32. }
  33. export function DataDrillHistory(props: IDataDrillHistoryProps) {
  34. const { drillHistory, onSelectDrillHistory, itemId, widgetId } = props
  35. return (
  36. <Breadcrumb separator=">">
  37. {
  38. <Breadcrumb.Item onClick={drill(false, -1)} key={`dhall`}>
  39. 返回
  40. </Breadcrumb.Item>
  41. }
  42. {drillHistory && drillHistory.length
  43. ? drillHistory.map((history, index) => (
  44. <Breadcrumb.Item onClick={drill(history, index)} key={`dh${index}`}>
  45. {history.currentGroup}
  46. <Icon
  47. type={`${history.type === 'up' ? 'arrow-up' : 'arrow-down'}`}
  48. />
  49. </Breadcrumb.Item>
  50. ))
  51. : ''}
  52. </Breadcrumb>
  53. )
  54. function drill(history, item) {
  55. return function () {
  56. if (item === drillHistory.length - 1) {
  57. return
  58. }
  59. if (onSelectDrillHistory) {
  60. onSelectDrillHistory(history, item, itemId, widgetId)
  61. }
  62. }
  63. }
  64. }
  65. export default DataDrillHistory