Skip to content
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
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 @@ -8,14 +8,16 @@ import {
API_EDITOR_TAB_TITLES,
MORE_ON_QUERY_SETTINGS,
} from "ee/constants/messages";
import { useDispatch, useSelector } from "react-redux";
import { useDispatch, useSelector, type DefaultRootState } from "react-redux";
import {
isPluginActionSettingsOpen,
openPluginActionSettings,
} from "../../store";
import { THEME } from "../../types/PluginActionTypes";
import { type DocsLink, openDoc } from "constants/DocumentationLinks";
import { ToolbarSettingsPopover } from "IDE";
import { updateRunBehaviourForActionSettings } from "utils/PluginUtils";
import { selectFeatureFlagCheck } from "ee/selectors/featureFlagsSelectors";

export interface SettingsProps {
formName: string;
Expand All @@ -41,6 +43,15 @@ const PluginActionSettingsPopover = (props: SettingsProps) => {
const [isOpen, setIsOpen] = useState(false);
const dispatch = useDispatch();

const featureFlagEnabled: boolean = useSelector((state: DefaultRootState) =>
selectFeatureFlagCheck(state, "release_reactive_actions_enabled"),
);

const updateSettingsConfig = updateRunBehaviourForActionSettings(
settingsConfig || [],
featureFlagEnabled,
);

const handleOpenChange = useCallback(
(open: boolean) => {
setIsOpen(open);
Expand Down Expand Up @@ -74,7 +85,7 @@ const PluginActionSettingsPopover = (props: SettingsProps) => {
>
<SettingsWrapper>
<ActionSettings
actionSettingsConfig={settingsConfig}
actionSettingsConfig={updateSettingsConfig}
formName={props.formName}
theme={THEME}
/>
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 PluginActionSettingsConfigChildren {
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 PluginActionSettingsConfig {
sectionName: string;
id: number;
children: PluginActionSettingsConfigChildren[];
}
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 @@ -14,11 +14,10 @@ import {
} from "ee/constants/messages";
import AnalyticsUtil from "ee/utils/AnalyticsUtil";
import type { OnUpdateSettingsProps } from "../types";
import {
RUN_BEHAVIOR_VALUES,
type ActionRunBehaviourType,
} from "PluginActionEditor/types/PluginActionTypes";
import { 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 +46,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) =>
(option.value !== "AUTOMATIC" && !flagValueForReactiveActions) ||
flagValueForReactiveActions,
) as SelectOptionProps[];
const selectedValue = options.find((opt) => opt.value === runBehaviour);

const onSelectOptions = useCallback(
Expand Down Expand Up @@ -82,7 +88,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