MigrationDetailsContent.tsx 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. /*
  2. Copyright (C) 2017 Cloudbase Solutions SRL
  3. This program is free software: you can redistribute it and/or modify
  4. it under the terms of the GNU Affero General Public License as
  5. published by the Free Software Foundation, either version 3 of the
  6. License, or (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU Affero General Public License for more details.
  11. You should have received a copy of the GNU Affero General Public License
  12. along with this program. If not, see <http://www.gnu.org/licenses/>.
  13. */
  14. import React from 'react'
  15. import { observer } from 'mobx-react'
  16. import styled from 'styled-components'
  17. import Button from '@src/components/ui/Button'
  18. import DetailsNavigation from '@src/components/modules/NavigationModule/DetailsNavigation'
  19. import MainDetails from '@src/components/modules/TransferModule/MainDetails'
  20. import Tasks from '@src/components/modules/TransferModule/Tasks'
  21. import type { Instance } from '@src/@types/Instance'
  22. import type { Endpoint, StorageBackend } from '@src/@types/Endpoint'
  23. import type { Field } from '@src/@types/Field'
  24. import { MigrationItemDetails } from '@src/@types/MainItem'
  25. import { MinionPool } from '@src/@types/MinionPool'
  26. import { Network } from '@src/@types/Network'
  27. import { ThemeProps } from '@src/components/Theme'
  28. const Wrapper = styled.div<any>`
  29. display: flex;
  30. justify-content: center;
  31. `
  32. const Buttons = styled.div<any>`
  33. margin-top: 24px;
  34. & > button:last-child {
  35. float: right;
  36. }
  37. `
  38. const DetailsBody = styled.div<any>`
  39. ${ThemeProps.exactWidth(ThemeProps.contentWidth)}
  40. `
  41. const NavigationItems = [
  42. {
  43. label: 'Migration',
  44. value: '',
  45. }, {
  46. label: 'Tasks',
  47. value: 'tasks',
  48. },
  49. ]
  50. type Props = {
  51. item: MigrationItemDetails | null,
  52. itemId: string
  53. minionPools: MinionPool[]
  54. detailsLoading: boolean,
  55. storageBackends: StorageBackend[]
  56. instancesDetails: Instance[],
  57. instancesDetailsLoading: boolean,
  58. networks: Network[],
  59. sourceSchema: Field[],
  60. sourceSchemaLoading: boolean,
  61. destinationSchema: Field[],
  62. destinationSchemaLoading: boolean,
  63. endpoints: Endpoint[],
  64. page: string,
  65. onDeleteMigrationClick: () => void,
  66. }
  67. @observer
  68. class MigrationDetailsContent extends React.Component<Props> {
  69. renderBottomControls() {
  70. return (
  71. <Buttons>
  72. <Button
  73. alert
  74. hollow
  75. onClick={this.props.onDeleteMigrationClick}
  76. >Delete Migration
  77. </Button>
  78. </Buttons>
  79. )
  80. }
  81. renderMainDetails() {
  82. if (this.props.page !== '') {
  83. return null
  84. }
  85. return (
  86. <MainDetails
  87. item={this.props.item}
  88. storageBackends={this.props.storageBackends}
  89. minionPools={this.props.minionPools}
  90. instancesDetails={this.props.instancesDetails}
  91. instancesDetailsLoading={this.props.instancesDetailsLoading}
  92. networks={this.props.networks}
  93. sourceSchema={this.props.sourceSchema}
  94. sourceSchemaLoading={this.props.sourceSchemaLoading}
  95. destinationSchema={this.props.destinationSchema}
  96. destinationSchemaLoading={this.props.destinationSchemaLoading}
  97. endpoints={this.props.endpoints}
  98. bottomControls={this.renderBottomControls()}
  99. loading={this.props.detailsLoading}
  100. />
  101. )
  102. }
  103. renderTasks() {
  104. if (this.props.page !== 'tasks' || !this.props.item || !this.props.item.tasks) {
  105. return null
  106. }
  107. return (
  108. <Tasks
  109. items={this.props.item.tasks}
  110. loading={this.props.detailsLoading}
  111. instancesDetails={this.props.instancesDetails}
  112. />
  113. )
  114. }
  115. render() {
  116. return (
  117. <Wrapper>
  118. <DetailsNavigation
  119. items={NavigationItems}
  120. selectedValue={this.props.page}
  121. itemId={this.props.itemId}
  122. itemType="migration"
  123. />
  124. <DetailsBody>
  125. {this.renderMainDetails()}
  126. {this.renderTasks()}
  127. </DetailsBody>
  128. </Wrapper>
  129. )
  130. }
  131. }
  132. export default MigrationDetailsContent