WizardSummary.tsx 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816
  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 { Info } from "luxon";
  15. import { observer } from "mobx-react";
  16. import React from "react";
  17. import styled from "styled-components";
  18. import fieldHelper from "@src/@types/Field";
  19. import { MinionPool } from "@src/@types/MinionPool";
  20. import { ProviderTypes } from "@src/@types/Providers";
  21. import { INSTANCE_OSMORPHING_MINION_POOL_MAPPINGS } from "@src/components/modules/WizardModule/WizardOptions";
  22. import { getDisks } from "@src/components/modules/WizardModule/WizardStorage";
  23. import { ThemePalette, ThemeProps } from "@src/components/Theme";
  24. import StatusPill from "@src/components/ui/StatusComponents/StatusPill";
  25. import { deploymentFields } from "@src/constants";
  26. import configLoader from "@src/utils/Config";
  27. import DateUtils from "@src/utils/DateUtils";
  28. import LabelDictionary from "@src/utils/LabelDictionary";
  29. import networkArrowImage from "./images/network-arrow.svg";
  30. import type { Schedule } from "@src/@types/Schedule";
  31. import type { WizardData } from "@src/@types/WizardData";
  32. import type { StorageMap, StorageBackend } from "@src/@types/Endpoint";
  33. import type { Instance, Disk, InstanceScript } from "@src/@types/Instance";
  34. import type { Field } from "@src/@types/Field";
  35. const Wrapper = styled.div`
  36. width: 100%;
  37. display: flex;
  38. justify-content: space-between;
  39. `;
  40. const Column = styled.div`
  41. ${ThemeProps.exactWidth("calc(50% - 80px)")}
  42. `;
  43. const Section = styled.div<any>`
  44. margin-bottom: 42px;
  45. &:last-child {
  46. margin-bottom: 0;
  47. }
  48. `;
  49. const SectionTitle = styled.div<any>`
  50. font-size: 24px;
  51. font-weight: ${ThemeProps.fontWeights.light};
  52. margin-bottom: 16px;
  53. `;
  54. const Overview = styled.div<any>``;
  55. const OverviewLabel = styled.div<any>`
  56. font-size: 10px;
  57. font-weight: ${ThemeProps.fontWeights.medium};
  58. text-transform: uppercase;
  59. color: ${ThemePalette.grayscale[5]};
  60. margin-bottom: 4px;
  61. `;
  62. const OverviewRow = styled.div<any>`
  63. margin-bottom: 32px;
  64. &:last-child {
  65. margin-bottom: 0;
  66. }
  67. `;
  68. const OverviewRowData = styled.div<any>`
  69. display: flex;
  70. `;
  71. const OverviewRowLabel = styled.div<any>`
  72. margin-left: 16px;
  73. white-space: nowrap;
  74. overflow: hidden;
  75. text-overflow: ellipsis;
  76. `;
  77. const Table = styled.div<any>``;
  78. const Row = styled.div<any>`
  79. display: flex;
  80. flex-direction: ${props => props.direction || "column"};
  81. padding: 8px 0;
  82. border-top: 1px solid ${ThemePalette.grayscale[1]};
  83. color: ${ThemePalette.grayscale[4]};
  84. &:last-child {
  85. border-bottom: 1px solid ${ThemePalette.grayscale[1]};
  86. }
  87. `;
  88. const ScriptFileName = styled.div<any>`
  89. max-width: 124px;
  90. text-overflow: ellipsis;
  91. overflow: hidden;
  92. margin-left: 16px;
  93. white-space: nowrap;
  94. flex-shrink: 0;
  95. `;
  96. const InstanceRowTitle = styled.div<any>`
  97. margin-bottom: 4px;
  98. `;
  99. const InstanceRowSubtitle = styled.div<any>`
  100. font-size: 10px;
  101. color: ${ThemePalette.grayscale[5]};
  102. margin-bottom: 4px;
  103. &:last-child {
  104. margin-bottom: 0;
  105. }
  106. `;
  107. const SourceNetwork = styled.div<any>`
  108. width: 50%;
  109. margin-right: 16px;
  110. overflow-wrap: break-word;
  111. `;
  112. const NetworkArrow = styled.div<any>`
  113. width: 32px;
  114. height: 16px;
  115. background: url("${networkArrowImage}") center no-repeat;
  116. `;
  117. const TargetNetwork = styled.div<any>`
  118. width: 50%;
  119. text-align: right;
  120. margin-left: 20px;
  121. display: flex;
  122. flex-direction: column;
  123. margin-top: -16px;
  124. `;
  125. const TargetNetworkName = styled.div<any>`
  126. width: 100%;
  127. text-overflow: ellipsis;
  128. overflow: hidden;
  129. margin-top: 8px;
  130. &:first-child {
  131. margin-top: 16px;
  132. }
  133. `;
  134. const OptionsList = styled.div<any>``;
  135. const Option = styled.div<any>`
  136. display: flex;
  137. margin-bottom: 8px;
  138. `;
  139. const OptionLabel = styled.div<any>`
  140. color: ${ThemePalette.grayscale[4]};
  141. ${ThemeProps.exactWidth("50%")}
  142. overflow: hidden;
  143. text-overflow: ellipsis;
  144. white-space: nowrap;
  145. `;
  146. const OptionValue = styled.div<any>`
  147. text-align: right;
  148. ${ThemeProps.exactWidth("50%")}
  149. text-overflow: ellipsis;
  150. overflow: hidden;
  151. `;
  152. const ObjectTable = styled.div`
  153. margin-top: 24px;
  154. `;
  155. const ObjectTableTitle = styled.div`
  156. margin-bottom: 8px;
  157. `;
  158. type Props = {
  159. data: WizardData;
  160. wizardType: "replica" | "migration";
  161. schedules: Schedule[];
  162. minionPools: MinionPool[];
  163. defaultStorage: { value: string | null; busType?: string | null } | undefined;
  164. storageMap: StorageMap[];
  165. instancesDetails: Instance[];
  166. sourceSchema: Field[];
  167. destinationSchema: Field[];
  168. uploadedUserScripts: InstanceScript[];
  169. executionOptions: Field[];
  170. };
  171. @observer
  172. class WizardSummary extends React.Component<Props> {
  173. getDefaultBooleanOption(fieldName: string, defaultValue: boolean): boolean {
  174. if (!this.props.data.destOptions) {
  175. return defaultValue;
  176. }
  177. if (this.props.data.destOptions[fieldName] != null) {
  178. return this.props.data.destOptions[fieldName];
  179. }
  180. return defaultValue;
  181. }
  182. renderScheduleLabel(schedule: Schedule) {
  183. const scheduleInfo = schedule.schedule;
  184. let monthLabel;
  185. if (!scheduleInfo) {
  186. return null;
  187. }
  188. if (scheduleInfo.month == null) {
  189. monthLabel = "Every month";
  190. } else {
  191. monthLabel = `Every ${
  192. Info.months()[scheduleInfo.month ? scheduleInfo.month - 1 : 0]
  193. }`;
  194. }
  195. let dayOfMonthLabel;
  196. if (scheduleInfo.dom == null) {
  197. dayOfMonthLabel = "every day";
  198. } else {
  199. dayOfMonthLabel = `every ${DateUtils.getOrdinalDay(scheduleInfo.dom)}`;
  200. }
  201. let dayOfWeekLabel;
  202. if (scheduleInfo.dow == null) {
  203. dayOfWeekLabel = "every weekday";
  204. } else {
  205. dayOfWeekLabel = `every ${Info.weekdays()[scheduleInfo.dow]}`;
  206. }
  207. const padNumber = (number: number) =>
  208. (number || 0) < 10 ? `0${number || 0}` : (number || 0).toString();
  209. let timeLabel;
  210. if (scheduleInfo.minute == null) {
  211. if (scheduleInfo.hour == null) {
  212. timeLabel = "every hour, every minute";
  213. } else {
  214. timeLabel = `at ${padNumber(
  215. scheduleInfo.hour
  216. )} o'clock, every minute UTC`;
  217. }
  218. } else if (scheduleInfo.hour == null) {
  219. timeLabel = `every hour, at minute ${padNumber(scheduleInfo.minute)} UTC`;
  220. } else {
  221. timeLabel = `at ${padNumber(scheduleInfo.hour)}:${padNumber(
  222. scheduleInfo.minute
  223. )} UTC`;
  224. }
  225. return `${monthLabel}, ${dayOfMonthLabel}, ${dayOfWeekLabel}, ${timeLabel}`;
  226. }
  227. renderScheduleSection() {
  228. const schedules = this.props.schedules;
  229. if (
  230. this.props.wizardType !== "replica" ||
  231. !schedules ||
  232. schedules.length === 0
  233. ) {
  234. return null;
  235. }
  236. return (
  237. <Section>
  238. <SectionTitle>Schedule</SectionTitle>
  239. <Table>
  240. {schedules.map(schedule => (
  241. <Row key={schedule.id} schedule>
  242. {this.renderScheduleLabel(schedule)}
  243. </Row>
  244. ))}
  245. </Table>
  246. </Section>
  247. );
  248. }
  249. renderSourceOptionsSection() {
  250. const data = this.props.data;
  251. const type =
  252. this.props.wizardType.charAt(0).toUpperCase() +
  253. this.props.wizardType.substr(1);
  254. const provider =
  255. this.props.data && this.props.data.source && this.props.data.source.type;
  256. if (!data.sourceOptions) {
  257. return null;
  258. }
  259. return (
  260. <Section>
  261. <SectionTitle>{type} Source Options</SectionTitle>
  262. <OptionsList>
  263. {data.sourceOptions
  264. ? Object.keys(data.sourceOptions).map(optionName => {
  265. if (
  266. !data.sourceOptions ||
  267. data.sourceOptions[optionName] == null ||
  268. data.sourceOptions[optionName] === "" ||
  269. typeof data.sourceOptions[optionName] === "object"
  270. ) {
  271. return null;
  272. }
  273. const optionLabel = optionName
  274. .split("/")
  275. .map(n =>
  276. LabelDictionary.get(
  277. n,
  278. `${data.source ? data.source.type : ""}-source`
  279. )
  280. )
  281. .join(" - ");
  282. const optionValue = fieldHelper.getValueAlias({
  283. name: optionName,
  284. value: data.sourceOptions?.[optionName],
  285. fields: this.props.sourceSchema,
  286. targetProvider: provider,
  287. });
  288. return (
  289. <Option key={optionName}>
  290. <OptionLabel title={optionLabel}>{optionLabel}</OptionLabel>
  291. <OptionValue title={optionValue}>{optionValue}</OptionValue>
  292. </Option>
  293. );
  294. })
  295. : null}
  296. {this.renderObjectTable(
  297. data.sourceOptions,
  298. this.props.sourceSchema,
  299. provider
  300. )}
  301. </OptionsList>
  302. </Section>
  303. );
  304. }
  305. hasDefaultValue(option: any): option is { defaultValue: boolean } {
  306. return option && typeof option.defaultValue !== 'undefined';
  307. }
  308. renderTransferExecuteOptions() {
  309. const type =
  310. this.props.wizardType.charAt(0).toUpperCase() +
  311. this.props.wizardType.substr(1);
  312. const data = this.props.data;
  313. if (!this.props.executionOptions || this.props.executionOptions.length === 0) {
  314. return null;
  315. }
  316. const deploymentFieldNames = deploymentFields.map(f => f.name);
  317. const filteredExecutionOptions = this.props.executionOptions.filter(
  318. option => !deploymentFieldNames.includes(option.name)
  319. );
  320. const allOptions = [...filteredExecutionOptions, ...deploymentFields];
  321. return (
  322. <Section>
  323. <SectionTitle>{type} Transfer Execution Options</SectionTitle>
  324. <OptionsList>
  325. {allOptions.map(option => (
  326. <Option key={option.name}>
  327. <OptionLabel>{option.label}</OptionLabel>
  328. <OptionValue>
  329. {data.executeOptions && data.executeOptions[option.name] !== undefined
  330. ? data.executeOptions[option.name] ? "Yes" : "No"
  331. : this.hasDefaultValue(option) && option.defaultValue ? "Yes" : "No"}
  332. </OptionValue>
  333. </Option>
  334. ))}
  335. </OptionsList>
  336. </Section>
  337. );
  338. }
  339. renderObjectTable(
  340. options: any,
  341. schema: Field[],
  342. provider?: ProviderTypes | null
  343. ) {
  344. if (!options) {
  345. return null;
  346. }
  347. const objectKeys: string[] = Object.keys(options).filter(
  348. key =>
  349. typeof options[key] === "object" &&
  350. key !== INSTANCE_OSMORPHING_MINION_POOL_MAPPINGS
  351. );
  352. return objectKeys.map(key =>
  353. options[key] != null ? (
  354. <ObjectTable key={key}>
  355. <ObjectTableTitle>{LabelDictionary.get(key)}</ObjectTableTitle>
  356. {Object.keys(options[key]).map(propertyName => {
  357. const value = options[key][propertyName];
  358. if (value == null || value === "") {
  359. return null;
  360. }
  361. let optionValue;
  362. if (
  363. key.indexOf("password") > -1 ||
  364. propertyName.indexOf("password") > -1
  365. ) {
  366. optionValue = "•••••••••";
  367. } else {
  368. optionValue = fieldHelper.getValueAlias({
  369. name: propertyName,
  370. value,
  371. fields: schema,
  372. targetProvider: provider,
  373. });
  374. }
  375. return (
  376. <Option key={propertyName}>
  377. <OptionLabel title={propertyName}>
  378. {LabelDictionary.get(propertyName)}
  379. </OptionLabel>
  380. <OptionValue title={options[key][propertyName]}>
  381. {optionValue}
  382. </OptionValue>
  383. </Option>
  384. );
  385. })}
  386. </ObjectTable>
  387. ) : null
  388. );
  389. }
  390. renderMinionPoolMapping() {
  391. const allMappings =
  392. this.props.data.destOptions?.[INSTANCE_OSMORPHING_MINION_POOL_MAPPINGS];
  393. if (!allMappings) {
  394. return null;
  395. }
  396. const mappings: any = {};
  397. Object.keys(allMappings).forEach(map => {
  398. if (allMappings[map]) {
  399. mappings[map] = allMappings[map];
  400. }
  401. });
  402. if (!Object.keys(mappings).length) {
  403. return null;
  404. }
  405. const getMinionPoolName = (id: string) => {
  406. const minionPool = this.props.minionPools.find(m => m.id === id);
  407. return minionPool?.name || id;
  408. };
  409. return (
  410. <ObjectTable>
  411. <ObjectTableTitle>
  412. Instance OSMorphing Minion Pool Mappings
  413. </ObjectTableTitle>
  414. {Object.keys(mappings).map(instanceId => {
  415. const instanceName =
  416. this.props.instancesDetails.find(
  417. i => i.instance_name === instanceId || i.id === instanceId
  418. )?.name || instanceId;
  419. return (
  420. <Option key={instanceId}>
  421. <OptionLabel title={instanceName}>{instanceName}</OptionLabel>
  422. <OptionValue title={mappings[instanceId]}>
  423. {getMinionPoolName(mappings[instanceId])}
  424. </OptionValue>
  425. </Option>
  426. );
  427. })}
  428. </ObjectTable>
  429. );
  430. }
  431. renderTargetOptionsSection() {
  432. const data = this.props.data;
  433. const provider = data?.target?.type;
  434. const type =
  435. this.props.wizardType.charAt(0).toUpperCase() +
  436. this.props.wizardType.substr(1);
  437. const executeNowOption = (
  438. <Option>
  439. <OptionLabel>Execute now?</OptionLabel>
  440. <OptionValue>
  441. {this.getDefaultBooleanOption("execute_now", true) ? "Yes" : "No"}
  442. </OptionValue>
  443. </Option>
  444. );
  445. const separateVmOption = (
  446. <Option>
  447. <OptionLabel>Separate {type}/VM?</OptionLabel>
  448. <OptionValue>
  449. {this.getDefaultBooleanOption("separate_vm", true) ? "Yes" : "No"}
  450. </OptionValue>
  451. </Option>
  452. );
  453. const renderDefaultStorageOption = () => (
  454. <Option>
  455. <OptionLabel>Default Storage</OptionLabel>
  456. <OptionValue>
  457. {this.props.defaultStorage!.value}
  458. {this.props.defaultStorage!.busType ? (
  459. <>
  460. <br />
  461. Bus Type: {this.props.defaultStorage!.busType}
  462. </>
  463. ) : null}
  464. </OptionValue>
  465. </Option>
  466. );
  467. return (
  468. <Section>
  469. <SectionTitle>{type} Target Options</SectionTitle>
  470. <OptionsList>
  471. {this.props.wizardType === "replica" ? executeNowOption : null}
  472. {this.props.wizardType === "migration" ? executeNowOption : null}
  473. {this.props.data.selectedInstances &&
  474. this.props.data.selectedInstances.length > 1
  475. ? separateVmOption
  476. : null}
  477. {this.props.defaultStorage ? renderDefaultStorageOption() : null}
  478. {data.destOptions
  479. ? Object.keys(data.destOptions).map(optionName => {
  480. if (
  481. optionName === "execute_now" ||
  482. optionName === "separate_vm" ||
  483. !data.destOptions ||
  484. data.destOptions[optionName] == null ||
  485. data.destOptions[optionName] === "" ||
  486. typeof data.destOptions[optionName] === "object"
  487. ) {
  488. return null;
  489. }
  490. const optionLabel = optionName
  491. .split("/")
  492. .map(n =>
  493. LabelDictionary.get(
  494. n,
  495. `${data.target ? data.target.type : ""}-destination`
  496. )
  497. )
  498. .join(" - ");
  499. const optionValue = fieldHelper.getValueAlias({
  500. name: optionName,
  501. value: data.destOptions?.[optionName],
  502. fields: this.props.destinationSchema,
  503. targetProvider: provider,
  504. });
  505. return (
  506. <Option key={optionName}>
  507. <OptionLabel title={optionLabel}>{optionLabel}</OptionLabel>
  508. <OptionValue title={optionValue}>{optionValue}</OptionValue>
  509. </Option>
  510. );
  511. })
  512. : null}
  513. {this.renderMinionPoolMapping()}
  514. {this.renderObjectTable(
  515. data.destOptions,
  516. this.props.destinationSchema,
  517. provider
  518. )}
  519. </OptionsList>
  520. </Section>
  521. );
  522. }
  523. renderStorageSection(type: "backend" | "disk") {
  524. const storageMap = this.props.storageMap.filter(
  525. mapping => mapping.type === type
  526. );
  527. const disks = getDisks(this.props.instancesDetails, type);
  528. if (disks.length === 0 || storageMap.length === 0) {
  529. return null;
  530. }
  531. const fieldName = type === "backend" ? "storage_backend_identifier" : "id";
  532. let fullStorageMap: {
  533. source: Disk;
  534. target: StorageBackend | null;
  535. busType?: string | null;
  536. }[] = disks
  537. .filter(d => d[fieldName])
  538. .map(disk => {
  539. const diskMapped = storageMap.find(
  540. s => s.source[fieldName] === disk[fieldName]
  541. );
  542. if (diskMapped) {
  543. return {
  544. source: diskMapped.source,
  545. target: diskMapped.target,
  546. busType: diskMapped.targetBusType,
  547. };
  548. }
  549. return { source: disk, target: null };
  550. });
  551. fullStorageMap.sort((m1, m2) =>
  552. String(m1.source[fieldName]).localeCompare(String(m2.source[fieldName]))
  553. );
  554. fullStorageMap = fullStorageMap.filter(fsm => fsm.target && fsm.target.id);
  555. const title =
  556. type === "backend" ? "Storage Backend Mapping" : "Disk Mapping";
  557. if (fullStorageMap.length === 0) {
  558. return null;
  559. }
  560. return (
  561. <Section>
  562. <SectionTitle>{title}</SectionTitle>
  563. <Table>
  564. {fullStorageMap
  565. .filter(m => m.target)
  566. .map(mapping => (
  567. <Row
  568. key={`${type}-${mapping.source[fieldName] || ""}-${
  569. mapping.target ? mapping.target.name : ""
  570. }`}
  571. direction="row"
  572. >
  573. <SourceNetwork>{mapping.source[fieldName]}</SourceNetwork>
  574. <NetworkArrow />
  575. <TargetNetwork>
  576. <TargetNetworkName>
  577. {mapping.target ? mapping.target.name : "Default"}
  578. </TargetNetworkName>
  579. {mapping.busType ? (
  580. <TargetNetworkName>
  581. Bus Type: {mapping.busType}
  582. </TargetNetworkName>
  583. ) : null}
  584. </TargetNetwork>
  585. </Row>
  586. ))}
  587. </Table>
  588. </Section>
  589. );
  590. }
  591. renderNetworksSection() {
  592. const data = this.props.data;
  593. if (data.networks == null) {
  594. return null;
  595. }
  596. return (
  597. <Section>
  598. <SectionTitle>Networks</SectionTitle>
  599. <Table>
  600. {data.networks.map(mapping => (
  601. <Row key={mapping.sourceNic.network_name} direction="row">
  602. <SourceNetwork>{mapping.sourceNic.network_name}</SourceNetwork>
  603. <NetworkArrow />
  604. <TargetNetwork>
  605. <TargetNetworkName>
  606. {mapping.targetNetwork!.name}
  607. </TargetNetworkName>
  608. {mapping.targetSecurityGroups?.length ? (
  609. <TargetNetworkName>
  610. Security Groups:{" "}
  611. {mapping.targetSecurityGroups
  612. .map(s => (typeof s === "string" ? s : s.name))
  613. .join(", ")}
  614. </TargetNetworkName>
  615. ) : null}
  616. {mapping.targetPortKey ? (
  617. <TargetNetworkName>
  618. Port Key: {mapping.targetPortKey}
  619. </TargetNetworkName>
  620. ) : null}
  621. </TargetNetwork>
  622. </Row>
  623. ))}
  624. </Table>
  625. </Section>
  626. );
  627. }
  628. renderInstancesSection() {
  629. const data = this.props.data;
  630. return (
  631. <Section>
  632. <SectionTitle>Instances</SectionTitle>
  633. <Table>
  634. {data.selectedInstances
  635. ? data.selectedInstances.map(instance => {
  636. const flavorName = instance.flavor_name
  637. ? `/${instance.flavor_name}`
  638. : "";
  639. return (
  640. <Row key={instance.id}>
  641. <InstanceRowTitle>{instance.name}</InstanceRowTitle>
  642. <InstanceRowSubtitle>
  643. {instance.instance_name || instance.id}
  644. </InstanceRowSubtitle>
  645. <InstanceRowSubtitle>{`${instance.num_cpu}vCPU/${instance.memory_mb}MB${flavorName}`}</InstanceRowSubtitle>
  646. </Row>
  647. );
  648. })
  649. : null}
  650. </Table>
  651. </Section>
  652. );
  653. }
  654. renderUserScripts() {
  655. if (this.props.uploadedUserScripts.length === 0) {
  656. return null;
  657. }
  658. return (
  659. <Section>
  660. <SectionTitle>Uploaded User Scripts</SectionTitle>
  661. <Table>
  662. {this.props.uploadedUserScripts.map(s => (
  663. <Row
  664. key={s.instanceId || s.global || undefined}
  665. style={{
  666. flexDirection: "row",
  667. justifyContent: "space-between",
  668. flexShrink: 0,
  669. alignItems: "center",
  670. }}
  671. >
  672. <InstanceRowTitle>
  673. {s.global
  674. ? s.global === "windows"
  675. ? "Global Windows Script"
  676. : "Global Linux Script"
  677. : s.instanceId}
  678. </InstanceRowTitle>
  679. <ScriptFileName title={s.fileName}>{s.fileName}</ScriptFileName>
  680. </Row>
  681. ))}
  682. </Table>
  683. </Section>
  684. );
  685. }
  686. renderOverviewSection() {
  687. const data = this.props.data;
  688. const type =
  689. this.props.wizardType.charAt(0).toUpperCase() +
  690. this.props.wizardType.substr(1);
  691. return (
  692. <Section>
  693. <SectionTitle>Overview</SectionTitle>
  694. <Overview>
  695. <OverviewRow>
  696. <OverviewLabel>Source</OverviewLabel>
  697. <OverviewRowData>
  698. <StatusPill
  699. secondary
  700. small
  701. label={configLoader.config.providerNames[data.source!.type]}
  702. />
  703. <OverviewRowLabel>
  704. {data.source ? data.source.name : ""}
  705. </OverviewRowLabel>
  706. </OverviewRowData>
  707. </OverviewRow>
  708. <OverviewRow>
  709. <OverviewLabel>Target</OverviewLabel>
  710. <OverviewRowData>
  711. <StatusPill
  712. secondary
  713. small
  714. label={configLoader.config.providerNames[data.target!.type]}
  715. />
  716. <OverviewRowLabel>
  717. {data.target && data.target.name}
  718. </OverviewRowLabel>
  719. </OverviewRowData>
  720. </OverviewRow>
  721. <OverviewRow>
  722. <OverviewLabel>Type</OverviewLabel>
  723. <OverviewRowData>
  724. <StatusPill
  725. alert={type === "Replica"}
  726. small
  727. label={this.props.wizardType.toUpperCase()}
  728. />
  729. <OverviewRowLabel>Coriolis {type}</OverviewRowLabel>
  730. </OverviewRowData>
  731. </OverviewRow>
  732. </Overview>
  733. </Section>
  734. );
  735. }
  736. render() {
  737. return (
  738. <Wrapper>
  739. <Column>
  740. {this.renderOverviewSection()}
  741. {this.renderInstancesSection()}
  742. {this.renderNetworksSection()}
  743. {this.renderUserScripts()}
  744. </Column>
  745. <Column>
  746. {this.renderSourceOptionsSection()}
  747. {this.renderTargetOptionsSection()}
  748. {this.renderStorageSection("backend")}
  749. {this.renderStorageSection("disk")}
  750. {this.renderScheduleSection()}
  751. {this.renderTransferExecuteOptions()}
  752. </Column>
  753. </Wrapper>
  754. );
  755. }
  756. }
  757. export default WizardSummary;