Skip to content

chore: added automatic option to run behaviour behind feature flag #40608

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 25 commits into from
May 16, 2025
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
cd7d202
chore: run-behaviour add automatic
May 8, 2025
ffe58f4
chore: run-behaviour add automatic
May 8, 2025
9545860
chore: run-behaviour add automatic
May 8, 2025
33af677
chore: added run behaviour for js actions
May 9, 2025
8d6718f
removing unnecessary code
ankitakinger May 9, 2025
43cc91c
addressing coderrabbitai comments
ankitakinger May 9, 2025
94aa2b9
Merge branch 'feat/reactive-actions-run-behaviour' of https://github.…
ankitakinger May 9, 2025
079b154
adding the filtering logic for automatic dropdown option only on fron…
ankitakinger May 9, 2025
0823335
reverting a change
ankitakinger May 9, 2025
db1eb04
fixing client build
ankitakinger May 9, 2025
2d7ea5f
Merge branch 'feat/reactive-actions-run-behaviour' of https://github.…
ankitakinger May 9, 2025
609b5fe
Merge branch 'chore/run-behviour-with-ff' of https://github.com/appsm…
ankitakinger May 9, 2025
164db73
minor refactoring
ankitakinger May 9, 2025
b88b3c2
updated the logic for filtering automatic run behaviour
May 12, 2025
76b632d
Merge branch 'chore/run-behviour-with-ff' of https://github.com/appsm…
ankitakinger May 12, 2025
45a3fae
addressing review comments
ankitakinger May 12, 2025
7929ff8
addressing review comments
ankitakinger May 12, 2025
45fead2
addressing review comments
ankitakinger May 12, 2025
372a411
addressing review comments
ankitakinger May 12, 2025
0793005
Merge pull request #40629 from appsmithorg/chore/remove-unnecessary-code
ankitakinger May 12, 2025
75578e9
Merge branch 'release' of https://github.com/appsmithorg/appsmith int…
ankitakinger May 13, 2025
7220957
fixing client build
ankitakinger May 13, 2025
fe8f0aa
addressing review comment
ankitakinger May 16, 2025
6193c86
Merge branch 'release' of https://github.com/appsmithorg/appsmith int…
ankitakinger May 16, 2025
4c4074c
reverting a file change
ankitakinger May 16, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -427,4 +427,4 @@
"axios": "^1.8.3",
"esbuild": "^0.25.1"
}
}
}
3 changes: 2 additions & 1 deletion app/client/src/PluginActionEditor/PluginActionContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@ import type { Action } from "entities/Action";
import type { Plugin } from "entities/Plugin";
import type { Datasource, EmbeddedRestDatasource } from "entities/Datasource";
import type { ActionResponse } from "api/ActionAPI";
import type { PluginActionSettingsConfig } from "./types/PluginActionTypes";

