Skip to content

Commit

Permalink
Added missing excluded actions for undo action in designer (#7487)
Browse files Browse the repository at this point in the history
  • Loading branch information
mateuszkp96 authored Jan 22, 2025
1 parent d4ea5e8 commit b044a55
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 22 deletions.
11 changes: 6 additions & 5 deletions designer/client/src/components/modals/DeployProcessDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@ import { WindowButtonProps, WindowContentProps } from "@touk/window-manager";
import React, { useCallback, useMemo, useState } from "react";
import { useTranslation } from "react-i18next";
import { useSelector } from "react-redux";
import { getProcessName } from "../../reducers/selectors/graph";
import { getProcessName, getProcessVersionId } from "../../reducers/selectors/graph";
import { getFeatureSettings } from "../../reducers/selectors/settings";
import { ProcessName } from "../Process/types";
import { ProcessName, ProcessVersionId } from "../Process/types";
import { PromptContent, WindowKind } from "../../windowManager";
import CommentInput from "../comment/CommentInput";
import ProcessDialogWarnings from "./ProcessDialogWarnings";
import { FormHelperText, Typography } from "@mui/material";
import { LoadingButtonTypes } from "../../windowManager/LoadingButton";

export type ToggleProcessActionModalData = {
action: (processName: ProcessName, comment: string) => Promise<unknown>;
action: (processName: ProcessName, processVersionId: ProcessVersionId, comment: string) => Promise<unknown>;
displayWarnings?: boolean;
};

Expand All @@ -23,19 +23,20 @@ export function DeployProcessDialog(props: WindowContentProps<WindowKind, Toggle
meta: { action, displayWarnings },
} = props.data;
const processName = useSelector(getProcessName);
const processVersionId = useSelector(getProcessVersionId);
const [comment, setComment] = useState("");
const [validationError, setValidationError] = useState("");
const featureSettings = useSelector(getFeatureSettings);
const deploymentCommentSettings = featureSettings.deploymentCommentSettings;

const confirmAction = useCallback(async () => {
try {
await action(processName, comment);
await action(processName, processVersionId, comment);
props.close();
} catch (error) {
setValidationError(error?.response?.data);
}
}, [action, comment, processName, props]);
}, [action, comment, processName, props, processVersionId]);

