Skip to content

Commit

Permalink
Merge pull request eclipse-xpanse#789 from WangLiNaruto/feature/defau…
Browse files Browse the repository at this point in the history
…lt_billing_mode

update api
  • Loading branch information
swaroopar authored May 15, 2024
2 parents 88c4e0a + 58af36d commit 3d8d0c2
Show file tree
Hide file tree
Showing 15 changed files with 870 additions and 504 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@ import { Row, Tag, Tooltip } from 'antd';
import { PlayCircleOutlined, PoweroffOutlined, StopOutlined, SyncOutlined } from '@ant-design/icons';

export function DeployedServicesRunningStatus(record: DeployedService): React.JSX.Element {
if (
record.serviceState === DeployedService.serviceState.RUNNING ||
record.serviceState === DeployedService.serviceState.STOPPING_FAILED
) {
if (record.serviceState === DeployedService.serviceState.RUNNING) {
return (
<Tooltip
title={
Expand All @@ -24,10 +21,7 @@ export function DeployedServicesRunningStatus(record: DeployedService): React.JS
</Tag>
</Tooltip>
);
} else if (
record.serviceState === DeployedService.serviceState.STOPPED ||
record.serviceState === DeployedService.serviceState.STARTING_FAILED
) {
} else if (record.serviceState === DeployedService.serviceState.STOPPED) {
return (
<Tooltip
title={<Row className={'service-instance-list-service-state'}>stopped at - {record.lastStoppedAt}</Row>}
Expand All @@ -39,7 +33,8 @@ export function DeployedServicesRunningStatus(record: DeployedService): React.JS
);
} else if (
record.serviceState === DeployedService.serviceState.STOPPING ||
record.serviceState === DeployedService.serviceState.STARTING
record.serviceState === DeployedService.serviceState.STARTING ||
record.serviceState === DeployedService.serviceState.RESTARTING
) {
return (
<Tag icon={<SyncOutlined />} color='processing'>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -586,10 +586,7 @@ function MyServices(): React.JSX.Element {
return true;
}

return (
record.serviceState === DeployedService.serviceState.RUNNING ||
record.serviceState === DeployedService.serviceState.STOPPING_FAILED
);
return record.serviceState === DeployedService.serviceState.RUNNING;
};

const isDisabledStopOrRestartBtn = (record: DeployedService) => {
Expand All @@ -609,10 +606,7 @@ function MyServices(): React.JSX.Element {
return true;
}

return (
record.serviceState === DeployedService.serviceState.STOPPED ||
record.serviceState === DeployedService.serviceState.STARTING_FAILED
);
return record.serviceState === DeployedService.serviceState.STOPPED;
};

const closeDestroyResultAlert = (isClose: boolean) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,8 @@ import { DeployedService, ServiceStatusManagementService } from '../../../../../
export function useServiceStateRestartQuery(refreshData: () => void) {
return useMutation({
mutationFn: (deployedService: DeployedService) => {
deployedService.serviceState = DeployedService.serviceState.STOPPING;
return ServiceStatusManagementService.restartService(deployedService.id);
},
onSuccess: refreshData,
onSettled: (data: DeployedService | undefined, _error, deployedService: DeployedService, _context) => {
if (data) {
deployedService.serviceState = data.serviceState;
}
},
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,8 @@ import { DeployedService, ServiceStatusManagementService } from '../../../../../
export function useServiceStateStartQuery(refreshData: () => void) {
return useMutation({
mutationFn: (deployedService: DeployedService) => {
deployedService.serviceState = DeployedService.serviceState.STARTING;
return ServiceStatusManagementService.startService(deployedService.id);
},
onSuccess: refreshData,
onSettled: (data: DeployedService | undefined, _error, deployedService: DeployedService, _context) => {
if (data) {
deployedService.serviceState = data.serviceState;
}
},
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,8 @@ import { DeployedService, ServiceStatusManagementService } from '../../../../../
export function useServiceStateStopQuery(refreshData: () => void) {
return useMutation({
mutationFn: (deployedService: DeployedService) => {
deployedService.serviceState = DeployedService.serviceState.STOPPING;
return ServiceStatusManagementService.stopService(deployedService.id);
},
onSuccess: refreshData,
onSettled: (data, _error, variables, _context) => {
if (data) {
variables.serviceState = data.serviceState;
}
},
});
}
Loading

0 comments on commit 3d8d0c2

Please sign in to comment.