Skip to content

Commit

Permalink
PR review: rename activity->action
Browse files Browse the repository at this point in the history
  • Loading branch information
gskrobisz committed Jan 9, 2025
1 parent d74804b commit f763629
Show file tree
Hide file tree
Showing 22 changed files with 88 additions and 91 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ trait TestWithParametersSupport[+T] { self: Source =>
* e.g.
* {"DEPLOY": { "parametername": ...parameter configuration... }
*/
trait WithActivityParameters { self: Source =>
def activityParametersDefinition: Map[String, Map[String, ParameterConfig]]
trait WithActionParameters { self: Source =>
def actionParametersDefinition: Map[String, Map[String, ParameterConfig]]
}

/**
Expand Down
2 changes: 1 addition & 1 deletion designer/client/src/actions/actionTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export type ActionTypes =
| "PROCESS_RENAME"
| "EDIT_LABELS"
| "SHOW_METRICS"
| "UPDATE_ACTIVITY_PARAMETERS"
| "UPDATE_ACTION_PARAMETERS"
| "UPDATE_TEST_CAPABILITIES"
| "UPDATE_TEST_FORM_PARAMETERS"
| "DISPLAY_PROCESS"
Expand Down
8 changes: 4 additions & 4 deletions designer/client/src/actions/nk/process.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ export function loadProcessState(processName: ProcessName, processVersionId: num
);
}

export function fetchActivityParameters(processName: ProcessName, scenarioGraph: ScenarioGraph) {
export function fetchActionParameters(processName: ProcessName, scenarioGraph: ScenarioGraph) {
return (dispatch) =>
HttpService.getActivityParameters(processName, scenarioGraph).then(({ data }) => {
HttpService.getActionParameters(processName, scenarioGraph).then(({ data }) => {
dispatch({
type: "UPDATE_ACTIVITY_PARAMETERS",
activityParameters: data,
type: "UPDATE_ACTION_PARAMETERS",
actionParameters: data,
});
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,26 @@ import { ExpressionLang } from "../graph/node-modal/editors/expression/types";
import React, { useCallback } from "react";
import { FieldLabel } from "../graph/node-modal/FieldLabel";
import { getValidationErrorsForField } from "../graph/node-modal/editors/Validators";
import { ActivityNodeParameters, ActivityParameterConfig } from "../../types/activity";
import { ActionNodeParameters, ActionParameterConfig } from "../../types/action";
import { NodesDeploymentData } from "../../http/HttpService";
import { NodeValidationError } from "../../types";
import { default as EditableEditor } from "../graph/node-modal/editors/EditableEditor";

interface Props {
nodeName: string;
propertyName: string;
propertyConfig: ActivityParameterConfig;
propertyConfig: ActionParameterConfig;
nodesData: NodesDeploymentData;
onChange: <K extends keyof ActivityNodeParameters["parameters"]>(
onChange: <K extends keyof ActionNodeParameters["parameters"]>(
nodeId: string,
property: K,
newValue: ActivityNodeParameters["parameters"][K],
defaultValue?: ActivityNodeParameters["parameters"][K],
newValue: ActionNodeParameters["parameters"][K],
defaultValue?: ActionNodeParameters["parameters"][K],
) => void;
errors: NodeValidationError[];
}

export function ActivityProperty(props: Props): JSX.Element {
export function ActionParameter(props: Props): JSX.Element {
const { nodeName, propertyName, propertyConfig, errors, nodesData, onChange } = props;

const current = nodesData[nodeName][propertyName] || "";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,27 @@ 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 { getActivityParameters, getProcessName } from "../../reducers/selectors/graph";
import { getActionParameters, getProcessName } from "../../reducers/selectors/graph";
import { getFeatureSettings } from "../../reducers/selectors/settings";
import { ProcessName } 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";
import { ActivityNodeParameters } from "../../types/activity";
import { ActionNodeParameters } from "../../types/action";
import { AdvancedParametersSection } from "./AdvancedParametersSection";
import { mapValues } from "lodash";
import { NodesDeploymentData } from "../../http/HttpService";
import { ActivityProperty } from "./ActivityProperty";
import { ActionParameter } from "./ActionParameter";
import { NodeTable } from "../graph/node-modal/NodeDetailsContent/NodeTable";

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

function initialNodesData(params: ActivityNodeParameters[]) {
function initialNodesData(params: ActionNodeParameters[]) {
return params.reduce(
(paramObj, { nodeId, parameters }) => ({
...paramObj,
Expand All @@ -40,8 +40,8 @@ export function DeployWithParametersDialog(props: WindowContentProps<WindowKind,
} = props.data;
const processName = useSelector(getProcessName);

const activityParameters = useSelector(getActivityParameters);
const activityNodeParameters = activityParameters["DEPLOY"] || ([] as ActivityNodeParameters[]);
const activityParameters = useSelector(getActionParameters);
const activityNodeParameters = activityParameters["DEPLOY"] || ([] as ActionNodeParameters[]);
const initialValues = useMemo(() => initialNodesData(activityNodeParameters), [activityNodeParameters]);
const [values, setValues] = useState(initialValues);

Expand Down Expand Up @@ -90,12 +90,12 @@ export function DeployWithParametersDialog(props: WindowContentProps<WindowKind,
<FormHelperText title={validationError} error>
{validationError}
</FormHelperText>
{activityNodeParameters.map((anp: ActivityNodeParameters) => (
{activityNodeParameters.map((anp: ActionNodeParameters) => (
<AdvancedParametersSection key={anp.nodeId} nodeId={anp.nodeId}>
<NodeTable>
{Object.entries(anp.parameters).map(([paramName, paramConfig]) => {
return (
<ActivityProperty
<ActionParameter
key={paramName}
nodeName={anp.nodeId}
propertyName={paramName}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { useDispatch, useSelector } from "react-redux";
import { getProcessName, getScenarioGraph } from "../../../reducers/selectors/graph";
import { useEffect } from "react";
import { fetchActivityParameters } from "../../../actions/nk";
export function useActivityCapabilities() {
import { fetchActionParameters } from "../../../actions/nk";
export function useActionCapabilities() {
const dispatch = useDispatch();

const scenarioName = useSelector(getProcessName);
const scenarioGraph = useSelector(getScenarioGraph);

useEffect(() => {
dispatch(fetchActivityParameters(scenarioName, scenarioGraph));
dispatch(fetchActionParameters(scenarioName, scenarioGraph));
}, [dispatch, scenarioName, scenarioGraph]);
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { ToolbarButton } from "../../../toolbarComponents/toolbarButtons";
import { ToolbarButtonProps } from "../../types";
import { ACTION_DIALOG_WIDTH } from "../../../../stylesheets/variables";

import { useActivityCapabilities } from "../../../modals/GenericAction/useActivityCapabilities";
import { useActionCapabilities } from "../../../modals/GenericAction/useActionCapabilities";

export default function DeployButton(props: ToolbarButtonProps) {
const dispatch = useDispatch();
Expand All @@ -26,7 +26,7 @@ export default function DeployButton(props: ToolbarButtonProps) {
const { disabled, type } = props;

// TODO: find better place to reload activity capabilities and properties
useActivityCapabilities();
useActionCapabilities();

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

Expand Down
6 changes: 3 additions & 3 deletions designer/client/src/http/HttpService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -666,14 +666,14 @@ class HttpService {
return promise;
}

getActivityParameters(processName: string, scenarioGraph: ScenarioGraph) {
getActionParameters(processName: string, scenarioGraph: ScenarioGraph) {
const promise = api.post(
`/activityInfo/${encodeURIComponent(processName)}/activityParameters`,
`/actionInfo/${encodeURIComponent(processName)}/actionParameters`,
this.#sanitizeScenarioGraph(scenarioGraph),
);
promise.catch((error) =>
this.#addError(
i18next.t("notification.error.failedToGetTestParameters", "Failed to get activity parameters definition"),
i18next.t("notification.error.failedToGetActionParameters", "Failed to get action parameters definition"),
error,
true,
),
Expand Down
4 changes: 2 additions & 2 deletions designer/client/src/reducers/graph/reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,10 @@ const graphReducer: Reducer<GraphState> = (state = emptyGraphState, action) => {
testFormParameters: action.testFormParameters,
};
}
case "UPDATE_ACTIVITY_PARAMETERS": {
case "UPDATE_ACTION_PARAMETERS": {
return {
...state,
activityParameters: action.activityParameters,
actionParameters: action.actionParameters,
};
}
case "DISPLAY_PROCESS": {
Expand Down
4 changes: 2 additions & 2 deletions designer/client/src/reducers/graph/types.ts
Original file line number Diff line number Diff line change
@@ -1,7 +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";
import { ActionParameters } from "../../types/action";

export interface NodeCounts {
errors?: number;
Expand All @@ -16,7 +16,7 @@ export type GraphState = {
scenario?: Scenario;
selectionState?: string[];
layout: Layout;
activityParameters?: ActivityParameters;
actionParameters?: ActionParameters;
testCapabilities?: TestCapabilities;
testFormParameters?: TestFormParameters[];
testResults: TestResults;
Expand Down
4 changes: 2 additions & 2 deletions designer/client/src/reducers/selectors/graph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { ProcessCounts } from "../graph";
import { RootState } from "../index";
import { getProcessState } from "./scenarioState";
import { TestFormParameters } from "../../common/TestResultUtils";
import { ActivityParameters } from "../../types/activity";
import { ActionParameters } from "../../types/action";

export const getGraph = (state: RootState) => state.graphReducer.history.present;

Expand Down Expand Up @@ -71,7 +71,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 getActionParameters = createSelector(getGraph, (g) => g.actionParameters || ({} as ActionParameters));
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);
Expand Down
18 changes: 18 additions & 0 deletions designer/client/src/types/action.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { NodeId } from "./node";
import { ActionName } from "../components/Process/types";

export interface ActionParameterConfig {
editor: any;
label: string;
defaultValue: string | null;
hintText: string | null;
}

export type ActionParameterName = string;

export interface ActionNodeParameters {
nodeId: NodeId;
parameters: { [key: ActionParameterName]: ActionParameterConfig };
}

export type ActionParameters = { [key: ActionName]: ActionNodeParameters[] };
19 changes: 0 additions & 19 deletions designer/client/src/types/activity.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ package object definition {
hintText: Option[String]
)

@JsonCodec final case class UiActivityParameterConfig(
@JsonCodec final case class UiActionParameterConfig(
defaultValue: Option[String],
editor: ParameterEditor,
label: Option[String],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ import de.heikoseeberger.akkahttpcirce.FailFastCirceSupport
import pl.touk.nussknacker.engine.api.graph.ScenarioGraph
import pl.touk.nussknacker.ui.api.utils.ScenarioDetailsOps.ScenarioWithDetailsOps
import pl.touk.nussknacker.ui.process.ProcessService
import pl.touk.nussknacker.ui.process.newactivity.ActivityInfoService
import pl.touk.nussknacker.ui.process.newactivity.ActionInfoService
import pl.touk.nussknacker.ui.process.processingtype.provider.ProcessingTypeDataProvider
import pl.touk.nussknacker.ui.security.api.LoggedUser

import scala.concurrent.ExecutionContext

class ActivityInfoResources(
class ActionInfoResources(
protected val processService: ProcessService,
activityInfoService: ProcessingTypeDataProvider[ActivityInfoService, _]
actionInfoService: ProcessingTypeDataProvider[ActionInfoService, _]
)(implicit val ec: ExecutionContext)
extends Directives
with FailFastCirceSupport
Expand All @@ -23,14 +23,14 @@ class ActivityInfoResources(
with LazyLogging {

def securedRoute(implicit user: LoggedUser): Route = {
pathPrefix("activityInfo" / ProcessNameSegment) { processName =>
pathPrefix("actionInfo" / ProcessNameSegment) { processName =>
(post & processDetailsForName(processName)) { processDetails =>
entity(as[ScenarioGraph]) { scenarioGraph =>
path("activityParameters") {
path("actionParameters") {
complete {
activityInfoService
actionInfoService
.forProcessingTypeUnsafe(processDetails.processingType)
.getActivityParameters(
.getActionParameters(
scenarioGraph,
processDetails.processVersionUnsafe,
processDetails.isFragment
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,30 @@ import pl.touk.nussknacker.engine.api.ProcessVersion
import pl.touk.nussknacker.engine.api.definition.RawParameterEditor
import pl.touk.nussknacker.engine.api.graph.ScenarioGraph
import pl.touk.nussknacker.engine.canonicalgraph.CanonicalProcess
import pl.touk.nussknacker.engine.definition.activity.ActivityInfoProvider
import pl.touk.nussknacker.restmodel.definition.UiActivityParameterConfig
import pl.touk.nussknacker.ui.process.newactivity.ActivityInfoService.{ActivityName, UiActivityNodeParameters}
import pl.touk.nussknacker.engine.definition.activity.ActionInfoProvider
import pl.touk.nussknacker.restmodel.definition.UiActionParameterConfig
import pl.touk.nussknacker.ui.process.newactivity.ActionInfoService.{ActivityName, UiActionNodeParameters}
import pl.touk.nussknacker.ui.security.api.LoggedUser
import pl.touk.nussknacker.ui.uiresolving.UIProcessResolver

// TODO: move to ActivityService? execute node compilation only once with ScenarioTestService?
class ActivityInfoService(activityInfoProvider: ActivityInfoProvider, processResolver: UIProcessResolver) {
class ActionInfoService(activityInfoProvider: ActionInfoProvider, processResolver: UIProcessResolver) {

def getActivityParameters(
def getActionParameters(
scenarioGraph: ScenarioGraph,
processVersion: ProcessVersion,
isFragment: Boolean
)(
implicit user: LoggedUser
): Map[ActivityName, List[UiActivityNodeParameters]] = {
): Map[ActivityName, List[UiActionNodeParameters]] = {
val canonical = toCanonicalProcess(scenarioGraph, processVersion, isFragment)
activityInfoProvider
.getActivityParameters(processVersion, canonical)
.getActionParameters(processVersion, canonical)
.map { case (activityName, nodeParamsMap) =>
activityName -> nodeParamsMap.map { case (nodeId, params) =>
UiActivityNodeParameters(
UiActionNodeParameters(
NodeId(nodeId),
params.map { case (name, value) =>
name -> UiActivityParameterConfig(
name -> UiActionParameterConfig(
value.defaultValue,
value.editor.getOrElse(RawParameterEditor),
value.label,
Expand All @@ -53,7 +52,7 @@ class ActivityInfoService(activityInfoProvider: ActivityInfoProvider, processRes

}

object ActivityInfoService {
object ActionInfoService {
type ActivityName = String
@JsonCodec case class UiActivityNodeParameters(nodeId: NodeId, parameters: Map[String, UiActivityParameterConfig])
@JsonCodec case class UiActionNodeParameters(nodeId: NodeId, parameters: Map[String, UiActionParameterConfig])
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ import pl.touk.nussknacker.ui.process.deployment.{
import pl.touk.nussknacker.ui.process.fragment.{DefaultFragmentRepository, FragmentResolver}
import pl.touk.nussknacker.ui.process.label.ScenarioLabelsService
import pl.touk.nussknacker.ui.process.migrate.{HttpRemoteEnvironment, ProcessModelMigrator, TestModelMigrations}
import pl.touk.nussknacker.ui.process.newactivity.{ActivityInfoService, ActivityService}
import pl.touk.nussknacker.ui.process.newactivity.{ActionInfoService, ActivityService}
import pl.touk.nussknacker.ui.process.newdeployment.synchronize.{
DeploymentsStatusesSynchronizationConfig,
DeploymentsStatusesSynchronizationScheduler,
Expand Down Expand Up @@ -218,7 +218,7 @@ class AkkaHttpBasedRouteProvider(
)
}
val scenarioActivityService = scenarioTestServiceDeps.mapValues { case (_, processResolver, _, modelData, _) =>
new ActivityInfoService(
new ActionInfoService(
new ModelDataActivityInfoProvider(modelData),
processResolver
)
Expand Down Expand Up @@ -513,7 +513,7 @@ class AkkaHttpBasedRouteProvider(
)
}
),
new ActivityInfoResources(processService, scenarioActivityService),
new ActionInfoResources(processService, scenarioActivityService),
new StatusResources(stateDefinitionService),
)

Expand Down
Loading

0 comments on commit f763629

Please sign in to comment.