const { t } = useTranslation();
const buttons: WindowButtonProps[] = useMemo(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,27 @@ import { useDispatch, useSelector } from "react-redux";
import { loadProcessState } from "../../../../actions/nk";
import Icon from "../../../../assets/img/toolbarButtons/stop.svg";
import HttpService from "../../../../http/HttpService";
import { getProcessName, getProcessVersionId, isCancelPossible } from "../../../../reducers/selectors/graph";
import { getProcessName, isCancelPossible } from "../../../../reducers/selectors/graph";
import { getCapabilities } from "../../../../reducers/selectors/other";
import { WindowKind, useWindows } from "../../../../windowManager";
import { ToggleProcessActionModalData } from "../../../modals/DeployProcessDialog";
import { ToolbarButton } from "../../../toolbarComponents/toolbarButtons";
import { ToolbarButtonProps } from "../../types";
import { ACTION_DIALOG_WIDTH } from "../../../../stylesheets/variables";
import { ProcessName, ProcessVersionId } from "../../../Process/types";

export default function CancelDeployButton(props: ToolbarButtonProps) {
const { t } = useTranslation();
const dispatch = useDispatch();
const { disabled, type } = props;
const cancelPossible = useSelector(isCancelPossible);
const processName = useSelector(getProcessName);
const processVersionId = useSelector(getProcessVersionId);
const capabilities = useSelector(getCapabilities);
const available = !disabled && cancelPossible && capabilities.deploy;

const { open } = useWindows();
const action = (p, c) => HttpService.cancel(p, c).finally(() => dispatch(loadProcessState(processName, processVersionId)));
const action = (name: ProcessName, versionId: ProcessVersionId, comment: string) =>
HttpService.cancel(name, comment).finally(() => dispatch(loadProcessState(name, versionId)));
const message = t("panels.actions.deploy-canel.dialog", "Cancel scenario {{name}}", { name: processName });

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,26 @@ import { useDispatch, useSelector } from "react-redux";
import { disableToolTipsHighlight, enableToolTipsHighlight, loadProcessState } from "../../../../actions/nk";
import Icon from "../../../../assets/img/toolbarButtons/deploy.svg";
import HttpService from "../../../../http/HttpService";
import { getProcessName, getProcessVersionId, hasError, isDeployPossible, isSaveDisabled } from "../../../../reducers/selectors/graph";
import { getProcessName, hasError, isDeployPossible, isSaveDisabled } from "../../../../reducers/selectors/graph";
import { getCapabilities } from "../../../../reducers/selectors/other";
import { useWindows } from "../../../../windowManager";
import { WindowKind } from "../../../../windowManager";
import { ToggleProcessActionModalData } from "../../../modals/DeployProcessDialog";
import { ToolbarButton } from "../../../toolbarComponents/toolbarButtons";
import { ToolbarButtonProps } from "../../types";
import { ACTION_DIALOG_WIDTH } from "../../../../stylesheets/variables";
import { ProcessName, ProcessVersionId } from "../../../Process/types";

export default function DeployButton(props: ToolbarButtonProps) {
const dispatch = useDispatch();
const deployPossible = useSelector(isDeployPossible);
const saveDisabled = useSelector(isSaveDisabled);
const hasErrors = useSelector(hasError);
const processName = useSelector(getProcessName);
const processVersionId = useSelector(getProcessVersionId);
const capabilities = useSelector(getCapabilities);
const { disabled, type } = props;

const available = !disabled && deployPossible && capabilities.deploy;

const { t } = useTranslation();
const deployToolTip = !capabilities.deploy
? t("panels.actions.deploy.tooltips.forbidden", "Deploy forbidden for current scenario.")
Expand All @@ -39,7 +38,8 @@ export default function DeployButton(props: ToolbarButtonProps) {
const { open } = useWindows();

const message = t("panels.actions.deploy.dialog", "Deploy scenario {{name}}", { name: processName });
const action = (p, c) => HttpService.deploy(p, c).finally(() => dispatch(loadProcessState(processName, processVersionId)));
const action = (name: ProcessName, versionId: ProcessVersionId, comment: string) =>
HttpService.deploy(name, comment).finally(() => dispatch(loadProcessState(name, versionId)));

return (
<ToolbarButton
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,7 @@ import { useDispatch, useSelector } from "react-redux";
import { loadProcessState } from "../../../../actions/nk";
import Icon from "../../../../assets/img/toolbarButtons/run-off-schedule.svg";
import HttpService from "../../../../http/HttpService";
import {
getProcessName,
getProcessVersionId,
isRunOffSchedulePossible,
isRunOffScheduleVisible,
} from "../../../../reducers/selectors/graph";
import { getProcessName, isRunOffSchedulePossible, isRunOffScheduleVisible } from "../../../../reducers/selectors/graph";
import { getCapabilities } from "../../../../reducers/selectors/other";
import { useWindows, WindowKind } from "../../../../windowManager";
import { ToggleProcessActionModalData } from "../../../modals/DeployProcessDialog";
Expand All @@ -19,7 +14,7 @@ import { ACTION_DIALOG_WIDTH } from "../../../../stylesheets/variables";
import ProcessStateUtils from "../../../Process/ProcessStateUtils";
import { RootState } from "../../../../reducers";
import { getProcessState } from "../../../../reducers/selectors/scenarioState";
import { PredefinedActionName } from "../../../Process/types";
import { PredefinedActionName, ProcessName, ProcessVersionId } from "../../../Process/types";

export default function RunOffScheduleButton(props: ToolbarButtonProps) {
const { t } = useTranslation();
Expand All @@ -29,12 +24,12 @@ export default function RunOffScheduleButton(props: ToolbarButtonProps) {
const isVisible = useSelector(isRunOffScheduleVisible);
const isPossible = useSelector(isRunOffSchedulePossible);
const processName = useSelector(getProcessName);
const processVersionId = useSelector(getProcessVersionId);
const capabilities = useSelector(getCapabilities);
const available = !disabled && isPossible && capabilities.deploy;

const { open } = useWindows();
const action = (p, c) => HttpService.runOffSchedule(p, c).finally(() => dispatch(loadProcessState(processName, processVersionId)));
const action = (name: ProcessName, versionId: ProcessVersionId, comment: string) =>
HttpService.runOffSchedule(name, comment).finally(() => dispatch(loadProcessState(name, versionId)));
const message = t("panels.actions.run-of-out-schedule.dialog", "Perform single execution", { name: processName });

const defaultTooltip = t("panels.actions.run-off-schedule.tooltip", "run now");
Expand Down
2 changes: 1 addition & 1 deletion designer/client/src/reducers/graph/reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ const undoableReducer = undoable<GraphState, Action>(reducer, {
groupBy: batchGroupBy.init(),
filter: combineFilters((action, nextState, prevState) => {
return !isEqual(getUndoableState(nextState), getUndoableState(prevState._latestUnfiltered));
}, excludeAction(["VALIDATION_RESULT", "UPDATE_IMPORTED_PROCESS", "PROCESS_STATE_LOADED", "UPDATE_TEST_CAPABILITIES", "UPDATE_BACKEND_NOTIFICATIONS", "PROCESS_DEFINITION_DATA", "PROCESS_TOOLBARS_CONFIGURATION_LOADED", "CORRECT_INVALID_SCENARIO", "GET_SCENARIO_ACTIVITIES", "LOGGED_USER", "REGISTER_TOOLBARS", "UI_SETTINGS"])),
}, excludeAction(["VALIDATION_RESULT", "UPDATE_IMPORTED_PROCESS", "PROCESS_STATE_LOADED", "UPDATE_TEST_CAPABILITIES", "UPDATE_BACKEND_NOTIFICATIONS", "PROCESS_DEFINITION_DATA", "PROCESS_TOOLBARS_CONFIGURATION_LOADED", "CORRECT_INVALID_SCENARIO", "GET_SCENARIO_ACTIVITIES", "LOGGED_USER", "REGISTER_TOOLBARS", "UI_SETTINGS", "MARK_BACKEND_NOTIFICATION_READ", "UPDATE_TEST_FORM_PARAMETERS"])),
});

// apply only undoable changes for undo actions
Expand Down

0 comments on commit b044a55

Please sign in to comment.