Skip to content

Commit 3e0ef34

Browse files
Scenario status panel & minor fixes (#8118)
* optimize scenario state * separate disabled from isLoading in buttons - enable counts * memoize ProcessStateUtils * extract scenario details content * minor changes * debug box component * new button variant - menu * minor styles * new panel * Updated snapshots (#8120) Co-authored-by: JulianWielga <[email protected]> * fixed reducer * Updated snapshots (#8127) Co-authored-by: JulianWielga <[email protected]> --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: JulianWielga <[email protected]>
1 parent faa6349 commit 3e0ef34

29 files changed

+288
-103
lines changed

designer/client/src/actions/actionTypes.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ export type ActionTypes =
2727
| "LOADING_FAILED"
2828
| "TOGGLE_PROCESS_ACTION_MODAL"
2929
| "TOGGLE_CUSTOM_ACTION"
30-
| "PROCESS_STATE_LOADED"
3130
| "PROCESS_VERSIONS_LOADED"
3231
| "ARCHIVED"
3332
| "EDIT_PROPERTIES";

designer/client/src/actions/nk/process.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
import { omit } from "lodash/fp";
22
import { ActionCreators as UndoActionCreators } from "redux-undo";
33

4-
import type { ProcessName, ProcessVersionId, Scenario } from "../../components/Process/types";
4+
import type { ProcessName, ProcessStateType, ProcessVersionId, Scenario } from "../../components/Process/types";
55
import { replaceSearchQuery } from "../../containers/hooks/useSearchQuery";
66
import { getProcessDefinitionData } from "../../reducers/selectors/processDefinitionData";
77
import type { ProcessDefinitionData, ScenarioGraph } from "../../types";
88
import type { Action, ThunkAction } from "../reduxTypes";
99
import HttpService from "./../../http/HttpService";
1010

1111
export type ScenarioActions =
12+
| {
13+
type: "PROCESS_STATE_LOADED";
14+
processState: ProcessStateType;
15+
}
1216
| {
1317
type: "CORRECT_INVALID_SCENARIO";
1418
processDefinitionData: ProcessDefinitionData;
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import { Box } from "@mui/material";
2+
import type { PropsWithChildren } from "react";
3+
import React, { memo } from "react";
4+
5+
const randomInt = (min: number, max: number) => Math.floor(Math.random() * (max - min)) + min;
6+
const setDepth = (instance: HTMLDivElement) => {
7+
if (!instance) return;
8+
const parentDepth = getComputedStyle(instance.parentElement).getPropertyValue("--depth");
9+
const numericDepth = parseInt(parentDepth || "0", 10);
10+
instance.style.setProperty("--depth", `${numericDepth + 1}`);
11+
};
12+
13+
export const DebugBox = memo(function DebugBox({ children }: PropsWithChildren) {
14+
return (
15+
<Box
16+
ref={setDepth}
17+
sx={{
18+
outlineWidth: 2,
19+
outlineStyle: "solid",
20+
outlineOffset: "calc(var(--depth, 0) * -2px)",
21+
}}
22+
style={{
23+
outlineColor: `rgba(${randomInt(0, 255)}, ${randomInt(0, 255)}, ${randomInt(0, 255)})`,
24+
}}
25+
>
26+
{children}
27+
</Box>
28+
);
29+
});

designer/client/src/components/Process/ProcessStateUtils.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
1+
import { memoizeByArgsWithTTL } from "../../helpers/memoizeByArgsWithTTL";
2+
import { WrapAllMethods } from "../../WrapAllMethods";
13
import { descriptionProcessArchived, unknownDescription, unknownTooltip } from "./messages";
24
import type { ActionName, ProcessStateType, Scenario } from "./types";
35
import { PredefinedActionName } from "./types";
46

57
export const unknownIcon = "/assets/states/status-unknown.svg";
68
const archivedIcon = "/assets/process/archived.svg";
79

10+
@WrapAllMethods(memoizeByArgsWithTTL)
811
class ProcessStateUtils {
912
public canDeploy = (state: ProcessStateType): boolean => state?.allowedActions.includes(PredefinedActionName.Deploy);
1013

designer/client/src/components/toolbarComponents/ToolbarsLayer.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,14 +121,14 @@ export const OverlayGrid9 = Overlay.withComponent(Grid9);
121121
export const AbsoluteOverlayGrid9 = AbsolutePanel.withComponent(OverlayGrid9);
122122

123123
const StyledToolbarsContainer = styled(ToolbarsContainer)(({ theme, side }) => {
124-
const padding = `calc(${theme.spacing(0.375)} / 2)`;
124+
const padding = theme.spacing(0.25);
125125
switch (side) {
126126
case ToolbarsSide.LeftTop:
127127
case ToolbarsSide.RightTop:
128-
return { paddingBottom: padding };
128+
return { paddingTop: padding, paddingBottom: padding };
129129
case ToolbarsSide.LeftBottom:
130130
case ToolbarsSide.RightBottom:
131-
return { paddingTop: padding };
131+
return { paddingTop: padding, paddingBottom: padding };
132132
default:
133133
return {
134134
padding: theme.spacing(0.5),

designer/client/src/components/toolbarComponents/toolbarButtons/ButtonMenu.tsx

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ const ExpandButton = styled(Button)(({ theme }) => {
3232

3333
export const ButtonMenu = forwardRef<HTMLButtonElement, ToolbarButtonMenuWrapperProps>(function ButtonMenu(
3434
{ options = [], selected, onChange, className, buttonProps },
35-
ref
35+
ref,
3636
) {
3737
const [anchorPosition, setAnchorPosition] = React.useState<null | PopoverPosition>(null);
3838
const { variant } = useContext(ToolbarButtonsContext);
@@ -58,24 +58,31 @@ export const ButtonMenu = forwardRef<HTMLButtonElement, ToolbarButtonMenuWrapper
5858
},
5959
},
6060
".toolbarButton-Root": {
61-
paddingRight: ButtonsVariant.horizontal === variant ? 3.5 : ButtonsVariant.xs === variant ? 2.5 : null,
61+
paddingRight: [ButtonsVariant.menu, ButtonsVariant.horizontal].includes(variant)
62+
? 3.5
63+
: ButtonsVariant.xs === variant
64+
? 2.5
65+
: null,
6266
},
6367
}}
6468
>
6569
<ExpandButton
6670
sx={{
6771
height: ButtonsVariant.small === variant ? 20 : ButtonsVariant.label !== variant ? "auto" : null,
68-
width:
69-
ButtonsVariant.horizontal === variant
70-
? 26
71-
: [ButtonsVariant.small, ButtonsVariant.xs].includes(variant)
72-
? 20
73-
: null,
72+
width: [ButtonsVariant.menu, ButtonsVariant.horizontal].includes(variant)
73+
? 26
74+
: [ButtonsVariant.small, ButtonsVariant.xs].includes(variant)
75+
? 20
76+
: null,
7477
justifyContent: "center",
7578
zoom: variant === ButtonsVariant.xs ? 0.75 : null,
7679
borderTopLeftRadius: 0,
77-
borderBottomLeftRadius: [ButtonsVariant.horizontal, ButtonsVariant.xs].includes(variant) ? 0 : null,
78-
borderBottomRightRadius: [ButtonsVariant.horizontal, ButtonsVariant.xs].includes(variant) ? null : 0,
80+
borderBottomLeftRadius: [ButtonsVariant.menu, ButtonsVariant.horizontal, ButtonsVariant.xs].includes(variant)
81+
? 0
82+
: null,
83+
borderBottomRightRadius: [ButtonsVariant.menu, ButtonsVariant.horizontal, ButtonsVariant.xs].includes(variant)
84+
? null
85+
: 0,
7986
}}
8087
className={"toolbarButton-MenuExpand"}
8188
disabled={buttonProps.disabled}

designer/client/src/components/toolbarComponents/toolbarButtons/ButtonRoot.tsx

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,18 @@ export const ButtonRoot = forwardRef<HTMLButtonElement, Omit<ToolbarButtonProps,
2929
title={title || name}
3030
className={"toolbarButton-Root"}
3131
sx={(theme) => ({
32-
width: [ButtonsVariant.horizontal, ButtonsVariant.xs].includes(variant)
32+
width: [ButtonsVariant.menu, ButtonsVariant.horizontal, ButtonsVariant.xs].includes(variant)
3333
? "auto"
3434
: `calc(${ButtonsVariant.small === variant ? PANEL_BUTTON_SMALL_SIZE : PANEL_BUTTON_SIZE}px - 2 * var(--margin))`,
3535
padding:
36-
variant === ButtonsVariant.horizontal
36+
ButtonsVariant.menu === variant
37+
? "0 8px 0 0"
38+
: ButtonsVariant.horizontal === variant
3739
? "4px 8px"
3840
: [ButtonsVariant.small, ButtonsVariant.xs].includes(variant)
3941
? 0
4042
: "4px 0",
41-
flexDirection: [ButtonsVariant.horizontal, ButtonsVariant.xs].includes(variant) ? "row" : null,
43+
flexDirection: [ButtonsVariant.menu, ButtonsVariant.horizontal, ButtonsVariant.xs].includes(variant) ? "row" : null,
4244
zoom: variant === ButtonsVariant.xs ? 0.75 : null,
4345
borderColor: hasError ? theme.palette.error.main : null,
4446
color: hasError ? theme.palette.error.main : isActive ? theme.palette.success.main : null,
@@ -49,7 +51,15 @@ export const ButtonRoot = forwardRef<HTMLButtonElement, Omit<ToolbarButtonProps,
4951
title={title}
5052
className={"toolbarButton-Icon"}
5153
sx={
52-
variant === ButtonsVariant.horizontal
54+
[ButtonsVariant.menu].includes(variant)
55+
? {
56+
"&, &>*": {
57+
flex: "none",
58+
height: "1.5em",
59+
width: "1.5em",
60+
},
61+
}
62+
: [ButtonsVariant.horizontal].includes(variant)
5363
? {
5464
"&, &>*": {
5565
flex: "none",
@@ -64,14 +74,24 @@ export const ButtonRoot = forwardRef<HTMLButtonElement, Omit<ToolbarButtonProps,
6474
</Icon>
6575
</Badge>
6676
<Typography
67-
variant={ButtonsVariant.horizontal === variant ? "button" : "overline"}
77+
variant={
78+
[ButtonsVariant.menu].includes(variant)
79+
? "caption"
80+
: [ButtonsVariant.horizontal].includes(variant)
81+
? "button"
82+
: "overline"
83+
}
6884
className={"toolbarButton-Label"}
6985
sx={{
7086
color: "inherit",
7187
display: [ButtonsVariant.small, ButtonsVariant.xs].includes(variant) ? "none" : null,
72-
whiteSpace: variant === ButtonsVariant.horizontal ? "nowrap" : null,
73-
textTransform: variant === ButtonsVariant.label ? "lowercase" : null,
74-
marginLeft: variant === ButtonsVariant.horizontal ? 1 : null,
88+
whiteSpace: [ButtonsVariant.menu, ButtonsVariant.horizontal].includes(variant) ? "nowrap" : null,
89+
textTransform: [ButtonsVariant.label].includes(variant) ? "lowercase" : "capitalize",
90+
marginLeft: [ButtonsVariant.menu].includes(variant)
91+
? 0.5
92+
: [ButtonsVariant.horizontal].includes(variant)
93+
? 1
94+
: null,
7595
}}
7696
>
7797
{name}

designer/client/src/components/toolbarComponents/toolbarButtons/ToolbarButton.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const ToolbarButtonComponent = forwardRef<HTMLButtonElement, ToolbarButtonProps>
1212
if ("isLoading" in props) {
1313
const { isLoading, loadingProgress, loadingVariant, children, disabled, ...passProps } = props;
1414
return (
15-
<ToolbarButtonComponent {...passProps} ref={ref} disabled={disabled || isLoading}>
15+
<ToolbarButtonComponent {...passProps} ref={ref} disabled={disabled}>
1616
<ButtonProgress enabled={isLoading} variant={loadingVariant} value={loadingProgress} />
1717
{children}
1818
</ToolbarButtonComponent>

designer/client/src/components/toolbarComponents/toolbarButtons/ToolbarButtons.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { PropsOf } from "@emotion/react";
22
import { styled } from "@mui/material";
33
import type { PropsWithChildren } from "react";
4-
import React, { createContext } from "react";
4+
import React, { createContext, forwardRef } from "react";
55

66
const ToolbarButtonsContainer = styled("div")(() => ({
77
display: "flex",
@@ -14,6 +14,7 @@ export enum ButtonsVariant {
1414
small = "small",
1515
label = "label",
1616
horizontal = "horizontal",
17+
menu = "menu",
1718
}
1819

1920
export const ToolbarButtonsContext = createContext<{ variant: ButtonsVariant }>({ variant: ButtonsVariant.label });
@@ -22,10 +23,10 @@ type Props = {
2223
variant?: ButtonsVariant;
2324
} & PropsOf<typeof ToolbarButtonsContainer>;
2425

25-
export function ToolbarButtons({ variant, ...props }: PropsWithChildren<Props>): JSX.Element {
26+
export const ToolbarButtons = forwardRef<HTMLDivElement, PropsWithChildren<Props>>(function ToolbarButtons({ variant, ...props }, ref) {
2627
return (
2728
<ToolbarButtonsContext.Provider value={{ variant: variant || ButtonsVariant.label }}>
28-
<ToolbarButtonsContainer {...props} />
29+
<ToolbarButtonsContainer {...props} ref={ref} />
2930
</ToolbarButtonsContext.Provider>
3031
);
31-
}
32+
});

designer/client/src/components/toolbarComponents/toolbarWrapper/ToolbarWrapper.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,14 @@ export type ToolbarWrapperProps = PropsWithChildren<{
2121
onCollapse?: () => void;
2222
color?: string;
2323
disableCollapse?: boolean;
24+
noDrag?: boolean;
2425
}>;
2526

2627
export const TOOLBAR_WRAPPER_CLASSNAME = "toolbar-wrapper";
2728

2829
export function ToolbarWrapper(props: ToolbarWrapperProps): React.JSX.Element | null {
2930
const theme = useTheme();
30-
const { title, children, id, onClose, onExpand, onCollapse, color, disableCollapse } = props;
31+
const { title, children, id, onClose, onExpand, onCollapse, color, disableCollapse, noDrag } = props;
3132
const handlerProps = useDragHandler();
3233

3334
const dispatch = useDispatch();
@@ -64,11 +65,11 @@ export function ToolbarWrapper(props: ToolbarWrapperProps): React.JSX.Element |
6465
color={color || theme.palette.background.paper}
6566
width={SIDEBAR_WIDTH}
6667
data-testid={id}
67-
{...(isCollapsible ? {} : handlerProps)}
68+
{...(isCollapsible || noDrag ? {} : handlerProps)}
6869
>
6970
{(isCollapsible || onClose) && (
7071
<PanelHeader
71-
{...(isCollapsible ? handlerProps : {})}
72+
{...(isCollapsible && !noDrag ? handlerProps : {})}
7273
color={color || theme.palette.background.paper}
7374
onClick={toggleCollapsed}
7475
onKeyDown={(e) => {

designer/client/src/components/toolbarSettings/getToolbarComponent.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,16 @@ import { ActivitiesPanel } from "../toolbars/activities";
99
import { CreatorPanel } from "../toolbars/creator/CreatorPanel";
1010
import ProcessActions from "../toolbars/scenarioActions/ProcessActions";
1111
import ScenarioDetails from "../toolbars/scenarioDetails/ScenarioDetails";
12+
import ScenarioStatusPanel from "../toolbars/scenarioDetails/ScenarioStatusPanel";
1213
import { SearchPanel } from "../toolbars/search/SearchPanel";
1314
import { UserSettingsPanel } from "../toolbars/UserSettingsPanel";
1415
import { HorizontalButtonsToolbar } from "./HorizontalButtonsToolbar";
1516
import type { ToolbarConfig } from "./types";
1617

1718
export function getToolbarComponent(config?: ToolbarConfig): ComponentType<ToolbarPanelProps> {
1819
switch (config?.id) {
20+
case "scenario-status-panel":
21+
return ScenarioStatusPanel;
1922
case "process-info-panel":
2023
return ScenarioDetails;
2124
case "process-actions-panel":

designer/client/src/components/toolbars/activities/ActivitiesPanelRow.tsx

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ import React, { memo, useEffect, useMemo, useRef } from "react";
33
import { useTranslation } from "react-i18next";
44
import { useSelector } from "react-redux";
55

6-
import type { RootState } from "../../../reducers";
7-
import { getProcessState } from "../../../reducers/selectors/scenarioState";
6+
import { getIsRunning } from "../../../reducers/selectors/scenarioState";
87
import type { UIActivity } from "./ActivitiesPanel";
9-
import { DateItem, ActivityItem, ToggleButtonItem } from "./ActivityPanelRowItem";
8+
import { ActivityItem, DateItem, ToggleButtonItem } from "./ActivityPanelRowItem";
109
import { ActivityItemProvider } from "./ActivityPanelRowItem/ActivityItemProvider";
10+
import { ActivityTypesRelatedToExecutions } from "./types";
1111

1212
interface Props {
1313
index: number;
@@ -20,17 +20,19 @@ interface Props {
2020
}
2121

2222
export const ActivitiesPanelRow = memo(({ index, style, setRowHeight, handleShowRows, handleHideRows, activities, searchQuery }: Props) => {
23-
const scenarioState = useSelector((state: RootState) => getProcessState(state));
23+
const isRunning = useSelector(getIsRunning);
2424

2525
const { t } = useTranslation();
2626
const rowRef = useRef<HTMLDivElement>(null);
2727
const activity = useMemo(() => activities[index], [activities, index]);
2828
const firstDeployedIndex = useMemo(
29-
() => activities.findIndex((activeItem) => activeItem.uiType === "item" && activeItem.type === "SCENARIO_DEPLOYED"),
29+
() =>
30+
activities.findIndex(
31+
(activeItem) => activeItem.uiType === "item" && activeItem.type === ActivityTypesRelatedToExecutions.ScenarioDeployed,
32+
),
3033
[activities],
3134
);
32-
const scenarioStatusesToActiveDeploy = ["RUNNING", "SCHEDULED"];
33-
const isDeploymentActive = firstDeployedIndex === index && scenarioStatusesToActiveDeploy.includes(scenarioState.status.name);
35+
const isDeploymentActive = firstDeployedIndex === index && isRunning;
3436
const isFirstDateItem = activities.findIndex((activeItem) => activeItem.uiType === "date") === index;
3537

3638
useEffect(() => {

designer/client/src/components/toolbars/scenarioActions/ProcessActions.tsx

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,21 @@
1-
import { Box, Typography } from "@mui/material";
21
import i18next from "i18next";
32
import React, { memo } from "react";
4-
import { useSelector } from "react-redux";
53

6-
import type { RootState } from "../../../reducers";
7-
import { getScenario } from "../../../reducers/selectors/graph";
8-
import { getProcessState } from "../../../reducers/selectors/scenarioState";
9-
import ProcessStateIcon from "../../Process/ProcessStateIcon";
10-
import ProcessStateUtils from "../../Process/ProcessStateUtils";
114
import type { ToolbarPanelProps } from "../../toolbarComponents/ButtonsToolbar";
125
import { ToolbarButtons } from "../../toolbarComponents/toolbarButtons";
136
import { ToolbarWrapper } from "../../toolbarComponents/toolbarWrapper/ToolbarWrapper";
7+
import { PanelScenarioDetails, ScenarioDetailsItemWrapper } from "../scenarioDetails/ScenarioDetailsComponents";
8+
import { ScenarioState } from "./ScenarioState";
149

1510
const ProcessActions = memo(({ buttonsVariant, children, ...props }: ToolbarPanelProps) => {
16-
const scenario = useSelector((state: RootState) => getScenario(state));
17-
const processState = useSelector((state: RootState) => getProcessState(state));
18-
1911
// TODO: better styling of process info toolbar in case of many custom actions
20-
2112
return (
2213
<ToolbarWrapper {...props} title={i18next.t("panels.scenarioActions.title", "Scenario actions")}>
23-
{!scenario.isFragment && (
24-
<Box display={"flex"} px={2} pt={2} pb={1.5}>
25-
<ProcessStateIcon scenario={scenario} processState={processState} />
26-
<Typography component={"div"} variant={"body2"} pl={1}>
27-
{ProcessStateUtils.getStateDescription(scenario, processState)}
28-
</Typography>
29-
</Box>
30-
)}
14+
<PanelScenarioDetails>
15+
<ScenarioDetailsItemWrapper>
16+
<ScenarioState />
17+
</ScenarioDetailsItemWrapper>
18+
</PanelScenarioDetails>
3119
<ToolbarButtons variant={buttonsVariant}>{children}</ToolbarButtons>
3220
</ToolbarWrapper>
3321
);

0 commit comments

Comments
 (0)