Skip to content

Commit

Permalink
Disable cancel button if there is a latching failure (#942)
Browse files Browse the repository at this point in the history
* Disable cancel button if there is a latching failure

Signed-off-by: Aaron Chong <[email protected]>

* Cleaner separation for latching related delivery alert

Signed-off-by: Aaron Chong <[email protected]>

* Refactor delivery action response route, to log user action

Signed-off-by: Aaron Chong <[email protected]>

* Lint

Signed-off-by: Aaron Chong <[email protected]>

---------

Signed-off-by: Aaron Chong <[email protected]>
  • Loading branch information
aaronchongth authored Apr 30, 2024
1 parent a37bad9 commit 78574d5
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 38 deletions.
60 changes: 31 additions & 29 deletions packages/api-client/lib/openapi/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export const Action = {
Resume: 'resume',
} as const;

export type Action = (typeof Action)[keyof typeof Action];
export type Action = typeof Action[keyof typeof Action];

/**
*
Expand Down Expand Up @@ -103,7 +103,7 @@ export const ActivityDiscoveryRequestTypeEnum = {
} as const;

export type ActivityDiscoveryRequestTypeEnum =
(typeof ActivityDiscoveryRequestTypeEnum)[keyof typeof ActivityDiscoveryRequestTypeEnum];
typeof ActivityDiscoveryRequestTypeEnum[keyof typeof ActivityDiscoveryRequestTypeEnum];

/**
*
Expand Down Expand Up @@ -168,7 +168,7 @@ export const ApiServerModelsDeliveryAlertsDeliveryAlertCategory = {
} as const;

export type ApiServerModelsDeliveryAlertsDeliveryAlertCategory =
(typeof ApiServerModelsDeliveryAlertsDeliveryAlertCategory)[keyof typeof ApiServerModelsDeliveryAlertsDeliveryAlertCategory];
typeof ApiServerModelsDeliveryAlertsDeliveryAlertCategory[keyof typeof ApiServerModelsDeliveryAlertsDeliveryAlertCategory];

/**
* An enumeration.
Expand All @@ -182,7 +182,7 @@ export const ApiServerModelsDeliveryAlertsDeliveryAlertTier = {
} as const;

export type ApiServerModelsDeliveryAlertsDeliveryAlertTier =
(typeof ApiServerModelsDeliveryAlertsDeliveryAlertTier)[keyof typeof ApiServerModelsDeliveryAlertsDeliveryAlertTier];
typeof ApiServerModelsDeliveryAlertsDeliveryAlertTier[keyof typeof ApiServerModelsDeliveryAlertsDeliveryAlertTier];

/**
* An enumeration.
Expand All @@ -198,7 +198,7 @@ export const ApiServerModelsRmfApiLogEntryTier = {
} as const;

export type ApiServerModelsRmfApiLogEntryTier =
(typeof ApiServerModelsRmfApiLogEntryTier)[keyof typeof ApiServerModelsRmfApiLogEntryTier];
typeof ApiServerModelsRmfApiLogEntryTier[keyof typeof ApiServerModelsRmfApiLogEntryTier];

/**
* An enumeration.
Expand All @@ -217,7 +217,7 @@ export const ApiServerModelsRmfApiRobotStateStatus = {
} as const;

export type ApiServerModelsRmfApiRobotStateStatus =
(typeof ApiServerModelsRmfApiRobotStateStatus)[keyof typeof ApiServerModelsRmfApiRobotStateStatus];
typeof ApiServerModelsRmfApiRobotStateStatus[keyof typeof ApiServerModelsRmfApiRobotStateStatus];

/**
* An enumeration.
Expand Down Expand Up @@ -255,7 +255,7 @@ export const ApiServerModelsRmfApiTaskStateStatus = {
} as const;

export type ApiServerModelsRmfApiTaskStateStatus =
(typeof ApiServerModelsRmfApiTaskStateStatus)[keyof typeof ApiServerModelsRmfApiTaskStateStatus];
typeof ApiServerModelsRmfApiTaskStateStatus[keyof typeof ApiServerModelsRmfApiTaskStateStatus];

/**
* An enumeration.
Expand Down Expand Up @@ -617,7 +617,7 @@ export const CancelTaskRequestTypeEnum = {
} as const;

export type CancelTaskRequestTypeEnum =
(typeof CancelTaskRequestTypeEnum)[keyof typeof CancelTaskRequestTypeEnum];
typeof CancelTaskRequestTypeEnum[keyof typeof CancelTaskRequestTypeEnum];

/**
*
Expand Down Expand Up @@ -844,7 +844,7 @@ export const DispatchTaskRequestTypeEnum = {
} as const;

export type DispatchTaskRequestTypeEnum =
(typeof DispatchTaskRequestTypeEnum)[keyof typeof DispatchTaskRequestTypeEnum];
typeof DispatchTaskRequestTypeEnum[keyof typeof DispatchTaskRequestTypeEnum];

/**
*
Expand Down Expand Up @@ -2064,7 +2064,7 @@ export const ResultSuccessEnum = {
False: false,
} as const;

export type ResultSuccessEnum = (typeof ResultSuccessEnum)[keyof typeof ResultSuccessEnum];
export type ResultSuccessEnum = typeof ResultSuccessEnum[keyof typeof ResultSuccessEnum];

/**
*
Expand All @@ -2085,7 +2085,7 @@ export const ResultItemSuccessEnum = {
} as const;

export type ResultItemSuccessEnum =
(typeof ResultItemSuccessEnum)[keyof typeof ResultItemSuccessEnum];
typeof ResultItemSuccessEnum[keyof typeof ResultItemSuccessEnum];

/**
*
Expand All @@ -2112,7 +2112,7 @@ export const ResultItem1SuccessEnum = {
} as const;

export type ResultItem1SuccessEnum =
(typeof ResultItem1SuccessEnum)[keyof typeof ResultItem1SuccessEnum];
typeof ResultItem1SuccessEnum[keyof typeof ResultItem1SuccessEnum];

/**
* Information about the resume request that ended this interruption. This field will be missing if the interruption is still active.
Expand Down Expand Up @@ -2281,7 +2281,7 @@ export const RobotTaskResponseSuccessEnum = {
} as const;

export type RobotTaskResponseSuccessEnum =
(typeof RobotTaskResponseSuccessEnum)[keyof typeof RobotTaskResponseSuccessEnum];
typeof RobotTaskResponseSuccessEnum[keyof typeof RobotTaskResponseSuccessEnum];

/**
* Template for defining a response message that only indicates success and describes any errors
Expand Down Expand Up @@ -2398,7 +2398,7 @@ export const Status1 = {
CanceledInFlight: 'canceled_in_flight',
} as const;

export type Status1 = (typeof Status1)[keyof typeof Status1];
export type Status1 = typeof Status1[keyof typeof Status1];

/**
*
Expand Down Expand Up @@ -2469,7 +2469,7 @@ export const TaskDiscoveryTypeEnum = {
} as const;

export type TaskDiscoveryTypeEnum =
(typeof TaskDiscoveryTypeEnum)[keyof typeof TaskDiscoveryTypeEnum];
typeof TaskDiscoveryTypeEnum[keyof typeof TaskDiscoveryTypeEnum];

/**
*
Expand All @@ -2490,7 +2490,7 @@ export const TaskDiscoveryRequestTypeEnum = {
} as const;

export type TaskDiscoveryRequestTypeEnum =
(typeof TaskDiscoveryRequestTypeEnum)[keyof typeof TaskDiscoveryRequestTypeEnum];
typeof TaskDiscoveryRequestTypeEnum[keyof typeof TaskDiscoveryRequestTypeEnum];

/**
* Response to a task dispatch request
Expand Down Expand Up @@ -2523,7 +2523,7 @@ export const TaskDispatchResponseSuccessEnum = {
} as const;

export type TaskDispatchResponseSuccessEnum =
(typeof TaskDispatchResponseSuccessEnum)[keyof typeof TaskDispatchResponseSuccessEnum];
typeof TaskDispatchResponseSuccessEnum[keyof typeof TaskDispatchResponseSuccessEnum];

/**
*
Expand All @@ -2550,7 +2550,7 @@ export const TaskDispatchResponseItemSuccessEnum = {
} as const;

export type TaskDispatchResponseItemSuccessEnum =
(typeof TaskDispatchResponseItemSuccessEnum)[keyof typeof TaskDispatchResponseItemSuccessEnum];
typeof TaskDispatchResponseItemSuccessEnum[keyof typeof TaskDispatchResponseItemSuccessEnum];

/**
*
Expand All @@ -2577,7 +2577,7 @@ export const TaskDispatchResponseItem1SuccessEnum = {
} as const;

export type TaskDispatchResponseItem1SuccessEnum =
(typeof TaskDispatchResponseItem1SuccessEnum)[keyof typeof TaskDispatchResponseItem1SuccessEnum];
typeof TaskDispatchResponseItem1SuccessEnum[keyof typeof TaskDispatchResponseItem1SuccessEnum];

/**
*
Expand Down Expand Up @@ -2684,7 +2684,7 @@ export const TaskInterruptionRequestTypeEnum = {
} as const;

export type TaskInterruptionRequestTypeEnum =
(typeof TaskInterruptionRequestTypeEnum)[keyof typeof TaskInterruptionRequestTypeEnum];
typeof TaskInterruptionRequestTypeEnum[keyof typeof TaskInterruptionRequestTypeEnum];

/**
* Response to a request for a task to be interrupted
Expand Down Expand Up @@ -2742,7 +2742,7 @@ export const TaskKillRequestTypeEnum = {
} as const;

export type TaskKillRequestTypeEnum =
(typeof TaskKillRequestTypeEnum)[keyof typeof TaskKillRequestTypeEnum];
typeof TaskKillRequestTypeEnum[keyof typeof TaskKillRequestTypeEnum];

/**
* Response to a request to kill a task
Expand Down Expand Up @@ -2800,7 +2800,7 @@ export const TaskPhaseSkipRequestTypeEnum = {
} as const;

export type TaskPhaseSkipRequestTypeEnum =
(typeof TaskPhaseSkipRequestTypeEnum)[keyof typeof TaskPhaseSkipRequestTypeEnum];
typeof TaskPhaseSkipRequestTypeEnum[keyof typeof TaskPhaseSkipRequestTypeEnum];

/**
*
Expand Down Expand Up @@ -2900,7 +2900,7 @@ export const TaskResumeRequestTypeEnum = {
} as const;

export type TaskResumeRequestTypeEnum =
(typeof TaskResumeRequestTypeEnum)[keyof typeof TaskResumeRequestTypeEnum];
typeof TaskResumeRequestTypeEnum[keyof typeof TaskResumeRequestTypeEnum];

/**
* Response to a request to resume a task
Expand Down Expand Up @@ -2952,7 +2952,7 @@ export const TaskRewindRequestTypeEnum = {
} as const;

export type TaskRewindRequestTypeEnum =
(typeof TaskRewindRequestTypeEnum)[keyof typeof TaskRewindRequestTypeEnum];
typeof TaskRewindRequestTypeEnum[keyof typeof TaskRewindRequestTypeEnum];

/**
* Response to a request to rewind a task
Expand Down Expand Up @@ -3264,7 +3264,7 @@ export const UndoPhaseSkipRequestTypeEnum = {
} as const;

export type UndoPhaseSkipRequestTypeEnum =
(typeof UndoPhaseSkipRequestTypeEnum)[keyof typeof UndoPhaseSkipRequestTypeEnum];
typeof UndoPhaseSkipRequestTypeEnum[keyof typeof UndoPhaseSkipRequestTypeEnum];

/**
* Response to an undo phase skip request
Expand Down Expand Up @@ -5610,8 +5610,9 @@ export const BuildingApiFp = function (configuration?: Configuration) {
async getBuildingMapBuildingMapGet(
options?: AxiosRequestConfig,
): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<BuildingMap>> {
const localVarAxiosArgs =
await localVarAxiosParamCreator.getBuildingMapBuildingMapGet(options);
const localVarAxiosArgs = await localVarAxiosParamCreator.getBuildingMapBuildingMapGet(
options,
);
return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
},
};
Expand Down Expand Up @@ -9565,8 +9566,9 @@ export const TasksApiFp = function (configuration?: Configuration) {
): Promise<
(axios?: AxiosInstance, basePath?: string) => AxiosPromise<Array<TaskFavoritePydantic>>
> {
const localVarAxiosArgs =
await localVarAxiosParamCreator.getFavoritesTasksFavoriteTasksGet(options);
const localVarAxiosArgs = await localVarAxiosParamCreator.getFavoritesTasksFavoriteTasksGet(
options,
);
return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
},
/**
Expand Down
2 changes: 1 addition & 1 deletion packages/api-client/lib/version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ import { version as rmfModelVer } from 'rmf-models';

export const version = {
rmfModels: rmfModelVer,
rmfServer: '4febac0944ca42150e94e4b9366e1e6d792ab29e',
rmfServer: '55378951e4ae4161a348a1c106837076c4c56a72',
openapiGenerator: '6.2.1',
};
10 changes: 2 additions & 8 deletions packages/api-server/api_server/routes/delivery_alerts.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
import logging

from fastapi import Depends
from rx import operators as rxops

from api_server.authenticator import user_dep
from api_server.fast_io import FastIORouter, SubscriptionRequest
from api_server.gateway import rmf_gateway
from api_server.logging import get_logger
from api_server.models import User
from api_server.logging import LoggerAdapter, get_logger
from api_server.models.delivery_alerts import (
DeliveryAlert,
action_to_msg,
Expand All @@ -32,8 +28,7 @@ async def respond_to_delivery_alert(
task_id: str,
action: DeliveryAlert.Action,
message: str,
user: User = Depends(user_dep),
logger: logging.Logger = Depends(get_logger),
logger: LoggerAdapter = Depends(get_logger),
):
delivery_alert = DeliveryAlert(
id=delivery_alert_id,
Expand All @@ -43,7 +38,6 @@ async def respond_to_delivery_alert(
task_id=task_id,
message=message,
)
logger.info(f"Delivery alert responded by {user.username}")
logger.info(delivery_alert)
rmf_gateway().respond_to_delivery_alert(
alert_id=delivery_alert.id,
Expand Down
13 changes: 13 additions & 0 deletions packages/dashboard/src/components/delivery-alert-store.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,19 @@ const DeliveryWarningDialog = React.memo((props: DeliveryWarningDialogProps) =>
>
Cancelled
</Button>
) : deliveryAlert.message && deliveryAlert.message.includes(' latch ') ? (
<Button
size="small"
variant="contained"
disabled
autoFocus
sx={{
fontSize: isScreenHeightLessThan800 ? '0.8rem' : '1rem',
padding: isScreenHeightLessThan800 ? '4px 8px' : '6px 12px',
}}
>
Cancel
</Button>
) : newTaskState ? (
<Tooltip title="Cancels the current delivery task.">
<TaskCancelButton
Expand Down

0 comments on commit 78574d5

Please sign in to comment.