From b9a4f0c3fb6a3e38d90a0b440aa2cf231577a5bb Mon Sep 17 00:00:00 2001 From: Daniel Vincze Date: Thu, 5 Dec 2024 17:30:24 +0200 Subject: [PATCH] Fix deployment scenario field name and image --- src/@types/MainItem.ts | 2 +- .../TransferListItem/TransferListItem.tsx | 16 +++++++++++++--- .../TransferListItem}/images/live-migration.svg | 0 .../TransferListItem}/images/replica.svg | 0 .../DeploymentDetailsPage.tsx | 6 +++--- .../smart/DeploymentsPage/DeploymentsPage.tsx | 15 +-------------- .../smart/TransfersPage/TransfersPage.tsx | 13 ------------- 7 files changed, 18 insertions(+), 34 deletions(-) rename src/components/{smart/TransfersPage => modules/TransferModule/TransferListItem}/images/live-migration.svg (100%) rename src/components/{smart/TransfersPage => modules/TransferModule/TransferListItem}/images/replica.svg (100%) diff --git a/src/@types/MainItem.ts b/src/@types/MainItem.ts index bd7c442f..6ebc0fae 100644 --- a/src/@types/MainItem.ts +++ b/src/@types/MainItem.ts @@ -110,7 +110,7 @@ export type UserScriptData = { export type DeploymentItem = BaseItem & { type: "deployment"; transfer_id: string; - transfer_scenario: string; + transfer_scenario_type: string; }; export type DeploymentItemOptions = DeploymentItem & { diff --git a/src/components/modules/TransferModule/TransferListItem/TransferListItem.tsx b/src/components/modules/TransferModule/TransferListItem/TransferListItem.tsx index c9c35a98..d11c900f 100644 --- a/src/components/modules/TransferModule/TransferListItem/TransferListItem.tsx +++ b/src/components/modules/TransferModule/TransferListItem/TransferListItem.tsx @@ -25,6 +25,8 @@ import DateUtils from "@src/utils/DateUtils"; import arrowImage from "./images/arrow.svg"; import scheduleImage from "./images/schedule.svg"; +import replicaItemImage from "./images/replica.svg"; +import liveMigrationItemImage from "./images/live-migration.svg"; const CheckboxStyled = styled(Checkbox)` opacity: ${props => (props.checked ? 1 : 0)}; @@ -109,7 +111,6 @@ type Props = { item: ActionItem; onClick: () => void; selected: boolean; - getListItemImage: (item: ActionItem) => string; showScheduleIcon?: boolean; endpointType: (endpointId: string) => string; getUserName: (userId: string) => string | undefined; @@ -129,13 +130,22 @@ class TransferListItem extends React.Component { scenario = this.props.item.scenario; break; case "deployment": - scenario = this.props.item.transfer_scenario; + scenario = this.props.item.transfer_scenario_type; break; default: } return scenario; } + getListItemImage(): string { + let scenario = this.getTransferScenarioType(); + let image = replicaItemImage; + if (scenario === "live_migration") { + image = liveMigrationItemImage; + } + return image; + } + renderCreationDate() { return ( { onChange={this.props.onSelectedChange} /> - + <TitleLabel>{getTransferItemTitle(this.props.item)}</TitleLabel> <StatusWrapper> diff --git a/src/components/smart/TransfersPage/images/live-migration.svg b/src/components/modules/TransferModule/TransferListItem/images/live-migration.svg similarity index 100% rename from src/components/smart/TransfersPage/images/live-migration.svg rename to src/components/modules/TransferModule/TransferListItem/images/live-migration.svg diff --git a/src/components/smart/TransfersPage/images/replica.svg b/src/components/modules/TransferModule/TransferListItem/images/replica.svg similarity index 100% rename from src/components/smart/TransfersPage/images/replica.svg rename to src/components/modules/TransferModule/TransferListItem/images/replica.svg diff --git a/src/components/smart/DeploymentDetailsPage/DeploymentDetailsPage.tsx b/src/components/smart/DeploymentDetailsPage/DeploymentDetailsPage.tsx index 99ec73fe..0c8f10a8 100644 --- a/src/components/smart/DeploymentDetailsPage/DeploymentDetailsPage.tsx +++ b/src/components/smart/DeploymentDetailsPage/DeploymentDetailsPage.tsx @@ -104,7 +104,7 @@ class DeploymentDetailsPage extends React.Component<Props, State> { getDeploymentScenarioItemType(details: DeploymentItemDetails | null): string { let item_type = "replica"; - let scenario = details?.transfer_scenario; + let scenario = details?.transfer_scenario_type; if (scenario && scenario === "live_migration") { item_type = "migration"; } @@ -113,7 +113,7 @@ class DeploymentDetailsPage extends React.Component<Props, State> { getTransferTypePillShouldRed(details: DeploymentItemDetails | null): boolean { let should_red = true; - let scenario = details?.transfer_scenario; + let scenario = details?.transfer_scenario_type; if (scenario && scenario === "live_migration") { should_red = false; } @@ -122,7 +122,7 @@ class DeploymentDetailsPage extends React.Component<Props, State> { getDeploymentScenarioTypeImage(details: DeploymentItemDetails | null): string { let image = replicaDeploymentImage; - let scenario = details?.transfer_scenario; + let scenario = details?.transfer_scenario_type; if (scenario && scenario === "live_migration") { image = liveMigrationDeploymentImage; } diff --git a/src/components/smart/DeploymentsPage/DeploymentsPage.tsx b/src/components/smart/DeploymentsPage/DeploymentsPage.tsx index 6d37f395..f089847f 100644 --- a/src/components/smart/DeploymentsPage/DeploymentsPage.tsx +++ b/src/components/smart/DeploymentsPage/DeploymentsPage.tsx @@ -34,8 +34,6 @@ import { DeploymentItem } from "@src/@types/MainItem"; import userStore from "@src/stores/UserStore"; import TransferListItem from "@src/components/modules/TransferModule/TransferListItem"; import deploymentLargeImage from "./images/deployment-large.svg"; -import replicaDeploymentItemImage from "./images/replica-deployment.svg"; -import liveMigrationDeploymentItemImage from "./images/live-migration-deployment.svg" const Wrapper = styled.div<any>``; @@ -100,17 +98,9 @@ class DeploymentsPage extends React.Component<{ history: any }, State> { getDeploymentType(deploymentId: string): string { const deployment = deploymentStore.deployments.find(m => m.id === deploymentId); - return deployment ? deployment.transfer_scenario : ""; + return deployment ? deployment.transfer_scenario_type : ""; } - getDeploymentItemImage(item: DeploymentItem): string { - let image = replicaDeploymentItemImage; - if (item.transfer_scenario === "live_migration") { - image = liveMigrationDeploymentItemImage; - } - return image; - } - handleProjectChange() { endpointStore.getEndpoints({ showLoading: true }); deploymentStore.getDeployments({ showLoading: true }); @@ -300,9 +290,6 @@ class DeploymentsPage extends React.Component<{ history: any }, State> { renderItemComponent={options => ( <TransferListItem {...options} - getListItemImage={item => { - return this.getDeploymentItemImage(item); - }} endpointType={id => { const endpoint = this.getEndpoint(id); if (endpoint) { diff --git a/src/components/smart/TransfersPage/TransfersPage.tsx b/src/components/smart/TransfersPage/TransfersPage.tsx index b1a82c21..cf79017d 100644 --- a/src/components/smart/TransfersPage/TransfersPage.tsx +++ b/src/components/smart/TransfersPage/TransfersPage.tsx @@ -44,8 +44,6 @@ import { TransferItem } from "@src/@types/MainItem"; import userStore from "@src/stores/UserStore"; import TransferListItem from "@src/components/modules/TransferModule/TransferListItem"; import replicaLargeImage from "./images/replica-large.svg"; -import replicaItemImage from "./images/replica.svg"; -import liveMigrationItemImage from "./images/live-migration.svg"; const Wrapper = styled.div<any>``; @@ -119,14 +117,6 @@ class TransfersPage extends React.Component<{ history: any }, State> { return transfer?.last_execution_status || ""; } - getTransferItemImage(item: TransferItem): string { - let image = replicaItemImage; - if (item.scenario === "live_migration") { - image = liveMigrationItemImage; - } - return image; - } - handleProjectChange() { transferStore.getTransfers(); endpointStore.getEndpoints({ showLoading: true }); @@ -450,9 +440,6 @@ class TransfersPage extends React.Component<{ history: any }, State> { renderItemComponent={options => ( <TransferListItem {...options} - getListItemImage={item => { - return this.getTransferItemImage(item); - }} showScheduleIcon={this.isTransferScheduled(options.item.id)} endpointType={id => { const endpoint = this.getEndpoint(id);