MigrationDetail.js 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  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, { Component, PropTypes } from 'react';
  15. import withStyles from 'isomorphic-style-loader/lib/withStyles';
  16. import s from './MigrationDetail.scss';
  17. import Moment from 'react-moment';
  18. import LoadingIcon from "../LoadingIcon";
  19. import EndpointLink from '../EndpointLink';
  20. import ConfirmationDialog from '../ConfirmationDialog'
  21. import MigrationActions from '../../actions/MigrationActions';
  22. import MigrationNetworks from '../MigrationNetworks';
  23. const title = 'Migration details';
  24. class MigrationDetail extends Component {
  25. static contextTypes = {
  26. onSetTitle: PropTypes.func.isRequired,
  27. };
  28. static propTypes = {
  29. migration: PropTypes.object
  30. }
  31. constructor(props) {
  32. super(props)
  33. this.state = {
  34. confirmationDialog: {
  35. visible: false,
  36. message: "Are you sure?",
  37. onConfirm: null,
  38. onCancel: null
  39. }
  40. }
  41. }
  42. componentWillMount() {
  43. this.context.onSetTitle(title);
  44. }
  45. createMigrationFromReplica(e, replica) {
  46. MigrationActions.createMigrationFromReplica(replica)
  47. }
  48. deleteMigration() {
  49. this.setState({
  50. confirmationDialog: {
  51. visible: true,
  52. onConfirm: () => {
  53. this.setState({ confirmationDialog: { visible: false }})
  54. let item = this.state.migrations.filter(migration => migration.id == this.props.migrationId)[0]
  55. MigrationActions.deleteMigration(item)
  56. Location.push('/cloud-endpoints')
  57. },
  58. onCancel: () => {
  59. this.setState({ confirmationDialog: { visible: false }})
  60. }
  61. }
  62. })
  63. }
  64. render() {
  65. let item = this.props.migration
  66. let output = null
  67. if (item) {
  68. let disabled = false
  69. if (item.type == "replica") {
  70. disabled = item.executions && item.executions.length &&
  71. item.executions[item.executions.length - 1].status != "COMPLETED"
  72. if (item.executions.length == 0) {
  73. disabled = true
  74. }
  75. }
  76. output = (
  77. <div className={s.root}>
  78. <div className={s.container}>
  79. <div className={s.columnLeft}>
  80. <div className={s.formGroup}>
  81. <div className={s.title}>
  82. Source
  83. </div>
  84. <div className={s.value}>
  85. <EndpointLink connectionId={item.origin_endpoint_id} />
  86. </div>
  87. <div className={s.cloudImg + " icon large-cloud " + item.origin_endpoint_type + " dim"}></div>
  88. <div className="arrow large"></div>
  89. </div>
  90. <div className={s.formGroup}>
  91. <div className={s.title}>
  92. Type
  93. </div>
  94. <div className={s.value}>
  95. {item.migrationType == "replica" ? "Coriolis Replica" : "Coriolis Migration"}
  96. </div>
  97. </div>
  98. <div className={s.formGroup}>
  99. <div className={s.title}>
  100. Notes
  101. </div>
  102. <div className={s.value}>
  103. {item.notes}
  104. </div>
  105. </div>
  106. </div>
  107. <div className={s.columnRight}>
  108. <div className={s.formGroup}>
  109. <div className={s.title}>
  110. Target
  111. </div>
  112. <div className={s.value}>
  113. <EndpointLink connectionId={item.destination_endpoint_id} />
  114. </div>
  115. <div className={s.cloudImg + " icon large-cloud " + item.destination_endpoint_type + " dim"}></div>
  116. </div>
  117. <div className={s.formGroup}>
  118. <div className={s.title}>
  119. Created
  120. </div>
  121. <div className={s.value}>
  122. <Moment format="MM/DD/YYYY HH:MM" date={item.created} />
  123. </div>
  124. </div>
  125. <div className={s.formGroup}>
  126. <div className={s.titleIp}>
  127. Id
  128. </div>
  129. <div className={s.value}>
  130. <a>{item.id}</a>
  131. </div>
  132. </div>
  133. {/*<div className={s.formGroup}>
  134. <div className={s.title}>
  135. Flavours
  136. </div>
  137. <div className={s.value}>
  138. {item.autoFlavors ? "Automatic flavour selection" : "Manual flavour selection"}
  139. </div>
  140. </div>*/}
  141. {/*<div className={s.formGroup}>
  142. <div className={s.title}>
  143. Disk Format
  144. </div>
  145. <div className={s.value}>
  146. {item.diskFormat}
  147. </div>
  148. </div>*/}
  149. </div>
  150. </div>
  151. <MigrationNetworks migration={item} />
  152. <div className={s.container + " " + s.buttons}>
  153. { item.type == "replica" && <button
  154. onClick={(e) => this.createMigrationFromReplica(e, item)}
  155. disabled={disabled} className={disabled ? "disabled": ""} >
  156. Migrate Replica
  157. </button>}
  158. <button className="wire" onClick={(e) => this.deleteMigration(e)}>Delete</button>
  159. </div>
  160. <ConfirmationDialog
  161. visible={this.state.confirmationDialog.visible}
  162. message={this.state.confirmationDialog.message}
  163. onConfirm={(e) => this.state.confirmationDialog.onConfirm(e)}
  164. onCancel={(e) => this.state.confirmationDialog.onCancel(e)}
  165. />
  166. </div>
  167. )
  168. }
  169. return output
  170. }
  171. }
  172. export default withStyles(MigrationDetail, s);