chore: Remove AI datasource creation options (#40310)
## Description Should not list AI datasources in creation flows
This commit is contained in:
parent
d64040bf52
commit
5294bacf21
|
|
@ -8,6 +8,7 @@ import {
|
||||||
getActions,
|
getActions,
|
||||||
getAllPageWidgets,
|
getAllPageWidgets,
|
||||||
getJSCollections,
|
getJSCollections,
|
||||||
|
getPluginByPackageName,
|
||||||
getPlugins,
|
getPlugins,
|
||||||
getRecentDatasourceIds,
|
getRecentDatasourceIds,
|
||||||
} from "ee/selectors/entitiesSelector";
|
} from "ee/selectors/entitiesSelector";
|
||||||
|
|
@ -24,7 +25,12 @@ import {
|
||||||
isMatching,
|
isMatching,
|
||||||
SEARCH_ITEM_TYPES,
|
SEARCH_ITEM_TYPES,
|
||||||
} from "./utils";
|
} from "./utils";
|
||||||
import { type Plugin, PluginType, UIComponentTypes } from "entities/Plugin";
|
import {
|
||||||
|
type Plugin,
|
||||||
|
PluginPackageName,
|
||||||
|
PluginType,
|
||||||
|
UIComponentTypes,
|
||||||
|
} from "entities/Plugin";
|
||||||
import { integrationEditorURL } from "ee/RouteBuilder";
|
import { integrationEditorURL } from "ee/RouteBuilder";
|
||||||
import type { AppState } from "ee/reducers";
|
import type { AppState } from "ee/reducers";
|
||||||
import { getCurrentAppWorkspace } from "ee/selectors/selectedWorkspaceSelectors";
|
import { getCurrentAppWorkspace } from "ee/selectors/selectedWorkspaceSelectors";
|
||||||
|
|
@ -41,6 +47,7 @@ import {
|
||||||
checkIfJSObjectCreationAllowed,
|
checkIfJSObjectCreationAllowed,
|
||||||
useWorkflowOptions,
|
useWorkflowOptions,
|
||||||
} from "ee/utils/workflowHelpers";
|
} from "ee/utils/workflowHelpers";
|
||||||
|
import { getIsAiAgentFlowEnabled } from "ee/selectors/aiAgentSelectors";
|
||||||
|
|
||||||
export interface FilterFileOperationsProps {
|
export interface FilterFileOperationsProps {
|
||||||
canCreateActions: boolean;
|
canCreateActions: boolean;
|
||||||
|
|
@ -72,21 +79,35 @@ export const useFilteredFileOperations = ({
|
||||||
(state: AppState) => getCurrentAppWorkspace(state).userPermissions ?? [],
|
(state: AppState) => getCurrentAppWorkspace(state).userPermissions ?? [],
|
||||||
);
|
);
|
||||||
|
|
||||||
const isFeatureEnabled = useFeatureFlag(FEATURE_FLAG.license_gac_enabled);
|
const isGACEnabled = useFeatureFlag(FEATURE_FLAG.license_gac_enabled);
|
||||||
|
const isAiAgentFlowEnabled = useSelector(getIsAiAgentFlowEnabled);
|
||||||
|
const AiPlugin = useSelector((state: AppState) =>
|
||||||
|
getPluginByPackageName(state, PluginPackageName.APPSMITH_AI),
|
||||||
|
);
|
||||||
|
|
||||||
const canCreateDatasource = getHasCreateDatasourcePermission(
|
const canCreateDatasource = getHasCreateDatasourcePermission(
|
||||||
isFeatureEnabled,
|
isGACEnabled,
|
||||||
userWorkspacePermissions,
|
userWorkspacePermissions,
|
||||||
);
|
);
|
||||||
|
|
||||||
// get all datasources, app ds listed first
|
// get all datasources, app ds listed first
|
||||||
const allDatasources = [...appWideDS, ...otherDS].filter(
|
const allDatasources = [...appWideDS, ...otherDS]
|
||||||
|
.filter(
|
||||||
(ds) =>
|
(ds) =>
|
||||||
getHasCreateDatasourceActionPermission(
|
getHasCreateDatasourceActionPermission(
|
||||||
isFeatureEnabled,
|
isGACEnabled,
|
||||||
ds.userPermissions ?? [],
|
ds.userPermissions ?? [],
|
||||||
) && canCreateActions,
|
) && canCreateActions,
|
||||||
);
|
)
|
||||||
|
.filter((ds) => {
|
||||||
|
// We don't want to show the AI datasource in the
|
||||||
|
// lists if the AI agent flow is enabled
|
||||||
|
if (isAiAgentFlowEnabled && AiPlugin) {
|
||||||
|
return AiPlugin.id !== ds.pluginId;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
|
||||||
return useFilteredAndSortedFileOperations({
|
return useFilteredAndSortedFileOperations({
|
||||||
allDatasources,
|
allDatasources,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user