Skip to content
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

feat: add new .env variable "LANGFLOW_FEATURE_MVP_COMPONENTS" to show/hide integration sidebar components #4270

Merged
merged 18 commits into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
69dde9c
✨ (authContext.tsx): Add functionality to fetch global variables on a…
Cristhianzl Oct 24, 2024
02d028b
Merge branch 'main' of https://github.com/langflow-ai/langflow
Cristhianzl Oct 24, 2024
08d40da
📝 (endpoints.py): add feature_flags field to ConfigResponse schema
Cristhianzl Oct 24, 2024
60e6faa
✨ (use-get-config.ts): Add feature_flags field to ConfigResponse inte…
Cristhianzl Oct 24, 2024
f08d45b
♻️ (frontend/package-lock.json): remove extraneous flag from is-unico…
Cristhianzl Oct 24, 2024
f55b0f7
✨ (integration-side-bar.spec.ts): Add integration tests to ensure cor…
Cristhianzl Oct 23, 2024
d770a60
✨ (integration-side-bar.spec.ts): update integration-side-bar tests t…
Cristhianzl Oct 24, 2024
fe3f4a8
✨ (integration-side-bar.spec.ts): add a 4-second delay before making …
Cristhianzl Oct 24, 2024
9dfc5a8
[autofix.ci] apply automated fixes
autofix-ci[bot] Oct 24, 2024
fa4af83
Merge branch 'main' into cz/mvp-components-flags
Cristhianzl Oct 24, 2024
4e14f44
Update src/backend/base/langflow/api/v1/schemas.py
Cristhianzl Oct 24, 2024
daf0336
Update src/backend/base/langflow/api/v1/endpoints.py
Cristhianzl Oct 24, 2024
7e9c42e
formata
Cristhianzl Oct 24, 2024
615732c
[autofix.ci] apply automated fixes
autofix-ci[bot] Oct 24, 2024
5a0cd92
Merge branch 'main' into cz/mvp-components-flags
Cristhianzl Oct 24, 2024
a5e81b5
Merge branch 'main' into cz/mvp-components-flags
Cristhianzl Oct 27, 2024
7fd71a7
Merge branch 'main' into cz/mvp-components-flags
Cristhianzl Oct 28, 2024
d98d738
✨ (extraSidebarComponent/index.tsx): update featureFlags property acc…
Cristhianzl Oct 28, 2024
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
4 changes: 3 additions & 1 deletion src/backend/base/langflow/api/v1/endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
get_task_service,
get_telemetry_service,
)
from langflow.services.settings.feature_flags import FEATURE_FLAGS
from langflow.services.telemetry.schema import RunPayload
from langflow.utils.constants import SIDEBAR_CATEGORIES
from langflow.utils.version import get_version_info
Expand Down Expand Up @@ -629,7 +630,8 @@ def get_config():
from langflow.services.deps import get_settings_service

settings_service: SettingsService = get_settings_service()
return settings_service.settings.model_dump()

return {"feature_flags": FEATURE_FLAGS, **settings_service.settings.model_dump()}
except Exception as exc:
raise HTTPException(status_code=500, detail=str(exc)) from exc

Expand Down
2 changes: 2 additions & 0 deletions src/backend/base/langflow/api/v1/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from langflow.services.database.models.base import orjson_dumps
from langflow.services.database.models.flow import FlowCreate, FlowRead
from langflow.services.database.models.user import UserRead
from langflow.services.settings.feature_flags import FeatureFlags
from langflow.services.tracing.schema import Log
from langflow.utils.util_strings import truncate_long_strings

Expand Down Expand Up @@ -350,6 +351,7 @@ class FlowDataRequest(BaseModel):


class ConfigResponse(BaseModel):
feature_flags: FeatureFlags
frontend_timeout: int
auto_saving: bool
auto_saving_interval: int
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

class FeatureFlags(BaseSettings):
add_toolkit_output: bool = False
mvp_components: bool = False

class Config:
env_prefix = "LANGFLOW_FEATURE_"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export interface ConfigResponse {
auto_saving_interval: number;
health_check_max_retries: number;
max_file_size_upload: number;
feature_flags: Record<string, any>;
}

