Selaa lähdekoodia

Remove unused modules

Removes modules related to Assessment, custom Azure source and Migration.
Daniel Vincze 1 vuosi sitten
vanhempi
sitoutus
ade38f3f2d
27 muutettua tiedostoa jossa 0 lisäystä ja 3841 poistoa
  1. 0 1
      jest.config.ts
  2. 0 78
      src/@types/Assessment.ts
  3. 0 11
      src/components/App.tsx
  4. 0 149
      src/components/modules/AssessmentModule/AssessedVmListItem/AssessedVmListItem.tsx
  5. 0 6
      src/components/modules/AssessmentModule/AssessedVmListItem/package.json
  6. 0 618
      src/components/modules/AssessmentModule/AssessmentDetailsContent/AssessmentDetailsContent.tsx
  7. 0 13
      src/components/modules/AssessmentModule/AssessmentDetailsContent/images/arrow.svg
  8. 0 12
      src/components/modules/AssessmentModule/AssessmentDetailsContent/images/logo.svg
  9. 0 6
      src/components/modules/AssessmentModule/AssessmentDetailsContent/package.json
  10. 0 142
      src/components/modules/AssessmentModule/AssessmentListItem/AssessmentListItem.tsx
  11. 0 20
      src/components/modules/AssessmentModule/AssessmentListItem/images/assessment.svg
  12. 0 20
      src/components/modules/AssessmentModule/AssessmentListItem/images/azure-migrate.svg
  13. 0 6
      src/components/modules/AssessmentModule/AssessmentListItem/package.json
  14. 0 321
      src/components/modules/AssessmentModule/AssessmentMigrationOptions/AssessmentMigrationOptions.tsx
  15. 0 17
      src/components/modules/AssessmentModule/AssessmentMigrationOptions/images/assessment.svg
  16. 0 6
      src/components/modules/AssessmentModule/AssessmentMigrationOptions/package.json
  17. 0 689
      src/components/smart/AssessmentDetailsPage/AssessmentDetailsPage.tsx
  18. 0 20
      src/components/smart/AssessmentDetailsPage/images/assessment.svg
  19. 0 6
      src/components/smart/AssessmentDetailsPage/package.json
  20. 0 383
      src/components/smart/AssessmentsPage/AssessmentsPage.tsx
  21. 0 6
      src/components/smart/AssessmentsPage/package.json
  22. 0 106
      src/sources/AssessmentSource.ts
  23. 0 253
      src/sources/AzureSource.ts
  24. 0 369
      src/sources/MigrationSource.ts
  25. 0 71
      src/stores/AssessmentStore.ts
  26. 0 314
      src/stores/AzureStore.ts
  27. 0 198
      src/stores/MigrationStore.ts

+ 0 - 1
jest.config.ts

