Skip to content

Commit

Permalink
Fully Refactor transfer/deployment nomenclature
Browse files Browse the repository at this point in the history
  • Loading branch information
Dany9966 committed Dec 4, 2024
1 parent f4415c0 commit 3d94d5c
Show file tree
Hide file tree
Showing 111 changed files with 1,082 additions and 3,158 deletions.
2 changes: 1 addition & 1 deletion config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ const conf: Config = {
],

// The number of items per page applicable to main lists:
// replicas, migrations, endpoints, users etc.
// transfers, deployments, endpoints, users etc.
mainListItemsPerPage: 20,

maxMinionPoolEventsPerPage: 50,
Expand Down
8 changes: 4 additions & 4 deletions src/@types/Execution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ export type Execution = {
updated_at: string;
deleted_at?: string;
type:
| "replica_execution"
| "replica_disks_delete"
| "replica_deploy"
| "replica_update";
| "transfer_execution"
| "transfer_disks_delete"
| "transfer_deploy"
| "transfer_update";
};

export type ExecutionTasks = Execution & {
Expand Down
34 changes: 10 additions & 24 deletions src/@types/MainItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ type BaseItem = {
destination_environment: { [prop: string]: any };
source_environment: { [prop: string]: any };
transfer_result: { [prop: string]: Instance } | null;
replication_count?: number;
// replication_count?: number;
storage_mappings?: StorageMapping | null;
network_map?: TransferNetworkMap;
last_execution_status: string;
Expand All @@ -92,9 +92,9 @@ type BaseItem = {
user_scripts?: UserScriptData;
};

export type ReplicaItem = BaseItem & {
type: "replica";
scenario?: string;
export type TransferItem = BaseItem & {
type: "transfer";
scenario: string;
};

export type UserScriptData = {
Expand All @@ -107,44 +107,30 @@ export type UserScriptData = {
};
};

export type MigrationItem = BaseItem & {
type: "migration";
replica_id?: string;
};

export type MigrationItemOptions = MigrationItem & {
skip_os_morphing: boolean;
shutdown_instances: boolean;
};

export type DeploymentItem = BaseItem & {
type: "deployment";
replica_id: string;
replica_scenario: string;
transfer_id: string;
transfer_scenario: string;
};

export type DeploymentItemOptions = DeploymentItem & {
skip_os_morphing: boolean;
shutdown_instances: boolean;
};

export type TransferItem = ReplicaItem | DeploymentItem;
export type ActionItem = TransferItem | DeploymentItem;

export type ReplicaItemDetails = ReplicaItem & {
export type TransferItemDetails = TransferItem & {
executions: Execution[];
};

export type MigrationItemDetails = MigrationItem & {
tasks: Task[];
};

export type DeploymentItemDetails = DeploymentItem & {
tasks: Task[];
};

export type TransferItemDetails = ReplicaItemDetails | DeploymentItemDetails;
export type ActionItemDetails = TransferItemDetails | DeploymentItemDetails;

export const getTransferItemTitle = (item: TransferItem | null) => {
export const getTransferItemTitle = (item: ActionItem | null) => {
if (!item) {
return null;
}
Expand Down
2 changes: 1 addition & 1 deletion src/@types/Schedule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@ export type Schedule = {
};

export type ScheduleBulkItem = {
replicaId: string;
transferId: string;
schedules: Schedule[];
};
10 changes: 5 additions & 5 deletions src/components/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ import { observe } from "mobx";
import Fonts from "@src/components/ui/Fonts";
import NotificationsModule from "@src/components/modules/NotificationsModule";
import LoginPage from "@src/components/smart/LoginPage";
import ReplicasPage from "@src/components/smart/ReplicasPage";
import TransfersPage from "@src/components/smart/TransfersPage/TransfersPage";
import MessagePage from "@src/components/smart/MessagePage";
import ReplicaDetailsPage from "@src/components/smart/ReplicaDetailsPage";
import TransferDetailsPage from "@src/components/smart/TransferDetailsPage/TransferDetailsPage";
import DeploymentsPage from "@src/components/smart/DeploymentsPage";
import DeploymentDetailsPage from "@src/components/smart/DeploymentDetailsPage";
import MetalHubServersPage from "@src/components/smart/MetalHubServersPage";
Expand Down Expand Up @@ -211,9 +211,9 @@ class App extends React.Component<Record<string, unknown>, State> {
<Route path="/login" component={LoginPage} />
}
{renderRoute("/dashboard", DashboardPage)}
{renderRoute("/transfers", ReplicasPage, true)}
{renderRoute("/transfers/:id", ReplicaDetailsPage, true)}
{renderRoute("/transfers/:id/:page", ReplicaDetailsPage)}
{renderRoute("/transfers", TransfersPage, true)}
{renderRoute("/transfers/:id", TransferDetailsPage, true)}
{renderRoute("/transfers/:id/:page", TransferDetailsPage)}
{renderRoute("/deployments", DeploymentsPage, true)}
{renderRoute("/deployments/:id", DeploymentDetailsPage, true)}
{renderRoute("/deployments/:id/:page", DeploymentDetailsPage)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ import Button from "@src/components/ui/Button";
import {
InfoColumn,
MainItemInfo,
ItemReplicaBadge,
ItemTransferBadge,
ItemTitle,
ItemDescription,
} from "@src/components/ui/Dropdowns/NotificationDropdown";

import type { NotificationItemData } from "@src/@types/NotificationItem";

import { ThemePalette, ThemeProps } from "@src/components/Theme";
import replicaImage from "./images/replica.svg";
import transferImage from "./images/transfer.svg";

const Wrapper = styled.div<any>`
flex-grow: 1;
Expand Down Expand Up @@ -80,9 +80,9 @@ const NoItems = styled.div<any>`
align-items: center;
width: 100%;
`;
const ReplicaImage = styled.div<any>`
const TransferImage = styled.div<any>`
${ThemeProps.exactSize("148px")}
background: url('${replicaImage}') center no-repeat;
background: url('${transferImage}') center no-repeat;
`;
const Message = styled.div<any>`
text-align: center;
Expand All @@ -105,12 +105,12 @@ class DashboardActivity extends React.Component<Props> {
.filter((_, i) => i < (this.props.large ? 10 : 5))
.map((item, i) => {
const actionHref =
item.type === "replica"
item.type === "transfer"
? "transfers" : "deployments"

const executionsHref =
item.status === "RUNNING"
? item.type === "replica"
? item.type === "transfer"
? "/executions"
: item.type === "deployment"
? "/tasks"
Expand All @@ -129,9 +129,9 @@ class DashboardActivity extends React.Component<Props> {
<InfoColumn>
<MainItemInfo>
<StatusIcon status={item.status} hollow />
<ItemReplicaBadge type={item.type}>
{item.type === "replica" ? "TR" : "DE"}
</ItemReplicaBadge>
<ItemTransferBadge type={item.type}>
{item.type === "transfer" ? "TR" : "DE"}
</ItemTransferBadge>
<ItemTitle nowrap>{item.name}</ItemTitle>
</MainItemInfo>
<ItemDescription>{item.description}</ItemDescription>
Expand All @@ -146,7 +146,7 @@ class DashboardActivity extends React.Component<Props> {
renderNoItems() {
return (
<NoItems>
<ReplicaImage />
<TransferImage />
<Message>
There is no recent activity
<br />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ describe("DashboardContent", () => {

beforeEach(() => {
defaultProps = {
replicas: [],
transfers: [],
migrations: [],
endpoints: [],
projects: [],
replicasLoading: false,
transfersLoading: false,
migrationsLoading: false,
endpointsLoading: false,
usersLoading: false,
Expand All @@ -52,7 +52,7 @@ describe("DashboardContent", () => {
licenceError: null,
notificationItems: [],
isAdmin: false,
onNewReplicaClick: jest.fn(),
onNewTransferClick: jest.fn(),
onNewEndpointClick: jest.fn(),
onAddLicenceClick: jest.fn(),
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import type { Project } from "@src/@types/Project";
import type { User } from "@src/@types/User";
import type { Licence, LicenceServerStatus } from "@src/@types/Licence";
import type { NotificationItemData } from "@src/@types/NotificationItem";
import { ReplicaItem, DeploymentItem } from "@src/@types/MainItem";
import { TransferItem, DeploymentItem } from "@src/@types/MainItem";

const MIDDLE_WIDTHS = ["264px", "264px", "264px"];

Expand All @@ -52,11 +52,11 @@ const MiddleMobileLayout = styled.div<any>`
`;

type Props = {
replicas: ReplicaItem[];
transfers: TransferItem[];
deployments: DeploymentItem[];
endpoints: Endpoint[];
projects: Project[];
replicasLoading: boolean;
transfersLoading: boolean;
deploymentsLoading: boolean;
endpointsLoading: boolean;
usersLoading: boolean;
Expand All @@ -69,7 +69,7 @@ type Props = {
licenceError: string | null;
notificationItems: NotificationItemData[];
isAdmin: boolean;
onNewReplicaClick: () => void;
onNewTransferClick: () => void;
onNewEndpointClick: () => void;
onAddLicenceClick: () => void;
};
Expand Down Expand Up @@ -122,14 +122,14 @@ class DashboardContent extends React.Component<Props, State> {
width: MIDDLE_WIDTHS[0],
}
}
onNewClick={this.props.onNewReplicaClick}
onNewClick={this.props.onNewTransferClick}
/>,
<DashboardTopEndpoints
key="top-endpoints"
replicas={this.props.replicas}
transfers={this.props.transfers}
endpoints={this.props.endpoints}
loading={
this.props.replicasLoading ||
this.props.transfersLoading ||
this.props.deploymentsLoading ||
this.props.endpointsLoading
}
Expand Down Expand Up @@ -175,13 +175,13 @@ class DashboardContent extends React.Component<Props, State> {
}

getReplicas() {
return this.props.replicas.filter(
(r: ReplicaItem) => r.scenario === "replica");
return this.props.transfers.filter(
(r: TransferItem) => r.scenario === "replica");
}

getLiveMigrations() {
return this.props.replicas.filter(
(r: ReplicaItem) => r.scenario === "live_migration");
return this.props.transfers.filter(
(r: TransferItem) => r.scenario === "live_migration");
}

render() {
Expand All @@ -191,13 +191,13 @@ class DashboardContent extends React.Component<Props, State> {
value: this.getReplicas().length,
color: ThemePalette.alert,
link: "/transfers",
loading: this.props.replicasLoading,
loading: this.props.transfersLoading,
},
{
label: "Migrations",
value: this.getLiveMigrations().length,
link: "/transfers",
loading: this.props.replicasLoading,
loading: this.props.transfersLoading,
},
{
label: "Endpoints",
Expand Down Expand Up @@ -234,7 +234,7 @@ class DashboardContent extends React.Component<Props, State> {
<DashboardExecutions
replicas={this.getReplicas()}
migrations={this.getLiveMigrations()}
loading={this.props.replicasLoading || this.props.deploymentsLoading}
loading={this.props.transfersLoading || this.props.deploymentsLoading}
/>
</Wrapper>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
import { DateTime } from "luxon";
import React from "react";

import { MigrationItem, ReplicaItem } from "@src/@types/MainItem";
import { MigrationItem, TransferItem } from "@src/@types/MainItem";
import { render } from "@testing-library/react";
import userEvent from "@testing-library/user-event";
import TestUtils from "@tests/TestUtils";

import DashboardExecutions from "./DashboardExecutions";

type BuildType<T extends "replica" | "migration"> = T extends "replica"
? ReplicaItem
? TransferItem
: MigrationItem;

const buildItem = <T extends "replica" | "migration">(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { observer } from "mobx-react";
import * as React from "react";
import styled from "styled-components";

import { MigrationItem, ReplicaItem, TransferItem } from "@src/@types/MainItem";
import { TransferItem, ActionItem } from "@src/@types/MainItem";
import DashboardBarChart from "@src/components/modules/DashboardModule/DashboardBarChart";
import { ThemePalette, ThemeProps } from "@src/components/Theme";
import DropdownLink from "@src/components/ui/Dropdowns/DropdownLink";
Expand Down Expand Up @@ -129,8 +129,8 @@ const EmptyBackgroundImage = styled.div<any>`

type Props = {
// eslint-disable-next-line react/no-unused-prop-types
replicas: ReplicaItem[];
migrations: ReplicaItem[];
replicas: TransferItem[];
migrations: TransferItem[];
loading: boolean;
};
type GroupedData = {
Expand Down Expand Up @@ -169,7 +169,7 @@ class DashboardExecutions extends React.Component<Props, State> {
}

groupCreations(props: Props) {
let creations: ReplicaItem[] = [...props.replicas, ...props.migrations];
let creations: TransferItem[] = [...props.replicas, ...props.migrations];

const periodUnit: any = this.state.selectedPeriod.split("-")[1];
const periodValue: any = Number(this.state.selectedPeriod.split("-")[0]);
Expand All @@ -187,7 +187,7 @@ class DashboardExecutions extends React.Component<Props, State> {
this.groupByPeriod(creations, periodUnit);
}

groupByPeriod(transferItems: ReplicaItem[], periodUnit: string) {
groupByPeriod(transferItems: TransferItem[], periodUnit: string) {
const groupedData: GroupedData[] = [];
const periods: {
[period: string]: { replicas: number; migrations: number };
Expand Down
Loading

0 comments on commit 3d94d5c

Please sign in to comment.