export const useGetConfig: useQueryFunctionType<undefined, ConfigResponse> = (
Expand All @@ -27,6 +28,7 @@ export const useGetConfig: useQueryFunctionType<undefined, ConfigResponse> = (
const setMaxFileSizeUpload = useUtilityStore(
(state) => state.setMaxFileSizeUpload,
);
const setFeatureFlags = useUtilityStore((state) => state.setFeatureFlags);

const { query } = UseRequestProcessor();

Expand All @@ -43,6 +45,7 @@ export const useGetConfig: useQueryFunctionType<undefined, ConfigResponse> = (
setAutoSavingInterval(data.auto_saving_interval);
setHealthCheckMaxRetries(data.health_check_max_retries);
setMaxFileSizeUpload(data.max_file_size_upload);
setFeatureFlags(data.feature_flags);
}
return data;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { nodeIconsLucide } from "../../../../utils/styleUtils";
import ParentDisclosureComponent from "../ParentDisclosureComponent";
import { SidebarCategoryComponent } from "./SidebarCategoryComponent";

import { useUtilityStore } from "@/stores/utilityStore";
import { SidebarFilterComponent } from "./sidebarFilterComponent";
import { sortKeys } from "./utils";

Expand All @@ -31,6 +32,8 @@ export default function ExtraSidebar(): JSX.Element {
const hasStore = useStoreStore((state) => state.hasStore);
const filterType = useFlowStore((state) => state.filterType);

const featureFlags = useUtilityStore((state) => state.featureFlags);

const setErrorData = useAlertStore((state) => state.setErrorData);
const [dataFilter, setFilterData] = useState(data);
const [search, setSearch] = useState("");
Expand Down Expand Up @@ -248,7 +251,7 @@ export default function ExtraSidebar(): JSX.Element {
<div key={index}></div>
),
)}
{ENABLE_INTEGRATIONS && (
{(ENABLE_INTEGRATIONS || featureFlags.mvp_components) && (
<ParentDisclosureComponent
defaultOpen={true}
key={`${search.length !== 0}-${getFilterEdge.length !== 0}-Bundle`}
Expand Down
2 changes: 2 additions & 0 deletions src/frontend/src/stores/utilityStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,6 @@ export const useUtilityStore = create<UtilityStoreType>((set, get) => ({
setFlowsPagination: (flowsPagination: Pagination) => set({ flowsPagination }),
tags: [],
setTags: (tags: Tag[]) => set({ tags }),
featureFlags: {},
setFeatureFlags: (featureFlags: Record<string, any>) => set({ featureFlags }),
}));
2 changes: 2 additions & 0 deletions src/frontend/src/types/zustand/utility/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,6 @@ export type UtilityStoreType = {
setFlowsPagination: (pagination: Pagination) => void;
tags: Tag[];
setTags: (tags: Tag[]) => void;
featureFlags: Record<string, any>;
setFeatureFlags: (featureFlags: Record<string, any>) => void;
};
96 changes: 96 additions & 0 deletions src/frontend/tests/extended/features/integration-side-bar.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
import { expect, test } from "@playwright/test";

test("user should be able to see integrations in the sidebar if mvp_components is true", async ({
page,
}) => {
await page.route("**/api/v1/config", (route) => {
route.fulfill({
status: 200,
contentType: "application/json",
body: JSON.stringify({
feature_flags: {
mvp_components: true,
},
}),
headers: {
"content-type": "application/json",
...route.request().headers(),
},
});
});

await page.goto("/");
await page.waitForTimeout(1000);

let modalCount = 0;
try {
const modalTitleElement = await page?.getByTestId("modal-title");
if (modalTitleElement) {
modalCount = await modalTitleElement.count();
}
} catch (error) {
modalCount = 0;
}

while (modalCount === 0) {
await page.getByText("New Project", { exact: true }).click();
await page.waitForTimeout(3000);
modalCount = await page.getByTestId("modal-title")?.count();
}

await page.getByTestId("blank-flow").click();
await page.waitForSelector('[data-testid="extended-disclosure"]', {
timeout: 30000,
});

await expect(page.getByText("Integrations")).toBeVisible();
await expect(page.getByText("Notion")).toBeVisible();
});

test("user should NOT be able to see integrations in the sidebar if mvp_components is false", async ({
page,
}) => {
await page.waitForTimeout(4000);
await page.route("**/api/v1/config", (route) => {
route.fulfill({
status: 200,
contentType: "application/json",
body: JSON.stringify({
feature_flags: {
mvp_components: false,
},
}),
headers: {
"content-type": "application/json",
...route.request().headers(),
},
});
});

await page.goto("/");
await page.waitForTimeout(1000);

let modalCount = 0;
try {
const modalTitleElement = await page?.getByTestId("modal-title");
if (modalTitleElement) {
modalCount = await modalTitleElement.count();
}
} catch (error) {
modalCount = 0;
}

while (modalCount === 0) {
await page.getByText("New Project", { exact: true }).click();
await page.waitForTimeout(3000);
modalCount = await page.getByTestId("modal-title")?.count();
}

await page.getByTestId("blank-flow").click();
await page.waitForSelector('[data-testid="extended-disclosure"]', {
timeout: 30000,
});

await expect(page.getByText("Integrations")).not.toBeVisible();
await expect(page.getByText("Notion")).not.toBeVisible();
});
Loading