@@ -22,7 +22,6 @@ export default {
   // An array of glob patterns indicating a set of files for which coverage information should be collected
   collectCoverageFrom: [
     "**/*.tsx", // Include all .tsx files
-    "!**/AssessmentModule/**", // Exclude files within the AssessmentModule directory (this is a module that is not used in the app)
     "!**/story.tsx", // Exclude all storybook files
     "!**/test.tsx", // Exclude old test files
     "!**/plugins/**", // Exclude files within the plugins directory

+ 0 - 78
src/@types/Assessment.ts

@@ -1,78 +0,0 @@
-/*
-Copyright (C) 2017  Cloudbase Solutions SRL
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU Affero General Public License as
-published by the Free Software Foundation, either version 3 of the
-License, or (at your option) any later version.
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-GNU Affero General Public License for more details.
-You should have received a copy of the GNU Affero General Public License
-along with this program.  If not, see <http://www.gnu.org/licenses/>.
-*/
-
-import type { Endpoint } from "./Endpoint";
-import type { Instance } from "./Instance";
-import type { NetworkMap } from "./Network";
-
-export type VmSize = {
-  name: string;
-  size?: string;
-};
-
-export type AzureLocation = {
-  id: string;
-  name: string;
-};
-
-export type Group = {
-  id: string;
-  name: string;
-};
-
-export type VmItem = {
-  id: string;
-  properties: {
-    recommendedSize: string;
-    disks: {
-      [diskName: string]: {
-        recommendedDiskType: string;
-      };
-    };
-    datacenterManagementServerName: string;
-    datacenterMachineArmId: string;
-    displayName: string;
-    operatingSystemName: string;
-  };
-};
-
-export type Assessment = {
-  name: string;
-  id: string;
-  projectName: string;
-  resourceGroupName: string;
-  groupName: string;
-  assessmentName: string;
-  location: string;
-  project: {
-    name: string;
-  };
-  group: Group;
-  properties: {
-    status: string;
-    updatedTimestamp: string;
-    azureLocation: string;
-    numberOfMachines: string;
-  };
-  connectionInfo: { subscription_id: string } & Endpoint["connection_info"];
-};
-
-export type MigrationInfo = {
-  source: Endpoint | null;
-  target: Endpoint;
-  selectedInstances: Instance[];
-  fieldValues: { [fieldValue: string]: any };
-  networks: NetworkMap[];
-  vmSizes: { [vmSize: string]: VmSize };
-};

+ 0 - 11
src/components/App.tsx

@@ -29,8 +29,6 @@ import DeploymentDetailsPage from "@src/components/smart/DeploymentDetailsPage";
 import MetalHubServersPage from "@src/components/smart/MetalHubServersPage";
 import EndpointsPage from "@src/components/smart/EndpointsPage";
 import EndpointDetailsPage from "@src/components/smart/EndpointDetailsPage";
-import AssessmentsPage from "@src/components/smart/AssessmentsPage";
-import AssessmentDetailsPage from "@src/components/smart/AssessmentDetailsPage";
 import UsersPage from "@src/components/smart/UsersPage";
 import UserDetailsPage from "@src/components/smart/UserDetailsPage";
 import ProjectsPage from "@src/components/smart/ProjectsPage";
@@ -225,15 +223,6 @@ class App extends React.Component<Record<string, unknown>, State> {
             {renderRoute("/bare-metal-servers", MetalHubServersPage, true)}
             {renderRoute("/bare-metal-servers/:id", MetalHubServerDetailsPage)}
             {renderRoute("/wizard/:type", WizardPage)}
-            {renderOptionalRoute({
-              name: "planning",
-              component: AssessmentsPage,
-            })}
-            {renderOptionalRoute({
-              name: "planning",
-              component: AssessmentDetailsPage,
-              path: "/assessment/:info",
-            })}
             {renderOptionalRoute({
               name: "users",
               component: UsersPage,

+ 0 - 149
src/components/modules/AssessmentModule/AssessedVmListItem/AssessedVmListItem.tsx

@@ -1,149 +0,0 @@
-/*
-Copyright (C) 2017  Cloudbase Solutions SRL
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU Affero General Public License as
-published by the Free Software Foundation, either version 3 of the
-License, or (at your option) any later version.
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-GNU Affero General Public License for more details.
-You should have received a copy of the GNU Affero General Public License
-along with this program.  If not, see <http://www.gnu.org/licenses/>.
-*/
-
-import React from "react";
-import { observer } from "mobx-react";
-import styled, { css } from "styled-components";
-
-import Checkbox from "@src/components/ui/Checkbox";
-import InfoIcon from "@src/components/ui/InfoIcon";
-import DropdownLink from "@src/components/ui/Dropdowns/DropdownLink";
-import type { VmItem } from "@src/@types/Assessment";
-import { ThemePalette } from "@src/components/Theme";
-
-const Wrapper = styled.div<any>`
-  position: relative;
-  width: 100%;
-`;
-const Content = styled.div<any>`
-  display: flex;
-  margin-left: -32px;
-
-  & > div {
-    margin-left: 32px;
-  }
-
-  opacity: ${(props: any) => (props.disabled ? 0.6 : 1)};
-`;
-const columnWidth = (width: string) => css`
-  width: 100%;
-  max-width: ${width};
-`;
-const DisplayName = styled.div<any>`
-  display: flex;
-  ${(props: any) => columnWidth(props.width)}
-`;
-const Value = styled.div<any>`
-  color: ${ThemePalette.grayscale[4]};
-  ${(props: any) => columnWidth(props.width)}
-`;
-const DisplayNameLabel = styled.div<any>`
-  margin-left: 8px;
-  word-break: break-word;
-`;
-const InfoIconStyled = styled(InfoIcon)`
-  position: absolute;
-  left: -36px;
-  top: 0px;
-  z-index: 10000;
-`;
-
-type Props = {
-  item: VmItem;
-  selected: boolean;
-  onSelectedChange: (item: VmItem, isChecked: boolean) => void;
-  disabled: boolean;
-  loadingVmSizes: boolean;
-  vmSizes: string[];
-  onVmSizeChange: (size: string) => void;
-  selectedVmSize: string | null;
-  recommendedVmSize: string;
-};
-@observer
-class AssessedVmListItem extends React.Component<Props> {
-  renderInfoIcon() {
-    if (!this.props.disabled) {
-      return null;
-    }
-
-    return (
-      <InfoIconStyled
-        warning
-        text="We could not detect this VM on the source endpoint. Either the VM is missing or the selected endpoint is not the same as in the Azure Migrare Assesment."
-      />
-    );
-  }
-
-  render() {
-    const { disks } = this.props.item.properties;
-    let standardCount = 0;
-    let premiumCount = 0;
-    Object.keys(disks).forEach(diskKey => {
-      if (disks[diskKey].recommendedDiskType === "Standard") {
-        standardCount += 1;
-      }
-      if (disks[diskKey].recommendedDiskType === "Premium") {
-        premiumCount += 1;
-      }
-    });
-
-    return (
-      <Wrapper>
-        {this.renderInfoIcon()}
-        <Content disabled={this.props.disabled}>
-          <DisplayName width="25%">
-            <Checkbox
-              checked={this.props.selected}
-              onChange={checked => {
-                this.props.onSelectedChange(this.props.item, checked);
-              }}
-              disabled={this.props.disabled}
-            />
-            <DisplayNameLabel>{`${this.props.item.properties.displayName}`}</DisplayNameLabel>
-          </DisplayName>
-          <Value width="25%">
-            {this.props.item.properties.operatingSystemName}
-          </Value>
-          <Value width="25%">
-            {standardCount} Standard, {premiumCount} Premium
-          </Value>
-          <Value width="25%">
-            <DropdownLink
-              searchable
-              width="208px"
-              noItemsLabel={
-                this.props.loadingVmSizes ? "Loading..." : "No data"
-              }
-              selectItemLabel="Auto Determined"
-              items={
-                this.props.loadingVmSizes
-                  ? []
-                  : this.props.vmSizes.map(s => ({ value: s, label: s }))
-              }
-              selectedItem={this.props.selectedVmSize || ""}
-              listWidth="200px"
-              onChange={item => {
-                this.props.onVmSizeChange(item.value);
-              }}
-              disabled={this.props.disabled}
-              highlightedItem={this.props.recommendedVmSize}
-            />
-          </Value>
-        </Content>
-      </Wrapper>
-    );
-  }
-}
-
-export default AssessedVmListItem;

+ 0 - 6
src/components/modules/AssessmentModule/AssessedVmListItem/package.json

@@ -1,6 +0,0 @@
-{
-  "name": "AssessedVmListItem",
-  "version": "0.0.0",
-  "private": true,
-  "main": "./AssessedVmListItem.tsx"
-}

+ 0 - 618
src/components/modules/AssessmentModule/AssessmentDetailsContent/AssessmentDetailsContent.tsx

@@ -1,618 +0,0 @@
-/*
-Copyright (C) 2017  Cloudbase Solutions SRL
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU Affero General Public License as
-published by the Free Software Foundation, either version 3 of the
-License, or (at your option) any later version.
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-GNU Affero General Public License for more details.
-You should have received a copy of the GNU Affero General Public License
-along with this program.  If not, see <http://www.gnu.org/licenses/>.
-*/
-
-import { observer } from "mobx-react";
-import React from "react";
-import styled, { css } from "styled-components";
-
-import AssessedVmListItem from "@src/components/modules/AssessmentModule/AssessedVmListItem";
-import DetailsNavigation from "@src/components/modules/NavigationModule/DetailsNavigation";
-import { ThemePalette, ThemeProps } from "@src/components/Theme";
-import Button from "@src/components/ui/Button";
-import Checkbox from "@src/components/ui/Checkbox";
-import DropdownFilter from "@src/components/ui/Dropdowns/DropdownFilter";
-import DropdownLink from "@src/components/ui/Dropdowns/DropdownLink";
-import SmallLoading from "@src/components/ui/SmallLoading";
-import StatusImage from "@src/components/ui/StatusComponents/StatusImage";
-import Table from "@src/components/ui/Table";
-import DateUtils from "@src/utils/DateUtils";
-
-import arrowImage from "./images/arrow.svg";
-import azureMigrateImage from "./images/logo.svg";
-
-import type { Assessment, VmItem, AzureLocation } from "@src/@types/Assessment";
-import type { Endpoint } from "@src/@types/Endpoint";
-import type { Instance, Nic } from "@src/@types/Instance";
-import type { Network, NetworkMap } from "@src/@types/Network";
-const Wrapper = styled.div<any>`
-  display: flex;
-  justify-content: center;
-`;
-const Buttons = styled.div<any>`
-  margin-top: 46px;
-  display: flex;
-  flex-direction: column;
-
-  button:first-child {
-    margin-bottom: 16px;
-  }
-`;
-const DetailsBody = styled.div<any>`
-  ${ThemeProps.exactWidth(ThemeProps.contentWidth)}
-  margin-bottom: 32px;
-`;
-const Columns = styled.div<any>`
-  display: flex;
-  margin-left: -32px;
-`;
-const Column = styled.div<any>`
-  width: 50%;
-  margin-left: 32px;
-`;
-const Row = styled.div<any>`
-  margin-bottom: 32px;
-`;
-const Field = styled.div<any>`
-  display: flex;
-  flex-direction: column;
-`;
-const Label = styled.div<any>`
-  font-size: 10px;
-  color: ${ThemePalette.grayscale[3]};
-  font-weight: ${ThemeProps.fontWeights.medium};
-  text-transform: uppercase;
-`;
-const Value = styled.div<any>`
-  display: ${props => (props.flex ? "flex" : "inline-table")};
-  margin-top: 3px;
-  ${props => (props.capitalize ? "text-transform: capitalize;" : "")}
-`;
-const AzureMigrateLogo = styled.div<any>`
-  width: 208px;
-  height: 32px;
-  background: url("${azureMigrateImage}") center no-repeat;
-`;
-const LoadingWrapper = styled.div<any>`
-  display: flex;
-  flex-direction: column;
-  align-items: center;
-  margin: 32px 0;
-`;
-const LoadingText = styled.div<any>`
-  font-size: 18px;
-  margin-top: 32px;
-`;
-const SmallLoadingWrapper = styled.div<any>`
-  display: flex;
-  align-items: center;
-  justify-content: center;
-`;
-const SmallLoadingText = styled.div<any>`
-  font-size: 14px;
-  margin-left: 16px;
-`;
-const TableStyled = styled(Table)<any>`
-  margin-top: 62px;
-  ${props =>
-    props.addWidthPadding
-      ? css`
-          margin-left: -24px;
-          &:after {
-            margin-left: 24px;
-          }
-        `
-      : ""}
-`;
-const TableHeaderStyle = css`
-  margin-left: 24px;
-`;
-const TableBodyStyle = css`
-  padding-left: 24px;
-`;
-const NetworkItem = styled.div<any>`
-  display: flex;
-  width: 100%;
-`;
-const column = () => css`
-  padding-right: 32px;
-  width: 100%;
-  max-width: 25%;
-`;
-const NetworkName = styled.div<any>`
-  ${column()}
-`;
-const Arrow = styled.div<any>`
-  width: 32px;
-  height: 16px;
-  position: absolute;
-  right: 0;
-  background: url("${arrowImage}") no-repeat;
-  background-position-y: center;
-`;
-const ColumnStub = styled.div<any>`
-  ${column()}
-  position: relative;
-  &:last-child {
-    padding-right: 0;
-  }
-`;
-const VmHeaderItem = styled.div<any>`
-  display: flex;
-  font-size: 14px;
-`;
-const VmHeaderItemLabel = styled.div<any>`
-  font-size: 10px;
-  margin-left: 8px;
-`;
-
-const NavigationItems = [
-  {
-    label: "Details",
-    value: "",
-  },
-];
-
-type Props = {
-  item: Assessment | null;
-  detailsLoading: boolean;
-  instancesDetailsLoading: boolean;
-  instancesLoading: boolean;
-  networksLoading: boolean;
-  instancesDetailsProgress: number | null;
-  targetEndpoint: Endpoint;
-  targetEndpoints: Endpoint[];
-  onTargetEndpointChange: (endpoint: Endpoint) => void;
-  targetEndpointsLoading: boolean;
-  sourceEndpoints: Endpoint[];
-  sourceEndpoint: Endpoint | null;
-  sourceEndpointsLoading: boolean;
-  locations: AzureLocation[];
-  selectedLocation: string | null;
-  onLocationChange: (locationName: string) => void;
-  selectedResourceGroup: string;
-  resourceGroups: string[];
-  onResourceGroupChange: (resourceGroupName: string) => void;
-  targetOptionsLoading: boolean;
-  assessedVmsCount: number;
-  filteredAssessedVms: VmItem[];
-  selectedVms: string[];
-  instancesDetails: Instance[];
-  instances: Instance[];
-  loadingVmSizes: boolean;
-  vmSizes: string[];
-  onVmSizeChange: (vmId: string, size: string) => void;
-  onGetSelectedVmSize: (vm: VmItem) => string | null;
-  networks: Network[];
-  page: string;
-  onSourceEndpointChange: (endpoint: Endpoint) => void;
-  onVmSearchValueChange: (value: string) => void;
-  vmSearchValue: string;
-  onVmSelectedChange: (vm: VmItem, selected: boolean) => void;
-  onNetworkChange: (sourceNic: Nic, targetNetwork: Network) => void;
-  onRefresh: () => void;
-  onMigrateClick: () => void;
-  selectedNetworks: NetworkMap[];
-  selectAllVmsChecked: boolean;
-  onSelectAllVmsChange: (selected: boolean) => void;
-};
-@observer
-class AssessmentDetailsContent extends React.Component<Props> {
-  static defaultProps = {
-    page: "",
-  };
-
-  doesVmMatchSource(vm: VmItem) {
-    if (
-      !this.props.sourceEndpoint ||
-      !this.props.sourceEndpoint.connection_info
-    ) {
-      return false;
-    }
-
-    if (
-      this.props.instances.length > 0 &&
-      !this.props.instances.find(
-        i =>
-          i.name === vm.properties.displayName ||
-          i.instance_name === vm.properties.displayName
-      )
-    ) {
-      return false;
-    }
-
-    return (
-      this.props.sourceEndpoint.connection_info.host ===
-      vm.properties.datacenterManagementServerName
-    );
-  }
-
-  renderMainDetails() {
-    if (this.props.page !== "" || !this.props.item || !this.props.item.id) {
-      return null;
-    }
-
-    const status = this.props.item
-      ? this.props.item.properties.status === "Completed"
-        ? "Ready for Migration"
-        : this.props.item.properties.status
-      : "";
-
-    const locationItem: AzureLocation | undefined = this.props.locations.find(
-      l => l.id === this.props.selectedLocation
-    );
-
-    return (
-      <Columns>
-        <Column>
-          <Row>
-            <AzureMigrateLogo />
-          </Row>
-          <Row>
-            <Field>
-              <Label>Last Update</Label>
-              <Value>
-                {this.props.item
-                  ? DateUtils.getLocalDate(
-                      this.props.item.properties.updatedTimestamp
-                    ).toFormat("yyyy-LL-dd HH:mm:ss")
-                  : "-"}
-              </Value>
-            </Field>
-          </Row>
-          <Row>
-            <Field>
-              <Label>Migration Project</Label>
-              <Value>
-                {this.props.item ? this.props.item.projectName : ""}
-              </Value>
-            </Field>
-          </Row>
-          <Row>
-            <Field>
-              <Label>VM Group</Label>
-              <Value>{this.props.item ? this.props.item.groupName : ""}</Value>
-            </Field>
-          </Row>
-          <Row>
-            <Field>
-              <Label>Status</Label>
-              <Value>{status}</Value>
-            </Field>
-          </Row>
-        </Column>
-        <Column>
-          <Row>
-            <Field>
-              <Label>Source Endpoint</Label>
-              <Value>
-                <DropdownLink
-                  selectedItem={
-                    this.props.sourceEndpoint
-                      ? this.props.sourceEndpoint.id
-                      : ""
-                  }
-                  items={this.props.sourceEndpoints.map(endpoint => ({
-                    label: endpoint.name,
-                    value: endpoint.id,
-                    endpoint,
-                  }))}
-                  onChange={item => {
-                    this.props.onSourceEndpointChange(item.endpoint);
-                  }}
-                  selectItemLabel="Select Endpoint"
-                  noItemsLabel={
-                    this.props.sourceEndpointsLoading
-                      ? "Loading ...."
-                      : "No matching endpoints"
-                  }
-                />
-              </Value>
-            </Field>
-          </Row>
-          <Row>
-            <Field>
-              <Label>Target endpoint</Label>
-              <Value>
-                <DropdownLink
-                  selectedItem={
-                    this.props.targetEndpoint
-                      ? this.props.targetEndpoint.id
-                      : ""
-                  }
-                  items={this.props.targetEndpoints.map(endpoint => ({
-                    label: endpoint.name,
-                    value: endpoint.id,
-                    endpoint,
-                  }))}
-                  onChange={item => {
-                    this.props.onTargetEndpointChange(item.endpoint);
-                  }}
-                  selectItemLabel="Select Endpoint"
-                  noItemsLabel={
-                    this.props.targetEndpointsLoading
-                      ? "Loading ...."
-                      : "No Azure endpoints"
-                  }
-                />
-              </Value>
-            </Field>
-          </Row>
-          <Row>
-            <Field>
-              <Label>Resource Group</Label>
-              <Value>
-                <DropdownLink
-                  selectedItem={this.props.selectedResourceGroup}
-                  items={this.props.resourceGroups.map(group => ({
-                    label: group,
-                    value: group,
-                  }))}
-                  onChange={item => {
-                    this.props.onResourceGroupChange(item.value);
-                  }}
-                  noItemsLabel={
-                    this.props.targetOptionsLoading
-                      ? "Loading ...."
-                      : "No Resource Groups found"
-                  }
-                />
-              </Value>
-            </Field>
-          </Row>
-          <Row>
-            <Field>
-              <Label>Location</Label>
-              <Value>
-                <DropdownLink
-                  selectedItem={locationItem ? locationItem.id : ""}
-                  items={this.props.locations.map(location => ({
-                    label: location.name,
-                    value: location.id,
-                  }))}
-                  onChange={item => {
-                    this.props.onLocationChange(item.value);
-                  }}
-                  noItemsLabel={
-                    this.props.targetOptionsLoading
-                      ? "Loading ...."
-                      : "No Locations found"
-                  }
-                />
-              </Value>
-            </Field>
-          </Row>
-        </Column>
-      </Columns>
-    );
-  }
-
-  renderVmsTable() {
-    const loading = this.props.instancesLoading;
-
-    const items = this.props.filteredAssessedVms.map(vm => (
-      <AssessedVmListItem
-        key={vm.id}
-        item={vm}
-        selected={
-          this.props.selectedVms.filter(m => m === vm.properties.displayName)
-            .length > 0
-        }
-        onSelectedChange={(selectedVm, selected) => {
-          this.props.onVmSelectedChange(selectedVm, selected);
-        }}
-        disabled={!this.doesVmMatchSource(vm)}
-        loadingVmSizes={this.props.loadingVmSizes}
-        recommendedVmSize={vm.properties.recommendedSize}
-        vmSizes={this.props.vmSizes}
-        selectedVmSize={this.props.onGetSelectedVmSize(vm)}
-        onVmSizeChange={size => {
-          this.props.onVmSizeChange(vm.properties.displayName, size);
-        }}
-      />
-    ));
-
-    const vmCountLabel = `(${
-      this.props.filteredAssessedVms.length === this.props.assessedVmsCount
-        ? this.props.assessedVmsCount
-        : `${this.props.filteredAssessedVms.length} OUT OF ${this.props.assessedVmsCount}`
-    })`;
-    const vmHeaderItem = (
-      <VmHeaderItem>
-        {loading ? null : (
-          <Checkbox
-            checked={this.props.selectAllVmsChecked}
-            onChange={checked => {
-              this.props.onSelectAllVmsChange(checked);
-            }}
-          />
-        )}
-        <VmHeaderItemLabel>Virtual Machine {vmCountLabel}</VmHeaderItemLabel>
-        <DropdownFilter
-          searchPlaceholder="Filter Virtual Machines"
-          searchValue={this.props.vmSearchValue}
-          onSearchChange={value => {
-            this.props.onVmSearchValueChange(value);
-          }}
-        />
-      </VmHeaderItem>
-    );
-
-    return (
-      <TableStyled
-        addWidthPadding
-        items={loading ? [] : items}
-        bodyStyle={TableBodyStyle}
-        headerStyle={TableHeaderStyle}
-        header={[vmHeaderItem, "OS", "Target Disk Type", "Azure VM Size"]}
-        useSecondaryStyle
-        noItemsComponent={this.renderLoading(
-          "Loading instances, please wait ..."
-        )}
-      />
-    );
-  }
-
-  renderNetworkTable() {
-    const loading =
-      this.props.networksLoading || this.props.instancesDetailsLoading;
-
-    if (loading) {
-      return (
-        <TableStyled
-          items={[]}
-          header={["Source Network", "", "", "Target Network"]}
-          useSecondaryStyle
-          noItemsStyle={{ marginLeft: 0 }}
-          noItemsComponent={this.renderNetworksLoading()}
-        />
-      );
-    }
-
-    const nics: Nic[] = [];
-    this.props.instancesDetails.forEach(instance => {
-      if (!instance.devices || !instance.devices.nics) {
-        return;
-      }
-      instance.devices.nics.forEach(nic => {
-        if (nics.find(n => n.network_name === nic.network_name)) {
-          return;
-        }
-        nics.push(nic);
-      });
-    });
-
-    if (nics.length === 0) {
-      return null;
-    }
-
-    const items = nics.map(nic => {
-      let selectedNetworkName: string | undefined;
-      const selectedNetwork =
-        this.props.selectedNetworks &&
-        this.props.selectedNetworks.find(
-          n => n.sourceNic.network_name === nic.network_name
-        );
-      if (selectedNetwork) {
-        selectedNetworkName = selectedNetwork.targetNetwork?.name;
-      }
-
-      return (
-        <NetworkItem key={nic.network_name}>
-          <NetworkName width="25%">{nic.network_name}</NetworkName>
-          <ColumnStub width="25%">
-            <Arrow />
-          </ColumnStub>
-          <ColumnStub width="25%" />
-          <ColumnStub width="25%">
-            <DropdownLink
-              width="208px"
-              noItemsLabel="No Networks found"
-              selectItemLabel="Select Network"
-              selectedItem={selectedNetworkName}
-              onChange={item => {
-                this.props.onNetworkChange(nic, item.network);
-              }}
-              items={this.props.networks.map(network => ({
-                value: network.name || "",
-                label: network.name || "",
-                network,
-              }))}
-            />
-          </ColumnStub>
-        </NetworkItem>
-      );
-    });
-    return (
-      <TableStyled
-        items={loading ? [] : items}
-        header={["Source Network", "", "", "Target Network"]}
-        useSecondaryStyle
-        noItemsStyle={{ marginLeft: 0 }}
-        noItemsComponent={this.renderNetworksLoading()}
-      />
-    );
-  }
-
-  renderNetworksLoading() {
-    let loadingProgress = -1;
-    if (this.props.instancesDetailsLoading) {
-      if (this.props.instancesDetailsProgress != null) {
-        loadingProgress = Math.round(this.props.instancesDetailsProgress * 100);
-      }
-    }
-
-    return (
-      <SmallLoadingWrapper>
-        <SmallLoading loadingProgress={loadingProgress} />
-        <SmallLoadingText>Loading networks, please wait ...</SmallLoadingText>
-      </SmallLoadingWrapper>
-    );
-  }
-
-  renderButtons() {
-    return (
-      <Buttons>
-        <Button secondary onClick={this.props.onRefresh}>
-          Refresh
-        </Button>
-        <Button
-          disabled={
-            this.props.selectedVms.length === 0 ||
-            this.props.selectedNetworks.length === 0
-          }
-          onClick={() => {
-            this.props.onMigrateClick();
-          }}
-        >
-          Migrate / Replicate
-        </Button>
-      </Buttons>
-    );
-  }
-
-  renderLoading(message: string) {
-    return (
-      <LoadingWrapper>
-        <StatusImage loading />
-        <LoadingText>{message}</LoadingText>
-      </LoadingWrapper>
-    );
-  }
-
-  render() {
-    return (
-      <Wrapper>
-        <DetailsNavigation
-          items={NavigationItems}
-          selectedValue={this.props.page}
-          itemId={this.props.item ? this.props.item.id : ""}
-          customHref={() => "#"}
-        />
-        <DetailsBody>
-          {this.props.detailsLoading ? null : this.renderMainDetails()}
-          {this.props.detailsLoading
-            ? this.renderLoading("Loading assessment...")
-            : null}
-          {this.props.detailsLoading ? null : this.renderVmsTable()}
-          {this.props.detailsLoading || this.props.instancesLoading
-            ? null
-            : this.renderNetworkTable()}
-          {this.props.detailsLoading ? null : this.renderButtons()}
-        </DetailsBody>
-      </Wrapper>
-    );
-  }
-}
-
-export default AssessmentDetailsContent;

+ 0 - 13
src/components/modules/AssessmentModule/AssessmentDetailsContent/images/arrow.svg

@@ -1,13 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<svg width="20px" height="12px" viewBox="0 0 20 12" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
-    <!-- Generator: Sketch 48.1 (47250) - http://www.bohemiancoding.com/sketch -->
-
-    <desc>Created with Sketch.</desc>
-    <defs></defs>
-    <g id="Azure-Migrate/Net-2" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd" transform="translate(-423.000000, -58.000000)">
-        <g id="Icon/Arrow/Small" transform="translate(416.000000, 56.000000)" stroke="#A4AAB5" stroke-width="1.5">
-            <polyline id="Path-181-Copy-4" points="21 2.5 26 8 21 13.5"></polyline>
-            <path d="M7,8 L26,8" id="Line" transform="translate(16.500000, 8.000000) rotate(-180.000000) translate(-16.500000, -8.000000) "></path>
-        </g>
-    </g>
-</svg>

Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 0 - 12
src/components/modules/AssessmentModule/AssessmentDetailsContent/images/logo.svg


+ 0 - 6
src/components/modules/AssessmentModule/AssessmentDetailsContent/package.json

@@ -1,6 +0,0 @@
-{
-  "name": "AssessmentDetailsContent",
-  "version": "0.0.0",
-  "private": true,
-  "main": "./AssessmentDetailsContent.tsx"
-}

+ 0 - 142
src/components/modules/AssessmentModule/AssessmentListItem/AssessmentListItem.tsx

@@ -1,142 +0,0 @@
-/*
-Copyright (C) 2017  Cloudbase Solutions SRL
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU Affero General Public License as
-published by the Free Software Foundation, either version 3 of the
-License, or (at your option) any later version.
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-GNU Affero General Public License for more details.
-You should have received a copy of the GNU Affero General Public License
-along with this program.  If not, see <http://www.gnu.org/licenses/>.
-*/
-
-import React from "react";
-import { observer } from "mobx-react";
-import styled from "styled-components";
-
-import StatusPill from "@src/components/ui/StatusComponents/StatusPill";
-
-import type { Assessment } from "@src/@types/Assessment";
-
-import { ThemePalette, ThemeProps } from "@src/components/Theme";
-import assessmentImage from "./images/assessment.svg";
-import azureMigrateImage from "./images/azure-migrate.svg";
-
-const Content = styled.div<any>`
-  display: flex;
-  align-items: center;
-  border-top: 1px solid ${ThemePalette.grayscale[1]};
-  padding: 8px 16px;
-  cursor: pointer;
-  flex-grow: 1;
-  transition: all ${ThemeProps.animations.swift};
-  min-width: 785px;
-
-  &:hover {
-    background: ${ThemePalette.grayscale[1]};
-  }
-`;
-const Wrapper = styled.div<any>`
-  display: flex;
-  align-items: center;
-
-  &:last-child ${Content} {
-    border-bottom: 1px solid ${ThemePalette.grayscale[1]};
-  }
-`;
-const Image = styled.div<any>`
-  min-width: 48px;
-  height: 48px;
-  background: url("${(props: any) => props.image}") no-repeat center;
-  margin-right: 16px;
-`;
-const Title = styled.div<any>`
-  flex-grow: 1;
-  overflow: hidden;
-  margin-right: 48px;
-  min-width: 100px;
-`;
-const TitleLabel = styled.div<any>`
-  font-size: 16px;
-  overflow: hidden;
-  white-space: nowrap;
-  text-overflow: ellipsis;
-`;
-const AssessmentType = styled.div<any>`
-  display: flex;
-  justify-content: center;
-  align-items: center;
-  margin-right: 46px;
-  ${ThemeProps.exactWidth("180px")}
-`;
-const AssessmentImage = styled.div<any>`
-  width: 48px;
-  height: 32px;
-  background: url("${azureMigrateImage}") center no-repeat;
-  margin-right: 12px;
-`;
-const AssessmentLabel = styled.div<any>`
-  font-size: 15px;
-  color: ${ThemePalette.grayscale[4]};
-  width: 64px;
-`;
-const TotalVms = styled.div<any>`
-  ${ThemeProps.exactWidth("96px")}
-  margin-right: 48px;
-`;
-const Project = styled.div<any>`
-  ${ThemeProps.exactWidth("175px")}
-  margin-right: 48px;
-`;
-const ItemLabel = styled.div<any>`
-  color: ${ThemePalette.grayscale[4]};
-`;
-const ItemValue = styled.div<any>`
-  color: ${ThemePalette.primary};
-`;
-
-type Props = {
-  item: Assessment;
-  onClick: () => void;
-};
-@observer
-class AssessmentListItem extends React.Component<Props> {
-  render() {
-    let status = this.props.item.properties.status.toUpperCase();
-    let label = status;
-    if (status === "CREATED" || status === "RUNNING") {
-      status = "RUNNING";
-      label = "CREATING";
-    } else if (status === "COMPLETED") {
-      label = "READY";
-    }
-
-    return (
-      <Wrapper>
-        <Content onClick={this.props.onClick}>
-          <Image image={assessmentImage} />
-          <Title>
-            <TitleLabel>{this.props.item.name}</TitleLabel>
-            <StatusPill status={status} label={label} />
-          </Title>
-          <AssessmentType>
-            <AssessmentImage />
-            <AssessmentLabel>Azure Migrate</AssessmentLabel>
-          </AssessmentType>
-          <Project>
-            <ItemLabel>Project</ItemLabel>
-            <ItemValue>{this.props.item.project.name}</ItemValue>
-          </Project>
-          <TotalVms>
-            <ItemLabel>Instances</ItemLabel>
-            <ItemValue>{this.props.item.properties.numberOfMachines}</ItemValue>
-          </TotalVms>
-        </Content>
-      </Wrapper>
-    );
-  }
-}
-
-export default AssessmentListItem;

+ 0 - 20
src/components/modules/AssessmentModule/AssessmentListItem/images/assessment.svg

@@ -1,20 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<svg width="48px" height="48px" viewBox="0 0 48 48" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
-    <!-- Generator: Sketch 48.1 (47250) - http://www.bohemiancoding.com/sketch -->
-
-    <desc>Created with Sketch.</desc>
-    <defs></defs>
-    <g id="AM-0" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd" transform="translate(-400.000000, -200.000000)">
-        <g id="Azure-Migrate/Icon48" transform="translate(400.000000, 200.000000)">
-            <path d="M24,48 C37.254834,48 48,37.254834 48,24 C48,10.745166 37.254834,0 24,0 C10.745166,0 0,10.745166 0,24 C0,37.254834 10.745166,48 24,48 Z" id="Pat-Benetar" fill="#C8CCD7"></path>
-            <g id="Group-2" stroke-width="1" transform="translate(7.000000, 11.000000)" stroke="#0044CA" stroke-linecap="round">
-                <g id="Group" stroke-width="1.5">
-                    <polyline id="Rectangle-Copy" stroke-linejoin="round" transform="translate(15.583333, 14.400000) rotate(-405.000000) translate(-15.583333, -14.400000) " points="19.2563602 10.6664762 19.2563602 18.1335238 11.9103064 18.1335238"></polyline>
-                    <polyline id="Rectangle-Copy" stroke-linejoin="round" transform="translate(22.194444, 14.400000) rotate(-405.000000) translate(-22.194444, -14.400000) " points="25.8674713 10.6664762 25.8674713 18.1335238 18.5214176 18.1335238"></polyline>
-                    <polyline id="Rectangle-Copy" stroke-linejoin="round" transform="translate(8.972222, 14.400000) rotate(-405.000000) translate(-8.972222, -14.400000) " points="12.6452491 10.6664762 12.6452491 18.1335238 5.29919533 18.1335238"></polyline>
-                    <path d="M13.6,0 C9.20788,0 5.69092,3.71625102 5.50392,8.36338293 C2.32288,9.29135481 0,12.36108 0,16.0002424 C0,20.3964728 3.3694,24 7.48,24 L27.88,24 C31.2426,24 34,21.0509985 34,17.4547438 C34,14.6184661 32.232,12.2127208 29.85608,11.363292 C29.71192,7.09942123 26.46016,3.63625345 22.44,3.63625345 C21.73348,3.63625345 21.07592,3.82242962 20.42108,4.02315081 C18.95976,1.64504106 16.46756,0 13.6,0 Z" id="Path-Copy" transform="translate(17.000000, 12.000000) scale(-1, 1) translate(-17.000000, -12.000000) "></path>
-                </g>
-            </g>
-        </g>
-    </g>
-</svg>

+ 0 - 20
src/components/modules/AssessmentModule/AssessmentListItem/images/azure-migrate.svg

@@ -1,20 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<svg width="48px" height="31px" viewBox="0 0 48 31" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
-    <!-- Generator: Sketch 48.1 (47250) - http://www.bohemiancoding.com/sketch -->
-
-    <desc>Created with Sketch.</desc>
-    <defs></defs>
-    <g id="AM-0" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd" transform="translate(-778.000000, -210.000000)">
-        <g id="Group-6-Copy-2" transform="translate(778.000000, 210.000000)">
-            <g id="Group-5">
-                <path d="M41.1428571,25.6610799 L41.1428571,25.8333333 L9.42857143,25.8333333 L9.42857143,19.8055556 L12.2649615,19.8055556 C11.0112733,17.8117364 10.2857143,15.4493255 10.2857143,12.9166667 C10.2857143,5.78298865 16.0420532,0 23.1428571,0 C29.0801086,0 34.0774087,4.04304133 35.5557249,9.53815127 C36.718957,8.94525657 38.0349221,8.61111111 39.4285714,8.61111111 C44.1624407,8.61111111 48,12.4664369 48,17.2222222 C48,21.3882053 45.0552691,24.8632254 41.1428571,25.6610799 Z" id="Combined-Shape-Copy-5" fill="#616870"></path>
-                <path d="M5.14285714,30.9836864 C2.26609384,30.763834 0,28.3491684 0,25.4027778 C0,22.3115173 2.49441354,19.8055556 5.57142857,19.8055556 C5.77612888,19.8055556 5.97825079,19.8166461 6.17723144,19.8382617 C6.06064143,19.1271392 6,18.3970731 6,17.6527778 C6,10.2813105 11.9482169,4.30555556 19.2857143,4.30555556 C25.3772266,4.30555556 30.5112269,8.42413185 32.0791898,14.0406827 C33.3683783,13.3243978 34.8510789,12.9166667 36.4285714,12.9166667 C41.3991342,12.9166667 45.4285714,16.9647587 45.4285714,21.9583333 C45.4285714,26.5133595 42.0758068,30.2816802 37.7142857,30.9084352 L37.7142857,31 L5.14285714,31 L5.14285714,30.9836864 Z" id="Combined-Shape-Copy-4" fill="#A4AAB5"></path>
-                <g id="Group-3" transform="translate(13.714286, 6.027778)" fill="#FFFFFF" fill-rule="nonzero">
-                    <path d="M-0.00923979018,24.9722222 L8.44556964,16.5174128 L2.26149019,10.3333333 L7.1102224,10.3333333 L13.3055258,16.5286367 L4.86194026,24.9722222 L-0.00923979018,24.9722222 Z" id="Combined-Shape"></path>
-                    <path d="M15.4312364,22.3888889 L21.3027125,16.5174128 L16.8408553,12.0555556 L21.6895875,12.0555556 L26.1626686,16.5286367 L20.3024164,22.3888889 L15.4312364,22.3888889 Z" id="Combined-Shape-Copy"></path>
-                    <path d="M10.2883793,10.3333333 L16.1598554,4.46185723 L11.6979981,0 L16.5467303,0 L21.0198115,4.47308115 L15.1595593,10.3333333 L10.2883793,10.3333333 Z" id="Combined-Shape-Copy-2"></path>
-                </g>
-            </g>
-        </g>
-    </g>
-</svg>

+ 0 - 6
src/components/modules/AssessmentModule/AssessmentListItem/package.json

@@ -1,6 +0,0 @@
-{
-  "name": "AssessmentListItem",
-  "version": "0.0.0",
-  "private": true,
-  "main": "./AssessmentListItem.tsx"
-}

+ 0 - 321
src/components/modules/AssessmentModule/AssessmentMigrationOptions/AssessmentMigrationOptions.tsx

@@ -1,321 +0,0 @@
-/*
-Copyright (C) 2017  Cloudbase Solutions SRL
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU Affero General Public License as
-published by the Free Software Foundation, either version 3 of the
-License, or (at your option) any later version.
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-GNU Affero General Public License for more details.
-You should have received a copy of the GNU Affero General Public License
-along with this program.  If not, see <http://www.gnu.org/licenses/>.
-*/
-
-import * as React from "react";
-import { observer } from "mobx-react";
-import styled from "styled-components";
-
-import Button from "@src/components/ui/Button";
-import FieldInput from "@src/components/ui/FieldInput";
-import ToggleButtonBar from "@src/components/ui/ToggleButtonBar";
-
-import type { Field } from "@src/@types/Field";
-
-import { ThemeProps } from "@src/components/Theme";
-
-import LabelDictionary from "@src/utils/LabelDictionary";
-
-import assessmentImage from "./images/assessment.svg";
-
-const Wrapper = styled.div<any>`
-  padding: 48px 32px 32px 32px;
-  display: flex;
-  flex-direction: column;
-  align-items: center;
-  min-height: 0;
-`;
-const Image = styled.div<any>`
-  width: 96px;
-  height: 96px;
-  background: url("${assessmentImage}") center no-repeat;
-`;
-const ToggleButtonBarStyled = styled(ToggleButtonBar)`
-  margin-top: 48px;
-`;
-const Fields = styled.div<any>`
-  display: flex;
-  margin-top: 32px;
-  flex-direction: column;
-  overflow: auto;
-  width: 100%;
-  min-height: 0;
-`;
-const FieldStyled = styled(FieldInput)`
-  ${ThemeProps.exactWidth(`${ThemeProps.inputSizes.large.width}px`)}
-  margin-bottom: 16px;
-`;
-const Row = styled.div<any>`
-  display: flex;
-  flex-shrink: 0;
-  justify-content: space-between;
-`;
-
-const Buttons = styled.div<any>`
-  display: flex;
-  justify-content: space-between;
-  width: 100%;
-  margin-top: 32px;
-`;
-
-const generalFields = [
-  {
-    name: "use_replica",
-    type: "boolean",
-  },
-  {
-    name: "separate_vm",
-    type: "boolean",
-  },
-];
-const replicaFields = [
-  {
-    name: "shutdown_instances",
-    type: "boolean",
-  },
-];
-const migrationFields = [
-  {
-    name: "skip_os_morphing",
-    type: "boolean",
-  },
-];
-
-type Props = {
-  onCancelClick: () => void;
-  onExecuteClick: (fieldValues: { [prop: string]: any }) => void;
-  executeButtonDisabled: boolean;
-  replicaSchema: Field[];
-  migrationSchema: Field[];
-  onResizeUpdate?: (scrollableRef: HTMLElement, scrollOffset?: number) => void;
-};
-type State = {
-  fieldValues: { [prop: string]: any };
-  showAdvancedOptions: boolean;
-};
-@observer
-class AssessmentMigrationOptions extends React.Component<Props, State> {
-  state: State = {
-    fieldValues: {
-      separate_vm: true,
-      use_replica: false,
-      shutdown_instances: false,
-      skip_os_morphing: false,
-    },
-    showAdvancedOptions: false,
-  };
-
-  // scrollableRef: HTMLElement | undefined | null
-
-  getFieldValue(fieldName: string) {
-    if (this.state.fieldValues[fieldName] != null) {
-      return this.state.fieldValues[fieldName];
-    }
-    return null;
-  }
-
-  getObjectFieldValue(fieldName: string, propName: string) {
-    return (
-      this.state.fieldValues[fieldName] &&
-      this.state.fieldValues[fieldName][propName]
-    );
-  }
-
-  handleValueChange(fieldName: string, value: any) {
-    this.setState(prevState => {
-      const fieldValues = { ...prevState.fieldValues };
-      if (value != null) {
-        fieldValues[fieldName] = value;
-      } else {
-        delete fieldValues[fieldName];
-      }
-      return { fieldValues };
-    });
-  }
-
-  // UNSAFE_componentDidUpdate(_: Props, prevState: State) {
-  //   if (prevState.showAdvancedOptions !== this.state.showAdvancedOptions
-  //     && this.props.onResizeUpdate && this.scrollableRef) {
-  //     this.props.onResizeUpdate(this.scrollableRef)
-  //   }
-  // }
-
-  handleObjectValueChange(fieldName: string, propName: string, value: any) {
-    this.setState(prevState => {
-      const fieldValues = { ...prevState.fieldValues };
-      if (!fieldValues[fieldName]) {
-        fieldValues[fieldName] = {};
-      }
-      fieldValues[fieldName][propName] = value;
-      return { fieldValues };
-    });
-  }
-
-  renderFields() {
-    let fields: any = generalFields;
-    const useReplica = this.getFieldValue("use_replica");
-    const skipFields = [
-      "location",
-      "resource_group",
-      "network_map",
-      "storage_map",
-      "vm_size",
-      "worker_size",
-    ];
-    // eslint-disable-next-line no-shadow
-    const cleanup = (cleanupFields: any[]) =>
-      cleanupFields
-        .filter((f: { name: string }) => !skipFields.find(n => n === f.name))
-        .map((f: { type: string; nullableBoolean: boolean }) => {
-          if (f.type === "boolean") {
-            // eslint-disable-next-line no-param-reassign
-            f.nullableBoolean = true;
-          }
-          return { ...f };
-        });
-
-    if (useReplica) {
-      fields = [...fields, ...replicaFields];
-      if (this.state.showAdvancedOptions) {
-        fields = [...fields, ...cleanup(this.props.replicaSchema)];
-      }
-    } else {
-      fields = [...fields, ...migrationFields];
-      if (this.state.showAdvancedOptions) {
-        fields = [...fields, ...cleanup(this.props.migrationSchema)];
-      }
-    }
-
-    const sortPriority: any = {
-      boolean: 1,
-      string: 2,
-      object: 3,
-    };
-    fields.sort((a: any, b: any) => {
-      if (sortPriority[a.type] && sortPriority[b.type]) {
-        return sortPriority[a.type] - sortPriority[b.type];
-      }
-      if (sortPriority[a.type]) {
-        return -1;
-      }
-      if (sortPriority[b.type]) {
-        return 1;
-      }
-      return a.name.localeCompare(b.name);
-    });
-
-    const rows: JSX.Element[] = [];
-    let lastField: JSX.Element;
-    fields.forEach((field: any, index: number) => {
-      let additionalProps;
-      if (field.type === "object" && field.properties) {
-        additionalProps = {
-          valueCallback: (callbackField: { name: string }) =>
-            this.getObjectFieldValue(field.name, callbackField.name),
-          onChange: (value: any, callbackField: { name: string }) => {
-            const propName = callbackField.name.substr(
-              callbackField.name.lastIndexOf("/") + 1
-            );
-            this.handleObjectValueChange(field.name, propName, value);
-          },
-          properties: field.properties.map((p: any) => ({
-            ...p,
-            required: false,
-          })),
-        };
-      } else {
-        const value = this.getFieldValue(field.name);
-        additionalProps = {
-          value,
-          // eslint-disable-next-line no-shadow
-          onChange: (changeValue: any) => {
-            this.handleValueChange(field.name, changeValue);
-          },
-          type: field.type,
-        };
-      }
-
-      const currentField = (
-        <FieldStyled
-          width={ThemeProps.inputSizes.large.width}
-          // eslint-disable-next-line react/jsx-props-no-spreading
-          {...field}
-          // eslint-disable-next-line react/jsx-props-no-spreading
-          {...additionalProps}
-          label={field.label || LabelDictionary.get(field.name)}
-        />
-      );
-      const pushRow = (field1: React.ReactNode, field2?: React.ReactNode) => {
-        rows.push(
-          <Row key={field.name}>
-            {field1}
-            {field2}
-          </Row>
-        );
-      };
-      if (index === fields.length - 1 && index % 2 === 0) {
-        pushRow(currentField);
-      } else if (index % 2 !== 0) {
-        pushRow(lastField, currentField);
-      } else {
-        lastField = currentField;
-      }
-    });
-
-    return (
-      // <Fields ref={(ref: HTMLElement | null | undefined) => { this.scrollableRef = ref }}>
-      <Fields>{rows}</Fields>
-    );
-  }
-
-  render() {
-    return (
-      <Wrapper>
-        <Image />
-        <ToggleButtonBarStyled
-          items={[
-            { label: "Basic", value: "basic" },
-            { label: "Advanced", value: "advanced" },
-          ]}
-          selectedValue={this.state.showAdvancedOptions ? "advanced" : "basic"}
-          onChange={item => {
-            this.setState({ showAdvancedOptions: item.value === "advanced" });
-          }}
-        />
-        {this.renderFields()}
-        <Buttons>
-          <Button
-            large
-            secondary
-            onClick={() => {
-              this.props.onCancelClick();
-            }}
-          >
-            Cancel
-          </Button>
-          <Button
-            large
-            onClick={() => {
-              this.props.onExecuteClick(this.state.fieldValues);
-            }}
-            disabled={this.props.executeButtonDisabled}
-          >
-            Execute
-          </Button>
-        </Buttons>
-      </Wrapper>
-    );
-  }
-}
-
-export default AssessmentMigrationOptions;

+ 0 - 17
src/components/modules/AssessmentModule/AssessmentMigrationOptions/images/assessment.svg

@@ -1,17 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<svg width="96px" height="68px" viewBox="0 0 96 68" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
-    <!-- Generator: Sketch 48.1 (47250) - http://www.bohemiancoding.com/sketch -->
-
-    <desc>Created with Sketch.</desc>
-    <defs></defs>
-    <g id="NAM-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd" transform="translate(-240.000000, -110.000000)">
-        <g id="Modal/Icon-96/2-Buttons" stroke="#0044CA" stroke-width="1.5">
-            <g id="Azure-Migrate/Icon96" transform="translate(240.000000, 96.000000)">
-                <polyline id="Rectangle-Copy" stroke-linecap="round" stroke-linejoin="round" transform="translate(44.000000, 54.800000) rotate(-405.000000) translate(-44.000000, -54.800000) " points="54.3708995 44.2216826 54.3708995 65.3783174 33.6291005 65.3783174"></polyline>
-                <polyline id="Rectangle-Copy" stroke-linecap="round" stroke-linejoin="round" transform="translate(62.666667, 54.800000) rotate(-405.000000) translate(-62.666667, -54.800000) " points="73.0375661 44.2216826 73.0375661 65.3783174 52.2957672 65.3783174"></polyline>
-                <polyline id="Rectangle-Copy" stroke-linecap="round" stroke-linejoin="round" transform="translate(25.333333, 54.800000) rotate(-405.000000) translate(-25.333333, -54.800000) " points="35.7042328 44.2216826 35.7042328 65.3783174 14.9624339 65.3783174"></polyline>
-                <path d="M38.4,14.75 C26.4942961,14.75 16.8057103,24.8628507 16.2898777,37.726303 L16.2682887,38.2646725 L15.751187,38.4160451 C6.95162499,40.9919634 0.75,49.5048643 0.75,59.3340202 C0.75,71.3871691 9.94011624,81.25 21.12,81.25 L78.72,81.25 C87.7878838,81.25 95.25,73.2416583 95.25,63.4551074 C95.25,55.9253123 90.6318176,49.2645554 84.0462573,46.9019388 L83.5670876,46.7300333 L83.5499453,46.2212492 C83.1534893,34.4544158 74.2216824,25.0527181 63.36,25.0527181 C61.7595305,25.0527181 60.3552686,25.3544351 57.8800133,26.1157834 L57.323809,26.2868628 L57.0199148,25.7905971 C52.8472502,18.9765458 45.9267364,14.75 38.4,14.75 Z" id="Path-Copy" transform="translate(48.000000, 48.000000) scale(-1, 1) translate(-48.000000, -48.000000) "></path>
-            </g>
-        </g>
-    </g>
-</svg>

+ 0 - 6
src/components/modules/AssessmentModule/AssessmentMigrationOptions/package.json

@@ -1,6 +0,0 @@
-{
-  "name": "AssessmentMigrationOptions",
-  "version": "0.0.0",
-  "private": true,
-  "main": "./AssessmentMigrationOptions.tsx"
-}

+ 0 - 689
src/components/smart/AssessmentDetailsPage/AssessmentDetailsPage.tsx

@@ -1,689 +0,0 @@
-/*
-Copyright (C) 2017  Cloudbase Solutions SRL
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU Affero General Public License as
-published by the Free Software Foundation, either version 3 of the
-License, or (at your option) any later version.
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-GNU Affero General Public License for more details.
-You should have received a copy of the GNU Affero General Public License
-along with this program.  If not, see <http://www.gnu.org/licenses/>.
-*/
-
-import React from "react";
-import styled from "styled-components";
-import cookie from "js-cookie";
-import { observer } from "mobx-react";
-
-import DetailsTemplate from "@src/components/modules/TemplateModule/DetailsTemplate";
-import DetailsPageHeader from "@src/components/modules/DetailsModule/DetailsPageHeader";
-import DetailsContentHeader from "@src/components/modules/DetailsModule/DetailsContentHeader";
-import AssessmentDetailsContent from "@src/components/modules/AssessmentModule/AssessmentDetailsContent";
-import Modal from "@src/components/ui/Modal";
-import AssessmentMigrationOptions from "@src/components/modules/AssessmentModule/AssessmentMigrationOptions";
-import type { Endpoint } from "@src/@types/Endpoint";
-import type { Nic } from "@src/@types/Instance";
-import type { VmItem } from "@src/@types/Assessment";
-import type { Field } from "@src/@types/Field";
-import type { Network, NetworkMap } from "@src/@types/Network";
-
-import azureStore from "@src/stores/AzureStore";
-import type { LocalData } from "@src/stores/AzureStore";
-import endpointStore from "@src/stores/EndpointStore";
-import notificationStore from "@src/stores/NotificationStore";
-import replicaStore from "@src/stores/TransferStore";
-import instanceStore from "@src/stores/InstanceStore";
-import networkStore from "@src/stores/NetworkStore";
-import userStore from "@src/stores/UserStore";
-import assessmentStore from "@src/stores/AssessmentStore";
-import providerStore from "@src/stores/ProviderStore";
-
-import DomUtils from "@src/utils/DomUtils";
-import assessmentImage from "./images/assessment.svg";
-
-const Wrapper = styled.div<any>``;
-
-type Props = {
-  match: any;
-  history: any;
-};
-type State = {
-  selectedNetworks: NetworkMap[];
-  showMigrationOptions: boolean;
-  executeButtonDisabled: boolean;
-  vmSearchValue: string;
-  loadingTargetVmSizes: boolean;
-  replicaSchema: Field[];
-  migrationSchema: Field[];
-};
-@observer
-class AssessmentDetailsPage extends React.Component<Props, State> {
-  state: State = {
-    selectedNetworks: [],
-    showMigrationOptions: false,
-    executeButtonDisabled: false,
-    vmSearchValue: "",
-    loadingTargetVmSizes: false,
-    replicaSchema: [],
-    migrationSchema: [],
-  };
-
-  UNSAFE_componentWillMount() {
-    document.title = "Assessment Details";
-    const urlData: LocalData = DomUtils.decodeFromBase64Url(
-      this.props.match.params.info
-    );
-    if (!azureStore.loadLocalData(urlData.assessmentName)) {
-      azureStore.setLocalData(urlData);
-    }
-    this.azureAuthenticate();
-  }
-
-  componentWillUnmount() {
-    azureStore.clearAssessmentDetails();
-    azureStore.clearAssessedVms();
-    instanceStore.clearInstancesDetails();
-  }
-
-  getLocalData(): LocalData {
-    // at this point we know for sure that at least URL data is there
-    const data: any = azureStore.localData;
-    return data;
-  }
-
-  getUrlInfo() {
-    return DomUtils.decodeFromBase64Url(this.props.match.params.info);
-  }
-
-  getSourceEndpoints() {
-    const vms = azureStore.assessedVms;
-    const connectionsInfo = endpointStore.connectionsInfo;
-
-    if (vms.length === 0 || connectionsInfo.length === 0) {
-      return [];
-    }
-    const endpoints = connectionsInfo.filter(endpoint =>
-      vms.find(
-        vm =>
-          endpoint.connection_info.host &&
-          endpoint.connection_info.host.toLowerCase() ===
-            vm.properties.datacenterManagementServerName.toLowerCase()
-      )
-    );
-    return endpoints;
-  }
-
-  getTargetEndpoints() {
-    const endpoints = endpointStore.endpoints;
-    return endpoints.filter(e => e.type === "azure");
-  }
-
-  getInstancesDetailsProgress() {
-    const count = instanceStore.instancesDetailsCount;
-    if (count < 5) {
-      return null;
-    }
-    const remaining = instanceStore.instancesDetailsRemaining;
-    return (count - remaining) / count;
-  }
-
-  getFilteredAssessedVms(vms?: VmItem[]) {
-    let usableVms = vms;
-    if (!usableVms) {
-      usableVms = azureStore.assessedVms;
-    }
-    return usableVms.filter(
-      vm =>
-        `${vm.properties.displayName}`
-          .toLowerCase()
-          .indexOf(this.state.vmSearchValue.toLowerCase()) > -1
-    );
-  }
-
-  getSourceEndpointId() {
-    const localData = this.getLocalData();
-    return localData.sourceEndpoint ? localData.sourceEndpoint.id : null;
-  }
-
-  getEnabledVms() {
-    const sourceConnInfo = endpointStore.connectionsInfo.find(
-      e => e.id === this.getSourceEndpointId()
-    );
-    if (!sourceConnInfo) {
-      return [];
-    }
-
-    const sourceHost = sourceConnInfo.connection_info.host;
-    if (!sourceHost) {
-      return [];
-    }
-    return azureStore.assessedVms.filter(vm => {
-      if (
-        vm.properties.datacenterManagementServerName.toLowerCase() ===
-          sourceHost.toLowerCase() &&
-        instanceStore.instances.find(
-          i =>
-            i.name === vm.properties.displayName ||
-            i.instance_name === vm.properties.displayName
-        )
-      ) {
-        return true;
-      }
-      return false;
-    });
-  }
-
-  getSelectAllVmsChecked() {
-    if (
-      this.getFilteredAssessedVms().length === 0 ||
-      this.getEnabledVms().length === 0
-    ) {
-      return false;
-    }
-    const selectedVms = this.getLocalData().selectedVms;
-    return (
-      selectedVms.length ===
-      this.getFilteredAssessedVms(this.getEnabledVms()).length
-    );
-  }
-
-  handleVmSelectedChange(vm: VmItem, selected: boolean) {
-    let selectedVms = this.getLocalData().selectedVms;
-    const instanceInfo = instanceStore.instances.find(
-      i =>
-        i.name === vm.properties.displayName ||
-        i.instance_name === vm.properties.displayName
-    );
-    if (selected) {
-      selectedVms = [...selectedVms, vm.properties.displayName];
-      azureStore.updateSelectedVms(selectedVms);
-      if (instanceStore.loadingInstancesDetails) {
-        this.loadInstancesDetails();
-        return;
-      }
-      const sourceEndpointId = this.getSourceEndpointId();
-      if (!sourceEndpointId || !instanceInfo) {
-        return;
-      }
-      const localData = this.getLocalData();
-      instanceStore.addInstanceDetails({
-        endpointId: sourceEndpointId,
-        instanceInfo,
-        cache: true,
-        env: {
-          location: localData.locationName,
-          resource_group: localData.resourceGroupName,
-        },
-        targetProvider: "azure",
-      });
-    } else {
-      selectedVms = selectedVms.filter(m => m !== vm.properties.displayName);
-      azureStore.updateSelectedVms(selectedVms);
-      if (instanceStore.loadingInstancesDetails) {
-        this.loadInstancesDetails();
-        return;
-      }
-      if (instanceInfo) {
-        instanceStore.removeInstanceDetails(instanceInfo);
-      }
-    }
-  }
-
-  handleSelectAllVmsChange(selected: boolean) {
-    const selectedVms = selected
-      ? [...this.getFilteredAssessedVms(this.getEnabledVms())]
-      : [];
-    azureStore.updateSelectedVms(
-      selectedVms.map(v => v.properties.displayName)
-    );
-    this.loadInstancesDetails();
-  }
-
-  handleSourceEndpointChange(sourceEndpoint: Endpoint | null) {
-    this.setState({ selectedNetworks: [] });
-    azureStore.updateSourceEndpoint(sourceEndpoint);
-    const sourceEndpointId = this.getSourceEndpointId();
-    if (!sourceEndpointId) {
-      return;
-    }
-    instanceStore.loadInstances(sourceEndpointId).then(() => {
-      this.initSelectedVms();
-      this.loadInstancesDetails();
-    });
-  }
-
-  handleResourceGroupChange(resourceGroupName: string) {
-    azureStore.updateResourceGroup(resourceGroupName);
-    this.loadNetworks();
-    this.loadTargetVmSizes();
-  }
-
-  handleLocationChange(locationName: string) {
-    azureStore.updateLocation(locationName);
-    this.loadNetworks();
-    this.loadTargetVmSizes();
-  }
-
-  handleTargetEndpointChange(endpoint: Endpoint) {
-    azureStore.updateTargetEndpoint(endpoint);
-    this.loadTargetOptions().then(() => {
-      this.loadTargetVmSizes();
-      this.loadNetworks();
-    });
-  }
-
-  handleUserItemClick(item: { value: string }) {
-    switch (item.value) {
-      case "signout":
-        userStore.logout();
-        break;
-      default:
-    }
-  }
-
-  handleNetworkChange(sourceNic: Nic, targetNetwork: Network) {
-    this.setState(prevState => {
-      let selectedNetworks = prevState.selectedNetworks;
-
-      selectedNetworks = selectedNetworks.filter(
-        n => n.sourceNic.network_name !== sourceNic.network_name
-      );
-      selectedNetworks.push({ sourceNic, targetNetwork });
-      return { selectedNetworks };
-    });
-  }
-
-  handleRefresh() {
-    localStorage.removeItem("instances");
-    localStorage.removeItem(`assessments-${cookie.get("projectId") || ""}`);
-    localStorage.removeItem("instancesDetails");
-    localStorage.removeItem("networks");
-    window.location.reload();
-  }
-
-  handleMigrateClick() {
-    const endpointType = this.getLocalData().endpoint.type;
-    providerStore
-      .loadOptionsSchema({
-        providerName: endpointType,
-        optionsType: "destination",
-      })
-      .then(() => {
-        this.setState({ replicaSchema: providerStore.destinationSchema });
-        return providerStore.loadOptionsSchema({
-          providerName: endpointType,
-          optionsType: "destination",
-        });
-      })
-      .then(() => {
-        this.setState({ migrationSchema: providerStore.destinationSchema });
-      });
-    this.setState({ showMigrationOptions: true });
-  }
-
-  handleCloseMigrationOptions() {
-    this.setState({ showMigrationOptions: false });
-  }
-
-  handleVmSizeChange(vmId: string, vmSize: string) {
-    azureStore.updateVmSize(vmId, vmSize);
-  }
-
-  handleGetVmSize(vm: VmItem): string {
-    return this.getLocalData().selectedVmSizes[vm.properties.displayName];
-  }
-
-  handleVmSearchValueChange(vmSearchValue: string) {
-    this.setState({ vmSearchValue });
-  }
-
-  azureAuthenticate() {
-    const connectionInfo = this.getUrlInfo().connectionInfo;
-    azureStore.authenticate(connectionInfo).then(() => {
-      this.loadAssessmentDetails();
-    });
-  }
-
-  loadEndpoints() {
-    endpointStore.getEndpoints({ showLoading: true }).then(() => {
-      this.loadSourceEndpointsInfo();
-    });
-  }
-
-  loadSourceEndpointsInfo() {
-    endpointStore
-      .getConnectionsInfo(
-        endpointStore.endpoints.filter(e => e.type === "vmware_vsphere")
-      )
-      .then(() => {
-        const endpoints = this.getSourceEndpoints();
-        const sourceEndpoint = endpoints.find(
-          e => e.id === this.getSourceEndpointId()
-        );
-        if (sourceEndpoint) {
-          this.handleSourceEndpointChange(sourceEndpoint);
-        } else if (endpoints.length > 0) {
-          this.handleSourceEndpointChange(endpoints[0]);
-        } else {
-          this.handleSourceEndpointChange(null);
-        }
-      });
-  }
-
-  loadAssessmentDetails() {
-    const urlInfo = this.getUrlInfo();
-    azureStore.getAssessmentDetails({ ...urlInfo }).then(() => {
-      const location = azureStore.assessmentDetails
-        ? azureStore.assessmentDetails.properties.azureLocation
-        : "";
-      azureStore.setLocation(location);
-      // azureStore.getVmSizes({ ...urlInfo, location })
-      this.loadNetworks();
-      this.loadTargetOptions();
-      this.loadTargetVmSizes();
-    });
-
-    azureStore.getAssessedVms({ ...urlInfo }).then(() => {
-      this.initVmSizes();
-      this.loadEndpoints();
-    });
-  }
-
-  async loadTargetOptions(): Promise<void> {
-    const localData = this.getLocalData();
-    const options = await providerStore.getOptionsValues({
-      optionsType: "destination",
-      endpointId: localData.endpoint.id,
-      providerName: localData.endpoint.type,
-      allowMultiple: true,
-    });
-    const locations = options.find(o => o.name === "location") as any;
-    if (locations && locations.values) {
-      const localDataFind = locations.values.find(
-        (l: { id: string }) => l.id === localData.locationName
-      );
-      if (!localDataFind) {
-        azureStore.updateLocation(locations.values[0].id);
-      }
-
-      azureStore.saveLocations(locations.values);
-    }
-    const resourceGroups = options.find(
-      o_1 => o_1.name === "resource_group"
-    ) as any;
-    if (resourceGroups && resourceGroups.values) {
-      const localDataFind = resourceGroups.values.find(
-        (g: string) => g === localData.resourceGroupName
-      );
-      if (!localDataFind) {
-        azureStore.updateResourceGroup(resourceGroups.values[0] as string);
-      }
-      azureStore.saveResourceGroups(resourceGroups.values);
-    }
-  }
-
-  loadTargetVmSizes() {
-    const localData = this.getLocalData();
-    this.setState({ loadingTargetVmSizes: true });
-    providerStore
-      .getOptionsValues({
-        optionsType: "destination",
-        endpointId: localData.endpoint.id,
-        providerName: localData.endpoint.type,
-        envData: {
-          location: localData.locationName,
-          resource_group: localData.resourceGroupName,
-        },
-        allowMultiple: true,
-      })
-      .then(options => {
-        const vmSizes: any = options.find(o => o.name === "vm_size");
-        if (vmSizes && vmSizes.values) {
-          azureStore.saveTargetVmSizes(vmSizes.values);
-        }
-        this.setState({ loadingTargetVmSizes: false });
-      });
-  }
-
-  initSelectedVms() {
-    const localData = this.getLocalData();
-    const enabledVms = this.getEnabledVms().map(
-      vm => vm.properties.displayName
-    );
-    if (localData.selectedVms.length === 0) {
-      azureStore.updateSelectedVms(enabledVms);
-    } else {
-      azureStore.updateSelectedVms(
-        enabledVms.filter(id => localData.selectedVms.find(i => i === id))
-      );
-    }
-  }
-
-  initVmSizes() {
-    const vmSizes: any = {};
-    const vms = azureStore.assessedVms;
-    const localData = this.getLocalData();
-
-    vms.forEach(vm => {
-      vmSizes[vm.properties.displayName] =
-        localData.selectedVmSizes[vm.properties.displayName] ||
-        vm.properties.recommendedSize ||
-        "auto";
-    });
-    azureStore.updateVmSizes(vmSizes);
-  }
-
-  loadNetworks() {
-    const localData = this.getLocalData();
-    this.setState({ selectedNetworks: [] });
-    networkStore.loadNetworks(
-      localData.endpoint.id,
-      {
-        location: localData.locationName,
-        resource_group: localData.resourceGroupName,
-      },
-      { cache: true }
-    );
-  }
-
-  loadInstancesDetails() {
-    const localData = this.getLocalData();
-    const selectedVms = localData.selectedVms;
-    const instancesInfo = instanceStore.instances.filter(i =>
-      selectedVms.find(m => i.instance_name === m || i.name === m)
-    );
-    instanceStore.clearInstancesDetails();
-    const sourceEndpointId = this.getSourceEndpointId();
-    if (!sourceEndpointId) {
-      return;
-    }
-    instanceStore.loadInstancesDetails({
-      endpointId: sourceEndpointId,
-      instances: instancesInfo,
-      // cache: true,
-      skipLog: true,
-      env: {
-        location: localData.locationName,
-        resource_group: localData.resourceGroupName,
-      },
-      targetProvider: "azure",
-    });
-  }
-
-  handleMigrationExecute(fieldValues: { [prop: string]: any }) {
-    const selectedVms = this.getLocalData().selectedVms;
-    const selectedInstances = instanceStore.instancesDetails.filter(i =>
-      selectedVms.find(m => i.name === m || i.instance_name === m)
-    );
-    const vmSizes: any = {};
-    const localData = this.getLocalData();
-    selectedInstances.forEach(i => {
-      const vm = selectedVms.find(m => i.name === m || i.instance_name === m);
-      const selectedVmSize =
-        localData.selectedVmSizes[i.instance_name || i.name];
-      if (vm && azureStore.vmSizes.find(s => s === selectedVmSize)) {
-        vmSizes[i.instance_name || i.name] = selectedVmSize;
-      }
-    });
-
-    this.setState({ executeButtonDisabled: true });
-    const fieldValuesLocal = fieldValues;
-    fieldValuesLocal.resource_group = localData.resourceGroupName;
-    fieldValuesLocal.location = localData.locationName;
-
-    assessmentStore
-      .migrate({
-        source: localData.sourceEndpoint,
-        target: localData.endpoint,
-        networks: [...this.state.selectedNetworks],
-        fieldValues: fieldValuesLocal,
-        vmSizes,
-        selectedInstances,
-      })
-      .then(() => {
-        this.setState({ showMigrationOptions: false });
-        const type = fieldValuesLocal.use_replica ? "Replica" : "Migration";
-        notificationStore.alert(`${type} was succesfully created`, "success");
-
-        if (type === "Replica") {
-          assessmentStore.migrations.forEach(replica => {
-            replicaStore.execute(replica.id, [
-              {
-                name: "shutdown_instances",
-                value: fieldValuesLocal.shutdown_instances || false,
-              },
-            ]);
-          });
-        }
-
-        this.props.history.push(`/${type.toLowerCase()}s`);
-      });
-  }
-
-  render() {
-    const details = azureStore.assessmentDetails;
-    const loading =
-      azureStore.loadingAssessmentDetails ||
-      azureStore.authenticating ||
-      azureStore.loadingAssessedVms;
-    const endpointsLoading =
-      endpointStore.connectionsInfoLoading || endpointStore.loading;
-    const status = details ? details.properties.status.toUpperCase() : "";
-    const statusLabel = status === "COMPLETED" ? "READY" : status;
-    const localData = this.getLocalData();
-
-    return (
-      <Wrapper>
-        <DetailsTemplate
-          pageHeaderComponent={
-            <DetailsPageHeader
-              user={userStore.loggedUser}
-              onUserItemClick={item => {
-                this.handleUserItemClick(item);
-              }}
-            />
-          }
-          contentHeaderComponent={
-            <DetailsContentHeader
-              statusPill={status}
-              statusLabel={statusLabel}
-              itemTitle={details?.name}
-              itemType="Azure Migrate"
-              backLink="/planning"
-              typeImage={assessmentImage}
-            />
-          }
-          contentComponent={
-            <AssessmentDetailsContent
-              item={details}
-              detailsLoading={loading}
-              instancesDetailsLoading={instanceStore.loadingInstancesDetails}
-              instancesDetailsProgress={this.getInstancesDetailsProgress()}
-              instancesLoading={instanceStore.instancesLoading}
-              networksLoading={networkStore.loading}
-              targetEndpointsLoading={endpointStore.loading}
-              loadingVmSizes={this.state.loadingTargetVmSizes}
-              sourceEndpointsLoading={endpointsLoading}
-              targetOptionsLoading={
-                providerStore.destinationOptionsSecondaryLoading
-              }
-              targetEndpoints={this.getTargetEndpoints()}
-              targetEndpoint={localData.endpoint}
-              onTargetEndpointChange={endpoint => {
-                this.handleTargetEndpointChange(endpoint);
-              }}
-              sourceEndpoints={this.getSourceEndpoints()}
-              sourceEndpoint={localData.sourceEndpoint}
-              locations={azureStore.locations}
-              selectedLocation={localData.locationName}
-              onLocationChange={locationName => {
-                this.handleLocationChange(locationName);
-              }}
-              selectedResourceGroup={localData.resourceGroupName}
-              resourceGroups={azureStore.coriolisResourceGroups}
-              onResourceGroupChange={resourceGroupName => {
-                this.handleResourceGroupChange(resourceGroupName);
-              }}
-              assessedVmsCount={azureStore.assessedVms.length}
-              filteredAssessedVms={this.getFilteredAssessedVms()}
-              onSourceEndpointChange={endpoint =>
-                this.handleSourceEndpointChange(endpoint)
-              }
-              selectedVms={localData.selectedVms}
-              onVmSelectedChange={(vm, selected) => {
-                this.handleVmSelectedChange(vm, selected);
-              }}
-              selectAllVmsChecked={this.getSelectAllVmsChecked()}
-              onSelectAllVmsChange={checked => {
-                this.handleSelectAllVmsChange(checked);
-              }}
-              instances={instanceStore.instances}
-              instancesDetails={instanceStore.instancesDetails}
-              networks={networkStore.networks}
-              selectedNetworks={this.state.selectedNetworks}
-              vmSizes={azureStore.vmSizes}
-              onVmSizeChange={(vmId, size) => {
-                this.handleVmSizeChange(vmId, size);
-              }}
-              onGetSelectedVmSize={vm => this.handleGetVmSize(vm)}
-              vmSearchValue={this.state.vmSearchValue}
-              onVmSearchValueChange={value => {
-                this.handleVmSearchValueChange(value);
-              }}
-              onNetworkChange={(sourceNic, targetNetwork) => {
-                this.handleNetworkChange(sourceNic, targetNetwork);
-              }}
-              onRefresh={() => this.handleRefresh()}
-              onMigrateClick={() => {
-                this.handleMigrateClick();
-              }}
-            />
-          }
-        />
-        <Modal
-          isOpen={this.state.showMigrationOptions}
-          title="Options"
-          onRequestClose={() => {
-            this.handleCloseMigrationOptions();
-          }}
-        >
-          <AssessmentMigrationOptions
-            onCancelClick={() => {
-              this.handleCloseMigrationOptions();
-            }}
-            onExecuteClick={fieldValues => {
-              this.handleMigrationExecute(fieldValues);
-            }}
-            replicaSchema={this.state.replicaSchema}
-            migrationSchema={this.state.migrationSchema}
-            executeButtonDisabled={this.state.executeButtonDisabled}
-          />
-        </Modal>
-      </Wrapper>
-    );
-  }
-}
-
-export default AssessmentDetailsPage;

+ 0 - 20
src/components/smart/AssessmentDetailsPage/images/assessment.svg

@@ -1,20 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<svg width="64px" height="64px" viewBox="0 0 64 64" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
-    <!-- Generator: Sketch 48.1 (47250) - http://www.bohemiancoding.com/sketch -->
-
-    <desc>Created with Sketch.</desc>
-    <defs></defs>
-    <g id="AM-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd" transform="translate(-224.000000, -80.000000)">
-        <g id="Group-3" transform="translate(224.000000, 80.000000)">
-            <path d="M32,64 C49.673112,64 64,49.673112 64,32 C64,14.326888 49.673112,0 32,0 C14.326888,0 0,14.326888 0,32 C0,49.673112 14.326888,64 32,64 Z" id="Pat-Benetar" fill="#FFFFFF"></path>
-            <g id="Group-2" transform="translate(10.000000, 15.000000)" stroke="#0044CA" stroke-linecap="round" stroke-width="1.5">
-                <g id="Group">
-                    <polyline id="Rectangle-Copy" stroke-linejoin="round" transform="translate(20.625000, 19.200000) rotate(-405.000000) translate(-20.625000, -19.200000) " points="25.4863591 14.2219683 25.4863591 24.1780317 15.7636409 24.1780317"></polyline>
-                    <polyline id="Rectangle-Copy" stroke-linejoin="round" transform="translate(29.375000, 19.200000) rotate(-405.000000) translate(-29.375000, -19.200000) " points="34.2363591 14.2219683 34.2363591 24.1780317 24.5136409 24.1780317"></polyline>
-                    <polyline id="Rectangle-Copy" stroke-linejoin="round" transform="translate(11.875000, 19.200000) rotate(-405.000000) translate(-11.875000, -19.200000) " points="16.7363591 14.2219683 16.7363591 24.1780317 7.01364088 24.1780317"></polyline>
-                    <path d="M18,0 C12.1869,0 7.5321,4.95500136 7.2846,11.1511772 C3.0744,12.3884731 0,16.48144 0,21.3336566 C0,27.1952971 4.4595,32 9.9,32 L36.9,32 C41.3505,32 45,28.0679979 45,23.2729917 C45,19.4912881 42.66,16.2836278 39.5154,15.151056 C39.3246,9.46589497 35.0208,4.84833793 29.7,4.84833793 C28.7649,4.84833793 27.8946,5.09657283 27.0279,5.36420108 C25.0938,2.19338808 21.7953,0 18,0 Z" id="Path-Copy" transform="translate(22.500000, 16.000000) scale(-1, 1) translate(-22.500000, -16.000000) "></path>
-                </g>
-            </g>
-        </g>
-    </g>
-</svg>

+ 0 - 6
src/components/smart/AssessmentDetailsPage/package.json

@@ -1,6 +0,0 @@
-{
-  "name": "AssessmentDetailsPage",
-  "version": "0.0.0",
-  "private": true,
-  "main": "./AssessmentDetailsPage.tsx"
-}

+ 0 - 383
src/components/smart/AssessmentsPage/AssessmentsPage.tsx

@@ -1,383 +0,0 @@
-/*
-Copyright (C) 2017  Cloudbase Solutions SRL
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU Affero General Public License as
-published by the Free Software Foundation, either version 3 of the
-License, or (at your option) any later version.
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-GNU Affero General Public License for more details.
-You should have received a copy of the GNU Affero General Public License
-along with this program.  If not, see <http://www.gnu.org/licenses/>.
-*/
-
-import React from "react";
-import styled from "styled-components";
-import { observer } from "mobx-react";
-
-import FilterList from "@src/components/ui/Lists/FilterList";
-import MainTemplate from "@src/components/modules/TemplateModule/MainTemplate";
-import PageHeader from "@src/components/smart/PageHeader";
-import Navigation from "@src/components/modules/NavigationModule/Navigation";
-import DropdownFilterGroup from "@src/components/ui/Dropdowns/DropdownFilterGroup";
-import AssessmentListItem from "@src/components/modules/AssessmentModule/AssessmentListItem";
-import type { Assessment } from "@src/@types/Assessment";
-import type { Endpoint } from "@src/@types/Endpoint";
-
-import azureStore from "@src/stores/AzureStore";
-import assessmentStore from "@src/stores/AssessmentStore";
-import endpointStore from "@src/stores/EndpointStore";
-import projectStore from "@src/stores/ProjectStore";
-import userStore from "@src/stores/UserStore";
-import configLoader from "@src/utils/Config";
-import DropdownLink from "@src/components/ui/Dropdowns/DropdownLink";
-import DomUtils from "@src/utils/DomUtils";
-
-const Wrapper = styled.div<any>``;
-
-type Props = { history: any };
-type State = { modalIsOpen: boolean };
-@observer
-class AssessmentsPage extends React.Component<Props, State> {
-  state = {
-    modalIsOpen: false,
-  };
-
-  disablePolling = false;
-
-  pollTimeout = 0;
-
-  UNSAFE_componentWillMount() {
-    document.title = "Coriolis Planning";
-
-    projectStore.getProjects();
-
-    if (!azureStore.isLoadedForCurrentProject()) {
-      assessmentStore.clearSelection();
-      azureStore.clearAssessments();
-    }
-
-    this.disablePolling = false;
-    this.pollData();
-
-    endpointStore.getEndpoints({ showLoading: true }).then(() => {
-      const endpoints = endpointStore.endpoints.filter(e => e.type === "azure");
-      if (endpoints.length > 0) {
-        this.chooseEndpoint(
-          assessmentStore.selectedEndpoint &&
-            assessmentStore.selectedEndpoint.id
-            ? assessmentStore.selectedEndpoint
-            : endpoints[0]
-        );
-      }
-    });
-  }
-
-  componentWillUnmount() {
-    this.disablePolling = true;
-    clearTimeout(this.pollTimeout);
-  }
-
-  getEndpointsDropdownConfig(): DropdownLink["props"] & { key: string } {
-    const endpoints = endpointStore.endpoints.filter(e => e.type === "azure");
-    return {
-      key: "endpoint",
-      selectedItem: assessmentStore.selectedEndpoint
-        ? assessmentStore.selectedEndpoint.id
-        : "",
-      items: endpoints.map(endpoint => ({
-        label: endpoint.name,
-        value: endpoint.id,
-        endpoint,
-      })),
-      onChange: (item: any) => {
-        this.chooseEndpoint(item.endpoint, true);
-      },
-      selectItemLabel: "Select Endpoint",
-      noItemsLabel: endpointStore.loading ? "Loading ..." : "No Endpoints",
-    };
-  }
-
-  getResourceGroupsDropdownConfig(): DropdownLink["props"] & { key: string } {
-    const groups = azureStore.assessmentResourceGroups;
-    return {
-      key: "resource-group",
-      selectedItem: assessmentStore.selectedResourceGroup
-        ? assessmentStore.selectedResourceGroup.id
-        : "",
-      items: groups.map(group => ({
-        label: group.name,
-        value: group.id,
-        group,
-      })),
-      onChange: (item: any) => {
-        this.chooseResourceGroup(item.group);
-      },
-      selectItemLabel: "Loading ...",
-      noItemsLabel: this.areResourceGroupsLoading()
-        ? "Loading ..."
-        : "No Resource Groups",
-    };
-  }
-
-  getFilterItems(): { label: string; value: string }[] {
-    const types = [{ label: "All projects", value: "all" }];
-    const assessments = azureStore.assessments;
-    const uniqueProjects: { name: string }[] = [];
-
-    assessments.forEach(a => {
-      if (uniqueProjects.findIndex(p => p.name === a.project.name) === -1) {
-        uniqueProjects.push(a.project);
-      }
-    });
-
-    const projects = uniqueProjects.map(p => ({
-      label: p.name,
-      value: p.name,
-    }));
-    return types.concat(projects);
-  }
-
-  handleReloadButtonClick() {
-    if (!endpointStore.connectionInfo) {
-      return;
-    }
-
-    azureStore.getAssessments({
-      subscriptionId: endpointStore.connectionInfo.subscription_id,
-      resourceGroupName: assessmentStore.selectedResourceGroup?.name || "",
-      projectId: userStore.loggedUser?.project.id || "",
-    });
-  }
-
-  handleItemClick(assessment: Assessment) {
-    if (assessment.properties.status.toUpperCase() !== "COMPLETED") {
-      return;
-    }
-
-    const connectionInfo = endpointStore.connectionInfo;
-    const endpoint = assessmentStore.selectedEndpoint;
-    const resourceGroupName = assessmentStore.selectedResourceGroup
-      ? assessmentStore.selectedResourceGroup.name
-      : "";
-    const projectName = assessment.project.name;
-    const groupName = assessment.group.name;
-    const assessmentName = assessment.name;
-
-    const info = {
-      endpoint,
-      connectionInfo,
-      resourceGroupName,
-      projectName,
-      groupName,
-      assessmentName,
-    };
-
-    this.props.history.push(
-      `/assessment/${DomUtils.encodeToBase64Url({ ...info })}`
-    );
-  }
-
-  handleProjectChange() {
-    assessmentStore.clearSelection();
-    azureStore.clearAssessments();
-    endpointStore.getEndpoints({ showLoading: true }).then(() => {
-      const endpoints = endpointStore.endpoints.filter(e => e.type === "azure");
-      if (endpoints.length > 0) {
-        this.chooseEndpoint(
-          assessmentStore.selectedEndpoint &&
-            assessmentStore.selectedEndpoint.id
-            ? assessmentStore.selectedEndpoint
-            : endpoints[0]
-        );
-      }
-    });
-  }
-
-  handleModalOpen() {
-    this.setState({ modalIsOpen: true });
-  }
-
-  handleModalClose() {
-    this.setState({ modalIsOpen: false }, () => {
-      this.pollData();
-    });
-  }
-
-  areResourceGroupsLoading() {
-    return azureStore.authenticating || azureStore.loadingResourceGroups;
-  }
-
-  pollData() {
-    if (this.disablePolling || this.state.modalIsOpen) {
-      return;
-    }
-
-    const connectionInfo = endpointStore.connectionInfo;
-    const selectedResourceGroup = assessmentStore.selectedResourceGroup;
-
-    if (
-      !connectionInfo ||
-      !connectionInfo.subscription_id ||
-      !selectedResourceGroup ||
-      !selectedResourceGroup.name
-    ) {
-      this.pollTimeout = window.setTimeout(() => {
-        this.pollData();
-      }, configLoader.config.requestPollTimeout);
-      return;
-    }
-
-    azureStore
-      .getAssessments({
-        subscriptionId: connectionInfo.subscription_id,
-        resourceGroupName: selectedResourceGroup.name,
-        projectId: userStore.loggedUser?.project.id || "",
-        backgroundLoading: true,
-        skipLog: true,
-      })
-      .then(() => {
-        this.pollTimeout = window.setTimeout(() => {
-          this.pollData();
-        }, configLoader.config.requestPollTimeout);
-      });
-  }
-
-  chooseResourceGroup(selectedResourceGroup: Assessment["group"]) {
-    if (!endpointStore.connectionInfo) {
-      return;
-    }
-
-    assessmentStore.updateSelectedResourceGroup(selectedResourceGroup);
-    azureStore.getAssessments({
-      subscriptionId: endpointStore.connectionInfo.subscription_id,
-      resourceGroupName: selectedResourceGroup.name,
-      projectId: userStore.loggedUser?.project.id || "",
-    });
-  }
-
-  chooseEndpoint(selectedEndpoint: Endpoint, clearResourceGroup?: boolean) {
-    if (
-      assessmentStore.selectedEndpoint &&
-      assessmentStore.selectedEndpoint.id === selectedEndpoint.id
-    ) {
-      return;
-    }
-
-    assessmentStore.updateSelectedEndpoint(selectedEndpoint);
-
-    if (clearResourceGroup) {
-      assessmentStore.updateSelectedResourceGroup(null);
-    }
-
-    endpointStore.getConnectionInfo(selectedEndpoint).then(() => {
-      const connectionInfo = endpointStore.connectionInfo;
-      if (!connectionInfo) {
-        return;
-      }
-      azureStore.authenticate(connectionInfo).then(() => {
-        azureStore
-          .getResourceGroups(connectionInfo.subscription_id)
-          .then(() => {
-            const groups = azureStore.assessmentResourceGroups;
-            const selectedGroup = assessmentStore.selectedResourceGroup;
-
-            if (
-              groups.filter((rg: any) =>
-                rg.id === selectedGroup ? selectedGroup?.id : ""
-              ).length > 0
-            ) {
-              return;
-            }
-            if (groups.length > 0) {
-              const defaultResourceGroup =
-                groups.find(
-                  g => g.name === connectionInfo.default_resource_group
-                ) || groups[0];
-              this.chooseResourceGroup(defaultResourceGroup);
-            }
-          });
-      });
-    });
-  }
-
-  itemFilterFunction(
-    item: any,
-    filterItem?: string | null,
-    filterText?: string
-  ) {
-    const assessment: Assessment = item;
-    if (
-      (filterItem !== "all" && assessment.project.name !== filterItem) ||
-      (item.name.toLowerCase().indexOf(filterText) === -1 &&
-        assessment.id.toLowerCase().indexOf(filterText || "") === -1)
-    ) {
-      return false;
-    }
-
-    return true;
-  }
-
-  render() {
-    return (
-      <Wrapper>
-        <MainTemplate
-          listNoMargin
-          navigationComponent={<Navigation currentPage="planning" />}
-          listComponent={
-            <FilterList
-              filterItems={this.getFilterItems()}
-              selectionLabel="assessments"
-              loading={
-                this.areResourceGroupsLoading() || azureStore.loadingAssessments
-              }
-              items={azureStore.assessments}
-              onItemClick={item => {
-                const itemAny: any = item;
-                const assessment: Assessment = itemAny;
-                this.handleItemClick(assessment);
-              }}
-              onReloadButtonClick={() => {
-                this.handleReloadButtonClick();
-              }}
-              itemFilterFunction={(...args) => this.itemFilterFunction(...args)}
-              renderItemComponent={options => {
-                const optionsAny: any = options;
-                // eslint-disable-next-line react/jsx-props-no-spreading
-                return <AssessmentListItem {...optionsAny} />;
-              }}
-              customFilterComponent={
-                <DropdownFilterGroup
-                  items={[
-                    this.getEndpointsDropdownConfig(),
-                    this.getResourceGroupsDropdownConfig(),
-                  ]}
-                />
-              }
-              emptyListImage={null}
-              emptyListMessage="You don’t have any Assessments."
-              emptyListExtraMessage="Try selecting a new Endpoint or a new Resource Group."
-            />
-          }
-          headerComponent={
-            <PageHeader
-              title="Planning"
-              onProjectChange={() => {
-                this.handleProjectChange();
-              }}
-              onModalOpen={() => {
-                this.handleModalOpen();
-              }}
-              onModalClose={() => {
-                this.handleModalClose();
-              }}
-            />
-          }
-        />
-      </Wrapper>
-    );
-  }
-}
-
-export default AssessmentsPage;

+ 0 - 6
src/components/smart/AssessmentsPage/package.json

@@ -1,6 +0,0 @@
-{
-  "name": "AssessmentsPage",
-  "version": "0.0.0",
-  "private": true,
-  "main": "./AssessmentsPage.tsx"
-}

+ 0 - 106
src/sources/AssessmentSource.ts

@@ -1,106 +0,0 @@
-/*
-Copyright (C) 2017  Cloudbase Solutions SRL
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU Affero General Public License as
-published by the Free Software Foundation, either version 3 of the
-License, or (at your option) any later version.
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-GNU Affero General Public License for more details.
-You should have received a copy of the GNU Affero General Public License
-along with this program.  If not, see <http://www.gnu.org/licenses/>.
-*/
-
-import type { MigrationInfo } from "@src/@types/Assessment";
-import Api from "@src/utils/ApiCaller";
-import configLoader from "@src/utils/Config";
-import notificationStore from "@src/stores/NotificationStore";
-import ObjectUtils from "@src/utils/ObjectUtils";
-import { MigrationItem } from "@src/@types/MainItem";
-
-class AssessmentSourceUtils {
-  static getNetworkMap(data: MigrationInfo) {
-    const networkMap: any = {};
-    if (data.networks && data.networks.length) {
-      data.networks.forEach(mapping => {
-        networkMap[mapping.sourceNic.network_name] =
-          mapping.targetNetwork!.name;
-      });
-    }
-    return networkMap;
-  }
-
-  static getDestinationEnv(data: MigrationInfo) {
-    const env: any = {};
-    const vmSize =
-      data.vmSizes[
-        Object.keys(data.vmSizes).filter(
-          k => k === data.selectedInstances[0].instance_name
-        )[0]
-      ];
-    if (vmSize) {
-      env.vm_size = vmSize;
-    }
-    const skipFields = [
-      "use_replica",
-      "separate_vm",
-      "shutdown_instances",
-      "skip_os_morphing",
-    ];
-    Object.keys(data.fieldValues)
-      .filter(f => !skipFields.find(sf => sf === f))
-      .forEach(fieldName => {
-        if (data.fieldValues[fieldName] != null) {
-          env[fieldName] = data.fieldValues[fieldName];
-        }
-      });
-
-    return env;
-  }
-}
-
-class AssessmentSource {
-  static migrate(data: MigrationInfo): Promise<MigrationItem> {
-    const type = data.fieldValues.use_replica ? "replica" : "migration";
-    const payload: any = {};
-    payload[type] = {
-      origin_endpoint_id: data.source ? data.source.id : "null",
-      destination_endpoint_id: data.target.id,
-      destination_environment: AssessmentSourceUtils.getDestinationEnv(data),
-      instances: data.selectedInstances.map(i => i.instance_name),
-      network_map: AssessmentSourceUtils.getNetworkMap(data),
-      notes: "",
-      replication_count: 2,
-    };
-
-    if (type === "migration") {
-      payload[type].skip_os_morphing = data.fieldValues.skip_os_morphing;
-    }
-    return Api.send({
-      url: `${configLoader.config.servicesUrls.coriolis}/${Api.projectId}/${type}s`,
-      method: "POST",
-      data: payload,
-    }).then(response => response.data[type]);
-  }
-
-  static migrateMultiple(data: MigrationInfo): Promise<MigrationItem[]> {
-    return Promise.all(
-      data.selectedInstances.map(async instance => {
-        const newData = { ...data };
-        newData.selectedInstances = [instance];
-        try {
-          return await this.migrate(newData);
-        } catch (e) {
-          notificationStore.alert(
-            `Error while migrating instance ${instance.name}`,
-            "error"
-          );
-          return null;
-        }
-      })
-    ).then(items => items.filter(ObjectUtils.notEmpty).map(i => i));
-  }
-}
-
-export default AssessmentSource;

+ 0 - 253
src/sources/AzureSource.ts

@@ -1,253 +0,0 @@
-/*
-Copyright (C) 2017  Cloudbase Solutions SRL
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU Affero General Public License as
-published by the Free Software Foundation, either version 3 of the
-License, or (at your option) any later version.
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-GNU Affero General Public License for more details.
-You should have received a copy of the GNU Affero General Public License
-along with this program.  If not, see <http://www.gnu.org/licenses/>.
-*/
-
-import Api from "@src/utils/ApiCaller";
-import DomUtils from "@src/utils/DomUtils";
-
-import type { Assessment, VmItem, VmSize } from "@src/@types/Assessment";
-
-const azureUrl = "https://management.azure.com/";
-const defaultApiVersion = "2019-10-01";
-
-const resourceGroupsUrl = (opts: { subscriptionId: string }) =>
-  `/subscriptions/${opts.subscriptionId}/resourceGroups`;
-const projectsUrl = ({ resourceGroupName, ...other }: any) =>
-  `${resourceGroupsUrl({
-    ...other,
-  })}/${resourceGroupName}/providers/Microsoft.Migrate/assessmentprojects`;
-const groupsUrl = ({ projectName, ...other }: any) =>
-  `${projectsUrl({ ...other })}/${projectName}/groups`;
-const assessmentsUrl = ({ groupName, ...other }: any) =>
-  `${groupsUrl({ ...other })}/${groupName}/assessments`;
-const assessmentDetailsUrl = ({ assessmentName, ...other }: any) =>
-  `${assessmentsUrl({ ...other })}/${assessmentName}`;
-const assessedVmsUrl = ({ ...other }) =>
-  `${assessmentDetailsUrl({ ...other })}/assessedMachines`;
-
-class Util {
-  static buildUrl(baseUrl: string, apiVersion?: string): string {
-    const url = `/proxy/azure/${DomUtils.encodeToBase64Url(
-      `${azureUrl + baseUrl}?api-version=${apiVersion || defaultApiVersion}`
-    )}`;
-    return url;
-  }
-
-  static sortAssessments(assessments: any[]) {
-    assessments.sort(
-      (a: any, b: any) =>
-        new Date(b.properties.updatedTimestamp).getTime() -
-        new Date(a.properties.updatedTimestamp).getTime()
-    );
-    return assessments;
-  }
-
-  static checkQueues(queues: any[], requestIds: any, callback: any) {
-    if (requestIds[0] !== requestIds[1]) {
-      return;
-    }
-
-    const doneQeues = queues.filter(q => q === 0).length;
-    if (doneQeues === queues.length) {
-      callback();
-    }
-  }
-
-  static isResponseValid(response: any): boolean {
-    if (response && response.data && response.data.error) {
-      const error = response.data.error;
-      console.error("%c", "color: #D0021B", `${error.code}: ${error.message}`);
-      return false;
-    }
-    return true;
-  }
-
-  static validateResponse(response: any, resolveData: any): Promise<any> {
-    if (!this.isResponseValid(response)) {
-      return Promise.reject();
-    }
-
-    if (resolveData) {
-      return Promise.resolve(resolveData);
-    }
-    return Promise.resolve(response);
-  }
-}
-
-class AzureSource {
-  static authenticate(connectionInfo: any): Promise<any> {
-    return Api.send({
-      url: "/proxy/azure/login",
-      method: "POST",
-      data: connectionInfo,
-    }).then(response => {
-      const entries = Object.keys(response.data.tokenCache)[0];
-      const accessToken = response.data.tokenCache[entries][0].accessToken;
-      Api.setDefaultHeader("Authorization", `Bearer ${accessToken}`);
-      return response.data;
-    });
-  }
-
-  static getResourceGroups(
-    subscriptionId: string
-  ): Promise<Assessment["group"][]> {
-    return Api.get(
-      Util.buildUrl(resourceGroupsUrl({ subscriptionId }), "2017-08-01")
-    ).then(response => Util.validateResponse(response, response.data.value));
-  }
-
-  static previousReqId: string;
-
-  static async getAssessments(
-    subscriptionId: string,
-    resourceGroupName: string,
-    skipLog?: boolean | null
-  ): Promise<Assessment[]> {
-    const cancelId = subscriptionId + resourceGroupName;
-    if (this.previousReqId) {
-      Api.cancelRequests(this.previousReqId);
-    }
-    this.previousReqId = cancelId;
-
-    // Load Projects
-    let projects: any[] = [];
-    const projectsResponse = await Api.send({
-      url: Util.buildUrl(projectsUrl({ resourceGroupName, subscriptionId })),
-      cancelId,
-      skipLog,
-    });
-    if (!Util.isResponseValid(projectsResponse)) {
-      projects = [];
-    }
-    projects = projectsResponse.data.value.filter(
-      (p: any) => p.type === "Microsoft.Migrate/assessmentprojects"
-    );
-
-    // Load groups for each project
-    const groupsResponses = await Promise.all(
-      projects.map(async (project: any) => {
-        let groups: any[] | null = null;
-
-        const groupsResponse = await Api.send({
-          url: Util.buildUrl(
-            groupsUrl({
-              projectName: project.name,
-              subscriptionId,
-              resourceGroupName,
-            })
-          ),
-          cancelId,
-        });
-        if (!Util.isResponseValid(groupsResponse)) {
-          groups = null;
-        }
-        groups = groupsResponse.data.value.map((group: any) => ({
-          ...group,
-          project,
-        }));
-        return groups;
-      })
-    );
-
-    let groups: any[] = [];
-    groupsResponses
-      .filter(r => r !== null)
-      .forEach(validGroupsReponse => {
-        groups = groups.concat(validGroupsReponse);
-      });
-
-    // Load assessments for each group
-    return Promise.all(
-      groups.map(group =>
-        Api.send({
-          url: Util.buildUrl(
-            assessmentsUrl({
-              subscriptionId,
-              resourceGroupName,
-              projectName: group.project.name,
-              groupName: group.name,
-            })
-          ),
-          cancelId,
-        }).then(assessmentResponse => {
-          if (!Util.isResponseValid(assessmentResponse)) {
-            return null;
-          }
-          return assessmentResponse.data.value.map(
-            (assessment: Assessment) => ({
-              ...assessment,
-              group,
-              project: group.project,
-              properies: {
-                ...assessment.properties,
-                azureLocation:
-                  assessment.properties.azureLocation.toLowerCase(),
-              },
-            })
-          );
-        })
-      )
-    );
-  }
-
-  static async getAssessmentDetails(info: Assessment): Promise<Assessment> {
-    const response = await Api.get(
-      Util.buildUrl(
-        assessmentDetailsUrl({
-          ...info,
-          subscriptionId: info.connectionInfo.subscription_id,
-        })
-      )
-    );
-    const assessment: Assessment = await Util.validateResponse(response, {
-      ...response.data,
-      ...info,
-    });
-    assessment.properties.azureLocation =
-      assessment.properties.azureLocation.toLowerCase();
-    return assessment;
-  }
-
-  static getAssessedVms(info: Assessment): Promise<VmItem[]> {
-    return Api.get(
-      Util.buildUrl(
-        assessedVmsUrl({
-          ...info,
-          subscriptionId: info.connectionInfo.subscription_id,
-        })
-      )
-    ).then(response => {
-      if (!Util.isResponseValid(response)) {
-        return [];
-      }
-
-      const vms = response.data.value;
-      vms.sort((a: any, b: any) => {
-        const getLabel = (item: any) => item.properties.displayName;
-        return getLabel(a).localeCompare(getLabel(b));
-      });
-      return vms;
-    });
-  }
-
-  static getVmSizes(info: Assessment): Promise<VmSize[]> {
-    return Api.get(
-      Util.buildUrl(
-        `/subscriptions/${info.connectionInfo.subscription_id}/providers/Microsoft.Compute/locations/${info.location}/vmSizes`,
-        "2017-12-01"
-      )
-    ).then(response => Util.validateResponse(response, response.data.value));
-  }
-}
-
-export default AzureSource;

+ 0 - 369
src/sources/MigrationSource.ts

@@ -1,369 +0,0 @@
-/*
-Copyright (C) 2017  Cloudbase Solutions SRL
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU Affero General Public License as
-published by the Free Software Foundation, either version 3 of the
-License, or (at your option) any later version.
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-GNU Affero General Public License for more details.
-You should have received a copy of the GNU Affero General Public License
-along with this program.  If not, see <http://www.gnu.org/licenses/>.
-*/
-
-import {
-  MigrationItem,
-  MigrationItemDetails,
-  MigrationItemOptions,
-  UserScriptData,
-} from "@src/@types/MainItem";
-import { ProgressUpdate, Task } from "@src/@types/Task";
-import { INSTANCE_OSMORPHING_MINION_POOL_MAPPINGS } from "@src/components/modules/WizardModule/WizardOptions";
-import { OptionsSchemaPlugin } from "@src/plugins";
-import DefaultOptionsSchemaPlugin from "@src/plugins/default/OptionsSchemaPlugin";
-import Api from "@src/utils/ApiCaller";
-import configLoader from "@src/utils/Config";
-
-import { sortTasks } from "./TransferSource";
-
-import type { InstanceScript } from "@src/@types/Instance";
-import type { Field } from "@src/@types/Field";
-import type { NetworkMap } from "@src/@types/Network";
-import type { Endpoint, StorageMap } from "@src/@types/Endpoint";
-
-class MigrationSourceUtils {
-  static sortTaskUpdates(updates: ProgressUpdate[]) {
-    if (!updates) {
-      return;
-    }
-    updates.sort((a, b) => {
-      const sortNull = !a && b ? 1 : a && !b ? -1 : !a && !b ? 0 : false;
-      if (sortNull !== false) {
-        return sortNull;
-      }
-      return a.index - b.index;
-    });
-  }
-
-  static sortMigrations(migrations: any[]) {
-    migrations.sort(
-      (a: any, b: any) =>
-        new Date(b.created_at).getTime() - new Date(a.created_at).getTime()
-    );
-
-    migrations.forEach((migration: { tasks: Task[] }) => {
-      sortTasks(migration.tasks, MigrationSourceUtils.sortTaskUpdates);
-    });
-  }
-}
-
-class MigrationSource {
-  async getMigrations(skipLog?: boolean): Promise<MigrationItem[]> {
-    const response = await Api.send({
-      url: `${configLoader.config.servicesUrls.coriolis}/${Api.projectId}/migrations`,
-      skipLog,
-    });
-    const migrations = response.data.migrations;
-    MigrationSourceUtils.sortMigrations(migrations);
-    return migrations;
-  }
-
-  async getMigration(
-    migrationId: string,
-    skipLog?: boolean
-  ): Promise<MigrationItemDetails> {
-    const response = await Api.send({
-      url: `${configLoader.config.servicesUrls.coriolis}/${Api.projectId}/migrations/${migrationId}`,
-      skipLog,
-      cancelId: migrationId,
-    });
-    const migration = response.data.migration;
-    sortTasks(migration.tasks, MigrationSourceUtils.sortTaskUpdates);
-    return migration;
-  }
-
-  async recreateFullCopy(
-    migration: MigrationItemOptions
-  ): Promise<MigrationItem> {
-    const {
-      // eslint-disable-next-line @typescript-eslint/naming-convention
-      origin_endpoint_id,
-      destination_endpoint_id,
-      destination_environment,
-      // eslint-disable-next-line @typescript-eslint/naming-convention
-      network_map,
-      instances,
-      storage_mappings,
-      notes,
-      destination_minion_pool_id,
-      // eslint-disable-next-line @typescript-eslint/naming-convention
-      origin_minion_pool_id,
-      instance_osmorphing_minion_pool_mappings,
-    } = migration;
-
-    const payload: any = {
-      migration: {
-        origin_endpoint_id,
-        destination_endpoint_id,
-        destination_environment,
-        network_map,
-        instances,
-        storage_mappings,
-        notes,
-        destination_minion_pool_id,
-        origin_minion_pool_id,
-        instance_osmorphing_minion_pool_mappings,
-      },
-    };
-
-    if (migration.skip_os_morphing != null) {
-      payload.migration.skip_os_morphing = migration.skip_os_morphing;
-    }
-
-    if (migration.source_environment) {
-      payload.migration.source_environment = migration.source_environment;
-    }
-
-    payload.migration.shutdown_instances = Boolean(
-      migration.shutdown_instances
-    );
-    payload.migration.replication_count = migration.replication_count || 2;
-
-    const response = await Api.send({
-      url: `${configLoader.config.servicesUrls.coriolis}/${Api.projectId}/migrations`,
-      method: "POST",
-      data: payload,
-    });
-    return response.data.migration;
-  }
-
-  async recreate(opts: {
-    sourceEndpoint: Endpoint;
-    destEndpoint: Endpoint;
-    instanceNames: string[];
-    destEnv: { [prop: string]: any } | null;
-    updatedDestEnv: { [prop: string]: any } | null;
-    sourceEnv?: { [prop: string]: any } | null;
-    updatedSourceEnv?: { [prop: string]: any } | null;
-    storageMappings?: { [prop: string]: any } | null;
-    updatedStorageMappings: StorageMap[] | null;
-    defaultStorage?: { value: string | null; busType?: string | null };
-    updatedDefaultStorage?: { value: string | null; busType?: string | null };
-    networkMappings?: any;
-    updatedNetworkMappings: NetworkMap[] | null;
-    defaultSkipOsMorphing: boolean | null;
-    replicationCount?: number | null;
-    migration: MigrationItemDetails;
-    uploadedScripts: InstanceScript[];
-    removedScripts: InstanceScript[];
-  }): Promise<MigrationItemDetails> {
-    const getValue = (fieldName: string): string | null => {
-      const updatedDestEnv =
-        opts.updatedDestEnv && opts.updatedDestEnv[fieldName];
-      return updatedDestEnv != null
-        ? updatedDestEnv
-        : opts.destEnv && opts.destEnv[fieldName];
-    };
-
-    const sourceParser = OptionsSchemaPlugin.for(opts.sourceEndpoint.type);
-    const destParser = OptionsSchemaPlugin.for(opts.destEndpoint.type);
-    const payload: any = {};
-
-    payload.migration = {
-      origin_endpoint_id: opts.sourceEndpoint.id,
-      destination_endpoint_id: opts.destEndpoint.id,
-      shutdown_instances: Boolean(
-        opts.updatedDestEnv && opts.updatedDestEnv.shutdown_instances
-      ),
-      replication_count:
-        (opts.updatedDestEnv && opts.updatedDestEnv.replication_count) ||
-        opts.replicationCount ||
-        2,
-      instances: opts.instanceNames,
-      notes: opts.updatedDestEnv?.title || opts.migration.notes || "",
-    };
-
-    const skipOsMorphingValue = getValue("skip_os_morphing");
-    if (skipOsMorphingValue != null) {
-      payload.migration.skip_os_morphing = skipOsMorphingValue;
-    } else if (opts.defaultSkipOsMorphing != null) {
-      payload.migration.skip_os_morphing = opts.defaultSkipOsMorphing;
-    }
-
-    if (
-      opts.networkMappings ||
-      (opts.updatedNetworkMappings && opts.updatedNetworkMappings.length)
-    ) {
-      payload.migration.network_map = {
-        ...opts.networkMappings,
-        ...destParser.getNetworkMap(opts.updatedNetworkMappings),
-      };
-    }
-
-    if (
-      (opts.storageMappings && Object.keys(opts.storageMappings).length) ||
-      (opts.updatedStorageMappings && opts.updatedStorageMappings.length)
-    ) {
-      payload.migration.storage_mappings = {
-        ...opts.storageMappings,
-        ...destParser.getStorageMap(
-          opts.updatedDefaultStorage || opts.defaultStorage,
-          opts.updatedStorageMappings
-        ),
-      };
-    }
-    const { migration } = opts;
-    const sourceEnv: any = {
-      ...opts.sourceEnv,
-    };
-    const updatedSourceEnv = opts.updatedSourceEnv
-      ? sourceParser.getDestinationEnv(opts.updatedSourceEnv)
-      : {};
-    const sourceMinionPoolId =
-      opts?.updatedSourceEnv?.minion_pool_id || migration.origin_minion_pool_id;
-    if (sourceMinionPoolId) {
-      payload.migration.origin_minion_pool_id = sourceMinionPoolId;
-    }
-    payload.migration.source_environment = {
-      ...sourceEnv,
-      ...updatedSourceEnv,
-    };
-
-    const destEnv: any = {
-      ...opts.destEnv,
-    };
-    const updatedDestEnv = opts.updatedDestEnv
-      ? sourceParser.getDestinationEnv(opts.updatedDestEnv)
-      : {};
-    const destMinionPoolId =
-      opts?.updatedDestEnv?.minion_pool_id ||
-      migration.destination_minion_pool_id;
-    if (destMinionPoolId) {
-      payload.migration.destination_minion_pool_id = destMinionPoolId;
-    }
-
-    const updatedDestEnvMappings =
-      updatedDestEnv[INSTANCE_OSMORPHING_MINION_POOL_MAPPINGS] || {};
-    const oldMappings =
-      migration[INSTANCE_OSMORPHING_MINION_POOL_MAPPINGS] || {};
-    const mergedMappings = { ...oldMappings, ...updatedDestEnvMappings };
-    if (Object.keys(mergedMappings).length) {
-      const newMappings: any = {};
-      Object.keys(mergedMappings).forEach(k => {
-        if (mergedMappings[k] !== null) {
-          newMappings[k] = mergedMappings[k];
-        }
-      });
-      payload.migration[INSTANCE_OSMORPHING_MINION_POOL_MAPPINGS] = newMappings;
-    }
-
-    delete updatedDestEnv[INSTANCE_OSMORPHING_MINION_POOL_MAPPINGS];
-
-    payload.migration.destination_environment = {
-      ...destEnv,
-      ...updatedDestEnv,
-    };
-
-    if (
-      opts.uploadedScripts?.length ||
-      opts.removedScripts?.length ||
-      migration.user_scripts
-    ) {
-      payload.migration.user_scripts =
-        new DefaultOptionsSchemaPlugin().getUserScripts(
-          opts.uploadedScripts || [],
-          opts.removedScripts || [],
-          migration.user_scripts
-        );
-    }
-
-    const response = await Api.send({
-      url: `${configLoader.config.servicesUrls.coriolis}/${Api.projectId}/migrations`,
-      method: "POST",
-      data: payload,
-    });
-    return response.data.migration;
-  }
-
-  async cancel(migrationId: string, force?: boolean | null): Promise<string> {
-    const data: any = { cancel: null };
-    if (force) {
-      data.cancel = { force: true };
-    }
-    await Api.send({
-      url: `${configLoader.config.servicesUrls.coriolis}/${Api.projectId}/migrations/${migrationId}/actions`,
-      method: "POST",
-      data,
-    });
-    return migrationId;
-  }
-
-  async delete(migrationId: string): Promise<string> {
-    await Api.send({
-      url: `${configLoader.config.servicesUrls.coriolis}/${Api.projectId}/migrations/${migrationId}`,
-      method: "DELETE",
-    });
-    return migrationId;
-  }
-
-  async migrateReplica(opts: {
-    replicaId: string;
-    options: Field[];
-    uploadedUserScripts: InstanceScript[];
-    removedUserScripts: InstanceScript[];
-    userScriptData: UserScriptData | null | undefined;
-    minionPoolMappings: { [instance: string]: string };
-  }): Promise<MigrationItem> {
-    const {
-      replicaId,
-      options,
-      uploadedUserScripts,
-      removedUserScripts,
-      userScriptData,
-      minionPoolMappings,
-    } = opts;
-    const payload: any = {
-      migration: {
-        replica_id: replicaId,
-      },
-    };
-    options.forEach(o => {
-      payload.migration[o.name] = o.value || o.default || false;
-    });
-
-    if (
-      uploadedUserScripts.length ||
-      removedUserScripts.length ||
-      userScriptData
-    ) {
-      payload.migration.user_scripts =
-        new DefaultOptionsSchemaPlugin().getUserScripts(
-          uploadedUserScripts,
-          removedUserScripts,
-          userScriptData
-        );
-    }
-
-    if (Object.keys(minionPoolMappings).length) {
-      const newMappings: any = {};
-      Object.keys(minionPoolMappings).forEach(k => {
-        if (minionPoolMappings[k] !== null) {
-          newMappings[k] = minionPoolMappings[k];
-        }
-      });
-      payload.migration[INSTANCE_OSMORPHING_MINION_POOL_MAPPINGS] = newMappings;
-    } else {
-      payload.migration[INSTANCE_OSMORPHING_MINION_POOL_MAPPINGS] = null;
-    }
-
-    const response = await Api.send({
-      url: `${configLoader.config.servicesUrls.coriolis}/${Api.projectId}/migrations`,
-      method: "POST",
-      data: payload,
-    });
-    return response.data.migration;
-  }
-}
-
-export default new MigrationSource();

+ 0 - 71
src/stores/AssessmentStore.ts

@@ -1,71 +0,0 @@
-/*
-Copyright (C) 2017  Cloudbase Solutions SRL
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU Affero General Public License as
-published by the Free Software Foundation, either version 3 of the
-License, or (at your option) any later version.
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-GNU Affero General Public License for more details.
-You should have received a copy of the GNU Affero General Public License
-along with this program.  If not, see <http://www.gnu.org/licenses/>.
-*/
-
-import { observable, action } from "mobx";
-
-import AssessmentSource from "@src/sources/AssessmentSource";
-import type { Endpoint } from "@src/@types/Endpoint";
-import type { Assessment, MigrationInfo } from "@src/@types/Assessment";
-import { MigrationItem } from "@src/@types/MainItem";
-
-class AssessmentStore {
-  @observable selectedEndpoint: Endpoint | null = null;
-
-  @observable selectedResourceGroup: Assessment["group"] | null = null;
-
-  @observable migrating = false;
-
-  @observable migrations: MigrationItem[] = [];
-
-  @action updateSelectedEndpoint(endpoint: Endpoint) {
-    this.selectedEndpoint = endpoint;
-  }
-
-  @action updateSelectedResourceGroup(
-    resourceGroup: Assessment["group"] | null
-  ) {
-    this.selectedResourceGroup = resourceGroup;
-  }
-
-  @action async migrate(data: MigrationInfo): Promise<void> {
-    this.migrating = true;
-    this.migrations = [];
-    const separateVm = data.fieldValues.separate_vm;
-
-    if (separateVm) {
-      try {
-        const items = await AssessmentSource.migrateMultiple(data);
-        this.migrating = false;
-        this.migrations = items;
-      } catch (e) {
-        this.migrating = false;
-      }
-    }
-
-    try {
-      const item = await AssessmentSource.migrate(data);
-      this.migrating = false;
-      this.migrations = [item];
-    } catch (e) {
-      this.migrating = false;
-    }
-  }
-
-  @action clearSelection() {
-    this.selectedEndpoint = null;
-    this.selectedResourceGroup = null;
-  }
-}
-
-export default new AssessmentStore();

+ 0 - 314
src/stores/AzureStore.ts

@@ -1,314 +0,0 @@
-/*
-Copyright (C) 2017  Cloudbase Solutions SRL
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU Affero General Public License as
-published by the Free Software Foundation, either version 3 of the
-License, or (at your option) any later version.
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-GNU Affero General Public License for more details.
-You should have received a copy of the GNU Affero General Public License
-along with this program.  If not, see <http://www.gnu.org/licenses/>.
-*/
-
-import { observable, action } from "mobx";
-import cookie from "js-cookie";
-
-import AzureSource from "@src/sources/AzureSource";
-import type { Assessment, VmItem, AzureLocation } from "@src/@types/Assessment";
-import type { NetworkMap } from "@src/@types/Network";
-import type { Endpoint } from "@src/@types/Endpoint";
-
-export type LocalData = {
-  endpoint: Endpoint;
-  sourceEndpoint: Endpoint | null;
-  connectionInfo: any;
-  resourceGroupName: string;
-  locationName: string;
-  assessmentName: string;
-  groupName: string;
-  projectName: string;
-  selectedVmSizes: { [prop: string]: string };
-  selectedVms: string[];
-  selectedNetworks: NetworkMap[];
-  [prop: string]: any;
-};
-
-class AzureLocalStorage {
-  static loadLocalData(assessmentName: string): LocalData | undefined {
-    const localDataArray: LocalData[] = JSON.parse(
-      localStorage.getItem(`assessments-${cookie.get("projectId") || ""}`) ||
-        "[]"
-    );
-    return localDataArray.find(a => a.assessmentName === assessmentName);
-  }
-
-  static setLocalData(data: LocalData) {
-    const localDataArray: LocalData[] = JSON.parse(
-      localStorage.getItem(`assessments-${cookie.get("projectId") || ""}`) ||
-        "[]"
-    );
-    const assessmentIndex = localDataArray.findIndex(
-      a => a.assessmentName === data.assessmentName
-    );
-    if (assessmentIndex > -1) {
-      localDataArray.splice(assessmentIndex, 1);
-    }
-    localDataArray.push(data);
-    localStorage.setItem(
-      `assessments-${cookie.get("projectId") || ""}`,
-      JSON.stringify(localDataArray)
-    );
-  }
-}
-
-class AzureStore {
-  @observable authenticating = false;
-
-  @observable loadingResourceGroups = false;
-
-  @observable assessmentResourceGroups: Assessment["group"][] = [];
-
-  @observable coriolisResourceGroups: string[] = [];
-
-  @observable loadingAssessments = false;
-
-  @observable loadingAssessmentDetails = false;
-
-  @observable assessmentDetails: Assessment | null = null;
-
-  @observable assessments: Assessment[] = [];
-
-  @observable loadingAssessedVms = false;
-
-  @observable assessedVms: VmItem[] = [];
-
-  @observable loadingVmSizes = false;
-
-  // @observable vmSizes: VmSize[] = []
-  @observable assessmentsProjectId = "";
-
-  @observable locations: AzureLocation[] = [];
-
-  @observable localData: LocalData | null | undefined = null;
-
-  @observable vmSizes: string[] = [];
-
-  @action loadLocalData(assessmentName: string): boolean {
-    this.localData = AzureLocalStorage.loadLocalData(assessmentName);
-    return Boolean(this.localData);
-  }
-
-  @action setLocalData(data: LocalData) {
-    const newData = data;
-    newData.selectedVmSizes = data.selectedVmSizes || {};
-    newData.selectedVms = data.selectedVms || [];
-    newData.selectedNetworks = data.selectedNetworks || [];
-
-    this.localData = newData;
-    AzureLocalStorage.setLocalData(newData);
-  }
-
-  @action updateResourceGroup(resourceGroupName: string) {
-    if (!this.localData) {
-      return;
-    }
-    this.localData.resourceGroupName = resourceGroupName;
-    AzureLocalStorage.setLocalData(this.localData);
-  }
-
-  @action updateNetworkMap(selectedNetworks: NetworkMap[]) {
-    if (!this.localData) {
-      return;
-    }
-    this.localData.selectedNetworks = selectedNetworks;
-    AzureLocalStorage.setLocalData(this.localData);
-  }
-
-  @action updateSourceEndpoint(sourceEndpoint: Endpoint | null) {
-    if (!this.localData) {
-      return;
-    }
-    this.localData.sourceEndpoint = sourceEndpoint;
-    AzureLocalStorage.setLocalData(this.localData);
-  }
-
-  @action updateSelectedVms(selectedVms: string[]) {
-    if (!this.localData) {
-      return;
-    }
-    this.localData.selectedVms = selectedVms;
-    AzureLocalStorage.setLocalData(this.localData);
-  }
-
-  @action updateVmSize(vmId: string, vmSize: string) {
-    if (!this.localData) {
-      return;
-    }
-    this.localData.selectedVmSizes[vmId] = vmSize;
-    if (this.localData) {
-      AzureLocalStorage.setLocalData(this.localData);
-    }
-  }
-
-  @action updateVmSizes(vmSizes: { [prop: string]: string }) {
-    if (!this.localData) {
-      return;
-    }
-    this.localData.selectedVmSizes = vmSizes;
-    AzureLocalStorage.setLocalData(this.localData);
-  }
-
-  @action updateLocation(locationName: string) {
-    if (!this.localData) {
-      return;
-    }
-    this.localData.locationName = locationName;
-    AzureLocalStorage.setLocalData(this.localData);
-  }
-
-  @action updateTargetEndpoint(endpoint: Endpoint) {
-    if (!this.localData) {
-      return;
-    }
-    this.localData.endpoint = endpoint;
-    AzureLocalStorage.setLocalData(this.localData);
-  }
-
-  @action async authenticate(connectionInfo: any): Promise<void> {
-    this.authenticating = true;
-    try {
-      await AzureSource.authenticate(connectionInfo);
-      this.authenticating = false;
-      return await Promise.resolve();
-    } catch (e) {
-      this.authenticating = false;
-      return Promise.reject();
-    }
-  }
-
-  @action async getResourceGroups(subscriptionId: string): Promise<void> {
-    this.loadingResourceGroups = true;
-
-    try {
-      const groups = await AzureSource.getResourceGroups(subscriptionId);
-      this.loadingResourceGroups = false;
-      this.assessmentResourceGroups = groups;
-    } catch (e) {
-      this.loadingResourceGroups = false;
-    }
-  }
-
-  @action isLoadedForCurrentProject() {
-    return this.assessmentsProjectId === (cookie.get("projectId") || "null");
-  }
-
-  @action async getAssessments(opts: {
-    subscriptionId: string;
-    resourceGroupName: string;
-    projectId: string;
-    backgroundLoading?: boolean;
-    skipLog?: boolean;
-  }): Promise<void> {
-    const {
-      subscriptionId,
-      resourceGroupName,
-      projectId,
-      backgroundLoading,
-      skipLog,
-    } = opts;
-    let cookieProjectId = cookie.get("projectId") || "null";
-    if (projectId !== cookieProjectId) {
-      return Promise.resolve();
-    }
-
-    if (!backgroundLoading) {
-      this.loadingAssessments = true;
-    }
-    const assessments = await AzureSource.getAssessments(
-      subscriptionId,
-      resourceGroupName,
-      skipLog
-    );
-    this.loadingAssessments = false;
-    cookieProjectId = cookie.get("projectId") || "null";
-    if (projectId !== cookieProjectId) {
-      return Promise.resolve();
-    }
-    this.assessmentsProjectId = cookieProjectId;
-    this.assessments = assessments;
-    return Promise.resolve();
-  }
-
-  @action async getAssessmentDetails(info: Assessment): Promise<void> {
-    this.loadingAssessmentDetails = true;
-    try {
-      const assessment = await AzureSource.getAssessmentDetails(info);
-      this.loadingAssessmentDetails = false;
-      this.assessmentDetails = assessment;
-    } catch (e) {
-      this.loadingAssessmentDetails = false;
-    }
-  }
-
-  @action saveLocations(locations: AzureLocation[]) {
-    this.locations = locations;
-  }
-
-  @action saveResourceGroups(resourceGroups: string[]) {
-    this.coriolisResourceGroups = resourceGroups;
-  }
-
-  @action saveTargetVmSizes(targetVmSizes: string[]) {
-    this.vmSizes = targetVmSizes;
-  }
-
-  @action setLocation(location: string) {
-    if (!this.localData || this.localData.locationName) {
-      return;
-    }
-    this.localData.locationName = location;
-  }
-
-  @action clearAssessmentDetails() {
-    this.assessmentDetails = null;
-    this.assessedVms = [];
-  }
-
-  @action async getAssessedVms(info: Assessment): Promise<void> {
-    this.loadingAssessedVms = true;
-
-    try {
-      const vms = await AzureSource.getAssessedVms(info);
-      this.loadingAssessedVms = false;
-      this.assessedVms = vms;
-    } catch (e) {
-      this.loadingAssessedVms = false;
-    }
-  }
-
-  // @action getVmSizes(info: Assessment): Promise<void> {
-  //   this.loadingVmSizes = true
-
-  //   return AzureSource.getVmSizes(info).then((sizes: VmSize[]) => {
-  //     this.loadingVmSizes = false
-  //     this.vmSizes = sizes
-  //   }).catch(() => {
-  //     this.loadingVmSizes = false
-  //   })
-  // }
-
-  @action clearAssessedVms() {
-    this.assessedVms = [];
-  }
-
-  @action clearAssessments() {
-    this.assessmentResourceGroups = [];
-    this.assessments = [];
-    this.locations = [];
-    this.coriolisResourceGroups = [];
-  }
-}
-
-export default new AzureStore();

+ 0 - 198
src/stores/MigrationStore.ts

@@ -1,198 +0,0 @@
-/*
-Copyright (C) 2017  Cloudbase Solutions SRL
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU Affero General Public License as
-published by the Free Software Foundation, either version 3 of the
-License, or (at your option) any later version.
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-GNU Affero General Public License for more details.
-You should have received a copy of the GNU Affero General Public License
-along with this program.  If not, see <http://www.gnu.org/licenses/>.
-*/
-
-import { observable, action, runInAction } from "mobx";
-
-import type {
-  UpdateData,
-  MigrationItem,
-  MigrationItemDetails,
-  MigrationItemOptions,
-  UserScriptData,
-} from "@src/@types/MainItem";
-import type { Field } from "@src/@types/Field";
-import type { Endpoint } from "@src/@types/Endpoint";
-import type { InstanceScript } from "@src/@types/Instance";
-import MigrationSource from "@src/sources/MigrationSource";
-import apiCaller from "@src/utils/ApiCaller";
-
-class MigrationStore {
-  @observable migrations: MigrationItem[] = [];
-
-  @observable migrationDetails: MigrationItemDetails | null = null;
-
-  @observable loading = true;
-
-  @observable detailsLoading = true;
-
-  migrationsLoaded = false;
-
-  @action async getMigrations(options?: {
-    showLoading?: boolean;
-    skipLog?: boolean;
-  }) {
-    if ((options && options.showLoading) || !this.migrationsLoaded) {
-      this.loading = true;
-    }
-
-    try {
-      const migrations = await MigrationSource.getMigrations(
-        options && options.skipLog
-      );
-      runInAction(() => {
-        this.migrations = migrations;
-        this.loading = false;
-        this.migrationsLoaded = true;
-      });
-    } catch (ex) {
-      runInAction(() => {
-        this.loading = false;
-      });
-      throw ex;
-    }
-  }
-
-  getDefaultSkipOsMorphing(migration: MigrationItemDetails | null) {
-    const tasks = migration && migration.tasks;
-    if (tasks && !tasks.find(t => t.task_type === "OS_MORPHING")) {
-      return true;
-    }
-    return null;
-  }
-
-  @action async recreateFullCopy(migration: MigrationItemOptions) {
-    return MigrationSource.recreateFullCopy(migration);
-  }
-
-  @action async recreate(opts: {
-    migration: MigrationItemDetails;
-    sourceEndpoint: Endpoint;
-    destEndpoint: Endpoint;
-    updateData: UpdateData;
-    defaultStorage: { value: string | null; busType?: string | null };
-    updatedDefaultStorage:
-      | { value: string | null; busType?: string | null }
-      | undefined;
-    replicationCount: number | null | undefined;
-  }): Promise<MigrationItemDetails> {
-    const {
-      migration,
-      sourceEndpoint,
-      destEndpoint,
-      updateData,
-      defaultStorage,
-      updatedDefaultStorage,
-      replicationCount,
-    } = opts;
-    const migrationResult = await MigrationSource.recreate({
-      sourceEndpoint,
-      destEndpoint,
-      migration,
-      instanceNames: migration.instances,
-      sourceEnv: migration.source_environment,
-      updatedSourceEnv: updateData.source,
-      destEnv: migration.destination_environment,
-      updatedDestEnv: updateData.destination,
-      storageMappings: migration.storage_mappings,
-      updatedStorageMappings: updateData.storage,
-      defaultStorage,
-      updatedDefaultStorage,
-      networkMappings: migration.network_map,
-      updatedNetworkMappings: updateData.network,
-      defaultSkipOsMorphing: this.getDefaultSkipOsMorphing(migration),
-      replicationCount,
-      uploadedScripts: updateData.uploadedScripts,
-      removedScripts: updateData.removedScripts,
-    });
-    return migrationResult;
-  }
-
-  @action async getMigration(
-    migrationId: string,
-    options?: { showLoading?: boolean; skipLog?: boolean }
-  ) {
-    if (options && options.showLoading) {
-      this.detailsLoading = true;
-    }
-
-    try {
-      const migration = await MigrationSource.getMigration(
-        migrationId,
-        options && options.skipLog
-      );
-      runInAction(() => {
-        this.migrationDetails = migration;
-        this.migrations = this.migrations.map(m =>
-          m.id === migration.id ? migration : m
-        );
-      });
-    } finally {
-      runInAction(() => {
-        this.detailsLoading = false;
-      });
-    }
-  }
-
-  @action async cancel(migrationId: string, force?: boolean | null) {
-    await MigrationSource.cancel(migrationId, force);
-  }
-
-  @action async delete(migrationId: string) {
-    await MigrationSource.delete(migrationId);
-    runInAction(() => {
-      this.migrations = this.migrations.filter(r => r.id !== migrationId);
-    });
-  }
-
-  @action async migrateReplica(opts: {
-    replicaId: string;
-    fields: Field[];
-    uploadedUserScripts: InstanceScript[];
-    removedUserScripts: InstanceScript[];
-    userScriptData: UserScriptData | null | undefined;
-    minionPoolMappings: { [instance: string]: string };
-  }) {
-    const {
-      replicaId,
-      fields: options,
-      uploadedUserScripts,
-      removedUserScripts,
-      userScriptData,
-      minionPoolMappings,
-    } = opts;
-    const migration = await MigrationSource.migrateReplica({
-      replicaId,
-      options,
-      uploadedUserScripts,
-      removedUserScripts,
-      userScriptData,
-      minionPoolMappings,
-    });
-    return migration;
-  }
-
-  @action cancelMigrationDetails() {
-    if (this.migrationDetails) {
-      apiCaller.cancelRequests(this.migrationDetails.id);
-    }
-    this.detailsLoading = false;
-  }
-
-  @action clearDetails() {
-    this.detailsLoading = true;
-    this.migrationDetails = null;
-  }
-}
-
-export default new MigrationStore();

Kaikkia tiedostoja ei voida näyttää, sillä liian monta tiedostoa muuttui tässä diffissä