feat: Add preview data for mongo mock db (#27031)
This PR introduces Preview data feature for Mock MongoDB Datasources.
This commit is contained in:
parent
4f20df633a
commit
d1de037ea4
|
|
@ -25,6 +25,7 @@ export const FEATURE_FLAG = {
|
|||
release_git_connect_v2_enabled: "release_git_connect_v2_enabled",
|
||||
deprecate_custom_fusioncharts_enabled:
|
||||
"deprecate_custom_fusioncharts_enabled",
|
||||
ab_mock_mongo_schema_enabled: "ab_mock_mongo_schema_enabled",
|
||||
} as const;
|
||||
|
||||
export type FeatureFlag = keyof typeof FEATURE_FLAG;
|
||||
|
|
@ -52,6 +53,7 @@ export const DEFAULT_FEATURE_FLAG_VALUE: FeatureFlags = {
|
|||
license_sso_oidc_enabled: false,
|
||||
release_git_connect_v2_enabled: false,
|
||||
deprecate_custom_fusioncharts_enabled: false,
|
||||
ab_mock_mongo_schema_enabled: false,
|
||||
};
|
||||
|
||||
export const AB_TESTING_EVENT_KEYS = {
|
||||
|
|
|
|||
|
|
@ -78,6 +78,7 @@ export interface QueryTemplate {
|
|||
title: string;
|
||||
body: string;
|
||||
pluginSpecifiedTemplates?: Array<{ key?: string; value?: unknown }>;
|
||||
suggested: boolean;
|
||||
}
|
||||
export interface DatasourceTable {
|
||||
type: string;
|
||||
|
|
|
|||
|
|
@ -31,7 +31,11 @@ import {
|
|||
} from "selectors/editorSelectors";
|
||||
import { GENERATE_PAGE_MODE } from "../GeneratePage/components/GeneratePageForm/GeneratePageForm";
|
||||
import { useDatasourceQuery } from "./hooks";
|
||||
import type { Datasource, DatasourceTable } from "entities/Datasource";
|
||||
import type {
|
||||
Datasource,
|
||||
DatasourceTable,
|
||||
QueryTemplate,
|
||||
} from "entities/Datasource";
|
||||
import { getCurrentApplication } from "@appsmith/selectors/applicationSelectors";
|
||||
import {
|
||||
hasCreateDatasourceActionPermission,
|
||||
|
|
@ -153,13 +157,24 @@ const DatasourceViewModeSchema = (props: Props) => {
|
|||
datasourceStructure &&
|
||||
datasourceStructure.tables
|
||||
) {
|
||||
const templates = datasourceStructure.tables.find(
|
||||
(structure: DatasourceTable) => structure.name === tableName,
|
||||
)?.templates;
|
||||
const templates: QueryTemplate[] | undefined =
|
||||
datasourceStructure.tables.find(
|
||||
(structure: DatasourceTable) => structure.name === tableName,
|
||||
)?.templates;
|
||||
|
||||
if (templates) {
|
||||
let suggestedTemPlate: QueryTemplate | undefined = templates?.find(
|
||||
(template) => template.suggested,
|
||||
);
|
||||
|
||||
// if no suggested template exists, default to first template.
|
||||
if (!suggestedTemPlate) {
|
||||
suggestedTemPlate = templates[0];
|
||||
}
|
||||
|
||||
fetchPreviewData({
|
||||
datasourceId: props.datasourceId,
|
||||
template: templates[0],
|
||||
template: suggestedTemPlate,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -88,7 +88,7 @@ import type { ApiDatasourceForm } from "entities/Datasource/RestAPIForm";
|
|||
import { formValuesToDatasource } from "transformers/RestAPIDatasourceFormTransformer";
|
||||
import { DSFormHeader } from "./DSFormHeader";
|
||||
import type { PluginType } from "entities/Action";
|
||||
import { PluginPackageName } from "entities/Action";
|
||||
import { PluginName, PluginPackageName } from "entities/Action";
|
||||
import DSDataFilter from "@appsmith/components/DSDataFilter";
|
||||
import { DEFAULT_ENV_ID } from "@appsmith/api/ApiUtils";
|
||||
import { isStorageEnvironmentCreated } from "@appsmith/utils/Environments";
|
||||
|
|
@ -1072,14 +1072,23 @@ const mapStateToProps = (state: AppState, props: any): ReduxStateProps => {
|
|||
const featureFlags = selectFeatureFlags(state);
|
||||
|
||||
// A/B feature flag for datasource view mode preview data.
|
||||
const isEnabledForDSViewModeSchema = selectFeatureFlagCheck(
|
||||
let isEnabledForDSViewModeSchema = selectFeatureFlagCheck(
|
||||
state,
|
||||
FEATURE_FLAG.ab_gsheet_schema_enabled,
|
||||
);
|
||||
|
||||
// for mongoDB, the feature flag should be based on ab_mock_mongo_schema_enabled.
|
||||
if (plugin?.name === PluginName.MONGO) {
|
||||
isEnabledForDSViewModeSchema = selectFeatureFlagCheck(
|
||||
state,
|
||||
FEATURE_FLAG.ab_mock_mongo_schema_enabled,
|
||||
);
|
||||
}
|
||||
|
||||
// should plugin be able to preview data
|
||||
const isPluginAllowedToPreviewData =
|
||||
DATASOURCES_ALLOWED_FOR_PREVIEW_MODE.includes(plugin?.name || "");
|
||||
DATASOURCES_ALLOWED_FOR_PREVIEW_MODE.includes(plugin?.name || "") ||
|
||||
(plugin?.name === PluginName.MONGO && !!(datasource as Datasource)?.isMock);
|
||||
|
||||
return {
|
||||
canCreateDatasourceActions,
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user