Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
47 changes: 20 additions & 27 deletions app/client/src/ce/hooks/datasourceEditorHooks.tsx
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
import { generateTemplateFormURL } from "@appsmith/RouteBuilder";
import React from "react";
import { useSelector } from "react-redux";
import NewActionButton from "pages/Editor/DataSourceEditor/NewActionButton";
import { EditorNames } from "./";
import type { Datasource } from "entities/Datasource";
import type { ApiDatasourceForm } from "entities/Datasource/RestAPIForm";
import { Button } from "design-system";
import {
GENERATE_NEW_PAGE_BUTTON_TEXT,
createMessage,
} from "@appsmith/constants/messages";
import { ActionParentEntityType } from "@appsmith/entities/Engine/actionHelpers";
import { FEATURE_FLAG } from "@appsmith/entities/FeatureFlag";
import type { AppState } from "@appsmith/reducers";
import { getPlugin } from "@appsmith/selectors/entitiesSelector";
import AnalyticsUtil from "@appsmith/utils/AnalyticsUtil";
import {
getHasCreatePagePermission,
hasCreateDSActionPermissionInApp,
} from "@appsmith/utils/BusinessFeatures/permissionPageHelpers";
import { Button } from "design-system";
import type { Datasource } from "entities/Datasource";
import type { ApiDatasourceForm } from "entities/Datasource/RestAPIForm";
import NewActionButton from "pages/Editor/DataSourceEditor/NewActionButton";
import { useShowPageGenerationOnHeader } from "pages/Editor/DataSourceEditor/hooks";
import React from "react";
import { useSelector } from "react-redux";
import history from "utils/history";
import { generateTemplateFormURL } from "@appsmith/RouteBuilder";
import {
getCurrentApplication,
getCurrentApplicationId,
getCurrentPageId,
getPagePermissions,
} from "selectors/editorSelectors";
import { isEnabledForPreviewData } from "utils/editorContextUtils";
import history from "utils/history";
import { useShowPageGenerationOnHeader } from "pages/Editor/DataSourceEditor/hooks";
import type { AppState } from "@appsmith/reducers";
import {
getHasCreatePagePermission,
hasCreateDSActionPermissionInApp,
} from "@appsmith/utils/BusinessFeatures/permissionPageHelpers";
import { FEATURE_FLAG } from "@appsmith/entities/FeatureFlag";
import { useFeatureFlag } from "utils/hooks/useFeatureFlag";
import { EditorNames } from "./";
import { ActionParentEntityType } from "@appsmith/entities/Engine/actionHelpers";
import { isEnabledForPreviewData } from "utils/editorContextUtils";
import { getPlugin } from "@appsmith/selectors/entitiesSelector";

export interface HeaderActionProps {
datasource: Datasource | ApiDatasourceForm | undefined;
Expand All @@ -48,9 +48,6 @@ export const useHeaderActions = (
) => {
const pageId = useSelector(getCurrentPageId);
const isFeatureEnabled = useFeatureFlag(FEATURE_FLAG.license_gac_enabled);
const releaseDragDropBuildingBlocks = useFeatureFlag(
FEATURE_FLAG.release_drag_drop_building_blocks_enabled,
);
const userAppPermissions = useSelector(
(state: AppState) => getCurrentApplication(state)?.userPermissions ?? [],
);
Expand All @@ -68,10 +65,6 @@ export const useHeaderActions = (
const isPluginAllowedToPreviewData =
!!plugin && isEnabledForPreviewData(datasource as Datasource, plugin);

const shouldShowSecondaryGenerateButton = releaseDragDropBuildingBlocks
? false
: !!isPluginAllowedToPreviewData;

if (editorType === EditorNames.APPLICATION) {
const canCreateDatasourceActions = hasCreateDSActionPermissionInApp({
isEnabled: isFeatureEnabled,
Expand Down Expand Up @@ -106,7 +99,7 @@ export const useHeaderActions = (
datasource={datasource as Datasource}
disabled={!canCreateDatasourceActions || !isPluginAuthorized}
eventFrom="datasource-pane"
isNewQuerySecondaryButton={shouldShowSecondaryGenerateButton}
isNewQuerySecondaryButton={!!isPluginAllowedToPreviewData}
pluginType={pluginType}
/>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,6 @@ const DatasourceViewModeSchema = (props: Props) => {
);

const isFeatureEnabled = useFeatureFlag(FEATURE_FLAG.license_gac_enabled);
const releaseDragDropBuildingBlocks = useFeatureFlag(
FEATURE_FLAG.release_drag_drop_building_blocks_enabled,
);

const editorType = useEditorType(history.location.pathname);

Expand Down Expand Up @@ -233,9 +230,7 @@ const DatasourceViewModeSchema = (props: Props) => {
// if there was a failure in the fetching of the data
// if tableName from schema is availble
// if the user has permissions
// if drag and drop building blocks are not enabled
const showGeneratePageBtn =
!releaseDragDropBuildingBlocks &&
!isDatasourceStructureLoading &&
!isLoading &&
!failedFetchingPreviewData &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -347,9 +347,6 @@ function GoogleSheetSchema(props: Props) {
);

const isFeatureEnabled = useFeatureFlag(FEATURE_FLAG.license_gac_enabled);
const releaseDragDropBuildingBlocks = useFeatureFlag(
FEATURE_FLAG.release_drag_drop_building_blocks_enabled,
);

const editorType = useEditorType(history.location.pathname);

Expand All @@ -375,7 +372,6 @@ function GoogleSheetSchema(props: Props) {
);

const showGeneratePageBtn =
!releaseDragDropBuildingBlocks &&
!isLoading &&
!isError &&
sheetData?.length &&
Expand Down
Loading