diff --git a/designer/client/src/actions/actionTypes.ts b/designer/client/src/actions/actionTypes.ts index 577b0fd71db..133f5a22fcf 100644 --- a/designer/client/src/actions/actionTypes.ts +++ b/designer/client/src/actions/actionTypes.ts @@ -23,6 +23,7 @@ export type ActionTypes = | "PROCESS_RENAME" | "EDIT_LABELS" | "SHOW_METRICS" + | "UPDATE_ACTIVITY_PARAMETERS" | "UPDATE_TEST_CAPABILITIES" | "UPDATE_TEST_FORM_PARAMETERS" | "DISPLAY_PROCESS" diff --git a/designer/client/src/actions/nk/process.ts b/designer/client/src/actions/nk/process.ts index fee47616013..4a5929f0b6f 100644 --- a/designer/client/src/actions/nk/process.ts +++ b/designer/client/src/actions/nk/process.ts @@ -35,6 +35,16 @@ export function loadProcessState(processName: ProcessName): ThunkAction { ); } +export function fetchActivityFormParameters(processName: ProcessName, scenarioGraph: ScenarioGraph) { + return (dispatch) => + HttpService.getActivityParameters(processName, scenarioGraph).then(({ data }) => { + dispatch({ + type: "UPDATE_ACTIVITY_PARAMETERS", + activityParameters: data, + }); + }); +} + export function fetchTestFormParameters(processName: ProcessName, scenarioGraph: ScenarioGraph) { return (dispatch) => HttpService.getTestFormParameters(processName, scenarioGraph).then(({ data }) => { diff --git a/designer/client/src/components/modals/DeployProcessDialog.tsx b/designer/client/src/components/modals/DeployProcessDialog.tsx index 369209ca610..a9c468f2b10 100644 --- a/designer/client/src/components/modals/DeployProcessDialog.tsx +++ b/designer/client/src/components/modals/DeployProcessDialog.tsx @@ -3,7 +3,7 @@ import { WindowButtonProps, WindowContentProps } from "@touk/window-manager"; import React, { useCallback, useMemo, useState } from "react"; import { useTranslation } from "react-i18next"; import { useDispatch, useSelector } from "react-redux"; -import { getProcessName } from "../../reducers/selectors/graph"; +import { getActivityParameters, getProcessName } from "../../reducers/selectors/graph"; import { getFeatureSettings } from "../../reducers/selectors/settings"; import { ProcessName } from "../Process/types"; import { PromptContent, WindowKind } from "../../windowManager"; @@ -23,6 +23,11 @@ export function DeployProcessDialog(props: WindowContentProps { + if (isRenamed) return; + dispatch(fetchActivityFormParameters(scenarioName, scenarioGraph)); + }, [dispatch, isRenamed, scenarioName, scenarioGraph]); +} diff --git a/designer/client/src/components/toolbars/scenarioActions/buttons/DeployButton.tsx b/designer/client/src/components/toolbars/scenarioActions/buttons/DeployButton.tsx index 740601021fb..687c027c72c 100644 --- a/designer/client/src/components/toolbars/scenarioActions/buttons/DeployButton.tsx +++ b/designer/client/src/components/toolbars/scenarioActions/buttons/DeployButton.tsx @@ -13,6 +13,8 @@ import { ToolbarButton } from "../../../toolbarComponents/toolbarButtons"; import { ToolbarButtonProps } from "../../types"; import { ACTION_DIALOG_WIDTH } from "../../../../stylesheets/variables"; +import { useActivityCapabilities } from "../../../modals/GenericAction/useActivityCapabilities"; + export default function DeployButton(props: ToolbarButtonProps) { const dispatch = useDispatch(); const deployPossible = useSelector(isDeployPossible); @@ -22,6 +24,9 @@ export default function DeployButton(props: ToolbarButtonProps) { const capabilities = useSelector(getCapabilities); const { disabled, type } = props; + // TODO: find better place to reload activity capabilities and properties + useActivityCapabilities(); + const available = !disabled && deployPossible && capabilities.deploy; const { t } = useTranslation(); diff --git a/designer/client/src/http/HttpService.ts b/designer/client/src/http/HttpService.ts index 2eccd59af46..6a37525efec 100644 --- a/designer/client/src/http/HttpService.ts +++ b/designer/client/src/http/HttpService.ts @@ -592,6 +592,21 @@ class HttpService { return promise; } + getActivityParameters(processName: string, scenarioGraph: ScenarioGraph) { + const promise = api.post( + `/activityInfo/${encodeURIComponent(processName)}/activityParameters`, + this.#sanitizeScenarioGraph(scenarioGraph), + ); + promise.catch((error) => + this.#addError( + i18next.t("notification.error.failedToGetTestParameters", "Failed to get activity parameters definition"), + error, + true, + ), + ); + return promise; + } + generateTestData(processName: string, testSampleSize: string, scenarioGraph: ScenarioGraph): Promise { const promise = api.post( `/testInfo/${encodeURIComponent(processName)}/generate/${testSampleSize}`, diff --git a/designer/client/src/reducers/graph/reducer.ts b/designer/client/src/reducers/graph/reducer.ts index 3f3d28aad87..f89194d86b6 100644 --- a/designer/client/src/reducers/graph/reducer.ts +++ b/designer/client/src/reducers/graph/reducer.ts @@ -84,6 +84,12 @@ const graphReducer: Reducer = (state = emptyGraphState, action) => { testFormParameters: action.testFormParameters, }; } + case "UPDATE_ACTIVITY_PARAMETERS": { + return { + ...state, + activityParameters: action.activityParameters, + }; + } case "DISPLAY_PROCESS": { const { scenario } = action; return { diff --git a/designer/client/src/reducers/graph/types.ts b/designer/client/src/reducers/graph/types.ts index 4f4002057f5..5e16836f8c0 100644 --- a/designer/client/src/reducers/graph/types.ts +++ b/designer/client/src/reducers/graph/types.ts @@ -1,6 +1,7 @@ import { Layout, RefreshData } from "../../actions/nk"; import { Scenario } from "../../components/Process/types"; import { TestCapabilities, TestFormParameters, TestResults } from "../../common/TestResultUtils"; +import { ActivityParameters } from "../../types/activity"; export interface NodeCounts { errors?: number; @@ -15,6 +16,7 @@ export type GraphState = { scenario?: Scenario; selectionState?: string[]; layout: Layout; + activityParameters?: ActivityParameters; testCapabilities?: TestCapabilities; testFormParameters?: TestFormParameters[]; testResults: TestResults; diff --git a/designer/client/src/reducers/selectors/graph.ts b/designer/client/src/reducers/selectors/graph.ts index 41642d30f66..1d8f45e7b7f 100644 --- a/designer/client/src/reducers/selectors/graph.ts +++ b/designer/client/src/reducers/selectors/graph.ts @@ -8,6 +8,7 @@ import { ProcessCounts } from "../graph"; import { RootState } from "../index"; import { getProcessState } from "./scenarioState"; import { TestFormParameters } from "../../common/TestResultUtils"; +import { ActivityParameters } from "../../types/activity"; export const getGraph = (state: RootState) => state.graphReducer.history.present; @@ -65,6 +66,7 @@ export const isArchivePossible = createSelector( [getProcessState, isFragment], (state, isFragment) => isFragment || ProcessStateUtils.canArchive(state), ); +export const getActivityParameters = createSelector(getGraph, (g) => g.activityParameters || ({} as ActivityParameters)); export const getTestCapabilities = createSelector(getGraph, (g) => g.testCapabilities); export const getTestParameters = createSelector(getGraph, (g) => g.testFormParameters || ([] as TestFormParameters[])); export const getTestResults = createSelector(getGraph, (g) => g.testResults); diff --git a/designer/client/src/types/activity.ts b/designer/client/src/types/activity.ts new file mode 100644 index 00000000000..bd8e9892fcf --- /dev/null +++ b/designer/client/src/types/activity.ts @@ -0,0 +1,17 @@ +import { NodeId } from "./node"; + +export interface ActivityParameterConfig { + editor: any; + label: string; + defaultValue: string | null; + hintText: string | null; +} + +export interface ActivityNodeParameters { + nodeId: NodeId; + parameters: Record; +} + +export type ActivityName = string; + +export type ActivityParameters = Record;