interface PluginActionContextType {
action: Action;
actionResponse?: ActionResponse;
editorConfig?: unknown[];
settingsConfig?: unknown[];
settingsConfig?: PluginActionSettingsConfig[];
plugin: Plugin;
datasource?: EmbeddedRestDatasource | Datasource;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { getPathAndValueFromActionDiffObject } from "utils/getPathAndValueFromAc
import { setActionProperty } from "actions/pluginActionActions";
import { usePluginActionContext } from "../../../../../PluginActionContext";
import { useDispatch } from "react-redux";
import type { PluginActionSettingsConfig } from "PluginActionEditor/types/PluginActionTypes";

export const useGoogleSheetsSetDefaultProperty = () => {
const {
Expand All @@ -30,7 +31,9 @@ export const useGoogleSheetsSetDefaultProperty = () => {

merge(
initialValues,
getConfigInitialValues(settingsConfig as Record<string, unknown>[]),
getConfigInitialValues(
settingsConfig as PluginActionSettingsConfig[],
),
);

// initialValues contains merge of action, editorConfig, settingsConfig and will be passed to redux form
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ import type { EditorTheme } from "components/editorComponents/CodeEditor/EditorC
import styled from "styled-components";
import { Text } from "@appsmith/ads";
import CenteredWrapper from "components/designSystems/appsmith/CenteredWrapper";
import { useSelector, type DefaultRootState } from "react-redux";
import { selectFeatureFlagCheck } from "ee/selectors/featureFlagsSelectors";
import { updateRunBehaviourForActionSettings } from "utils/PluginUtils";

interface ActionSettingsProps {
// TODO: Fix this the next time the file is edited
Expand Down Expand Up @@ -41,9 +44,18 @@ const ActionSettingsWrapper = styled.div`
`;

function ActionSettings(props: ActionSettingsProps): JSX.Element {
const featureFlagEnabled: boolean = useSelector((state: DefaultRootState) =>
selectFeatureFlagCheck(state, "release_reactive_actions_enabled"),
);

const updateSettingsConfig = updateRunBehaviourForActionSettings(
props.actionSettingsConfig || [],
featureFlagEnabled,
);

return (
<ActionSettingsWrapper>
{!props.actionSettingsConfig ? (
{!updateSettingsConfig ? (
<CenteredWrapper>
<Text color="var(--ads-v2-color-fg-error)" kind="heading-m">
Error: No settings config found
Expand All @@ -52,7 +64,7 @@ function ActionSettings(props: ActionSettingsProps): JSX.Element {
) : (
/* TODO: Fix this the next time the file is edited */
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
props.actionSettingsConfig.map((section: any) =>
updateSettingsConfig.map((section: any) =>
renderEachConfig(section, props.formName),
)
)}
Expand Down
35 changes: 19 additions & 16 deletions app/client/src/PluginActionEditor/types/PluginActionTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,26 @@ export const THEME = EditorTheme.LIGHT;
export enum ActionRunBehaviour {
ON_PAGE_LOAD = "ON_PAGE_LOAD",
MANUAL = "MANUAL",
AUTOMATIC = "AUTOMATIC",
}

export const RUN_BEHAVIOR = {
ON_PAGE_LOAD: {
label: "On page load",
subText: "Query runs when the page loads or when manually triggered",
value: ActionRunBehaviour.ON_PAGE_LOAD,
children: "On page load",
},
MANUAL: {
label: "Manual",
subText: "Query only runs when called in an event or JS with .run()",
value: ActionRunBehaviour.MANUAL,
children: "Manual",
},
};
export type ActionRunBehaviourType = `${ActionRunBehaviour}`;

export const RUN_BEHAVIOR_VALUES = Object.values(RUN_BEHAVIOR);
export interface ActionSettingsConfigChildren {
label: string;
configProperty: string;
controlType: string;
initialValue?: string | boolean;
options?: Array<{ label: string; value: string }>;
tooltipText?: string;
placeholder?: string;
dataType?: string;
subtitle?: string;
name?: string;
}

export type ActionRunBehaviourType = `${ActionRunBehaviour}`;
export interface ActionSettingsConfig {
sectionName: string;
id: number;
children: ActionSettingsConfigChildren[];
}
2 changes: 2 additions & 0 deletions app/client/src/ce/entities/FeatureFlag.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ export const FEATURE_FLAG = {
"license_external_saas_plugins_enabled",
release_computation_cache_enabled: "release_computation_cache_enabled",
release_ai_chat_integrations_enabled: "release_ai_chat_integrations_enabled",
release_reactive_actions_enabled: "release_reactive_actions_enabled",
} as const;

export type FeatureFlag = keyof typeof FEATURE_FLAG;
Expand Down Expand Up @@ -110,6 +111,7 @@ export const DEFAULT_FEATURE_FLAG_VALUE: FeatureFlags = {
license_external_saas_plugins_enabled: false,
release_computation_cache_enabled: false,
release_ai_chat_integrations_enabled: false,
release_reactive_actions_enabled: false,
};

export const AB_TESTING_EVENT_KEYS = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10043,6 +10043,12 @@ export const defaultAppState = {
controlType: "DROP_DOWN",
initialValue: "MANUAL",
options: [
{
label: "Automatic",
subText:
"Query runs on page load or when a variable it depends on changes",
value: "AUTOMATIC",
},
{
label: "On page load",
subText:
Expand Down Expand Up @@ -10094,6 +10100,12 @@ export const defaultAppState = {
controlType: "DROP_DOWN",
initialValue: "MANUAL",
options: [
{
label: "Automatic",
subText:
"Query runs on page load or when a variable it depends on changes",
value: "AUTOMATIC",
},
{
label: "On page load",
subText:
Expand Down Expand Up @@ -10145,6 +10157,12 @@ export const defaultAppState = {
controlType: "DROP_DOWN",
initialValue: "MANUAL",
options: [
{
label: "Automatic",
subText:
"Query runs on page load or when a variable it depends on changes",
value: "AUTOMATIC",
},
{
label: "On page load",
subText:
Expand Down Expand Up @@ -10225,6 +10243,12 @@ export const defaultAppState = {
controlType: "DROP_DOWN",
initialValue: "MANUAL",
options: [
{
label: "Automatic",
subText:
"Query runs on page load or when a variable it depends on changes",
value: "AUTOMATIC",
},
{
label: "On page load",
subText:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import saasActionSettingsConfig from "constants/AppsmithActionConstants/formConf
import apiActionDependencyConfig from "constants/AppsmithActionConstants/formConfig/ApiDependencyConfigs";
import apiActionDatasourceFormButtonConfig from "constants/AppsmithActionConstants/formConfig/ApiDatasourceFormsButtonConfig";
import type { EntityTypeValue } from "ee/entities/DataTree/types";
import type { PluginActionSettingsConfig } from "PluginActionEditor/types/PluginActionTypes";

export interface ExecuteActionPayloadEvent {
type: EventType;
Expand Down Expand Up @@ -166,9 +167,10 @@ export const POSTMAN = "POSTMAN";
export const CURL = "CURL";
export const Swagger = "Swagger";

// TODO: Fix this the next time the file is edited
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export const defaultActionSettings: Record<PluginType, any> = {
export const defaultActionSettings: Record<
PluginType,
PluginActionSettingsConfig[]
> = {
[PluginType.API]: apiActionSettingsConfig,
[PluginType.DB]: queryActionSettingsConfig,
[PluginType.SAAS]: saasActionSettingsConfig,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ import {
HTTP_PROTOCOL_VERSIONS,
} from "PluginActionEditor/constants/CommonApiConstants";
import {
RUN_BEHAVIOR,
RUN_BEHAVIOR_VALUES,
} from "PluginActionEditor/types/PluginActionTypes";
RUN_BEHAVIOR_CONFIG_PROPERTY,
} from "constants/AppsmithActionConstants/formConfig/PluginSettings";
import { ActionRunBehaviour } from "PluginActionEditor/types/PluginActionTypes";

export default [
{
Expand All @@ -18,9 +19,9 @@ export default [
children: [
{
label: "Run behavior",
configProperty: "runBehaviour",
configProperty: RUN_BEHAVIOR_CONFIG_PROPERTY,
controlType: "DROP_DOWN",
initialValue: RUN_BEHAVIOR.MANUAL.label,
initialValue: ActionRunBehaviour.MANUAL,
options: RUN_BEHAVIOR_VALUES,
},
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import {
RUN_BEHAVIOR,
RUN_BEHAVIOR_VALUES,
} from "PluginActionEditor/types/PluginActionTypes";
RUN_BEHAVIOR_CONFIG_PROPERTY,
} from "constants/AppsmithActionConstants/formConfig/PluginSettings";
import { ActionRunBehaviour } from "PluginActionEditor/types/PluginActionTypes";

export default [
{
Expand All @@ -10,9 +11,9 @@ export default [
children: [
{
label: "Run behavior",
configProperty: "runBehaviour",
configProperty: RUN_BEHAVIOR_CONFIG_PROPERTY,
controlType: "DROP_DOWN",
initialValue: RUN_BEHAVIOR.MANUAL.label,
initialValue: ActionRunBehaviour.MANUAL,
options: RUN_BEHAVIOR_VALUES,
},
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { ActionRunBehaviour } from "PluginActionEditor/types/PluginActionTypes";

export const RUN_BEHAVIOR_CONFIG_PROPERTY = "runBehaviour";

export const RUN_BEHAVIOR_VALUES = [
{
label: "Automatic",
subText: "Query runs on page load or when a variable it depends on changes",
value: ActionRunBehaviour.AUTOMATIC,
children: "Automatic",
},
{
label: "On page load",
subText: "Query runs when the page loads or when manually triggered",
value: ActionRunBehaviour.ON_PAGE_LOAD,
children: "On page load",
},
{
label: "Manual",
subText: "Query only runs when called in an event or JS with .run()",
value: ActionRunBehaviour.MANUAL,
children: "Manual",
},
];
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import {
RUN_BEHAVIOR,
RUN_BEHAVIOR_VALUES,
} from "PluginActionEditor/types/PluginActionTypes";
RUN_BEHAVIOR_CONFIG_PROPERTY,
} from "constants/AppsmithActionConstants/formConfig/PluginSettings";
import { ActionRunBehaviour } from "PluginActionEditor/types/PluginActionTypes";

export default [
{
Expand All @@ -10,9 +11,9 @@ export default [
children: [
{
label: "Run behavior",
configProperty: "runBehaviour",
configProperty: RUN_BEHAVIOR_CONFIG_PROPERTY,
controlType: "DROP_DOWN",
initialValue: RUN_BEHAVIOR.MANUAL.label,
initialValue: ActionRunBehaviour.MANUAL,
options: RUN_BEHAVIOR_VALUES,
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@ import {
import AnalyticsUtil from "ee/utils/AnalyticsUtil";
import type { OnUpdateSettingsProps } from "../types";
import {
RUN_BEHAVIOR_VALUES,
ActionRunBehaviour,
type ActionRunBehaviourType,
} from "PluginActionEditor/types/PluginActionTypes";
import styled from "styled-components";
import { RUN_BEHAVIOR_VALUES } from "constants/AppsmithActionConstants/formConfig/PluginSettings";
import { useFeatureFlag } from "utils/hooks/useFeatureFlag";

const OptionLabel = styled(Text)`
color: var(--ads-v2-color-fg);
Expand Down Expand Up @@ -47,7 +49,14 @@ interface FunctionSettingsRowProps extends Omit<Props, "actions"> {

const FunctionSettingRow = (props: FunctionSettingsRowProps) => {
const [runBehaviour, setRunBehaviour] = useState(props.action.runBehaviour);
const options = RUN_BEHAVIOR_VALUES as SelectOptionProps[];
const flagValueForReactiveActions = useFeatureFlag(
"release_reactive_actions_enabled",
);
const options = RUN_BEHAVIOR_VALUES.filter(
(option) =>
flagValueForReactiveActions ||
option.value !== ActionRunBehaviour.AUTOMATIC,
) as SelectOptionProps[];
const selectedValue = options.find((opt) => opt.value === runBehaviour);

const onSelectOptions = useCallback(
Expand Down Expand Up @@ -82,7 +91,6 @@ const FunctionSettingRow = (props: FunctionSettingsRowProps) => {
</Text>
<StyledSelect
data-testid={`t--dropdown-runBehaviour`}
defaultValue={selectedValue}
id={props.action.id}
isDisabled={props.disabled}
listHeight={240}
Expand Down
Loading
Loading